babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933
  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. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1058. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1059. */
  1060. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1061. /**
  1062. * Constant used to retrieve the position texture index in the textures array in the prepass
  1063. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1064. */
  1065. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1066. /**
  1067. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1068. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1069. */
  1070. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1071. /**
  1072. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1073. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1074. */
  1075. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1076. /**
  1077. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1078. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1079. */
  1080. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1081. /**
  1082. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1083. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1084. */
  1085. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1086. /**
  1087. * Constant used to retrieve albedo index in the textures array in the prepass
  1088. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1089. */
  1090. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1091. }
  1092. }
  1093. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1094. import { Nullable } from "babylonjs/types";
  1095. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1096. /**
  1097. * This represents the required contract to create a new type of texture loader.
  1098. */
  1099. export interface IInternalTextureLoader {
  1100. /**
  1101. * Defines wether the loader supports cascade loading the different faces.
  1102. */
  1103. supportCascades: boolean;
  1104. /**
  1105. * This returns if the loader support the current file information.
  1106. * @param extension defines the file extension of the file being loaded
  1107. * @param mimeType defines the optional mime type of the file being loaded
  1108. * @returns true if the loader can load the specified file
  1109. */
  1110. canLoad(extension: string, mimeType?: string): boolean;
  1111. /**
  1112. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1113. * @param data contains the texture data
  1114. * @param texture defines the BabylonJS internal texture
  1115. * @param createPolynomials will be true if polynomials have been requested
  1116. * @param onLoad defines the callback to trigger once the texture is ready
  1117. * @param onError defines the callback to trigger in case of error
  1118. */
  1119. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1120. /**
  1121. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1122. * @param data contains the texture data
  1123. * @param texture defines the BabylonJS internal texture
  1124. * @param callback defines the method to call once ready to upload
  1125. */
  1126. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/IPipelineContext" {
  1130. /**
  1131. * Class used to store and describe the pipeline context associated with an effect
  1132. */
  1133. export interface IPipelineContext {
  1134. /**
  1135. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1136. */
  1137. isAsync: boolean;
  1138. /**
  1139. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1140. */
  1141. isReady: boolean;
  1142. /** @hidden */
  1143. _getVertexShaderCode(): string | null;
  1144. /** @hidden */
  1145. _getFragmentShaderCode(): string | null;
  1146. /** @hidden */
  1147. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1148. }
  1149. }
  1150. declare module "babylonjs/Meshes/dataBuffer" {
  1151. /**
  1152. * Class used to store gfx data (like WebGLBuffer)
  1153. */
  1154. export class DataBuffer {
  1155. /**
  1156. * Gets or sets the number of objects referencing this buffer
  1157. */
  1158. references: number;
  1159. /** Gets or sets the size of the underlying buffer */
  1160. capacity: number;
  1161. /**
  1162. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1163. */
  1164. is32Bits: boolean;
  1165. /**
  1166. * Gets the underlying buffer
  1167. */
  1168. get underlyingResource(): any;
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1172. /** @hidden */
  1173. export interface IShaderProcessor {
  1174. attributeProcessor?: (attribute: string) => string;
  1175. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1176. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1177. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1178. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1179. lineProcessor?: (line: string, isFragment: boolean) => string;
  1180. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1181. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1182. }
  1183. }
  1184. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1185. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1186. /** @hidden */
  1187. export interface ProcessingOptions {
  1188. defines: string[];
  1189. indexParameters: any;
  1190. isFragment: boolean;
  1191. shouldUseHighPrecisionShader: boolean;
  1192. supportsUniformBuffers: boolean;
  1193. shadersRepository: string;
  1194. includesShadersStore: {
  1195. [key: string]: string;
  1196. };
  1197. processor?: IShaderProcessor;
  1198. version: string;
  1199. platformName: string;
  1200. lookForClosingBracketForUniformBuffer?: boolean;
  1201. }
  1202. }
  1203. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1204. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1205. /** @hidden */
  1206. export class ShaderCodeNode {
  1207. line: string;
  1208. children: ShaderCodeNode[];
  1209. additionalDefineKey?: string;
  1210. additionalDefineValue?: string;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. process(preprocessors: {
  1215. [key: string]: string;
  1216. }, options: ProcessingOptions): string;
  1217. }
  1218. }
  1219. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1220. /** @hidden */
  1221. export class ShaderCodeCursor {
  1222. private _lines;
  1223. lineIndex: number;
  1224. get currentLine(): string;
  1225. get canRead(): boolean;
  1226. set lines(value: string[]);
  1227. }
  1228. }
  1229. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1230. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1231. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1252. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1253. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1254. /** @hidden */
  1255. export class ShaderCodeTestNode extends ShaderCodeNode {
  1256. testExpression: ShaderDefineExpression;
  1257. isValid(preprocessors: {
  1258. [key: string]: string;
  1259. }): boolean;
  1260. }
  1261. }
  1262. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1263. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1264. /** @hidden */
  1265. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1266. define: string;
  1267. not: boolean;
  1268. constructor(define: string, not?: boolean);
  1269. isTrue(preprocessors: {
  1270. [key: string]: string;
  1271. }): boolean;
  1272. }
  1273. }
  1274. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1275. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1276. /** @hidden */
  1277. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1278. leftOperand: ShaderDefineExpression;
  1279. rightOperand: ShaderDefineExpression;
  1280. isTrue(preprocessors: {
  1281. [key: string]: string;
  1282. }): boolean;
  1283. }
  1284. }
  1285. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1286. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1287. /** @hidden */
  1288. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1289. leftOperand: ShaderDefineExpression;
  1290. rightOperand: ShaderDefineExpression;
  1291. isTrue(preprocessors: {
  1292. [key: string]: string;
  1293. }): boolean;
  1294. }
  1295. }
  1296. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1297. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1298. /** @hidden */
  1299. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1300. define: string;
  1301. operand: string;
  1302. testValue: string;
  1303. constructor(define: string, operand: string, testValue: string);
  1304. isTrue(preprocessors: {
  1305. [key: string]: string;
  1306. }): boolean;
  1307. }
  1308. }
  1309. declare module "babylonjs/Offline/IOfflineProvider" {
  1310. /**
  1311. * Class used to enable access to offline support
  1312. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1313. */
  1314. export interface IOfflineProvider {
  1315. /**
  1316. * Gets a boolean indicating if scene must be saved in the database
  1317. */
  1318. enableSceneOffline: boolean;
  1319. /**
  1320. * Gets a boolean indicating if textures must be saved in the database
  1321. */
  1322. enableTexturesOffline: boolean;
  1323. /**
  1324. * Open the offline support and make it available
  1325. * @param successCallback defines the callback to call on success
  1326. * @param errorCallback defines the callback to call on error
  1327. */
  1328. open(successCallback: () => void, errorCallback: () => void): void;
  1329. /**
  1330. * Loads an image from the offline support
  1331. * @param url defines the url to load from
  1332. * @param image defines the target DOM image
  1333. */
  1334. loadImage(url: string, image: HTMLImageElement): void;
  1335. /**
  1336. * Loads a file from offline support
  1337. * @param url defines the URL to load from
  1338. * @param sceneLoaded defines a callback to call on success
  1339. * @param progressCallBack defines a callback to call when progress changed
  1340. * @param errorCallback defines a callback to call on error
  1341. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1342. */
  1343. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1344. }
  1345. }
  1346. declare module "babylonjs/Misc/filesInputStore" {
  1347. /**
  1348. * Class used to help managing file picking and drag'n'drop
  1349. * File Storage
  1350. */
  1351. export class FilesInputStore {
  1352. /**
  1353. * List of files ready to be loaded
  1354. */
  1355. static FilesToLoad: {
  1356. [key: string]: File;
  1357. };
  1358. }
  1359. }
  1360. declare module "babylonjs/Misc/retryStrategy" {
  1361. import { WebRequest } from "babylonjs/Misc/webRequest";
  1362. /**
  1363. * Class used to define a retry strategy when error happens while loading assets
  1364. */
  1365. export class RetryStrategy {
  1366. /**
  1367. * Function used to defines an exponential back off strategy
  1368. * @param maxRetries defines the maximum number of retries (3 by default)
  1369. * @param baseInterval defines the interval between retries
  1370. * @returns the strategy function to use
  1371. */
  1372. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1373. }
  1374. }
  1375. declare module "babylonjs/Misc/baseError" {
  1376. /**
  1377. * @ignore
  1378. * Application error to support additional information when loading a file
  1379. */
  1380. export abstract class BaseError extends Error {
  1381. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1382. }
  1383. }
  1384. declare module "babylonjs/Misc/fileTools" {
  1385. import { WebRequest } from "babylonjs/Misc/webRequest";
  1386. import { Nullable } from "babylonjs/types";
  1387. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1388. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1389. import { BaseError } from "babylonjs/Misc/baseError";
  1390. /** @ignore */
  1391. export class LoadFileError extends BaseError {
  1392. request?: WebRequest;
  1393. file?: File;
  1394. /**
  1395. * Creates a new LoadFileError
  1396. * @param message defines the message of the error
  1397. * @param request defines the optional web request
  1398. * @param file defines the optional file
  1399. */
  1400. constructor(message: string, object?: WebRequest | File);
  1401. }
  1402. /** @ignore */
  1403. export class RequestFileError extends BaseError {
  1404. request: WebRequest;
  1405. /**
  1406. * Creates a new LoadFileError
  1407. * @param message defines the message of the error
  1408. * @param request defines the optional web request
  1409. */
  1410. constructor(message: string, request: WebRequest);
  1411. }
  1412. /** @ignore */
  1413. export class ReadFileError extends BaseError {
  1414. file: File;
  1415. /**
  1416. * Creates a new ReadFileError
  1417. * @param message defines the message of the error
  1418. * @param file defines the optional file
  1419. */
  1420. constructor(message: string, file: File);
  1421. }
  1422. /**
  1423. * @hidden
  1424. */
  1425. export class FileTools {
  1426. /**
  1427. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1428. */
  1429. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1430. /**
  1431. * Gets or sets the base URL to use to load assets
  1432. */
  1433. static BaseUrl: string;
  1434. /**
  1435. * Default behaviour for cors in the application.
  1436. * It can be a string if the expected behavior is identical in the entire app.
  1437. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1438. */
  1439. static CorsBehavior: string | ((url: string | string[]) => string);
  1440. /**
  1441. * Gets or sets a function used to pre-process url before using them to load assets
  1442. */
  1443. static PreprocessUrl: (url: string) => string;
  1444. /**
  1445. * Removes unwanted characters from an url
  1446. * @param url defines the url to clean
  1447. * @returns the cleaned url
  1448. */
  1449. private static _CleanUrl;
  1450. /**
  1451. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1452. * @param url define the url we are trying
  1453. * @param element define the dom element where to configure the cors policy
  1454. */
  1455. static SetCorsBehavior(url: string | string[], element: {
  1456. crossOrigin: string | null;
  1457. }): void;
  1458. /**
  1459. * Loads an image as an HTMLImageElement.
  1460. * @param input url string, ArrayBuffer, or Blob to load
  1461. * @param onLoad callback called when the image successfully loads
  1462. * @param onError callback called when the image fails to load
  1463. * @param offlineProvider offline provider for caching
  1464. * @param mimeType optional mime type
  1465. * @returns the HTMLImageElement of the loaded image
  1466. */
  1467. 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>;
  1468. /**
  1469. * Reads a file from a File object
  1470. * @param file defines the file to load
  1471. * @param onSuccess defines the callback to call when data is loaded
  1472. * @param onProgress defines the callback to call during loading process
  1473. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1474. * @param onError defines the callback to call when an error occurs
  1475. * @returns a file request object
  1476. */
  1477. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1478. /**
  1479. * Loads a file from a url
  1480. * @param url url to load
  1481. * @param onSuccess callback called when the file successfully loads
  1482. * @param onProgress callback called while file is loading (if the server supports this mode)
  1483. * @param offlineProvider defines the offline provider for caching
  1484. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1485. * @param onError callback called when the file fails to load
  1486. * @returns a file request object
  1487. */
  1488. 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;
  1489. /**
  1490. * Loads a file
  1491. * @param url url to load
  1492. * @param onSuccess callback called when the file successfully loads
  1493. * @param onProgress callback called while file is loading (if the server supports this mode)
  1494. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1495. * @param onError callback called when the file fails to load
  1496. * @param onOpened callback called when the web request is opened
  1497. * @returns a file request object
  1498. */
  1499. 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;
  1500. /**
  1501. * Checks if the loaded document was accessed via `file:`-Protocol.
  1502. * @returns boolean
  1503. */
  1504. static IsFileURL(): boolean;
  1505. }
  1506. }
  1507. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1508. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1509. import { WebRequest } from "babylonjs/Misc/webRequest";
  1510. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1511. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1512. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1513. /** @hidden */
  1514. export class ShaderProcessor {
  1515. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1516. private static _ProcessPrecision;
  1517. private static _ExtractOperation;
  1518. private static _BuildSubExpression;
  1519. private static _BuildExpression;
  1520. private static _MoveCursorWithinIf;
  1521. private static _MoveCursor;
  1522. private static _EvaluatePreProcessors;
  1523. private static _PreparePreProcessors;
  1524. private static _ProcessShaderConversion;
  1525. private static _ProcessIncludes;
  1526. /**
  1527. * Loads a file from a url
  1528. * @param url url to load
  1529. * @param onSuccess callback called when the file successfully loads
  1530. * @param onProgress callback called while file is loading (if the server supports this mode)
  1531. * @param offlineProvider defines the offline provider for caching
  1532. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1533. * @param onError callback called when the file fails to load
  1534. * @returns a file request object
  1535. * @hidden
  1536. */
  1537. 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;
  1538. }
  1539. }
  1540. declare module "babylonjs/Maths/math.like" {
  1541. import { float, int, DeepImmutable } from "babylonjs/types";
  1542. /**
  1543. * @hidden
  1544. */
  1545. export interface IColor4Like {
  1546. r: float;
  1547. g: float;
  1548. b: float;
  1549. a: float;
  1550. }
  1551. /**
  1552. * @hidden
  1553. */
  1554. export interface IColor3Like {
  1555. r: float;
  1556. g: float;
  1557. b: float;
  1558. }
  1559. /**
  1560. * @hidden
  1561. */
  1562. export interface IVector4Like {
  1563. x: float;
  1564. y: float;
  1565. z: float;
  1566. w: float;
  1567. }
  1568. /**
  1569. * @hidden
  1570. */
  1571. export interface IVector3Like {
  1572. x: float;
  1573. y: float;
  1574. z: float;
  1575. }
  1576. /**
  1577. * @hidden
  1578. */
  1579. export interface IVector2Like {
  1580. x: float;
  1581. y: float;
  1582. }
  1583. /**
  1584. * @hidden
  1585. */
  1586. export interface IMatrixLike {
  1587. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1588. updateFlag: int;
  1589. }
  1590. /**
  1591. * @hidden
  1592. */
  1593. export interface IViewportLike {
  1594. x: float;
  1595. y: float;
  1596. width: float;
  1597. height: float;
  1598. }
  1599. /**
  1600. * @hidden
  1601. */
  1602. export interface IPlaneLike {
  1603. normal: IVector3Like;
  1604. d: float;
  1605. normalize(): void;
  1606. }
  1607. }
  1608. declare module "babylonjs/Materials/iEffectFallbacks" {
  1609. import { Effect } from "babylonjs/Materials/effect";
  1610. /**
  1611. * Interface used to define common properties for effect fallbacks
  1612. */
  1613. export interface IEffectFallbacks {
  1614. /**
  1615. * Removes the defines that should be removed when falling back.
  1616. * @param currentDefines defines the current define statements for the shader.
  1617. * @param effect defines the current effect we try to compile
  1618. * @returns The resulting defines with defines of the current rank removed.
  1619. */
  1620. reduce(currentDefines: string, effect: Effect): string;
  1621. /**
  1622. * Removes the fallback from the bound mesh.
  1623. */
  1624. unBindMesh(): void;
  1625. /**
  1626. * Checks to see if more fallbacks are still availible.
  1627. */
  1628. hasMoreFallbacks: boolean;
  1629. }
  1630. }
  1631. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1632. /**
  1633. * Class used to evalaute queries containing `and` and `or` operators
  1634. */
  1635. export class AndOrNotEvaluator {
  1636. /**
  1637. * Evaluate a query
  1638. * @param query defines the query to evaluate
  1639. * @param evaluateCallback defines the callback used to filter result
  1640. * @returns true if the query matches
  1641. */
  1642. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1643. private static _HandleParenthesisContent;
  1644. private static _SimplifyNegation;
  1645. }
  1646. }
  1647. declare module "babylonjs/Misc/tags" {
  1648. /**
  1649. * Class used to store custom tags
  1650. */
  1651. export class Tags {
  1652. /**
  1653. * Adds support for tags on the given object
  1654. * @param obj defines the object to use
  1655. */
  1656. static EnableFor(obj: any): void;
  1657. /**
  1658. * Removes tags support
  1659. * @param obj defines the object to use
  1660. */
  1661. static DisableFor(obj: any): void;
  1662. /**
  1663. * Gets a boolean indicating if the given object has tags
  1664. * @param obj defines the object to use
  1665. * @returns a boolean
  1666. */
  1667. static HasTags(obj: any): boolean;
  1668. /**
  1669. * Gets the tags available on a given object
  1670. * @param obj defines the object to use
  1671. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1672. * @returns the tags
  1673. */
  1674. static GetTags(obj: any, asString?: boolean): any;
  1675. /**
  1676. * Adds tags to an object
  1677. * @param obj defines the object to use
  1678. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1679. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1680. */
  1681. static AddTagsTo(obj: any, tagsString: string): void;
  1682. /**
  1683. * @hidden
  1684. */
  1685. static _AddTagTo(obj: any, tag: string): void;
  1686. /**
  1687. * Removes specific tags from a specific object
  1688. * @param obj defines the object to use
  1689. * @param tagsString defines the tags to remove
  1690. */
  1691. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1692. /**
  1693. * @hidden
  1694. */
  1695. static _RemoveTagFrom(obj: any, tag: string): void;
  1696. /**
  1697. * Defines if tags hosted on an object match a given query
  1698. * @param obj defines the object to use
  1699. * @param tagsQuery defines the tag query
  1700. * @returns a boolean
  1701. */
  1702. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1703. }
  1704. }
  1705. declare module "babylonjs/Maths/math.scalar" {
  1706. /**
  1707. * Scalar computation library
  1708. */
  1709. export class Scalar {
  1710. /**
  1711. * Two pi constants convenient for computation.
  1712. */
  1713. static TwoPi: number;
  1714. /**
  1715. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1716. * @param a number
  1717. * @param b number
  1718. * @param epsilon (default = 1.401298E-45)
  1719. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. */
  1721. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1722. /**
  1723. * Returns a string : the upper case translation of the number i to hexadecimal.
  1724. * @param i number
  1725. * @returns the upper case translation of the number i to hexadecimal.
  1726. */
  1727. static ToHex(i: number): string;
  1728. /**
  1729. * Returns -1 if value is negative and +1 is value is positive.
  1730. * @param value the value
  1731. * @returns the value itself if it's equal to zero.
  1732. */
  1733. static Sign(value: number): number;
  1734. /**
  1735. * Returns the value itself if it's between min and max.
  1736. * Returns min if the value is lower than min.
  1737. * Returns max if the value is greater than max.
  1738. * @param value the value to clmap
  1739. * @param min the min value to clamp to (default: 0)
  1740. * @param max the max value to clamp to (default: 1)
  1741. * @returns the clamped value
  1742. */
  1743. static Clamp(value: number, min?: number, max?: number): number;
  1744. /**
  1745. * the log2 of value.
  1746. * @param value the value to compute log2 of
  1747. * @returns the log2 of value.
  1748. */
  1749. static Log2(value: number): number;
  1750. /**
  1751. * Loops the value, so that it is never larger than length and never smaller than 0.
  1752. *
  1753. * This is similar to the modulo operator but it works with floating point numbers.
  1754. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1755. * With t = 5 and length = 2.5, the result would be 0.0.
  1756. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1757. * @param value the value
  1758. * @param length the length
  1759. * @returns the looped value
  1760. */
  1761. static Repeat(value: number, length: number): number;
  1762. /**
  1763. * Normalize the value between 0.0 and 1.0 using min and max values
  1764. * @param value value to normalize
  1765. * @param min max to normalize between
  1766. * @param max min to normalize between
  1767. * @returns the normalized value
  1768. */
  1769. static Normalize(value: number, min: number, max: number): number;
  1770. /**
  1771. * Denormalize the value from 0.0 and 1.0 using min and max values
  1772. * @param normalized value to denormalize
  1773. * @param min max to denormalize between
  1774. * @param max min to denormalize between
  1775. * @returns the denormalized value
  1776. */
  1777. static Denormalize(normalized: number, min: number, max: number): number;
  1778. /**
  1779. * Calculates the shortest difference between two given angles given in degrees.
  1780. * @param current current angle in degrees
  1781. * @param target target angle in degrees
  1782. * @returns the delta
  1783. */
  1784. static DeltaAngle(current: number, target: number): number;
  1785. /**
  1786. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1787. * @param tx value
  1788. * @param length length
  1789. * @returns The returned value will move back and forth between 0 and length
  1790. */
  1791. static PingPong(tx: number, length: number): number;
  1792. /**
  1793. * Interpolates between min and max with smoothing at the limits.
  1794. *
  1795. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1796. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1797. * @param from from
  1798. * @param to to
  1799. * @param tx value
  1800. * @returns the smooth stepped value
  1801. */
  1802. static SmoothStep(from: number, to: number, tx: number): number;
  1803. /**
  1804. * Moves a value current towards target.
  1805. *
  1806. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1807. * Negative values of maxDelta pushes the value away from target.
  1808. * @param current current value
  1809. * @param target target value
  1810. * @param maxDelta max distance to move
  1811. * @returns resulting value
  1812. */
  1813. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1814. /**
  1815. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. *
  1817. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1818. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1819. * @param current current value
  1820. * @param target target value
  1821. * @param maxDelta max distance to move
  1822. * @returns resulting angle
  1823. */
  1824. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1825. /**
  1826. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1827. * @param start start value
  1828. * @param end target value
  1829. * @param amount amount to lerp between
  1830. * @returns the lerped value
  1831. */
  1832. static Lerp(start: number, end: number, amount: number): number;
  1833. /**
  1834. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1835. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1836. * @param start start value
  1837. * @param end target value
  1838. * @param amount amount to lerp between
  1839. * @returns the lerped value
  1840. */
  1841. static LerpAngle(start: number, end: number, amount: number): number;
  1842. /**
  1843. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1844. * @param a start value
  1845. * @param b target value
  1846. * @param value value between a and b
  1847. * @returns the inverseLerp value
  1848. */
  1849. static InverseLerp(a: number, b: number, value: number): number;
  1850. /**
  1851. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1852. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1853. * @param value1 spline value
  1854. * @param tangent1 spline value
  1855. * @param value2 spline value
  1856. * @param tangent2 spline value
  1857. * @param amount input value
  1858. * @returns hermite result
  1859. */
  1860. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1861. /**
  1862. * Returns a random float number between and min and max values
  1863. * @param min min value of random
  1864. * @param max max value of random
  1865. * @returns random value
  1866. */
  1867. static RandomRange(min: number, max: number): number;
  1868. /**
  1869. * This function returns percentage of a number in a given range.
  1870. *
  1871. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1872. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1873. * @param number to convert to percentage
  1874. * @param min min range
  1875. * @param max max range
  1876. * @returns the percentage
  1877. */
  1878. static RangeToPercent(number: number, min: number, max: number): number;
  1879. /**
  1880. * This function returns number that corresponds to the percentage in a given range.
  1881. *
  1882. * PercentToRange(0.34,0,100) will return 34.
  1883. * @param percent to convert to number
  1884. * @param min min range
  1885. * @param max max range
  1886. * @returns the number
  1887. */
  1888. static PercentToRange(percent: number, min: number, max: number): number;
  1889. /**
  1890. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1891. * @param angle The angle to normalize in radian.
  1892. * @return The converted angle.
  1893. */
  1894. static NormalizeRadians(angle: number): number;
  1895. }
  1896. }
  1897. declare module "babylonjs/Maths/math.constants" {
  1898. /**
  1899. * Constant used to convert a value to gamma space
  1900. * @ignorenaming
  1901. */
  1902. export const ToGammaSpace: number;
  1903. /**
  1904. * Constant used to convert a value to linear space
  1905. * @ignorenaming
  1906. */
  1907. export const ToLinearSpace = 2.2;
  1908. /**
  1909. * Constant used to define the minimal number value in Babylon.js
  1910. * @ignorenaming
  1911. */
  1912. let Epsilon: number;
  1913. export { Epsilon };
  1914. }
  1915. declare module "babylonjs/Maths/math.viewport" {
  1916. /**
  1917. * Class used to represent a viewport on screen
  1918. */
  1919. export class Viewport {
  1920. /** viewport left coordinate */
  1921. x: number;
  1922. /** viewport top coordinate */
  1923. y: number;
  1924. /**viewport width */
  1925. width: number;
  1926. /** viewport height */
  1927. height: number;
  1928. /**
  1929. * Creates a Viewport object located at (x, y) and sized (width, height)
  1930. * @param x defines viewport left coordinate
  1931. * @param y defines viewport top coordinate
  1932. * @param width defines the viewport width
  1933. * @param height defines the viewport height
  1934. */
  1935. constructor(
  1936. /** viewport left coordinate */
  1937. x: number,
  1938. /** viewport top coordinate */
  1939. y: number,
  1940. /**viewport width */
  1941. width: number,
  1942. /** viewport height */
  1943. height: number);
  1944. /**
  1945. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1946. * @param renderWidth defines the rendering width
  1947. * @param renderHeight defines the rendering height
  1948. * @returns a new Viewport
  1949. */
  1950. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1951. /**
  1952. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1953. * @param renderWidth defines the rendering width
  1954. * @param renderHeight defines the rendering height
  1955. * @param ref defines the target viewport
  1956. * @returns the current viewport
  1957. */
  1958. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1959. /**
  1960. * Returns a new Viewport copied from the current one
  1961. * @returns a new Viewport
  1962. */
  1963. clone(): Viewport;
  1964. }
  1965. }
  1966. declare module "babylonjs/Misc/arrayTools" {
  1967. /**
  1968. * Class containing a set of static utilities functions for arrays.
  1969. */
  1970. export class ArrayTools {
  1971. /**
  1972. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1973. * @param size the number of element to construct and put in the array
  1974. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1975. * @returns a new array filled with new objects
  1976. */
  1977. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1978. }
  1979. }
  1980. declare module "babylonjs/Maths/math.plane" {
  1981. import { DeepImmutable } from "babylonjs/types";
  1982. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1983. /**
  1984. * Represents a plane by the equation ax + by + cz + d = 0
  1985. */
  1986. export class Plane {
  1987. private static _TmpMatrix;
  1988. /**
  1989. * Normal of the plane (a,b,c)
  1990. */
  1991. normal: Vector3;
  1992. /**
  1993. * d component of the plane
  1994. */
  1995. d: number;
  1996. /**
  1997. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1998. * @param a a component of the plane
  1999. * @param b b component of the plane
  2000. * @param c c component of the plane
  2001. * @param d d component of the plane
  2002. */
  2003. constructor(a: number, b: number, c: number, d: number);
  2004. /**
  2005. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2006. */
  2007. asArray(): number[];
  2008. /**
  2009. * @returns a new plane copied from the current Plane.
  2010. */
  2011. clone(): Plane;
  2012. /**
  2013. * @returns the string "Plane".
  2014. */
  2015. getClassName(): string;
  2016. /**
  2017. * @returns the Plane hash code.
  2018. */
  2019. getHashCode(): number;
  2020. /**
  2021. * Normalize the current Plane in place.
  2022. * @returns the updated Plane.
  2023. */
  2024. normalize(): Plane;
  2025. /**
  2026. * Applies a transformation the plane and returns the result
  2027. * @param transformation the transformation matrix to be applied to the plane
  2028. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2029. */
  2030. transform(transformation: DeepImmutable<Matrix>): Plane;
  2031. /**
  2032. * Compute the dot product between the point and the plane normal
  2033. * @param point point to calculate the dot product with
  2034. * @returns the dot product (float) of the point coordinates and the plane normal.
  2035. */
  2036. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2037. /**
  2038. * Updates the current Plane from the plane defined by the three given points.
  2039. * @param point1 one of the points used to contruct the plane
  2040. * @param point2 one of the points used to contruct the plane
  2041. * @param point3 one of the points used to contruct the plane
  2042. * @returns the updated Plane.
  2043. */
  2044. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2045. /**
  2046. * Checks if the plane is facing a given direction
  2047. * @param direction the direction to check if the plane is facing
  2048. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2049. * @returns True is the vector "direction" is the same side than the plane normal.
  2050. */
  2051. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2052. /**
  2053. * Calculates the distance to a point
  2054. * @param point point to calculate distance to
  2055. * @returns the signed distance (float) from the given point to the Plane.
  2056. */
  2057. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2058. /**
  2059. * Creates a plane from an array
  2060. * @param array the array to create a plane from
  2061. * @returns a new Plane from the given array.
  2062. */
  2063. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2064. /**
  2065. * Creates a plane from three points
  2066. * @param point1 point used to create the plane
  2067. * @param point2 point used to create the plane
  2068. * @param point3 point used to create the plane
  2069. * @returns a new Plane defined by the three given points.
  2070. */
  2071. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2072. /**
  2073. * Creates a plane from an origin point and a normal
  2074. * @param origin origin of the plane to be constructed
  2075. * @param normal normal of the plane to be constructed
  2076. * @returns a new Plane the normal vector to this plane at the given origin point.
  2077. * Note : the vector "normal" is updated because normalized.
  2078. */
  2079. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2080. /**
  2081. * Calculates the distance from a plane and a point
  2082. * @param origin origin of the plane to be constructed
  2083. * @param normal normal of the plane to be constructed
  2084. * @param point point to calculate distance to
  2085. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2086. */
  2087. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2088. }
  2089. }
  2090. declare module "babylonjs/Engines/performanceConfigurator" {
  2091. /** @hidden */
  2092. export class PerformanceConfigurator {
  2093. /** @hidden */
  2094. static MatrixUse64Bits: boolean;
  2095. /** @hidden */
  2096. static MatrixTrackPrecisionChange: boolean;
  2097. /** @hidden */
  2098. static MatrixCurrentType: any;
  2099. /** @hidden */
  2100. static MatrixTrackedMatrices: Array<any> | null;
  2101. /** @hidden */
  2102. static SetMatrixPrecision(use64bits: boolean): void;
  2103. }
  2104. }
  2105. declare module "babylonjs/Maths/math.vector" {
  2106. import { Viewport } from "babylonjs/Maths/math.viewport";
  2107. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2108. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2109. import { Plane } from "babylonjs/Maths/math.plane";
  2110. /**
  2111. * Class representing a vector containing 2 coordinates
  2112. */
  2113. export class Vector2 {
  2114. /** defines the first coordinate */
  2115. x: number;
  2116. /** defines the second coordinate */
  2117. y: number;
  2118. /**
  2119. * Creates a new Vector2 from the given x and y coordinates
  2120. * @param x defines the first coordinate
  2121. * @param y defines the second coordinate
  2122. */
  2123. constructor(
  2124. /** defines the first coordinate */
  2125. x?: number,
  2126. /** defines the second coordinate */
  2127. y?: number);
  2128. /**
  2129. * Gets a string with the Vector2 coordinates
  2130. * @returns a string with the Vector2 coordinates
  2131. */
  2132. toString(): string;
  2133. /**
  2134. * Gets class name
  2135. * @returns the string "Vector2"
  2136. */
  2137. getClassName(): string;
  2138. /**
  2139. * Gets current vector hash code
  2140. * @returns the Vector2 hash code as a number
  2141. */
  2142. getHashCode(): number;
  2143. /**
  2144. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2145. * @param array defines the source array
  2146. * @param index defines the offset in source array
  2147. * @returns the current Vector2
  2148. */
  2149. toArray(array: FloatArray, index?: number): Vector2;
  2150. /**
  2151. * Update the current vector from an array
  2152. * @param array defines the destination array
  2153. * @param index defines the offset in the destination array
  2154. * @returns the current Vector3
  2155. */
  2156. fromArray(array: FloatArray, index?: number): Vector2;
  2157. /**
  2158. * Copy the current vector to an array
  2159. * @returns a new array with 2 elements: the Vector2 coordinates.
  2160. */
  2161. asArray(): number[];
  2162. /**
  2163. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2164. * @param source defines the source Vector2
  2165. * @returns the current updated Vector2
  2166. */
  2167. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2168. /**
  2169. * Sets the Vector2 coordinates with the given floats
  2170. * @param x defines the first coordinate
  2171. * @param y defines the second coordinate
  2172. * @returns the current updated Vector2
  2173. */
  2174. copyFromFloats(x: number, y: number): Vector2;
  2175. /**
  2176. * Sets the Vector2 coordinates with the given floats
  2177. * @param x defines the first coordinate
  2178. * @param y defines the second coordinate
  2179. * @returns the current updated Vector2
  2180. */
  2181. set(x: number, y: number): Vector2;
  2182. /**
  2183. * Add another vector with the current one
  2184. * @param otherVector defines the other vector
  2185. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2186. */
  2187. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2188. /**
  2189. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2190. * @param otherVector defines the other vector
  2191. * @param result defines the target vector
  2192. * @returns the unmodified current Vector2
  2193. */
  2194. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2195. /**
  2196. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2197. * @param otherVector defines the other vector
  2198. * @returns the current updated Vector2
  2199. */
  2200. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2201. /**
  2202. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2203. * @param otherVector defines the other vector
  2204. * @returns a new Vector2
  2205. */
  2206. addVector3(otherVector: Vector3): Vector2;
  2207. /**
  2208. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2209. * @param otherVector defines the other vector
  2210. * @returns a new Vector2
  2211. */
  2212. subtract(otherVector: Vector2): Vector2;
  2213. /**
  2214. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2215. * @param otherVector defines the other vector
  2216. * @param result defines the target vector
  2217. * @returns the unmodified current Vector2
  2218. */
  2219. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2220. /**
  2221. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2222. * @param otherVector defines the other vector
  2223. * @returns the current updated Vector2
  2224. */
  2225. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2226. /**
  2227. * Multiplies in place the current Vector2 coordinates by the given ones
  2228. * @param otherVector defines the other vector
  2229. * @returns the current updated Vector2
  2230. */
  2231. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2232. /**
  2233. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @returns a new Vector2
  2236. */
  2237. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2238. /**
  2239. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2240. * @param otherVector defines the other vector
  2241. * @param result defines the target vector
  2242. * @returns the unmodified current Vector2
  2243. */
  2244. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2245. /**
  2246. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2247. * @param x defines the first coordinate
  2248. * @param y defines the second coordinate
  2249. * @returns a new Vector2
  2250. */
  2251. multiplyByFloats(x: number, y: number): Vector2;
  2252. /**
  2253. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2254. * @param otherVector defines the other vector
  2255. * @returns a new Vector2
  2256. */
  2257. divide(otherVector: Vector2): Vector2;
  2258. /**
  2259. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2260. * @param otherVector defines the other vector
  2261. * @param result defines the target vector
  2262. * @returns the unmodified current Vector2
  2263. */
  2264. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2265. /**
  2266. * Divides the current Vector2 coordinates by the given ones
  2267. * @param otherVector defines the other vector
  2268. * @returns the current updated Vector2
  2269. */
  2270. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2271. /**
  2272. * Gets a new Vector2 with current Vector2 negated coordinates
  2273. * @returns a new Vector2
  2274. */
  2275. negate(): Vector2;
  2276. /**
  2277. * Negate this vector in place
  2278. * @returns this
  2279. */
  2280. negateInPlace(): Vector2;
  2281. /**
  2282. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2283. * @param result defines the Vector3 object where to store the result
  2284. * @returns the current Vector2
  2285. */
  2286. negateToRef(result: Vector2): Vector2;
  2287. /**
  2288. * Multiply the Vector2 coordinates by scale
  2289. * @param scale defines the scaling factor
  2290. * @returns the current updated Vector2
  2291. */
  2292. scaleInPlace(scale: number): Vector2;
  2293. /**
  2294. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2295. * @param scale defines the scaling factor
  2296. * @returns a new Vector2
  2297. */
  2298. scale(scale: number): Vector2;
  2299. /**
  2300. * Scale the current Vector2 values by a factor to a given Vector2
  2301. * @param scale defines the scale factor
  2302. * @param result defines the Vector2 object where to store the result
  2303. * @returns the unmodified current Vector2
  2304. */
  2305. scaleToRef(scale: number, result: Vector2): Vector2;
  2306. /**
  2307. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2308. * @param scale defines the scale factor
  2309. * @param result defines the Vector2 object where to store the result
  2310. * @returns the unmodified current Vector2
  2311. */
  2312. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2313. /**
  2314. * Gets a boolean if two vectors are equals
  2315. * @param otherVector defines the other vector
  2316. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2317. */
  2318. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2319. /**
  2320. * Gets a boolean if two vectors are equals (using an epsilon value)
  2321. * @param otherVector defines the other vector
  2322. * @param epsilon defines the minimal distance to consider equality
  2323. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2324. */
  2325. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2326. /**
  2327. * Gets a new Vector2 from current Vector2 floored values
  2328. * @returns a new Vector2
  2329. */
  2330. floor(): Vector2;
  2331. /**
  2332. * Gets a new Vector2 from current Vector2 floored values
  2333. * @returns a new Vector2
  2334. */
  2335. fract(): Vector2;
  2336. /**
  2337. * Gets the length of the vector
  2338. * @returns the vector length (float)
  2339. */
  2340. length(): number;
  2341. /**
  2342. * Gets the vector squared length
  2343. * @returns the vector squared length (float)
  2344. */
  2345. lengthSquared(): number;
  2346. /**
  2347. * Normalize the vector
  2348. * @returns the current updated Vector2
  2349. */
  2350. normalize(): Vector2;
  2351. /**
  2352. * Gets a new Vector2 copied from the Vector2
  2353. * @returns a new Vector2
  2354. */
  2355. clone(): Vector2;
  2356. /**
  2357. * Gets a new Vector2(0, 0)
  2358. * @returns a new Vector2
  2359. */
  2360. static Zero(): Vector2;
  2361. /**
  2362. * Gets a new Vector2(1, 1)
  2363. * @returns a new Vector2
  2364. */
  2365. static One(): Vector2;
  2366. /**
  2367. * Gets a new Vector2 set from the given index element of the given array
  2368. * @param array defines the data source
  2369. * @param offset defines the offset in the data source
  2370. * @returns a new Vector2
  2371. */
  2372. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2373. /**
  2374. * Sets "result" from the given index element of the given array
  2375. * @param array defines the data source
  2376. * @param offset defines the offset in the data source
  2377. * @param result defines the target vector
  2378. */
  2379. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2380. /**
  2381. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2382. * @param value1 defines 1st point of control
  2383. * @param value2 defines 2nd point of control
  2384. * @param value3 defines 3rd point of control
  2385. * @param value4 defines 4th point of control
  2386. * @param amount defines the interpolation factor
  2387. * @returns a new Vector2
  2388. */
  2389. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2390. /**
  2391. * 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".
  2392. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2393. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2394. * @param value defines the value to clamp
  2395. * @param min defines the lower limit
  2396. * @param max defines the upper limit
  2397. * @returns a new Vector2
  2398. */
  2399. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2400. /**
  2401. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2402. * @param value1 defines the 1st control point
  2403. * @param tangent1 defines the outgoing tangent
  2404. * @param value2 defines the 2nd control point
  2405. * @param tangent2 defines the incoming tangent
  2406. * @param amount defines the interpolation factor
  2407. * @returns a new Vector2
  2408. */
  2409. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2410. /**
  2411. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2412. * @param start defines the start vector
  2413. * @param end defines the end vector
  2414. * @param amount defines the interpolation factor
  2415. * @returns a new Vector2
  2416. */
  2417. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2418. /**
  2419. * Gets the dot product of the vector "left" and the vector "right"
  2420. * @param left defines first vector
  2421. * @param right defines second vector
  2422. * @returns the dot product (float)
  2423. */
  2424. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2425. /**
  2426. * Returns a new Vector2 equal to the normalized given vector
  2427. * @param vector defines the vector to normalize
  2428. * @returns a new Vector2
  2429. */
  2430. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2431. /**
  2432. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2433. * @param left defines 1st vector
  2434. * @param right defines 2nd vector
  2435. * @returns a new Vector2
  2436. */
  2437. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2438. /**
  2439. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2440. * @param left defines 1st vector
  2441. * @param right defines 2nd vector
  2442. * @returns a new Vector2
  2443. */
  2444. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2445. /**
  2446. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2447. * @param vector defines the vector to transform
  2448. * @param transformation defines the matrix to apply
  2449. * @returns a new Vector2
  2450. */
  2451. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2452. /**
  2453. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2454. * @param vector defines the vector to transform
  2455. * @param transformation defines the matrix to apply
  2456. * @param result defines the target vector
  2457. */
  2458. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2459. /**
  2460. * Determines if a given vector is included in a triangle
  2461. * @param p defines the vector to test
  2462. * @param p0 defines 1st triangle point
  2463. * @param p1 defines 2nd triangle point
  2464. * @param p2 defines 3rd triangle point
  2465. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2466. */
  2467. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2468. /**
  2469. * Gets the distance between the vectors "value1" and "value2"
  2470. * @param value1 defines first vector
  2471. * @param value2 defines second vector
  2472. * @returns the distance between vectors
  2473. */
  2474. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2475. /**
  2476. * Returns the squared distance between the vectors "value1" and "value2"
  2477. * @param value1 defines first vector
  2478. * @param value2 defines second vector
  2479. * @returns the squared distance between vectors
  2480. */
  2481. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2482. /**
  2483. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2484. * @param value1 defines first vector
  2485. * @param value2 defines second vector
  2486. * @returns a new Vector2
  2487. */
  2488. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2489. /**
  2490. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2491. * @param p defines the middle point
  2492. * @param segA defines one point of the segment
  2493. * @param segB defines the other point of the segment
  2494. * @returns the shortest distance
  2495. */
  2496. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2497. }
  2498. /**
  2499. * Class used to store (x,y,z) vector representation
  2500. * A Vector3 is the main object used in 3D geometry
  2501. * It can represent etiher the coordinates of a point the space, either a direction
  2502. * Reminder: js uses a left handed forward facing system
  2503. */
  2504. export class Vector3 {
  2505. private static _UpReadOnly;
  2506. private static _ZeroReadOnly;
  2507. /** @hidden */
  2508. _x: number;
  2509. /** @hidden */
  2510. _y: number;
  2511. /** @hidden */
  2512. _z: number;
  2513. /** @hidden */
  2514. _isDirty: boolean;
  2515. /** Gets or sets the x coordinate */
  2516. get x(): number;
  2517. set x(value: number);
  2518. /** Gets or sets the y coordinate */
  2519. get y(): number;
  2520. set y(value: number);
  2521. /** Gets or sets the z coordinate */
  2522. get z(): number;
  2523. set z(value: number);
  2524. /**
  2525. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2526. * @param x defines the first coordinates (on X axis)
  2527. * @param y defines the second coordinates (on Y axis)
  2528. * @param z defines the third coordinates (on Z axis)
  2529. */
  2530. constructor(x?: number, y?: number, z?: number);
  2531. /**
  2532. * Creates a string representation of the Vector3
  2533. * @returns a string with the Vector3 coordinates.
  2534. */
  2535. toString(): string;
  2536. /**
  2537. * Gets the class name
  2538. * @returns the string "Vector3"
  2539. */
  2540. getClassName(): string;
  2541. /**
  2542. * Creates the Vector3 hash code
  2543. * @returns a number which tends to be unique between Vector3 instances
  2544. */
  2545. getHashCode(): number;
  2546. /**
  2547. * Creates an array containing three elements : the coordinates of the Vector3
  2548. * @returns a new array of numbers
  2549. */
  2550. asArray(): number[];
  2551. /**
  2552. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2553. * @param array defines the destination array
  2554. * @param index defines the offset in the destination array
  2555. * @returns the current Vector3
  2556. */
  2557. toArray(array: FloatArray, index?: number): Vector3;
  2558. /**
  2559. * Update the current vector from an array
  2560. * @param array defines the destination array
  2561. * @param index defines the offset in the destination array
  2562. * @returns the current Vector3
  2563. */
  2564. fromArray(array: FloatArray, index?: number): Vector3;
  2565. /**
  2566. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2567. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2568. */
  2569. toQuaternion(): Quaternion;
  2570. /**
  2571. * Adds the given vector to the current Vector3
  2572. * @param otherVector defines the second operand
  2573. * @returns the current updated Vector3
  2574. */
  2575. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2576. /**
  2577. * Adds the given coordinates to the current Vector3
  2578. * @param x defines the x coordinate of the operand
  2579. * @param y defines the y coordinate of the operand
  2580. * @param z defines the z coordinate of the operand
  2581. * @returns the current updated Vector3
  2582. */
  2583. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2584. /**
  2585. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2586. * @param otherVector defines the second operand
  2587. * @returns the resulting Vector3
  2588. */
  2589. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2590. /**
  2591. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2592. * @param otherVector defines the second operand
  2593. * @param result defines the Vector3 object where to store the result
  2594. * @returns the current Vector3
  2595. */
  2596. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2597. /**
  2598. * Subtract the given vector from the current Vector3
  2599. * @param otherVector defines the second operand
  2600. * @returns the current updated Vector3
  2601. */
  2602. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2603. /**
  2604. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2605. * @param otherVector defines the second operand
  2606. * @returns the resulting Vector3
  2607. */
  2608. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2609. /**
  2610. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2611. * @param otherVector defines the second operand
  2612. * @param result defines the Vector3 object where to store the result
  2613. * @returns the current Vector3
  2614. */
  2615. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2616. /**
  2617. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2618. * @param x defines the x coordinate of the operand
  2619. * @param y defines the y coordinate of the operand
  2620. * @param z defines the z coordinate of the operand
  2621. * @returns the resulting Vector3
  2622. */
  2623. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2624. /**
  2625. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2626. * @param x defines the x coordinate of the operand
  2627. * @param y defines the y coordinate of the operand
  2628. * @param z defines the z coordinate of the operand
  2629. * @param result defines the Vector3 object where to store the result
  2630. * @returns the current Vector3
  2631. */
  2632. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2633. /**
  2634. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2635. * @returns a new Vector3
  2636. */
  2637. negate(): Vector3;
  2638. /**
  2639. * Negate this vector in place
  2640. * @returns this
  2641. */
  2642. negateInPlace(): Vector3;
  2643. /**
  2644. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the current Vector3
  2647. */
  2648. negateToRef(result: Vector3): Vector3;
  2649. /**
  2650. * Multiplies the Vector3 coordinates by the float "scale"
  2651. * @param scale defines the multiplier factor
  2652. * @returns the current updated Vector3
  2653. */
  2654. scaleInPlace(scale: number): Vector3;
  2655. /**
  2656. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2657. * @param scale defines the multiplier factor
  2658. * @returns a new Vector3
  2659. */
  2660. scale(scale: number): Vector3;
  2661. /**
  2662. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2663. * @param scale defines the multiplier factor
  2664. * @param result defines the Vector3 object where to store the result
  2665. * @returns the current Vector3
  2666. */
  2667. scaleToRef(scale: number, result: Vector3): Vector3;
  2668. /**
  2669. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2670. * @param scale defines the scale factor
  2671. * @param result defines the Vector3 object where to store the result
  2672. * @returns the unmodified current Vector3
  2673. */
  2674. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2675. /**
  2676. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2677. * @param origin defines the origin of the projection ray
  2678. * @param plane defines the plane to project to
  2679. * @returns the projected vector3
  2680. */
  2681. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2682. /**
  2683. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2684. * @param origin defines the origin of the projection ray
  2685. * @param plane defines the plane to project to
  2686. * @param result defines the Vector3 where to store the result
  2687. */
  2688. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2689. /**
  2690. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2691. * @param otherVector defines the second operand
  2692. * @returns true if both vectors are equals
  2693. */
  2694. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2695. /**
  2696. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2697. * @param otherVector defines the second operand
  2698. * @param epsilon defines the minimal distance to define values as equals
  2699. * @returns true if both vectors are distant less than epsilon
  2700. */
  2701. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2702. /**
  2703. * Returns true if the current Vector3 coordinates equals the given floats
  2704. * @param x defines the x coordinate of the operand
  2705. * @param y defines the y coordinate of the operand
  2706. * @param z defines the z coordinate of the operand
  2707. * @returns true if both vectors are equals
  2708. */
  2709. equalsToFloats(x: number, y: number, z: number): boolean;
  2710. /**
  2711. * Multiplies the current Vector3 coordinates by the given ones
  2712. * @param otherVector defines the second operand
  2713. * @returns the current updated Vector3
  2714. */
  2715. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2716. /**
  2717. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2718. * @param otherVector defines the second operand
  2719. * @returns the new Vector3
  2720. */
  2721. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2722. /**
  2723. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2724. * @param otherVector defines the second operand
  2725. * @param result defines the Vector3 object where to store the result
  2726. * @returns the current Vector3
  2727. */
  2728. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2729. /**
  2730. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2731. * @param x defines the x coordinate of the operand
  2732. * @param y defines the y coordinate of the operand
  2733. * @param z defines the z coordinate of the operand
  2734. * @returns the new Vector3
  2735. */
  2736. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2737. /**
  2738. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2739. * @param otherVector defines the second operand
  2740. * @returns the new Vector3
  2741. */
  2742. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2743. /**
  2744. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2745. * @param otherVector defines the second operand
  2746. * @param result defines the Vector3 object where to store the result
  2747. * @returns the current Vector3
  2748. */
  2749. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2750. /**
  2751. * Divides the current Vector3 coordinates by the given ones.
  2752. * @param otherVector defines the second operand
  2753. * @returns the current updated Vector3
  2754. */
  2755. divideInPlace(otherVector: Vector3): Vector3;
  2756. /**
  2757. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2758. * @param other defines the second operand
  2759. * @returns the current updated Vector3
  2760. */
  2761. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2762. /**
  2763. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2764. * @param other defines the second operand
  2765. * @returns the current updated Vector3
  2766. */
  2767. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2768. /**
  2769. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2770. * @param x defines the x coordinate of the operand
  2771. * @param y defines the y coordinate of the operand
  2772. * @param z defines the z coordinate of the operand
  2773. * @returns the current updated Vector3
  2774. */
  2775. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2776. /**
  2777. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2778. * @param x defines the x coordinate of the operand
  2779. * @param y defines the y coordinate of the operand
  2780. * @param z defines the z coordinate of the operand
  2781. * @returns the current updated Vector3
  2782. */
  2783. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2784. /**
  2785. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2786. * Check if is non uniform within a certain amount of decimal places to account for this
  2787. * @param epsilon the amount the values can differ
  2788. * @returns if the the vector is non uniform to a certain number of decimal places
  2789. */
  2790. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2791. /**
  2792. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2793. */
  2794. get isNonUniform(): boolean;
  2795. /**
  2796. * Gets a new Vector3 from current Vector3 floored values
  2797. * @returns a new Vector3
  2798. */
  2799. floor(): Vector3;
  2800. /**
  2801. * Gets a new Vector3 from current Vector3 floored values
  2802. * @returns a new Vector3
  2803. */
  2804. fract(): Vector3;
  2805. /**
  2806. * Gets the length of the Vector3
  2807. * @returns the length of the Vector3
  2808. */
  2809. length(): number;
  2810. /**
  2811. * Gets the squared length of the Vector3
  2812. * @returns squared length of the Vector3
  2813. */
  2814. lengthSquared(): number;
  2815. /**
  2816. * Normalize the current Vector3.
  2817. * Please note that this is an in place operation.
  2818. * @returns the current updated Vector3
  2819. */
  2820. normalize(): Vector3;
  2821. /**
  2822. * Reorders the x y z properties of the vector in place
  2823. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2824. * @returns the current updated vector
  2825. */
  2826. reorderInPlace(order: string): this;
  2827. /**
  2828. * Rotates the vector around 0,0,0 by a quaternion
  2829. * @param quaternion the rotation quaternion
  2830. * @param result vector to store the result
  2831. * @returns the resulting vector
  2832. */
  2833. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2834. /**
  2835. * Rotates a vector around a given point
  2836. * @param quaternion the rotation quaternion
  2837. * @param point the point to rotate around
  2838. * @param result vector to store the result
  2839. * @returns the resulting vector
  2840. */
  2841. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2842. /**
  2843. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2844. * The cross product is then orthogonal to both current and "other"
  2845. * @param other defines the right operand
  2846. * @returns the cross product
  2847. */
  2848. cross(other: Vector3): Vector3;
  2849. /**
  2850. * Normalize the current Vector3 with the given input length.
  2851. * Please note that this is an in place operation.
  2852. * @param len the length of the vector
  2853. * @returns the current updated Vector3
  2854. */
  2855. normalizeFromLength(len: number): Vector3;
  2856. /**
  2857. * Normalize the current Vector3 to a new vector
  2858. * @returns the new Vector3
  2859. */
  2860. normalizeToNew(): Vector3;
  2861. /**
  2862. * Normalize the current Vector3 to the reference
  2863. * @param reference define the Vector3 to update
  2864. * @returns the updated Vector3
  2865. */
  2866. normalizeToRef(reference: Vector3): Vector3;
  2867. /**
  2868. * Creates a new Vector3 copied from the current Vector3
  2869. * @returns the new Vector3
  2870. */
  2871. clone(): Vector3;
  2872. /**
  2873. * Copies the given vector coordinates to the current Vector3 ones
  2874. * @param source defines the source Vector3
  2875. * @returns the current updated Vector3
  2876. */
  2877. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2878. /**
  2879. * Copies the given floats to the current Vector3 coordinates
  2880. * @param x defines the x coordinate of the operand
  2881. * @param y defines the y coordinate of the operand
  2882. * @param z defines the z coordinate of the operand
  2883. * @returns the current updated Vector3
  2884. */
  2885. copyFromFloats(x: number, y: number, z: number): Vector3;
  2886. /**
  2887. * Copies the given floats to the current Vector3 coordinates
  2888. * @param x defines the x coordinate of the operand
  2889. * @param y defines the y coordinate of the operand
  2890. * @param z defines the z coordinate of the operand
  2891. * @returns the current updated Vector3
  2892. */
  2893. set(x: number, y: number, z: number): Vector3;
  2894. /**
  2895. * Copies the given float to the current Vector3 coordinates
  2896. * @param v defines the x, y and z coordinates of the operand
  2897. * @returns the current updated Vector3
  2898. */
  2899. setAll(v: number): Vector3;
  2900. /**
  2901. * Get the clip factor between two vectors
  2902. * @param vector0 defines the first operand
  2903. * @param vector1 defines the second operand
  2904. * @param axis defines the axis to use
  2905. * @param size defines the size along the axis
  2906. * @returns the clip factor
  2907. */
  2908. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2909. /**
  2910. * Get angle between two vectors
  2911. * @param vector0 angle between vector0 and vector1
  2912. * @param vector1 angle between vector0 and vector1
  2913. * @param normal direction of the normal
  2914. * @return the angle between vector0 and vector1
  2915. */
  2916. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2917. /**
  2918. * Returns a new Vector3 set from the index "offset" of the given array
  2919. * @param array defines the source array
  2920. * @param offset defines the offset in the source array
  2921. * @returns the new Vector3
  2922. */
  2923. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2924. /**
  2925. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2926. * @param array defines the source array
  2927. * @param offset defines the offset in the source array
  2928. * @returns the new Vector3
  2929. * @deprecated Please use FromArray instead.
  2930. */
  2931. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2932. /**
  2933. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2934. * @param array defines the source array
  2935. * @param offset defines the offset in the source array
  2936. * @param result defines the Vector3 where to store the result
  2937. */
  2938. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2939. /**
  2940. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2941. * @param array defines the source array
  2942. * @param offset defines the offset in the source array
  2943. * @param result defines the Vector3 where to store the result
  2944. * @deprecated Please use FromArrayToRef instead.
  2945. */
  2946. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2947. /**
  2948. * Sets the given vector "result" with the given floats.
  2949. * @param x defines the x coordinate of the source
  2950. * @param y defines the y coordinate of the source
  2951. * @param z defines the z coordinate of the source
  2952. * @param result defines the Vector3 where to store the result
  2953. */
  2954. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2955. /**
  2956. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2957. * @returns a new empty Vector3
  2958. */
  2959. static Zero(): Vector3;
  2960. /**
  2961. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2962. * @returns a new unit Vector3
  2963. */
  2964. static One(): Vector3;
  2965. /**
  2966. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2967. * @returns a new up Vector3
  2968. */
  2969. static Up(): Vector3;
  2970. /**
  2971. * Gets a up Vector3 that must not be updated
  2972. */
  2973. static get UpReadOnly(): DeepImmutable<Vector3>;
  2974. /**
  2975. * Gets a zero Vector3 that must not be updated
  2976. */
  2977. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2980. * @returns a new down Vector3
  2981. */
  2982. static Down(): Vector3;
  2983. /**
  2984. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2985. * @param rightHandedSystem is the scene right-handed (negative z)
  2986. * @returns a new forward Vector3
  2987. */
  2988. static Forward(rightHandedSystem?: boolean): Vector3;
  2989. /**
  2990. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2991. * @param rightHandedSystem is the scene right-handed (negative-z)
  2992. * @returns a new forward Vector3
  2993. */
  2994. static Backward(rightHandedSystem?: boolean): Vector3;
  2995. /**
  2996. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2997. * @returns a new right Vector3
  2998. */
  2999. static Right(): Vector3;
  3000. /**
  3001. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3002. * @returns a new left Vector3
  3003. */
  3004. static Left(): Vector3;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3007. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the transformed Vector3
  3011. */
  3012. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3015. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3023. * This method computes tranformed coordinates only, not transformed direction vectors
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3033. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3034. * @param vector defines the Vector3 to transform
  3035. * @param transformation defines the transformation matrix
  3036. * @returns the new Vector3
  3037. */
  3038. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3039. /**
  3040. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3041. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3042. * @param vector defines the Vector3 to transform
  3043. * @param transformation defines the transformation matrix
  3044. * @param result defines the Vector3 where to store the result
  3045. */
  3046. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3047. /**
  3048. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3049. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3050. * @param x define the x coordinate of the source vector
  3051. * @param y define the y coordinate of the source vector
  3052. * @param z define the z coordinate of the source vector
  3053. * @param transformation defines the transformation matrix
  3054. * @param result defines the Vector3 where to store the result
  3055. */
  3056. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3057. /**
  3058. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3059. * @param value1 defines the first control point
  3060. * @param value2 defines the second control point
  3061. * @param value3 defines the third control point
  3062. * @param value4 defines the fourth control point
  3063. * @param amount defines the amount on the spline to use
  3064. * @returns the new Vector3
  3065. */
  3066. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3067. /**
  3068. * 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"
  3069. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3070. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3071. * @param value defines the current value
  3072. * @param min defines the lower range value
  3073. * @param max defines the upper range value
  3074. * @returns the new Vector3
  3075. */
  3076. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3077. /**
  3078. * 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"
  3079. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3080. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3081. * @param value defines the current value
  3082. * @param min defines the lower range value
  3083. * @param max defines the upper range value
  3084. * @param result defines the Vector3 where to store the result
  3085. */
  3086. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3087. /**
  3088. * Checks if a given vector is inside a specific range
  3089. * @param v defines the vector to test
  3090. * @param min defines the minimum range
  3091. * @param max defines the maximum range
  3092. */
  3093. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3094. /**
  3095. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3096. * @param value1 defines the first control point
  3097. * @param tangent1 defines the first tangent vector
  3098. * @param value2 defines the second control point
  3099. * @param tangent2 defines the second tangent vector
  3100. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3101. * @returns the new Vector3
  3102. */
  3103. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3104. /**
  3105. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3106. * @param start defines the start value
  3107. * @param end defines the end value
  3108. * @param amount max defines amount between both (between 0 and 1)
  3109. * @returns the new Vector3
  3110. */
  3111. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3112. /**
  3113. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3114. * @param start defines the start value
  3115. * @param end defines the end value
  3116. * @param amount max defines amount between both (between 0 and 1)
  3117. * @param result defines the Vector3 where to store the result
  3118. */
  3119. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3120. /**
  3121. * Returns the dot product (float) between the vectors "left" and "right"
  3122. * @param left defines the left operand
  3123. * @param right defines the right operand
  3124. * @returns the dot product
  3125. */
  3126. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3127. /**
  3128. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3129. * The cross product is then orthogonal to both "left" and "right"
  3130. * @param left defines the left operand
  3131. * @param right defines the right operand
  3132. * @returns the cross product
  3133. */
  3134. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3135. /**
  3136. * Sets the given vector "result" with the cross product of "left" and "right"
  3137. * The cross product is then orthogonal to both "left" and "right"
  3138. * @param left defines the left operand
  3139. * @param right defines the right operand
  3140. * @param result defines the Vector3 where to store the result
  3141. */
  3142. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3143. /**
  3144. * Returns a new Vector3 as the normalization of the given vector
  3145. * @param vector defines the Vector3 to normalize
  3146. * @returns the new Vector3
  3147. */
  3148. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3149. /**
  3150. * Sets the given vector "result" with the normalization of the given first vector
  3151. * @param vector defines the Vector3 to normalize
  3152. * @param result defines the Vector3 where to store the result
  3153. */
  3154. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3155. /**
  3156. * Project a Vector3 onto screen space
  3157. * @param vector defines the Vector3 to project
  3158. * @param world defines the world matrix to use
  3159. * @param transform defines the transform (view x projection) matrix to use
  3160. * @param viewport defines the screen viewport to use
  3161. * @returns the new Vector3
  3162. */
  3163. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3164. /** @hidden */
  3165. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3166. /**
  3167. * Unproject from screen space to object space
  3168. * @param source defines the screen space Vector3 to use
  3169. * @param viewportWidth defines the current width of the viewport
  3170. * @param viewportHeight defines the current height of the viewport
  3171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3172. * @param transform defines the transform (view x projection) matrix to use
  3173. * @returns the new Vector3
  3174. */
  3175. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3176. /**
  3177. * Unproject from screen space to object space
  3178. * @param source defines the screen space Vector3 to use
  3179. * @param viewportWidth defines the current width of the viewport
  3180. * @param viewportHeight defines the current height of the viewport
  3181. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3182. * @param view defines the view matrix to use
  3183. * @param projection defines the projection matrix to use
  3184. * @returns the new Vector3
  3185. */
  3186. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3187. /**
  3188. * Unproject from screen space to object space
  3189. * @param source defines the screen space Vector3 to use
  3190. * @param viewportWidth defines the current width of the viewport
  3191. * @param viewportHeight defines the current height of the viewport
  3192. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3193. * @param view defines the view matrix to use
  3194. * @param projection defines the projection matrix to use
  3195. * @param result defines the Vector3 where to store the result
  3196. */
  3197. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3198. /**
  3199. * Unproject from screen space to object space
  3200. * @param sourceX defines the screen space x coordinate to use
  3201. * @param sourceY defines the screen space y coordinate to use
  3202. * @param sourceZ defines the screen space z coordinate to use
  3203. * @param viewportWidth defines the current width of the viewport
  3204. * @param viewportHeight defines the current height of the viewport
  3205. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3206. * @param view defines the view matrix to use
  3207. * @param projection defines the projection matrix to use
  3208. * @param result defines the Vector3 where to store the result
  3209. */
  3210. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3211. /**
  3212. * Gets the minimal coordinate values between two Vector3
  3213. * @param left defines the first operand
  3214. * @param right defines the second operand
  3215. * @returns the new Vector3
  3216. */
  3217. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3218. /**
  3219. * Gets the maximal coordinate values between two Vector3
  3220. * @param left defines the first operand
  3221. * @param right defines the second operand
  3222. * @returns the new Vector3
  3223. */
  3224. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3225. /**
  3226. * Returns the distance between the vectors "value1" and "value2"
  3227. * @param value1 defines the first operand
  3228. * @param value2 defines the second operand
  3229. * @returns the distance
  3230. */
  3231. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3232. /**
  3233. * Returns the squared distance between the vectors "value1" and "value2"
  3234. * @param value1 defines the first operand
  3235. * @param value2 defines the second operand
  3236. * @returns the squared distance
  3237. */
  3238. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3239. /**
  3240. * Returns a new Vector3 located at the center between "value1" and "value2"
  3241. * @param value1 defines the first operand
  3242. * @param value2 defines the second operand
  3243. * @returns the new Vector3
  3244. */
  3245. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3246. /**
  3247. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3248. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3249. * to something in order to rotate it from its local system to the given target system
  3250. * Note: axis1, axis2 and axis3 are normalized during this operation
  3251. * @param axis1 defines the first axis
  3252. * @param axis2 defines the second axis
  3253. * @param axis3 defines the third axis
  3254. * @returns a new Vector3
  3255. */
  3256. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3257. /**
  3258. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3259. * @param axis1 defines the first axis
  3260. * @param axis2 defines the second axis
  3261. * @param axis3 defines the third axis
  3262. * @param ref defines the Vector3 where to store the result
  3263. */
  3264. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3265. }
  3266. /**
  3267. * Vector4 class created for EulerAngle class conversion to Quaternion
  3268. */
  3269. export class Vector4 {
  3270. /** x value of the vector */
  3271. x: number;
  3272. /** y value of the vector */
  3273. y: number;
  3274. /** z value of the vector */
  3275. z: number;
  3276. /** w value of the vector */
  3277. w: number;
  3278. /**
  3279. * Creates a Vector4 object from the given floats.
  3280. * @param x x value of the vector
  3281. * @param y y value of the vector
  3282. * @param z z value of the vector
  3283. * @param w w value of the vector
  3284. */
  3285. constructor(
  3286. /** x value of the vector */
  3287. x: number,
  3288. /** y value of the vector */
  3289. y: number,
  3290. /** z value of the vector */
  3291. z: number,
  3292. /** w value of the vector */
  3293. w: number);
  3294. /**
  3295. * Returns the string with the Vector4 coordinates.
  3296. * @returns a string containing all the vector values
  3297. */
  3298. toString(): string;
  3299. /**
  3300. * Returns the string "Vector4".
  3301. * @returns "Vector4"
  3302. */
  3303. getClassName(): string;
  3304. /**
  3305. * Returns the Vector4 hash code.
  3306. * @returns a unique hash code
  3307. */
  3308. getHashCode(): number;
  3309. /**
  3310. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3311. * @returns the resulting array
  3312. */
  3313. asArray(): number[];
  3314. /**
  3315. * Populates the given array from the given index with the Vector4 coordinates.
  3316. * @param array array to populate
  3317. * @param index index of the array to start at (default: 0)
  3318. * @returns the Vector4.
  3319. */
  3320. toArray(array: FloatArray, index?: number): Vector4;
  3321. /**
  3322. * Update the current vector from an array
  3323. * @param array defines the destination array
  3324. * @param index defines the offset in the destination array
  3325. * @returns the current Vector3
  3326. */
  3327. fromArray(array: FloatArray, index?: number): Vector4;
  3328. /**
  3329. * Adds the given vector to the current Vector4.
  3330. * @param otherVector the vector to add
  3331. * @returns the updated Vector4.
  3332. */
  3333. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3334. /**
  3335. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3336. * @param otherVector the vector to add
  3337. * @returns the resulting vector
  3338. */
  3339. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3340. /**
  3341. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3342. * @param otherVector the vector to add
  3343. * @param result the vector to store the result
  3344. * @returns the current Vector4.
  3345. */
  3346. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3347. /**
  3348. * Subtract in place the given vector from the current Vector4.
  3349. * @param otherVector the vector to subtract
  3350. * @returns the updated Vector4.
  3351. */
  3352. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3353. /**
  3354. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3355. * @param otherVector the vector to add
  3356. * @returns the new vector with the result
  3357. */
  3358. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3359. /**
  3360. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3361. * @param otherVector the vector to subtract
  3362. * @param result the vector to store the result
  3363. * @returns the current Vector4.
  3364. */
  3365. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3366. /**
  3367. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3368. */
  3369. /**
  3370. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3371. * @param x value to subtract
  3372. * @param y value to subtract
  3373. * @param z value to subtract
  3374. * @param w value to subtract
  3375. * @returns new vector containing the result
  3376. */
  3377. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3378. /**
  3379. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3380. * @param x value to subtract
  3381. * @param y value to subtract
  3382. * @param z value to subtract
  3383. * @param w value to subtract
  3384. * @param result the vector to store the result in
  3385. * @returns the current Vector4.
  3386. */
  3387. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3388. /**
  3389. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3390. * @returns a new vector with the negated values
  3391. */
  3392. negate(): Vector4;
  3393. /**
  3394. * Negate this vector in place
  3395. * @returns this
  3396. */
  3397. negateInPlace(): Vector4;
  3398. /**
  3399. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3400. * @param result defines the Vector3 object where to store the result
  3401. * @returns the current Vector4
  3402. */
  3403. negateToRef(result: Vector4): Vector4;
  3404. /**
  3405. * Multiplies the current Vector4 coordinates by scale (float).
  3406. * @param scale the number to scale with
  3407. * @returns the updated Vector4.
  3408. */
  3409. scaleInPlace(scale: number): Vector4;
  3410. /**
  3411. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3412. * @param scale the number to scale with
  3413. * @returns a new vector with the result
  3414. */
  3415. scale(scale: number): Vector4;
  3416. /**
  3417. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3418. * @param scale the number to scale with
  3419. * @param result a vector to store the result in
  3420. * @returns the current Vector4.
  3421. */
  3422. scaleToRef(scale: number, result: Vector4): Vector4;
  3423. /**
  3424. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3425. * @param scale defines the scale factor
  3426. * @param result defines the Vector4 object where to store the result
  3427. * @returns the unmodified current Vector4
  3428. */
  3429. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3430. /**
  3431. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3432. * @param otherVector the vector to compare against
  3433. * @returns true if they are equal
  3434. */
  3435. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3436. /**
  3437. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3438. * @param otherVector vector to compare against
  3439. * @param epsilon (Default: very small number)
  3440. * @returns true if they are equal
  3441. */
  3442. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3443. /**
  3444. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3445. * @param x x value to compare against
  3446. * @param y y value to compare against
  3447. * @param z z value to compare against
  3448. * @param w w value to compare against
  3449. * @returns true if equal
  3450. */
  3451. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3452. /**
  3453. * Multiplies in place the current Vector4 by the given one.
  3454. * @param otherVector vector to multiple with
  3455. * @returns the updated Vector4.
  3456. */
  3457. multiplyInPlace(otherVector: Vector4): Vector4;
  3458. /**
  3459. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3460. * @param otherVector vector to multiple with
  3461. * @returns resulting new vector
  3462. */
  3463. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3464. /**
  3465. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3466. * @param otherVector vector to multiple with
  3467. * @param result vector to store the result
  3468. * @returns the current Vector4.
  3469. */
  3470. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3471. /**
  3472. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3473. * @param x x value multiply with
  3474. * @param y y value multiply with
  3475. * @param z z value multiply with
  3476. * @param w w value multiply with
  3477. * @returns resulting new vector
  3478. */
  3479. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3480. /**
  3481. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3482. * @param otherVector vector to devide with
  3483. * @returns resulting new vector
  3484. */
  3485. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3486. /**
  3487. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3488. * @param otherVector vector to devide with
  3489. * @param result vector to store the result
  3490. * @returns the current Vector4.
  3491. */
  3492. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3493. /**
  3494. * Divides the current Vector3 coordinates by the given ones.
  3495. * @param otherVector vector to devide with
  3496. * @returns the updated Vector3.
  3497. */
  3498. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3499. /**
  3500. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3501. * @param other defines the second operand
  3502. * @returns the current updated Vector4
  3503. */
  3504. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3505. /**
  3506. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3507. * @param other defines the second operand
  3508. * @returns the current updated Vector4
  3509. */
  3510. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3511. /**
  3512. * Gets a new Vector4 from current Vector4 floored values
  3513. * @returns a new Vector4
  3514. */
  3515. floor(): Vector4;
  3516. /**
  3517. * Gets a new Vector4 from current Vector3 floored values
  3518. * @returns a new Vector4
  3519. */
  3520. fract(): Vector4;
  3521. /**
  3522. * Returns the Vector4 length (float).
  3523. * @returns the length
  3524. */
  3525. length(): number;
  3526. /**
  3527. * Returns the Vector4 squared length (float).
  3528. * @returns the length squared
  3529. */
  3530. lengthSquared(): number;
  3531. /**
  3532. * Normalizes in place the Vector4.
  3533. * @returns the updated Vector4.
  3534. */
  3535. normalize(): Vector4;
  3536. /**
  3537. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3538. * @returns this converted to a new vector3
  3539. */
  3540. toVector3(): Vector3;
  3541. /**
  3542. * Returns a new Vector4 copied from the current one.
  3543. * @returns the new cloned vector
  3544. */
  3545. clone(): Vector4;
  3546. /**
  3547. * Updates the current Vector4 with the given one coordinates.
  3548. * @param source the source vector to copy from
  3549. * @returns the updated Vector4.
  3550. */
  3551. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3552. /**
  3553. * Updates the current Vector4 coordinates with the given floats.
  3554. * @param x float to copy from
  3555. * @param y float to copy from
  3556. * @param z float to copy from
  3557. * @param w float to copy from
  3558. * @returns the updated Vector4.
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3561. /**
  3562. * Updates the current Vector4 coordinates with the given floats.
  3563. * @param x float to set from
  3564. * @param y float to set from
  3565. * @param z float to set from
  3566. * @param w float to set from
  3567. * @returns the updated Vector4.
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Vector4;
  3570. /**
  3571. * Copies the given float to the current Vector3 coordinates
  3572. * @param v defines the x, y, z and w coordinates of the operand
  3573. * @returns the current updated Vector3
  3574. */
  3575. setAll(v: number): Vector4;
  3576. /**
  3577. * Returns a new Vector4 set from the starting index of the given array.
  3578. * @param array the array to pull values from
  3579. * @param offset the offset into the array to start at
  3580. * @returns the new vector
  3581. */
  3582. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3583. /**
  3584. * Updates the given vector "result" from the starting index of the given array.
  3585. * @param array the array to pull values from
  3586. * @param offset the offset into the array to start at
  3587. * @param result the vector to store the result in
  3588. */
  3589. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3590. /**
  3591. * Updates the given vector "result" from the starting index of the given Float32Array.
  3592. * @param array the array to pull values from
  3593. * @param offset the offset into the array to start at
  3594. * @param result the vector to store the result in
  3595. */
  3596. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3597. /**
  3598. * Updates the given vector "result" coordinates from the given floats.
  3599. * @param x float to set from
  3600. * @param y float to set from
  3601. * @param z float to set from
  3602. * @param w float to set from
  3603. * @param result the vector to the floats in
  3604. */
  3605. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3606. /**
  3607. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3608. * @returns the new vector
  3609. */
  3610. static Zero(): Vector4;
  3611. /**
  3612. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3613. * @returns the new vector
  3614. */
  3615. static One(): Vector4;
  3616. /**
  3617. * Returns a new normalized Vector4 from the given one.
  3618. * @param vector the vector to normalize
  3619. * @returns the vector
  3620. */
  3621. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3622. /**
  3623. * Updates the given vector "result" from the normalization of the given one.
  3624. * @param vector the vector to normalize
  3625. * @param result the vector to store the result in
  3626. */
  3627. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3628. /**
  3629. * Returns a vector with the minimum values from the left and right vectors
  3630. * @param left left vector to minimize
  3631. * @param right right vector to minimize
  3632. * @returns a new vector with the minimum of the left and right vector values
  3633. */
  3634. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3635. /**
  3636. * Returns a vector with the maximum values from the left and right vectors
  3637. * @param left left vector to maximize
  3638. * @param right right vector to maximize
  3639. * @returns a new vector with the maximum of the left and right vector values
  3640. */
  3641. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3642. /**
  3643. * Returns the distance (float) between the vectors "value1" and "value2".
  3644. * @param value1 value to calulate the distance between
  3645. * @param value2 value to calulate the distance between
  3646. * @return the distance between the two vectors
  3647. */
  3648. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3649. /**
  3650. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3651. * @param value1 value to calulate the distance between
  3652. * @param value2 value to calulate the distance between
  3653. * @return the distance between the two vectors squared
  3654. */
  3655. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3656. /**
  3657. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3658. * @param value1 value to calulate the center between
  3659. * @param value2 value to calulate the center between
  3660. * @return the center between the two vectors
  3661. */
  3662. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3663. /**
  3664. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3665. * This methods computes transformed normalized direction vectors only.
  3666. * @param vector the vector to transform
  3667. * @param transformation the transformation matrix to apply
  3668. * @returns the new vector
  3669. */
  3670. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3671. /**
  3672. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3673. * This methods computes transformed normalized direction vectors only.
  3674. * @param vector the vector to transform
  3675. * @param transformation the transformation matrix to apply
  3676. * @param result the vector to store the result in
  3677. */
  3678. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3679. /**
  3680. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3681. * This methods computes transformed normalized direction vectors only.
  3682. * @param x value to transform
  3683. * @param y value to transform
  3684. * @param z value to transform
  3685. * @param w value to transform
  3686. * @param transformation the transformation matrix to apply
  3687. * @param result the vector to store the results in
  3688. */
  3689. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3690. /**
  3691. * Creates a new Vector4 from a Vector3
  3692. * @param source defines the source data
  3693. * @param w defines the 4th component (default is 0)
  3694. * @returns a new Vector4
  3695. */
  3696. static FromVector3(source: Vector3, w?: number): Vector4;
  3697. }
  3698. /**
  3699. * Class used to store quaternion data
  3700. * @see https://en.wikipedia.org/wiki/Quaternion
  3701. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3702. */
  3703. export class Quaternion {
  3704. /** @hidden */
  3705. _x: number;
  3706. /** @hidden */
  3707. _y: number;
  3708. /** @hidden */
  3709. _z: number;
  3710. /** @hidden */
  3711. _w: number;
  3712. /** @hidden */
  3713. _isDirty: boolean;
  3714. /** Gets or sets the x coordinate */
  3715. get x(): number;
  3716. set x(value: number);
  3717. /** Gets or sets the y coordinate */
  3718. get y(): number;
  3719. set y(value: number);
  3720. /** Gets or sets the z coordinate */
  3721. get z(): number;
  3722. set z(value: number);
  3723. /** Gets or sets the w coordinate */
  3724. get w(): number;
  3725. set w(value: number);
  3726. /**
  3727. * Creates a new Quaternion from the given floats
  3728. * @param x defines the first component (0 by default)
  3729. * @param y defines the second component (0 by default)
  3730. * @param z defines the third component (0 by default)
  3731. * @param w defines the fourth component (1.0 by default)
  3732. */
  3733. constructor(x?: number, y?: number, z?: number, w?: number);
  3734. /**
  3735. * Gets a string representation for the current quaternion
  3736. * @returns a string with the Quaternion coordinates
  3737. */
  3738. toString(): string;
  3739. /**
  3740. * Gets the class name of the quaternion
  3741. * @returns the string "Quaternion"
  3742. */
  3743. getClassName(): string;
  3744. /**
  3745. * Gets a hash code for this quaternion
  3746. * @returns the quaternion hash code
  3747. */
  3748. getHashCode(): number;
  3749. /**
  3750. * Copy the quaternion to an array
  3751. * @returns a new array populated with 4 elements from the quaternion coordinates
  3752. */
  3753. asArray(): number[];
  3754. /**
  3755. * Check if two quaternions are equals
  3756. * @param otherQuaternion defines the second operand
  3757. * @return true if the current quaternion and the given one coordinates are strictly equals
  3758. */
  3759. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3760. /**
  3761. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3762. * @param otherQuaternion defines the other quaternion
  3763. * @param epsilon defines the minimal distance to consider equality
  3764. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3765. */
  3766. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3767. /**
  3768. * Clone the current quaternion
  3769. * @returns a new quaternion copied from the current one
  3770. */
  3771. clone(): Quaternion;
  3772. /**
  3773. * Copy a quaternion to the current one
  3774. * @param other defines the other quaternion
  3775. * @returns the updated current quaternion
  3776. */
  3777. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3778. /**
  3779. * Updates the current quaternion with the given float coordinates
  3780. * @param x defines the x coordinate
  3781. * @param y defines the y coordinate
  3782. * @param z defines the z coordinate
  3783. * @param w defines the w coordinate
  3784. * @returns the updated current quaternion
  3785. */
  3786. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3787. /**
  3788. * Updates the current quaternion from the given float coordinates
  3789. * @param x defines the x coordinate
  3790. * @param y defines the y coordinate
  3791. * @param z defines the z coordinate
  3792. * @param w defines the w coordinate
  3793. * @returns the updated current quaternion
  3794. */
  3795. set(x: number, y: number, z: number, w: number): Quaternion;
  3796. /**
  3797. * Adds two quaternions
  3798. * @param other defines the second operand
  3799. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3800. */
  3801. add(other: DeepImmutable<Quaternion>): Quaternion;
  3802. /**
  3803. * Add a quaternion to the current one
  3804. * @param other defines the quaternion to add
  3805. * @returns the current quaternion
  3806. */
  3807. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3808. /**
  3809. * Subtract two quaternions
  3810. * @param other defines the second operand
  3811. * @returns a new quaternion as the subtraction result of the given one from the current one
  3812. */
  3813. subtract(other: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies the current quaternion by a scale factor
  3816. * @param value defines the scale factor
  3817. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3818. */
  3819. scale(value: number): Quaternion;
  3820. /**
  3821. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3822. * @param scale defines the scale factor
  3823. * @param result defines the Quaternion object where to store the result
  3824. * @returns the unmodified current quaternion
  3825. */
  3826. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3827. /**
  3828. * Multiplies in place the current quaternion by a scale factor
  3829. * @param value defines the scale factor
  3830. * @returns the current modified quaternion
  3831. */
  3832. scaleInPlace(value: number): Quaternion;
  3833. /**
  3834. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3835. * @param scale defines the scale factor
  3836. * @param result defines the Quaternion object where to store the result
  3837. * @returns the unmodified current quaternion
  3838. */
  3839. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3840. /**
  3841. * Multiplies two quaternions
  3842. * @param q1 defines the second operand
  3843. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3844. */
  3845. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3846. /**
  3847. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3848. * @param q1 defines the second operand
  3849. * @param result defines the target quaternion
  3850. * @returns the current quaternion
  3851. */
  3852. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3853. /**
  3854. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3855. * @param q1 defines the second operand
  3856. * @returns the currentupdated quaternion
  3857. */
  3858. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3859. /**
  3860. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3861. * @param ref defines the target quaternion
  3862. * @returns the current quaternion
  3863. */
  3864. conjugateToRef(ref: Quaternion): Quaternion;
  3865. /**
  3866. * Conjugates in place (1-q) the current quaternion
  3867. * @returns the current updated quaternion
  3868. */
  3869. conjugateInPlace(): Quaternion;
  3870. /**
  3871. * Conjugates in place (1-q) the current quaternion
  3872. * @returns a new quaternion
  3873. */
  3874. conjugate(): Quaternion;
  3875. /**
  3876. * Gets length of current quaternion
  3877. * @returns the quaternion length (float)
  3878. */
  3879. length(): number;
  3880. /**
  3881. * Normalize in place the current quaternion
  3882. * @returns the current updated quaternion
  3883. */
  3884. normalize(): Quaternion;
  3885. /**
  3886. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3887. * @param order is a reserved parameter and is ignore for now
  3888. * @returns a new Vector3 containing the Euler angles
  3889. */
  3890. toEulerAngles(order?: string): Vector3;
  3891. /**
  3892. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3893. * @param result defines the vector which will be filled with the Euler angles
  3894. * @param order is a reserved parameter and is ignore for now
  3895. * @returns the current unchanged quaternion
  3896. */
  3897. toEulerAnglesToRef(result: Vector3): Quaternion;
  3898. /**
  3899. * Updates the given rotation matrix with the current quaternion values
  3900. * @param result defines the target matrix
  3901. * @returns the current unchanged quaternion
  3902. */
  3903. toRotationMatrix(result: Matrix): Quaternion;
  3904. /**
  3905. * Updates the current quaternion from the given rotation matrix values
  3906. * @param matrix defines the source matrix
  3907. * @returns the current updated quaternion
  3908. */
  3909. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3910. /**
  3911. * Creates a new quaternion from a rotation matrix
  3912. * @param matrix defines the source matrix
  3913. * @returns a new quaternion created from the given rotation matrix values
  3914. */
  3915. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3916. /**
  3917. * Updates the given quaternion with the given rotation matrix values
  3918. * @param matrix defines the source matrix
  3919. * @param result defines the target quaternion
  3920. */
  3921. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3922. /**
  3923. * Returns the dot product (float) between the quaternions "left" and "right"
  3924. * @param left defines the left operand
  3925. * @param right defines the right operand
  3926. * @returns the dot product
  3927. */
  3928. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3929. /**
  3930. * Checks if the two quaternions are close to each other
  3931. * @param quat0 defines the first quaternion to check
  3932. * @param quat1 defines the second quaternion to check
  3933. * @returns true if the two quaternions are close to each other
  3934. */
  3935. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3936. /**
  3937. * Creates an empty quaternion
  3938. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3939. */
  3940. static Zero(): Quaternion;
  3941. /**
  3942. * Inverse a given quaternion
  3943. * @param q defines the source quaternion
  3944. * @returns a new quaternion as the inverted current quaternion
  3945. */
  3946. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3947. /**
  3948. * Inverse a given quaternion
  3949. * @param q defines the source quaternion
  3950. * @param result the quaternion the result will be stored in
  3951. * @returns the result quaternion
  3952. */
  3953. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3954. /**
  3955. * Creates an identity quaternion
  3956. * @returns the identity quaternion
  3957. */
  3958. static Identity(): Quaternion;
  3959. /**
  3960. * Gets a boolean indicating if the given quaternion is identity
  3961. * @param quaternion defines the quaternion to check
  3962. * @returns true if the quaternion is identity
  3963. */
  3964. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3965. /**
  3966. * Creates a quaternion from a rotation around an axis
  3967. * @param axis defines the axis to use
  3968. * @param angle defines the angle to use
  3969. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3970. */
  3971. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3972. /**
  3973. * Creates a rotation around an axis and stores it into the given quaternion
  3974. * @param axis defines the axis to use
  3975. * @param angle defines the angle to use
  3976. * @param result defines the target quaternion
  3977. * @returns the target quaternion
  3978. */
  3979. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3980. /**
  3981. * Creates a new quaternion from data stored into an array
  3982. * @param array defines the data source
  3983. * @param offset defines the offset in the source array where the data starts
  3984. * @returns a new quaternion
  3985. */
  3986. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3987. /**
  3988. * Updates the given quaternion "result" from the starting index of the given array.
  3989. * @param array the array to pull values from
  3990. * @param offset the offset into the array to start at
  3991. * @param result the quaternion to store the result in
  3992. */
  3993. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3994. /**
  3995. * Create a quaternion from Euler rotation angles
  3996. * @param x Pitch
  3997. * @param y Yaw
  3998. * @param z Roll
  3999. * @returns the new Quaternion
  4000. */
  4001. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4002. /**
  4003. * Updates a quaternion from Euler rotation angles
  4004. * @param x Pitch
  4005. * @param y Yaw
  4006. * @param z Roll
  4007. * @param result the quaternion to store the result
  4008. * @returns the updated quaternion
  4009. */
  4010. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4011. /**
  4012. * Create a quaternion from Euler rotation vector
  4013. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4014. * @returns the new Quaternion
  4015. */
  4016. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4017. /**
  4018. * Updates a quaternion from Euler rotation vector
  4019. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4020. * @param result the quaternion to store the result
  4021. * @returns the updated quaternion
  4022. */
  4023. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4024. /**
  4025. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4026. * @param yaw defines the rotation around Y axis
  4027. * @param pitch defines the rotation around X axis
  4028. * @param roll defines the rotation around Z axis
  4029. * @returns the new quaternion
  4030. */
  4031. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4032. /**
  4033. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4034. * @param yaw defines the rotation around Y axis
  4035. * @param pitch defines the rotation around X axis
  4036. * @param roll defines the rotation around Z axis
  4037. * @param result defines the target quaternion
  4038. */
  4039. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4040. /**
  4041. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4042. * @param alpha defines the rotation around first axis
  4043. * @param beta defines the rotation around second axis
  4044. * @param gamma defines the rotation around third axis
  4045. * @returns the new quaternion
  4046. */
  4047. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4048. /**
  4049. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4050. * @param alpha defines the rotation around first axis
  4051. * @param beta defines the rotation around second axis
  4052. * @param gamma defines the rotation around third axis
  4053. * @param result defines the target quaternion
  4054. */
  4055. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4056. /**
  4057. * 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)
  4058. * @param axis1 defines the first axis
  4059. * @param axis2 defines the second axis
  4060. * @param axis3 defines the third axis
  4061. * @returns the new quaternion
  4062. */
  4063. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4064. /**
  4065. * 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
  4066. * @param axis1 defines the first axis
  4067. * @param axis2 defines the second axis
  4068. * @param axis3 defines the third axis
  4069. * @param ref defines the target quaternion
  4070. */
  4071. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4072. /**
  4073. * Interpolates between two quaternions
  4074. * @param left defines first quaternion
  4075. * @param right defines second quaternion
  4076. * @param amount defines the gradient to use
  4077. * @returns the new interpolated quaternion
  4078. */
  4079. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4080. /**
  4081. * Interpolates between two quaternions and stores it into a target quaternion
  4082. * @param left defines first quaternion
  4083. * @param right defines second quaternion
  4084. * @param amount defines the gradient to use
  4085. * @param result defines the target quaternion
  4086. */
  4087. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4088. /**
  4089. * Interpolate between two quaternions using Hermite interpolation
  4090. * @param value1 defines first quaternion
  4091. * @param tangent1 defines the incoming tangent
  4092. * @param value2 defines second quaternion
  4093. * @param tangent2 defines the outgoing tangent
  4094. * @param amount defines the target quaternion
  4095. * @returns the new interpolated quaternion
  4096. */
  4097. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4098. }
  4099. /**
  4100. * Class used to store matrix data (4x4)
  4101. */
  4102. export class Matrix {
  4103. /**
  4104. * Gets the precision of matrix computations
  4105. */
  4106. static get Use64Bits(): boolean;
  4107. private static _updateFlagSeed;
  4108. private static _identityReadOnly;
  4109. private _isIdentity;
  4110. private _isIdentityDirty;
  4111. private _isIdentity3x2;
  4112. private _isIdentity3x2Dirty;
  4113. /**
  4114. * Gets the update flag of the matrix which is an unique number for the matrix.
  4115. * It will be incremented every time the matrix data change.
  4116. * You can use it to speed the comparison between two versions of the same matrix.
  4117. */
  4118. updateFlag: number;
  4119. private readonly _m;
  4120. /**
  4121. * Gets the internal data of the matrix
  4122. */
  4123. get m(): DeepImmutable<Float32Array | Array<number>>;
  4124. /** @hidden */
  4125. _markAsUpdated(): void;
  4126. /** @hidden */
  4127. private _updateIdentityStatus;
  4128. /**
  4129. * Creates an empty matrix (filled with zeros)
  4130. */
  4131. constructor();
  4132. /**
  4133. * Check if the current matrix is identity
  4134. * @returns true is the matrix is the identity matrix
  4135. */
  4136. isIdentity(): boolean;
  4137. /**
  4138. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4139. * @returns true is the matrix is the identity matrix
  4140. */
  4141. isIdentityAs3x2(): boolean;
  4142. /**
  4143. * Gets the determinant of the matrix
  4144. * @returns the matrix determinant
  4145. */
  4146. determinant(): number;
  4147. /**
  4148. * Returns the matrix as a Float32Array or Array<number>
  4149. * @returns the matrix underlying array
  4150. */
  4151. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4152. /**
  4153. * Returns the matrix as a Float32Array or Array<number>
  4154. * @returns the matrix underlying array.
  4155. */
  4156. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4157. /**
  4158. * Inverts the current matrix in place
  4159. * @returns the current inverted matrix
  4160. */
  4161. invert(): Matrix;
  4162. /**
  4163. * Sets all the matrix elements to zero
  4164. * @returns the current matrix
  4165. */
  4166. reset(): Matrix;
  4167. /**
  4168. * Adds the current matrix with a second one
  4169. * @param other defines the matrix to add
  4170. * @returns a new matrix as the addition of the current matrix and the given one
  4171. */
  4172. add(other: DeepImmutable<Matrix>): Matrix;
  4173. /**
  4174. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4175. * @param other defines the matrix to add
  4176. * @param result defines the target matrix
  4177. * @returns the current matrix
  4178. */
  4179. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4180. /**
  4181. * Adds in place the given matrix to the current matrix
  4182. * @param other defines the second operand
  4183. * @returns the current updated matrix
  4184. */
  4185. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4186. /**
  4187. * Sets the given matrix to the current inverted Matrix
  4188. * @param other defines the target matrix
  4189. * @returns the unmodified current matrix
  4190. */
  4191. invertToRef(other: Matrix): Matrix;
  4192. /**
  4193. * add a value at the specified position in the current Matrix
  4194. * @param index the index of the value within the matrix. between 0 and 15.
  4195. * @param value the value to be added
  4196. * @returns the current updated matrix
  4197. */
  4198. addAtIndex(index: number, value: number): Matrix;
  4199. /**
  4200. * mutiply the specified position in the current Matrix by a value
  4201. * @param index the index of the value within the matrix. between 0 and 15.
  4202. * @param value the value to be added
  4203. * @returns the current updated matrix
  4204. */
  4205. multiplyAtIndex(index: number, value: number): Matrix;
  4206. /**
  4207. * Inserts the translation vector (using 3 floats) in the current matrix
  4208. * @param x defines the 1st component of the translation
  4209. * @param y defines the 2nd component of the translation
  4210. * @param z defines the 3rd component of the translation
  4211. * @returns the current updated matrix
  4212. */
  4213. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4214. /**
  4215. * Adds the translation vector (using 3 floats) in the current matrix
  4216. * @param x defines the 1st component of the translation
  4217. * @param y defines the 2nd component of the translation
  4218. * @param z defines the 3rd component of the translation
  4219. * @returns the current updated matrix
  4220. */
  4221. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4222. /**
  4223. * Inserts the translation vector in the current matrix
  4224. * @param vector3 defines the translation to insert
  4225. * @returns the current updated matrix
  4226. */
  4227. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4228. /**
  4229. * Gets the translation value of the current matrix
  4230. * @returns a new Vector3 as the extracted translation from the matrix
  4231. */
  4232. getTranslation(): Vector3;
  4233. /**
  4234. * Fill a Vector3 with the extracted translation from the matrix
  4235. * @param result defines the Vector3 where to store the translation
  4236. * @returns the current matrix
  4237. */
  4238. getTranslationToRef(result: Vector3): Matrix;
  4239. /**
  4240. * Remove rotation and scaling part from the matrix
  4241. * @returns the updated matrix
  4242. */
  4243. removeRotationAndScaling(): Matrix;
  4244. /**
  4245. * Multiply two matrices
  4246. * @param other defines the second operand
  4247. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4248. */
  4249. multiply(other: DeepImmutable<Matrix>): Matrix;
  4250. /**
  4251. * Copy the current matrix from the given one
  4252. * @param other defines the source matrix
  4253. * @returns the current updated matrix
  4254. */
  4255. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4256. /**
  4257. * Populates the given array from the starting index with the current matrix values
  4258. * @param array defines the target array
  4259. * @param offset defines the offset in the target array where to start storing values
  4260. * @returns the current matrix
  4261. */
  4262. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4263. /**
  4264. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4265. * @param other defines the second operand
  4266. * @param result defines the matrix where to store the multiplication
  4267. * @returns the current matrix
  4268. */
  4269. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4270. /**
  4271. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4272. * @param other defines the second operand
  4273. * @param result defines the array where to store the multiplication
  4274. * @param offset defines the offset in the target array where to start storing values
  4275. * @returns the current matrix
  4276. */
  4277. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4278. /**
  4279. * Check equality between this matrix and a second one
  4280. * @param value defines the second matrix to compare
  4281. * @returns true is the current matrix and the given one values are strictly equal
  4282. */
  4283. equals(value: DeepImmutable<Matrix>): boolean;
  4284. /**
  4285. * Clone the current matrix
  4286. * @returns a new matrix from the current matrix
  4287. */
  4288. clone(): Matrix;
  4289. /**
  4290. * Returns the name of the current matrix class
  4291. * @returns the string "Matrix"
  4292. */
  4293. getClassName(): string;
  4294. /**
  4295. * Gets the hash code of the current matrix
  4296. * @returns the hash code
  4297. */
  4298. getHashCode(): number;
  4299. /**
  4300. * Decomposes the current Matrix into a translation, rotation and scaling components
  4301. * @param scale defines the scale vector3 given as a reference to update
  4302. * @param rotation defines the rotation quaternion given as a reference to update
  4303. * @param translation defines the translation vector3 given as a reference to update
  4304. * @returns true if operation was successful
  4305. */
  4306. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4307. /**
  4308. * Gets specific row of the matrix
  4309. * @param index defines the number of the row to get
  4310. * @returns the index-th row of the current matrix as a new Vector4
  4311. */
  4312. getRow(index: number): Nullable<Vector4>;
  4313. /**
  4314. * Sets the index-th row of the current matrix to the vector4 values
  4315. * @param index defines the number of the row to set
  4316. * @param row defines the target vector4
  4317. * @returns the updated current matrix
  4318. */
  4319. setRow(index: number, row: Vector4): Matrix;
  4320. /**
  4321. * Compute the transpose of the matrix
  4322. * @returns the new transposed matrix
  4323. */
  4324. transpose(): Matrix;
  4325. /**
  4326. * Compute the transpose of the matrix and store it in a given matrix
  4327. * @param result defines the target matrix
  4328. * @returns the current matrix
  4329. */
  4330. transposeToRef(result: Matrix): Matrix;
  4331. /**
  4332. * Sets the index-th row of the current matrix with the given 4 x float values
  4333. * @param index defines the row index
  4334. * @param x defines the x component to set
  4335. * @param y defines the y component to set
  4336. * @param z defines the z component to set
  4337. * @param w defines the w component to set
  4338. * @returns the updated current matrix
  4339. */
  4340. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4341. /**
  4342. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4343. * @param scale defines the scale factor
  4344. * @returns a new matrix
  4345. */
  4346. scale(scale: number): Matrix;
  4347. /**
  4348. * Scale the current matrix values by a factor to a given result matrix
  4349. * @param scale defines the scale factor
  4350. * @param result defines the matrix to store the result
  4351. * @returns the current matrix
  4352. */
  4353. scaleToRef(scale: number, result: Matrix): Matrix;
  4354. /**
  4355. * Scale the current matrix values by a factor and add the result to a given matrix
  4356. * @param scale defines the scale factor
  4357. * @param result defines the Matrix to store the result
  4358. * @returns the current matrix
  4359. */
  4360. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4361. /**
  4362. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4363. * @param ref matrix to store the result
  4364. */
  4365. toNormalMatrix(ref: Matrix): void;
  4366. /**
  4367. * Gets only rotation part of the current matrix
  4368. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4369. */
  4370. getRotationMatrix(): Matrix;
  4371. /**
  4372. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4373. * @param result defines the target matrix to store data to
  4374. * @returns the current matrix
  4375. */
  4376. getRotationMatrixToRef(result: Matrix): Matrix;
  4377. /**
  4378. * Toggles model matrix from being right handed to left handed in place and vice versa
  4379. */
  4380. toggleModelMatrixHandInPlace(): void;
  4381. /**
  4382. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4383. */
  4384. toggleProjectionMatrixHandInPlace(): void;
  4385. /**
  4386. * Creates a matrix from an array
  4387. * @param array defines the source array
  4388. * @param offset defines an offset in the source array
  4389. * @returns a new Matrix set from the starting index of the given array
  4390. */
  4391. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4392. /**
  4393. * Copy the content of an array into a given matrix
  4394. * @param array defines the source array
  4395. * @param offset defines an offset in the source array
  4396. * @param result defines the target matrix
  4397. */
  4398. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4399. /**
  4400. * Stores an array into a matrix after having multiplied each component by a given factor
  4401. * @param array defines the source array
  4402. * @param offset defines the offset in the source array
  4403. * @param scale defines the scaling factor
  4404. * @param result defines the target matrix
  4405. */
  4406. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4407. /**
  4408. * Gets an identity matrix that must not be updated
  4409. */
  4410. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4411. /**
  4412. * Stores a list of values (16) inside a given matrix
  4413. * @param initialM11 defines 1st value of 1st row
  4414. * @param initialM12 defines 2nd value of 1st row
  4415. * @param initialM13 defines 3rd value of 1st row
  4416. * @param initialM14 defines 4th value of 1st row
  4417. * @param initialM21 defines 1st value of 2nd row
  4418. * @param initialM22 defines 2nd value of 2nd row
  4419. * @param initialM23 defines 3rd value of 2nd row
  4420. * @param initialM24 defines 4th value of 2nd row
  4421. * @param initialM31 defines 1st value of 3rd row
  4422. * @param initialM32 defines 2nd value of 3rd row
  4423. * @param initialM33 defines 3rd value of 3rd row
  4424. * @param initialM34 defines 4th value of 3rd row
  4425. * @param initialM41 defines 1st value of 4th row
  4426. * @param initialM42 defines 2nd value of 4th row
  4427. * @param initialM43 defines 3rd value of 4th row
  4428. * @param initialM44 defines 4th value of 4th row
  4429. * @param result defines the target matrix
  4430. */
  4431. 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;
  4432. /**
  4433. * Creates new matrix from a list of values (16)
  4434. * @param initialM11 defines 1st value of 1st row
  4435. * @param initialM12 defines 2nd value of 1st row
  4436. * @param initialM13 defines 3rd value of 1st row
  4437. * @param initialM14 defines 4th value of 1st row
  4438. * @param initialM21 defines 1st value of 2nd row
  4439. * @param initialM22 defines 2nd value of 2nd row
  4440. * @param initialM23 defines 3rd value of 2nd row
  4441. * @param initialM24 defines 4th value of 2nd row
  4442. * @param initialM31 defines 1st value of 3rd row
  4443. * @param initialM32 defines 2nd value of 3rd row
  4444. * @param initialM33 defines 3rd value of 3rd row
  4445. * @param initialM34 defines 4th value of 3rd row
  4446. * @param initialM41 defines 1st value of 4th row
  4447. * @param initialM42 defines 2nd value of 4th row
  4448. * @param initialM43 defines 3rd value of 4th row
  4449. * @param initialM44 defines 4th value of 4th row
  4450. * @returns the new matrix
  4451. */
  4452. 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;
  4453. /**
  4454. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4455. * @param scale defines the scale vector3
  4456. * @param rotation defines the rotation quaternion
  4457. * @param translation defines the translation vector3
  4458. * @returns a new matrix
  4459. */
  4460. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4461. /**
  4462. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4463. * @param scale defines the scale vector3
  4464. * @param rotation defines the rotation quaternion
  4465. * @param translation defines the translation vector3
  4466. * @param result defines the target matrix
  4467. */
  4468. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4469. /**
  4470. * Creates a new identity matrix
  4471. * @returns a new identity matrix
  4472. */
  4473. static Identity(): Matrix;
  4474. /**
  4475. * Creates a new identity matrix and stores the result in a given matrix
  4476. * @param result defines the target matrix
  4477. */
  4478. static IdentityToRef(result: Matrix): void;
  4479. /**
  4480. * Creates a new zero matrix
  4481. * @returns a new zero matrix
  4482. */
  4483. static Zero(): Matrix;
  4484. /**
  4485. * Creates a new rotation matrix for "angle" radians around the X axis
  4486. * @param angle defines the angle (in radians) to use
  4487. * @return the new matrix
  4488. */
  4489. static RotationX(angle: number): Matrix;
  4490. /**
  4491. * Creates a new matrix as the invert of a given matrix
  4492. * @param source defines the source matrix
  4493. * @returns the new matrix
  4494. */
  4495. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4496. /**
  4497. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4498. * @param angle defines the angle (in radians) to use
  4499. * @param result defines the target matrix
  4500. */
  4501. static RotationXToRef(angle: number, result: Matrix): void;
  4502. /**
  4503. * Creates a new rotation matrix for "angle" radians around the Y axis
  4504. * @param angle defines the angle (in radians) to use
  4505. * @return the new matrix
  4506. */
  4507. static RotationY(angle: number): Matrix;
  4508. /**
  4509. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4510. * @param angle defines the angle (in radians) to use
  4511. * @param result defines the target matrix
  4512. */
  4513. static RotationYToRef(angle: number, result: Matrix): void;
  4514. /**
  4515. * Creates a new rotation matrix for "angle" radians around the Z axis
  4516. * @param angle defines the angle (in radians) to use
  4517. * @return the new matrix
  4518. */
  4519. static RotationZ(angle: number): Matrix;
  4520. /**
  4521. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4522. * @param angle defines the angle (in radians) to use
  4523. * @param result defines the target matrix
  4524. */
  4525. static RotationZToRef(angle: number, result: Matrix): void;
  4526. /**
  4527. * Creates a new rotation matrix for "angle" radians around the given axis
  4528. * @param axis defines the axis to use
  4529. * @param angle defines the angle (in radians) to use
  4530. * @return the new matrix
  4531. */
  4532. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4533. /**
  4534. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4535. * @param axis defines the axis to use
  4536. * @param angle defines the angle (in radians) to use
  4537. * @param result defines the target matrix
  4538. */
  4539. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4540. /**
  4541. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4542. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4543. * @param from defines the vector to align
  4544. * @param to defines the vector to align to
  4545. * @param result defines the target matrix
  4546. */
  4547. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4548. /**
  4549. * Creates a rotation matrix
  4550. * @param yaw defines the yaw angle in radians (Y axis)
  4551. * @param pitch defines the pitch angle in radians (X axis)
  4552. * @param roll defines the roll angle in radians (Z axis)
  4553. * @returns the new rotation matrix
  4554. */
  4555. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4556. /**
  4557. * Creates a rotation matrix and stores it in a given matrix
  4558. * @param yaw defines the yaw angle in radians (Y axis)
  4559. * @param pitch defines the pitch angle in radians (X axis)
  4560. * @param roll defines the roll angle in radians (Z axis)
  4561. * @param result defines the target matrix
  4562. */
  4563. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4564. /**
  4565. * Creates a scaling matrix
  4566. * @param x defines the scale factor on X axis
  4567. * @param y defines the scale factor on Y axis
  4568. * @param z defines the scale factor on Z axis
  4569. * @returns the new matrix
  4570. */
  4571. static Scaling(x: number, y: number, z: number): Matrix;
  4572. /**
  4573. * Creates a scaling matrix and stores it in a given matrix
  4574. * @param x defines the scale factor on X axis
  4575. * @param y defines the scale factor on Y axis
  4576. * @param z defines the scale factor on Z axis
  4577. * @param result defines the target matrix
  4578. */
  4579. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4580. /**
  4581. * Creates a translation matrix
  4582. * @param x defines the translation on X axis
  4583. * @param y defines the translation on Y axis
  4584. * @param z defines the translationon Z axis
  4585. * @returns the new matrix
  4586. */
  4587. static Translation(x: number, y: number, z: number): Matrix;
  4588. /**
  4589. * Creates a translation matrix and stores it in a given matrix
  4590. * @param x defines the translation on X axis
  4591. * @param y defines the translation on Y axis
  4592. * @param z defines the translationon Z axis
  4593. * @param result defines the target matrix
  4594. */
  4595. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4596. /**
  4597. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4598. * @param startValue defines the start value
  4599. * @param endValue defines the end value
  4600. * @param gradient defines the gradient factor
  4601. * @returns the new matrix
  4602. */
  4603. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4604. /**
  4605. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4606. * @param startValue defines the start value
  4607. * @param endValue defines the end value
  4608. * @param gradient defines the gradient factor
  4609. * @param result defines the Matrix object where to store data
  4610. */
  4611. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4612. /**
  4613. * Builds a new matrix whose values are computed by:
  4614. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4615. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4616. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4617. * @param startValue defines the first matrix
  4618. * @param endValue defines the second matrix
  4619. * @param gradient defines the gradient between the two matrices
  4620. * @returns the new matrix
  4621. */
  4622. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4623. /**
  4624. * Update a matrix to values which are computed by:
  4625. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4626. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4627. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4628. * @param startValue defines the first matrix
  4629. * @param endValue defines the second matrix
  4630. * @param gradient defines the gradient between the two matrices
  4631. * @param result defines the target matrix
  4632. */
  4633. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4634. /**
  4635. * 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"
  4636. * This function works in left handed mode
  4637. * @param eye defines the final position of the entity
  4638. * @param target defines where the entity should look at
  4639. * @param up defines the up vector for the entity
  4640. * @returns the new matrix
  4641. */
  4642. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4643. /**
  4644. * 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".
  4645. * This function works in left handed mode
  4646. * @param eye defines the final position of the entity
  4647. * @param target defines where the entity should look at
  4648. * @param up defines the up vector for the entity
  4649. * @param result defines the target matrix
  4650. */
  4651. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4652. /**
  4653. * 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"
  4654. * This function works in right handed mode
  4655. * @param eye defines the final position of the entity
  4656. * @param target defines where the entity should look at
  4657. * @param up defines the up vector for the entity
  4658. * @returns the new matrix
  4659. */
  4660. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4661. /**
  4662. * 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".
  4663. * This function works in right handed mode
  4664. * @param eye defines the final position of the entity
  4665. * @param target defines where the entity should look at
  4666. * @param up defines the up vector for the entity
  4667. * @param result defines the target matrix
  4668. */
  4669. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4670. /**
  4671. * Create a left-handed orthographic projection matrix
  4672. * @param width defines the viewport width
  4673. * @param height defines the viewport height
  4674. * @param znear defines the near clip plane
  4675. * @param zfar defines the far clip plane
  4676. * @returns a new matrix as a left-handed orthographic projection matrix
  4677. */
  4678. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4679. /**
  4680. * Store a left-handed orthographic projection to a given matrix
  4681. * @param width defines the viewport width
  4682. * @param height defines the viewport height
  4683. * @param znear defines the near clip plane
  4684. * @param zfar defines the far clip plane
  4685. * @param result defines the target matrix
  4686. */
  4687. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4688. /**
  4689. * Create a left-handed orthographic projection matrix
  4690. * @param left defines the viewport left coordinate
  4691. * @param right defines the viewport right coordinate
  4692. * @param bottom defines the viewport bottom coordinate
  4693. * @param top defines the viewport top coordinate
  4694. * @param znear defines the near clip plane
  4695. * @param zfar defines the far clip plane
  4696. * @returns a new matrix as a left-handed orthographic projection matrix
  4697. */
  4698. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4699. /**
  4700. * Stores a left-handed orthographic projection into a given matrix
  4701. * @param left defines the viewport left coordinate
  4702. * @param right defines the viewport right coordinate
  4703. * @param bottom defines the viewport bottom coordinate
  4704. * @param top defines the viewport top coordinate
  4705. * @param znear defines the near clip plane
  4706. * @param zfar defines the far clip plane
  4707. * @param result defines the target matrix
  4708. */
  4709. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4710. /**
  4711. * Creates a right-handed orthographic projection matrix
  4712. * @param left defines the viewport left coordinate
  4713. * @param right defines the viewport right coordinate
  4714. * @param bottom defines the viewport bottom coordinate
  4715. * @param top defines the viewport top coordinate
  4716. * @param znear defines the near clip plane
  4717. * @param zfar defines the far clip plane
  4718. * @returns a new matrix as a right-handed orthographic projection matrix
  4719. */
  4720. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4721. /**
  4722. * Stores a right-handed orthographic projection into a given matrix
  4723. * @param left defines the viewport left coordinate
  4724. * @param right defines the viewport right coordinate
  4725. * @param bottom defines the viewport bottom coordinate
  4726. * @param top defines the viewport top coordinate
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. */
  4731. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4732. /**
  4733. * Creates a left-handed perspective projection matrix
  4734. * @param width defines the viewport width
  4735. * @param height defines the viewport height
  4736. * @param znear defines the near clip plane
  4737. * @param zfar defines the far clip plane
  4738. * @returns a new matrix as a left-handed perspective projection matrix
  4739. */
  4740. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4741. /**
  4742. * Creates a left-handed perspective projection matrix
  4743. * @param fov defines the horizontal field of view
  4744. * @param aspect defines the aspect ratio
  4745. * @param znear defines the near clip plane
  4746. * @param zfar defines the far clip plane
  4747. * @returns a new matrix as a left-handed perspective projection matrix
  4748. */
  4749. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4750. /**
  4751. * Stores a left-handed perspective projection into a given matrix
  4752. * @param fov defines the horizontal field of view
  4753. * @param aspect defines the aspect ratio
  4754. * @param znear defines the near clip plane
  4755. * @param zfar defines the far clip plane
  4756. * @param result defines the target matrix
  4757. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4758. */
  4759. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4760. /**
  4761. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4762. * @param fov defines the horizontal field of view
  4763. * @param aspect defines the aspect ratio
  4764. * @param znear defines the near clip plane
  4765. * @param zfar not used as infinity is used as far clip
  4766. * @param result defines the target matrix
  4767. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4768. */
  4769. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4770. /**
  4771. * Creates a right-handed perspective projection matrix
  4772. * @param fov defines the horizontal field of view
  4773. * @param aspect defines the aspect ratio
  4774. * @param znear defines the near clip plane
  4775. * @param zfar defines the far clip plane
  4776. * @returns a new matrix as a right-handed perspective projection matrix
  4777. */
  4778. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4779. /**
  4780. * Stores a right-handed perspective projection into a given matrix
  4781. * @param fov defines the horizontal field of view
  4782. * @param aspect defines the aspect ratio
  4783. * @param znear defines the near clip plane
  4784. * @param zfar defines the far clip plane
  4785. * @param result defines the target matrix
  4786. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4787. */
  4788. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4789. /**
  4790. * Stores a right-handed perspective projection into a given matrix
  4791. * @param fov defines the horizontal field of view
  4792. * @param aspect defines the aspect ratio
  4793. * @param znear defines the near clip plane
  4794. * @param zfar not used as infinity is used as far clip
  4795. * @param result defines the target matrix
  4796. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4797. */
  4798. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4799. /**
  4800. * Stores a perspective projection for WebVR info a given matrix
  4801. * @param fov defines the field of view
  4802. * @param znear defines the near clip plane
  4803. * @param zfar defines the far clip plane
  4804. * @param result defines the target matrix
  4805. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4806. */
  4807. static PerspectiveFovWebVRToRef(fov: {
  4808. upDegrees: number;
  4809. downDegrees: number;
  4810. leftDegrees: number;
  4811. rightDegrees: number;
  4812. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4813. /**
  4814. * Computes a complete transformation matrix
  4815. * @param viewport defines the viewport to use
  4816. * @param world defines the world matrix
  4817. * @param view defines the view matrix
  4818. * @param projection defines the projection matrix
  4819. * @param zmin defines the near clip plane
  4820. * @param zmax defines the far clip plane
  4821. * @returns the transformation matrix
  4822. */
  4823. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4824. /**
  4825. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4826. * @param matrix defines the matrix to use
  4827. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4828. */
  4829. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4830. /**
  4831. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4832. * @param matrix defines the matrix to use
  4833. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4834. */
  4835. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4836. /**
  4837. * Compute the transpose of a given matrix
  4838. * @param matrix defines the matrix to transpose
  4839. * @returns the new matrix
  4840. */
  4841. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4842. /**
  4843. * Compute the transpose of a matrix and store it in a target matrix
  4844. * @param matrix defines the matrix to transpose
  4845. * @param result defines the target matrix
  4846. */
  4847. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4848. /**
  4849. * Computes a reflection matrix from a plane
  4850. * @param plane defines the reflection plane
  4851. * @returns a new matrix
  4852. */
  4853. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4854. /**
  4855. * Computes a reflection matrix from a plane
  4856. * @param plane defines the reflection plane
  4857. * @param result defines the target matrix
  4858. */
  4859. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4860. /**
  4861. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4862. * @param xaxis defines the value of the 1st axis
  4863. * @param yaxis defines the value of the 2nd axis
  4864. * @param zaxis defines the value of the 3rd axis
  4865. * @param result defines the target matrix
  4866. */
  4867. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4868. /**
  4869. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4870. * @param quat defines the quaternion to use
  4871. * @param result defines the target matrix
  4872. */
  4873. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4874. }
  4875. /**
  4876. * @hidden
  4877. */
  4878. export class TmpVectors {
  4879. static Vector2: Vector2[];
  4880. static Vector3: Vector3[];
  4881. static Vector4: Vector4[];
  4882. static Quaternion: Quaternion[];
  4883. static Matrix: Matrix[];
  4884. }
  4885. }
  4886. declare module "babylonjs/Maths/math.path" {
  4887. import { DeepImmutable, Nullable } from "babylonjs/types";
  4888. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4889. /**
  4890. * Defines potential orientation for back face culling
  4891. */
  4892. export enum Orientation {
  4893. /**
  4894. * Clockwise
  4895. */
  4896. CW = 0,
  4897. /** Counter clockwise */
  4898. CCW = 1
  4899. }
  4900. /** Class used to represent a Bezier curve */
  4901. export class BezierCurve {
  4902. /**
  4903. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4904. * @param t defines the time
  4905. * @param x1 defines the left coordinate on X axis
  4906. * @param y1 defines the left coordinate on Y axis
  4907. * @param x2 defines the right coordinate on X axis
  4908. * @param y2 defines the right coordinate on Y axis
  4909. * @returns the interpolated value
  4910. */
  4911. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4912. }
  4913. /**
  4914. * Defines angle representation
  4915. */
  4916. export class Angle {
  4917. private _radians;
  4918. /**
  4919. * Creates an Angle object of "radians" radians (float).
  4920. * @param radians the angle in radians
  4921. */
  4922. constructor(radians: number);
  4923. /**
  4924. * Get value in degrees
  4925. * @returns the Angle value in degrees (float)
  4926. */
  4927. degrees(): number;
  4928. /**
  4929. * Get value in radians
  4930. * @returns the Angle value in radians (float)
  4931. */
  4932. radians(): number;
  4933. /**
  4934. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4935. * @param a defines first point as the origin
  4936. * @param b defines point
  4937. * @returns a new Angle
  4938. */
  4939. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4940. /**
  4941. * Gets a new Angle object from the given float in radians
  4942. * @param radians defines the angle value in radians
  4943. * @returns a new Angle
  4944. */
  4945. static FromRadians(radians: number): Angle;
  4946. /**
  4947. * Gets a new Angle object from the given float in degrees
  4948. * @param degrees defines the angle value in degrees
  4949. * @returns a new Angle
  4950. */
  4951. static FromDegrees(degrees: number): Angle;
  4952. }
  4953. /**
  4954. * This represents an arc in a 2d space.
  4955. */
  4956. export class Arc2 {
  4957. /** Defines the start point of the arc */
  4958. startPoint: Vector2;
  4959. /** Defines the mid point of the arc */
  4960. midPoint: Vector2;
  4961. /** Defines the end point of the arc */
  4962. endPoint: Vector2;
  4963. /**
  4964. * Defines the center point of the arc.
  4965. */
  4966. centerPoint: Vector2;
  4967. /**
  4968. * Defines the radius of the arc.
  4969. */
  4970. radius: number;
  4971. /**
  4972. * Defines the angle of the arc (from mid point to end point).
  4973. */
  4974. angle: Angle;
  4975. /**
  4976. * Defines the start angle of the arc (from start point to middle point).
  4977. */
  4978. startAngle: Angle;
  4979. /**
  4980. * Defines the orientation of the arc (clock wise/counter clock wise).
  4981. */
  4982. orientation: Orientation;
  4983. /**
  4984. * Creates an Arc object from the three given points : start, middle and end.
  4985. * @param startPoint Defines the start point of the arc
  4986. * @param midPoint Defines the midlle point of the arc
  4987. * @param endPoint Defines the end point of the arc
  4988. */
  4989. constructor(
  4990. /** Defines the start point of the arc */
  4991. startPoint: Vector2,
  4992. /** Defines the mid point of the arc */
  4993. midPoint: Vector2,
  4994. /** Defines the end point of the arc */
  4995. endPoint: Vector2);
  4996. }
  4997. /**
  4998. * Represents a 2D path made up of multiple 2D points
  4999. */
  5000. export class Path2 {
  5001. private _points;
  5002. private _length;
  5003. /**
  5004. * If the path start and end point are the same
  5005. */
  5006. closed: boolean;
  5007. /**
  5008. * Creates a Path2 object from the starting 2D coordinates x and y.
  5009. * @param x the starting points x value
  5010. * @param y the starting points y value
  5011. */
  5012. constructor(x: number, y: number);
  5013. /**
  5014. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5015. * @param x the added points x value
  5016. * @param y the added points y value
  5017. * @returns the updated Path2.
  5018. */
  5019. addLineTo(x: number, y: number): Path2;
  5020. /**
  5021. * 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.
  5022. * @param midX middle point x value
  5023. * @param midY middle point y value
  5024. * @param endX end point x value
  5025. * @param endY end point y value
  5026. * @param numberOfSegments (default: 36)
  5027. * @returns the updated Path2.
  5028. */
  5029. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5030. /**
  5031. * Closes the Path2.
  5032. * @returns the Path2.
  5033. */
  5034. close(): Path2;
  5035. /**
  5036. * Gets the sum of the distance between each sequential point in the path
  5037. * @returns the Path2 total length (float).
  5038. */
  5039. length(): number;
  5040. /**
  5041. * Gets the points which construct the path
  5042. * @returns the Path2 internal array of points.
  5043. */
  5044. getPoints(): Vector2[];
  5045. /**
  5046. * Retreives the point at the distance aways from the starting point
  5047. * @param normalizedLengthPosition the length along the path to retreive the point from
  5048. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5049. */
  5050. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5051. /**
  5052. * Creates a new path starting from an x and y position
  5053. * @param x starting x value
  5054. * @param y starting y value
  5055. * @returns a new Path2 starting at the coordinates (x, y).
  5056. */
  5057. static StartingAt(x: number, y: number): Path2;
  5058. }
  5059. /**
  5060. * Represents a 3D path made up of multiple 3D points
  5061. */
  5062. export class Path3D {
  5063. /**
  5064. * an array of Vector3, the curve axis of the Path3D
  5065. */
  5066. path: Vector3[];
  5067. private _curve;
  5068. private _distances;
  5069. private _tangents;
  5070. private _normals;
  5071. private _binormals;
  5072. private _raw;
  5073. private _alignTangentsWithPath;
  5074. private readonly _pointAtData;
  5075. /**
  5076. * new Path3D(path, normal, raw)
  5077. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5078. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5079. * @param path an array of Vector3, the curve axis of the Path3D
  5080. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5081. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5082. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5083. */
  5084. constructor(
  5085. /**
  5086. * an array of Vector3, the curve axis of the Path3D
  5087. */
  5088. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5089. /**
  5090. * Returns the Path3D array of successive Vector3 designing its curve.
  5091. * @returns the Path3D array of successive Vector3 designing its curve.
  5092. */
  5093. getCurve(): Vector3[];
  5094. /**
  5095. * Returns the Path3D array of successive Vector3 designing its curve.
  5096. * @returns the Path3D array of successive Vector3 designing its curve.
  5097. */
  5098. getPoints(): Vector3[];
  5099. /**
  5100. * @returns the computed length (float) of the path.
  5101. */
  5102. length(): number;
  5103. /**
  5104. * Returns an array populated with tangent vectors on each Path3D curve point.
  5105. * @returns an array populated with tangent vectors on each Path3D curve point.
  5106. */
  5107. getTangents(): Vector3[];
  5108. /**
  5109. * Returns an array populated with normal vectors on each Path3D curve point.
  5110. * @returns an array populated with normal vectors on each Path3D curve point.
  5111. */
  5112. getNormals(): Vector3[];
  5113. /**
  5114. * Returns an array populated with binormal vectors on each Path3D curve point.
  5115. * @returns an array populated with binormal vectors on each Path3D curve point.
  5116. */
  5117. getBinormals(): Vector3[];
  5118. /**
  5119. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5120. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5121. */
  5122. getDistances(): number[];
  5123. /**
  5124. * Returns an interpolated point along this path
  5125. * @param position the position of the point along this path, from 0.0 to 1.0
  5126. * @returns a new Vector3 as the point
  5127. */
  5128. getPointAt(position: number): Vector3;
  5129. /**
  5130. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5131. * @param position the position of the point along this path, from 0.0 to 1.0
  5132. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5133. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5134. */
  5135. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5136. /**
  5137. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5138. * @param position the position of the point along this path, from 0.0 to 1.0
  5139. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5140. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5141. */
  5142. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5143. /**
  5144. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5145. * @param position the position of the point along this path, from 0.0 to 1.0
  5146. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5147. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5148. */
  5149. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5150. /**
  5151. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5152. * @param position the position of the point along this path, from 0.0 to 1.0
  5153. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5154. */
  5155. getDistanceAt(position: number): number;
  5156. /**
  5157. * Returns the array index of the previous point of an interpolated point along this path
  5158. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5159. * @returns the array index
  5160. */
  5161. getPreviousPointIndexAt(position: number): number;
  5162. /**
  5163. * 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)
  5164. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5165. * @returns the sub position
  5166. */
  5167. getSubPositionAt(position: number): number;
  5168. /**
  5169. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5170. * @param target the vector of which to get the closest position to
  5171. * @returns the position of the closest virtual point on this path to the target vector
  5172. */
  5173. getClosestPositionTo(target: Vector3): number;
  5174. /**
  5175. * Returns a sub path (slice) of this path
  5176. * @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
  5177. * @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
  5178. * @returns a sub path (slice) of this path
  5179. */
  5180. slice(start?: number, end?: number): Path3D;
  5181. /**
  5182. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5183. * @param path path which all values are copied into the curves points
  5184. * @param firstNormal which should be projected onto the curve
  5185. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5186. * @returns the same object updated.
  5187. */
  5188. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5189. private _compute;
  5190. private _getFirstNonNullVector;
  5191. private _getLastNonNullVector;
  5192. private _normalVector;
  5193. /**
  5194. * Updates the point at data for an interpolated point along this curve
  5195. * @param position the position of the point along this curve, from 0.0 to 1.0
  5196. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5197. * @returns the (updated) point at data
  5198. */
  5199. private _updatePointAtData;
  5200. /**
  5201. * Updates the point at data from the specified parameters
  5202. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5203. * @param point the interpolated point
  5204. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5205. */
  5206. private _setPointAtData;
  5207. /**
  5208. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5209. */
  5210. private _updateInterpolationMatrix;
  5211. }
  5212. /**
  5213. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5214. * A Curve3 is designed from a series of successive Vector3.
  5215. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5216. */
  5217. export class Curve3 {
  5218. private _points;
  5219. private _length;
  5220. /**
  5221. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5222. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5223. * @param v1 (Vector3) the control point
  5224. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5225. * @param nbPoints (integer) the wanted number of points in the curve
  5226. * @returns the created Curve3
  5227. */
  5228. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5229. /**
  5230. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5231. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5232. * @param v1 (Vector3) the first control point
  5233. * @param v2 (Vector3) the second control point
  5234. * @param v3 (Vector3) the end point of the Cubic Bezier
  5235. * @param nbPoints (integer) the wanted number of points in the curve
  5236. * @returns the created Curve3
  5237. */
  5238. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5239. /**
  5240. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5241. * @param p1 (Vector3) the origin point of the Hermite Spline
  5242. * @param t1 (Vector3) the tangent vector at the origin point
  5243. * @param p2 (Vector3) the end point of the Hermite Spline
  5244. * @param t2 (Vector3) the tangent vector at the end point
  5245. * @param nbPoints (integer) the wanted number of points in the curve
  5246. * @returns the created Curve3
  5247. */
  5248. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5249. /**
  5250. * Returns a Curve3 object along a CatmullRom Spline curve :
  5251. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5252. * @param nbPoints (integer) the wanted number of points between each curve control points
  5253. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5254. * @returns the created Curve3
  5255. */
  5256. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5257. /**
  5258. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5259. * A Curve3 is designed from a series of successive Vector3.
  5260. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5261. * @param points points which make up the curve
  5262. */
  5263. constructor(points: Vector3[]);
  5264. /**
  5265. * @returns the Curve3 stored array of successive Vector3
  5266. */
  5267. getPoints(): Vector3[];
  5268. /**
  5269. * @returns the computed length (float) of the curve.
  5270. */
  5271. length(): number;
  5272. /**
  5273. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5274. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5275. * curveA and curveB keep unchanged.
  5276. * @param curve the curve to continue from this curve
  5277. * @returns the newly constructed curve
  5278. */
  5279. continue(curve: DeepImmutable<Curve3>): Curve3;
  5280. private _computeLength;
  5281. }
  5282. }
  5283. declare module "babylonjs/Animations/easing" {
  5284. /**
  5285. * This represents the main contract an easing function should follow.
  5286. * Easing functions are used throughout the animation system.
  5287. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5288. */
  5289. export interface IEasingFunction {
  5290. /**
  5291. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5292. * of the easing function.
  5293. * The link below provides some of the most common examples of easing functions.
  5294. * @see https://easings.net/
  5295. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5296. * @returns the corresponding value on the curve defined by the easing function
  5297. */
  5298. ease(gradient: number): number;
  5299. }
  5300. /**
  5301. * Base class used for every default easing function.
  5302. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5303. */
  5304. export class EasingFunction implements IEasingFunction {
  5305. /**
  5306. * Interpolation follows the mathematical formula associated with the easing function.
  5307. */
  5308. static readonly EASINGMODE_EASEIN: number;
  5309. /**
  5310. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5311. */
  5312. static readonly EASINGMODE_EASEOUT: number;
  5313. /**
  5314. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5315. */
  5316. static readonly EASINGMODE_EASEINOUT: number;
  5317. private _easingMode;
  5318. /**
  5319. * Sets the easing mode of the current function.
  5320. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5321. */
  5322. setEasingMode(easingMode: number): void;
  5323. /**
  5324. * Gets the current easing mode.
  5325. * @returns the easing mode
  5326. */
  5327. getEasingMode(): number;
  5328. /**
  5329. * @hidden
  5330. */
  5331. easeInCore(gradient: number): number;
  5332. /**
  5333. * Given an input gradient between 0 and 1, this returns the corresponding value
  5334. * of the easing function.
  5335. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5336. * @returns the corresponding value on the curve defined by the easing function
  5337. */
  5338. ease(gradient: number): number;
  5339. }
  5340. /**
  5341. * Easing function with a circle shape (see link below).
  5342. * @see https://easings.net/#easeInCirc
  5343. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5344. */
  5345. export class CircleEase extends EasingFunction implements IEasingFunction {
  5346. /** @hidden */
  5347. easeInCore(gradient: number): number;
  5348. }
  5349. /**
  5350. * Easing function with a ease back shape (see link below).
  5351. * @see https://easings.net/#easeInBack
  5352. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5353. */
  5354. export class BackEase extends EasingFunction implements IEasingFunction {
  5355. /** Defines the amplitude of the function */
  5356. amplitude: number;
  5357. /**
  5358. * Instantiates a back ease easing
  5359. * @see https://easings.net/#easeInBack
  5360. * @param amplitude Defines the amplitude of the function
  5361. */
  5362. constructor(
  5363. /** Defines the amplitude of the function */
  5364. amplitude?: number);
  5365. /** @hidden */
  5366. easeInCore(gradient: number): number;
  5367. }
  5368. /**
  5369. * Easing function with a bouncing shape (see link below).
  5370. * @see https://easings.net/#easeInBounce
  5371. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5372. */
  5373. export class BounceEase extends EasingFunction implements IEasingFunction {
  5374. /** Defines the number of bounces */
  5375. bounces: number;
  5376. /** Defines the amplitude of the bounce */
  5377. bounciness: number;
  5378. /**
  5379. * Instantiates a bounce easing
  5380. * @see https://easings.net/#easeInBounce
  5381. * @param bounces Defines the number of bounces
  5382. * @param bounciness Defines the amplitude of the bounce
  5383. */
  5384. constructor(
  5385. /** Defines the number of bounces */
  5386. bounces?: number,
  5387. /** Defines the amplitude of the bounce */
  5388. bounciness?: number);
  5389. /** @hidden */
  5390. easeInCore(gradient: number): number;
  5391. }
  5392. /**
  5393. * Easing function with a power of 3 shape (see link below).
  5394. * @see https://easings.net/#easeInCubic
  5395. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5396. */
  5397. export class CubicEase extends EasingFunction implements IEasingFunction {
  5398. /** @hidden */
  5399. easeInCore(gradient: number): number;
  5400. }
  5401. /**
  5402. * Easing function with an elastic shape (see link below).
  5403. * @see https://easings.net/#easeInElastic
  5404. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5405. */
  5406. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5407. /** Defines the number of oscillations*/
  5408. oscillations: number;
  5409. /** Defines the amplitude of the oscillations*/
  5410. springiness: number;
  5411. /**
  5412. * Instantiates an elastic easing function
  5413. * @see https://easings.net/#easeInElastic
  5414. * @param oscillations Defines the number of oscillations
  5415. * @param springiness Defines the amplitude of the oscillations
  5416. */
  5417. constructor(
  5418. /** Defines the number of oscillations*/
  5419. oscillations?: number,
  5420. /** Defines the amplitude of the oscillations*/
  5421. springiness?: number);
  5422. /** @hidden */
  5423. easeInCore(gradient: number): number;
  5424. }
  5425. /**
  5426. * Easing function with an exponential shape (see link below).
  5427. * @see https://easings.net/#easeInExpo
  5428. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5429. */
  5430. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5431. /** Defines the exponent of the function */
  5432. exponent: number;
  5433. /**
  5434. * Instantiates an exponential easing function
  5435. * @see https://easings.net/#easeInExpo
  5436. * @param exponent Defines the exponent of the function
  5437. */
  5438. constructor(
  5439. /** Defines the exponent of the function */
  5440. exponent?: number);
  5441. /** @hidden */
  5442. easeInCore(gradient: number): number;
  5443. }
  5444. /**
  5445. * Easing function with a power shape (see link below).
  5446. * @see https://easings.net/#easeInQuad
  5447. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5448. */
  5449. export class PowerEase extends EasingFunction implements IEasingFunction {
  5450. /** Defines the power of the function */
  5451. power: number;
  5452. /**
  5453. * Instantiates an power base easing function
  5454. * @see https://easings.net/#easeInQuad
  5455. * @param power Defines the power of the function
  5456. */
  5457. constructor(
  5458. /** Defines the power of the function */
  5459. power?: number);
  5460. /** @hidden */
  5461. easeInCore(gradient: number): number;
  5462. }
  5463. /**
  5464. * Easing function with a power of 2 shape (see link below).
  5465. * @see https://easings.net/#easeInQuad
  5466. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5467. */
  5468. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5469. /** @hidden */
  5470. easeInCore(gradient: number): number;
  5471. }
  5472. /**
  5473. * Easing function with a power of 4 shape (see link below).
  5474. * @see https://easings.net/#easeInQuart
  5475. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5476. */
  5477. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5478. /** @hidden */
  5479. easeInCore(gradient: number): number;
  5480. }
  5481. /**
  5482. * Easing function with a power of 5 shape (see link below).
  5483. * @see https://easings.net/#easeInQuint
  5484. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5485. */
  5486. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5487. /** @hidden */
  5488. easeInCore(gradient: number): number;
  5489. }
  5490. /**
  5491. * Easing function with a sin shape (see link below).
  5492. * @see https://easings.net/#easeInSine
  5493. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5494. */
  5495. export class SineEase extends EasingFunction implements IEasingFunction {
  5496. /** @hidden */
  5497. easeInCore(gradient: number): number;
  5498. }
  5499. /**
  5500. * Easing function with a bezier shape (see link below).
  5501. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5502. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5503. */
  5504. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5505. /** Defines the x component of the start tangent in the bezier curve */
  5506. x1: number;
  5507. /** Defines the y component of the start tangent in the bezier curve */
  5508. y1: number;
  5509. /** Defines the x component of the end tangent in the bezier curve */
  5510. x2: number;
  5511. /** Defines the y component of the end tangent in the bezier curve */
  5512. y2: number;
  5513. /**
  5514. * Instantiates a bezier function
  5515. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5516. * @param x1 Defines the x component of the start tangent in the bezier curve
  5517. * @param y1 Defines the y component of the start tangent in the bezier curve
  5518. * @param x2 Defines the x component of the end tangent in the bezier curve
  5519. * @param y2 Defines the y component of the end tangent in the bezier curve
  5520. */
  5521. constructor(
  5522. /** Defines the x component of the start tangent in the bezier curve */
  5523. x1?: number,
  5524. /** Defines the y component of the start tangent in the bezier curve */
  5525. y1?: number,
  5526. /** Defines the x component of the end tangent in the bezier curve */
  5527. x2?: number,
  5528. /** Defines the y component of the end tangent in the bezier curve */
  5529. y2?: number);
  5530. /** @hidden */
  5531. easeInCore(gradient: number): number;
  5532. }
  5533. }
  5534. declare module "babylonjs/Maths/math.color" {
  5535. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5536. /**
  5537. * Class used to hold a RBG color
  5538. */
  5539. export class Color3 {
  5540. /**
  5541. * Defines the red component (between 0 and 1, default is 0)
  5542. */
  5543. r: number;
  5544. /**
  5545. * Defines the green component (between 0 and 1, default is 0)
  5546. */
  5547. g: number;
  5548. /**
  5549. * Defines the blue component (between 0 and 1, default is 0)
  5550. */
  5551. b: number;
  5552. /**
  5553. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5554. * @param r defines the red component (between 0 and 1, default is 0)
  5555. * @param g defines the green component (between 0 and 1, default is 0)
  5556. * @param b defines the blue component (between 0 and 1, default is 0)
  5557. */
  5558. constructor(
  5559. /**
  5560. * Defines the red component (between 0 and 1, default is 0)
  5561. */
  5562. r?: number,
  5563. /**
  5564. * Defines the green component (between 0 and 1, default is 0)
  5565. */
  5566. g?: number,
  5567. /**
  5568. * Defines the blue component (between 0 and 1, default is 0)
  5569. */
  5570. b?: number);
  5571. /**
  5572. * Creates a string with the Color3 current values
  5573. * @returns the string representation of the Color3 object
  5574. */
  5575. toString(): string;
  5576. /**
  5577. * Returns the string "Color3"
  5578. * @returns "Color3"
  5579. */
  5580. getClassName(): string;
  5581. /**
  5582. * Compute the Color3 hash code
  5583. * @returns an unique number that can be used to hash Color3 objects
  5584. */
  5585. getHashCode(): number;
  5586. /**
  5587. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5588. * @param array defines the array where to store the r,g,b components
  5589. * @param index defines an optional index in the target array to define where to start storing values
  5590. * @returns the current Color3 object
  5591. */
  5592. toArray(array: FloatArray, index?: number): Color3;
  5593. /**
  5594. * Update the current color with values stored in an array from the starting index of the given array
  5595. * @param array defines the source array
  5596. * @param offset defines an offset in the source array
  5597. * @returns the current Color3 object
  5598. */
  5599. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5600. /**
  5601. * Returns a new Color4 object from the current Color3 and the given alpha
  5602. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5603. * @returns a new Color4 object
  5604. */
  5605. toColor4(alpha?: number): Color4;
  5606. /**
  5607. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5608. * @returns the new array
  5609. */
  5610. asArray(): number[];
  5611. /**
  5612. * Returns the luminance value
  5613. * @returns a float value
  5614. */
  5615. toLuminance(): number;
  5616. /**
  5617. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5618. * @param otherColor defines the second operand
  5619. * @returns the new Color3 object
  5620. */
  5621. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5622. /**
  5623. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5624. * @param otherColor defines the second operand
  5625. * @param result defines the Color3 object where to store the result
  5626. * @returns the current Color3
  5627. */
  5628. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5629. /**
  5630. * Determines equality between Color3 objects
  5631. * @param otherColor defines the second operand
  5632. * @returns true if the rgb values are equal to the given ones
  5633. */
  5634. equals(otherColor: DeepImmutable<Color3>): boolean;
  5635. /**
  5636. * Determines equality between the current Color3 object and a set of r,b,g values
  5637. * @param r defines the red component to check
  5638. * @param g defines the green component to check
  5639. * @param b defines the blue component to check
  5640. * @returns true if the rgb values are equal to the given ones
  5641. */
  5642. equalsFloats(r: number, g: number, b: number): boolean;
  5643. /**
  5644. * Multiplies in place each rgb value by scale
  5645. * @param scale defines the scaling factor
  5646. * @returns the updated Color3
  5647. */
  5648. scale(scale: number): Color3;
  5649. /**
  5650. * Multiplies the rgb values by scale and stores the result into "result"
  5651. * @param scale defines the scaling factor
  5652. * @param result defines the Color3 object where to store the result
  5653. * @returns the unmodified current Color3
  5654. */
  5655. scaleToRef(scale: number, result: Color3): Color3;
  5656. /**
  5657. * Scale the current Color3 values by a factor and add the result to a given Color3
  5658. * @param scale defines the scale factor
  5659. * @param result defines color to store the result into
  5660. * @returns the unmodified current Color3
  5661. */
  5662. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5663. /**
  5664. * Clamps the rgb values by the min and max values and stores the result into "result"
  5665. * @param min defines minimum clamping value (default is 0)
  5666. * @param max defines maximum clamping value (default is 1)
  5667. * @param result defines color to store the result into
  5668. * @returns the original Color3
  5669. */
  5670. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5671. /**
  5672. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5673. * @param otherColor defines the second operand
  5674. * @returns the new Color3
  5675. */
  5676. add(otherColor: DeepImmutable<Color3>): Color3;
  5677. /**
  5678. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5679. * @param otherColor defines the second operand
  5680. * @param result defines Color3 object to store the result into
  5681. * @returns the unmodified current Color3
  5682. */
  5683. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5684. /**
  5685. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5686. * @param otherColor defines the second operand
  5687. * @returns the new Color3
  5688. */
  5689. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5690. /**
  5691. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5692. * @param otherColor defines the second operand
  5693. * @param result defines Color3 object to store the result into
  5694. * @returns the unmodified current Color3
  5695. */
  5696. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5697. /**
  5698. * Copy the current object
  5699. * @returns a new Color3 copied the current one
  5700. */
  5701. clone(): Color3;
  5702. /**
  5703. * Copies the rgb values from the source in the current Color3
  5704. * @param source defines the source Color3 object
  5705. * @returns the updated Color3 object
  5706. */
  5707. copyFrom(source: DeepImmutable<Color3>): Color3;
  5708. /**
  5709. * Updates the Color3 rgb values from the given floats
  5710. * @param r defines the red component to read from
  5711. * @param g defines the green component to read from
  5712. * @param b defines the blue component to read from
  5713. * @returns the current Color3 object
  5714. */
  5715. copyFromFloats(r: number, g: number, b: number): Color3;
  5716. /**
  5717. * Updates the Color3 rgb values from the given floats
  5718. * @param r defines the red component to read from
  5719. * @param g defines the green component to read from
  5720. * @param b defines the blue component to read from
  5721. * @returns the current Color3 object
  5722. */
  5723. set(r: number, g: number, b: number): Color3;
  5724. /**
  5725. * Compute the Color3 hexadecimal code as a string
  5726. * @returns a string containing the hexadecimal representation of the Color3 object
  5727. */
  5728. toHexString(): string;
  5729. /**
  5730. * Computes a new Color3 converted from the current one to linear space
  5731. * @returns a new Color3 object
  5732. */
  5733. toLinearSpace(): Color3;
  5734. /**
  5735. * Converts current color in rgb space to HSV values
  5736. * @returns a new color3 representing the HSV values
  5737. */
  5738. toHSV(): Color3;
  5739. /**
  5740. * Converts current color in rgb space to HSV values
  5741. * @param result defines the Color3 where to store the HSV values
  5742. */
  5743. toHSVToRef(result: Color3): void;
  5744. /**
  5745. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5746. * @param convertedColor defines the Color3 object where to store the linear space version
  5747. * @returns the unmodified Color3
  5748. */
  5749. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5750. /**
  5751. * Computes a new Color3 converted from the current one to gamma space
  5752. * @returns a new Color3 object
  5753. */
  5754. toGammaSpace(): Color3;
  5755. /**
  5756. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5757. * @param convertedColor defines the Color3 object where to store the gamma space version
  5758. * @returns the unmodified Color3
  5759. */
  5760. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5761. private static _BlackReadOnly;
  5762. /**
  5763. * Convert Hue, saturation and value to a Color3 (RGB)
  5764. * @param hue defines the hue
  5765. * @param saturation defines the saturation
  5766. * @param value defines the value
  5767. * @param result defines the Color3 where to store the RGB values
  5768. */
  5769. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5770. /**
  5771. * Creates a new Color3 from the string containing valid hexadecimal values
  5772. * @param hex defines a string containing valid hexadecimal values
  5773. * @returns a new Color3 object
  5774. */
  5775. static FromHexString(hex: string): Color3;
  5776. /**
  5777. * Creates a new Color3 from the starting index of the given array
  5778. * @param array defines the source array
  5779. * @param offset defines an offset in the source array
  5780. * @returns a new Color3 object
  5781. */
  5782. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5783. /**
  5784. * Creates a new Color3 from the starting index element of the given array
  5785. * @param array defines the source array to read from
  5786. * @param offset defines the offset in the source array
  5787. * @param result defines the target Color3 object
  5788. */
  5789. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5790. /**
  5791. * Creates a new Color3 from integer values (< 256)
  5792. * @param r defines the red component to read from (value between 0 and 255)
  5793. * @param g defines the green component to read from (value between 0 and 255)
  5794. * @param b defines the blue component to read from (value between 0 and 255)
  5795. * @returns a new Color3 object
  5796. */
  5797. static FromInts(r: number, g: number, b: number): Color3;
  5798. /**
  5799. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5800. * @param start defines the start Color3 value
  5801. * @param end defines the end Color3 value
  5802. * @param amount defines the gradient value between start and end
  5803. * @returns a new Color3 object
  5804. */
  5805. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5806. /**
  5807. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5808. * @param left defines the start value
  5809. * @param right defines the end value
  5810. * @param amount defines the gradient factor
  5811. * @param result defines the Color3 object where to store the result
  5812. */
  5813. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5814. /**
  5815. * Returns a Color3 value containing a red color
  5816. * @returns a new Color3 object
  5817. */
  5818. static Red(): Color3;
  5819. /**
  5820. * Returns a Color3 value containing a green color
  5821. * @returns a new Color3 object
  5822. */
  5823. static Green(): Color3;
  5824. /**
  5825. * Returns a Color3 value containing a blue color
  5826. * @returns a new Color3 object
  5827. */
  5828. static Blue(): Color3;
  5829. /**
  5830. * Returns a Color3 value containing a black color
  5831. * @returns a new Color3 object
  5832. */
  5833. static Black(): Color3;
  5834. /**
  5835. * Gets a Color3 value containing a black color that must not be updated
  5836. */
  5837. static get BlackReadOnly(): DeepImmutable<Color3>;
  5838. /**
  5839. * Returns a Color3 value containing a white color
  5840. * @returns a new Color3 object
  5841. */
  5842. static White(): Color3;
  5843. /**
  5844. * Returns a Color3 value containing a purple color
  5845. * @returns a new Color3 object
  5846. */
  5847. static Purple(): Color3;
  5848. /**
  5849. * Returns a Color3 value containing a magenta color
  5850. * @returns a new Color3 object
  5851. */
  5852. static Magenta(): Color3;
  5853. /**
  5854. * Returns a Color3 value containing a yellow color
  5855. * @returns a new Color3 object
  5856. */
  5857. static Yellow(): Color3;
  5858. /**
  5859. * Returns a Color3 value containing a gray color
  5860. * @returns a new Color3 object
  5861. */
  5862. static Gray(): Color3;
  5863. /**
  5864. * Returns a Color3 value containing a teal color
  5865. * @returns a new Color3 object
  5866. */
  5867. static Teal(): Color3;
  5868. /**
  5869. * Returns a Color3 value containing a random color
  5870. * @returns a new Color3 object
  5871. */
  5872. static Random(): Color3;
  5873. }
  5874. /**
  5875. * Class used to hold a RBGA color
  5876. */
  5877. export class Color4 {
  5878. /**
  5879. * Defines the red component (between 0 and 1, default is 0)
  5880. */
  5881. r: number;
  5882. /**
  5883. * Defines the green component (between 0 and 1, default is 0)
  5884. */
  5885. g: number;
  5886. /**
  5887. * Defines the blue component (between 0 and 1, default is 0)
  5888. */
  5889. b: number;
  5890. /**
  5891. * Defines the alpha component (between 0 and 1, default is 1)
  5892. */
  5893. a: number;
  5894. /**
  5895. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5896. * @param r defines the red component (between 0 and 1, default is 0)
  5897. * @param g defines the green component (between 0 and 1, default is 0)
  5898. * @param b defines the blue component (between 0 and 1, default is 0)
  5899. * @param a defines the alpha component (between 0 and 1, default is 1)
  5900. */
  5901. constructor(
  5902. /**
  5903. * Defines the red component (between 0 and 1, default is 0)
  5904. */
  5905. r?: number,
  5906. /**
  5907. * Defines the green component (between 0 and 1, default is 0)
  5908. */
  5909. g?: number,
  5910. /**
  5911. * Defines the blue component (between 0 and 1, default is 0)
  5912. */
  5913. b?: number,
  5914. /**
  5915. * Defines the alpha component (between 0 and 1, default is 1)
  5916. */
  5917. a?: number);
  5918. /**
  5919. * Adds in place the given Color4 values to the current Color4 object
  5920. * @param right defines the second operand
  5921. * @returns the current updated Color4 object
  5922. */
  5923. addInPlace(right: DeepImmutable<Color4>): Color4;
  5924. /**
  5925. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5926. * @returns the new array
  5927. */
  5928. asArray(): number[];
  5929. /**
  5930. * Stores from the starting index in the given array the Color4 successive values
  5931. * @param array defines the array where to store the r,g,b components
  5932. * @param index defines an optional index in the target array to define where to start storing values
  5933. * @returns the current Color4 object
  5934. */
  5935. toArray(array: number[], index?: number): Color4;
  5936. /**
  5937. * Update the current color with values stored in an array from the starting index of the given array
  5938. * @param array defines the source array
  5939. * @param offset defines an offset in the source array
  5940. * @returns the current Color4 object
  5941. */
  5942. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5943. /**
  5944. * Determines equality between Color4 objects
  5945. * @param otherColor defines the second operand
  5946. * @returns true if the rgba values are equal to the given ones
  5947. */
  5948. equals(otherColor: DeepImmutable<Color4>): boolean;
  5949. /**
  5950. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5951. * @param right defines the second operand
  5952. * @returns a new Color4 object
  5953. */
  5954. add(right: DeepImmutable<Color4>): Color4;
  5955. /**
  5956. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5957. * @param right defines the second operand
  5958. * @returns a new Color4 object
  5959. */
  5960. subtract(right: DeepImmutable<Color4>): Color4;
  5961. /**
  5962. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5963. * @param right defines the second operand
  5964. * @param result defines the Color4 object where to store the result
  5965. * @returns the current Color4 object
  5966. */
  5967. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5968. /**
  5969. * Creates a new Color4 with the current Color4 values multiplied by scale
  5970. * @param scale defines the scaling factor to apply
  5971. * @returns a new Color4 object
  5972. */
  5973. scale(scale: number): Color4;
  5974. /**
  5975. * Multiplies the current Color4 values by scale and stores the result in "result"
  5976. * @param scale defines the scaling factor to apply
  5977. * @param result defines the Color4 object where to store the result
  5978. * @returns the current unmodified Color4
  5979. */
  5980. scaleToRef(scale: number, result: Color4): Color4;
  5981. /**
  5982. * Scale the current Color4 values by a factor and add the result to a given Color4
  5983. * @param scale defines the scale factor
  5984. * @param result defines the Color4 object where to store the result
  5985. * @returns the unmodified current Color4
  5986. */
  5987. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5988. /**
  5989. * Clamps the rgb values by the min and max values and stores the result into "result"
  5990. * @param min defines minimum clamping value (default is 0)
  5991. * @param max defines maximum clamping value (default is 1)
  5992. * @param result defines color to store the result into.
  5993. * @returns the cuurent Color4
  5994. */
  5995. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5996. /**
  5997. * Multipy an Color4 value by another and return a new Color4 object
  5998. * @param color defines the Color4 value to multiply by
  5999. * @returns a new Color4 object
  6000. */
  6001. multiply(color: Color4): Color4;
  6002. /**
  6003. * Multipy a Color4 value by another and push the result in a reference value
  6004. * @param color defines the Color4 value to multiply by
  6005. * @param result defines the Color4 to fill the result in
  6006. * @returns the result Color4
  6007. */
  6008. multiplyToRef(color: Color4, result: Color4): Color4;
  6009. /**
  6010. * Creates a string with the Color4 current values
  6011. * @returns the string representation of the Color4 object
  6012. */
  6013. toString(): string;
  6014. /**
  6015. * Returns the string "Color4"
  6016. * @returns "Color4"
  6017. */
  6018. getClassName(): string;
  6019. /**
  6020. * Compute the Color4 hash code
  6021. * @returns an unique number that can be used to hash Color4 objects
  6022. */
  6023. getHashCode(): number;
  6024. /**
  6025. * Creates a new Color4 copied from the current one
  6026. * @returns a new Color4 object
  6027. */
  6028. clone(): Color4;
  6029. /**
  6030. * Copies the given Color4 values into the current one
  6031. * @param source defines the source Color4 object
  6032. * @returns the current updated Color4 object
  6033. */
  6034. copyFrom(source: Color4): Color4;
  6035. /**
  6036. * Copies the given float values into the current one
  6037. * @param r defines the red component to read from
  6038. * @param g defines the green component to read from
  6039. * @param b defines the blue component to read from
  6040. * @param a defines the alpha component to read from
  6041. * @returns the current updated Color4 object
  6042. */
  6043. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6044. /**
  6045. * Copies the given float values into the current one
  6046. * @param r defines the red component to read from
  6047. * @param g defines the green component to read from
  6048. * @param b defines the blue component to read from
  6049. * @param a defines the alpha component to read from
  6050. * @returns the current updated Color4 object
  6051. */
  6052. set(r: number, g: number, b: number, a: number): Color4;
  6053. /**
  6054. * Compute the Color4 hexadecimal code as a string
  6055. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6056. * @returns a string containing the hexadecimal representation of the Color4 object
  6057. */
  6058. toHexString(returnAsColor3?: boolean): string;
  6059. /**
  6060. * Computes a new Color4 converted from the current one to linear space
  6061. * @returns a new Color4 object
  6062. */
  6063. toLinearSpace(): Color4;
  6064. /**
  6065. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6066. * @param convertedColor defines the Color4 object where to store the linear space version
  6067. * @returns the unmodified Color4
  6068. */
  6069. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6070. /**
  6071. * Computes a new Color4 converted from the current one to gamma space
  6072. * @returns a new Color4 object
  6073. */
  6074. toGammaSpace(): Color4;
  6075. /**
  6076. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6077. * @param convertedColor defines the Color4 object where to store the gamma space version
  6078. * @returns the unmodified Color4
  6079. */
  6080. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6081. /**
  6082. * Creates a new Color4 from the string containing valid hexadecimal values
  6083. * @param hex defines a string containing valid hexadecimal values
  6084. * @returns a new Color4 object
  6085. */
  6086. static FromHexString(hex: string): Color4;
  6087. /**
  6088. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6089. * @param left defines the start value
  6090. * @param right defines the end value
  6091. * @param amount defines the gradient factor
  6092. * @returns a new Color4 object
  6093. */
  6094. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6095. /**
  6096. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6097. * @param left defines the start value
  6098. * @param right defines the end value
  6099. * @param amount defines the gradient factor
  6100. * @param result defines the Color4 object where to store data
  6101. */
  6102. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6103. /**
  6104. * Creates a new Color4 from a Color3 and an alpha value
  6105. * @param color3 defines the source Color3 to read from
  6106. * @param alpha defines the alpha component (1.0 by default)
  6107. * @returns a new Color4 object
  6108. */
  6109. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6110. /**
  6111. * Creates a new Color4 from the starting index element of the given array
  6112. * @param array defines the source array to read from
  6113. * @param offset defines the offset in the source array
  6114. * @returns a new Color4 object
  6115. */
  6116. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6117. /**
  6118. * Creates a new Color4 from the starting index element of the given array
  6119. * @param array defines the source array to read from
  6120. * @param offset defines the offset in the source array
  6121. * @param result defines the target Color4 object
  6122. */
  6123. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6124. /**
  6125. * Creates a new Color3 from integer values (< 256)
  6126. * @param r defines the red component to read from (value between 0 and 255)
  6127. * @param g defines the green component to read from (value between 0 and 255)
  6128. * @param b defines the blue component to read from (value between 0 and 255)
  6129. * @param a defines the alpha component to read from (value between 0 and 255)
  6130. * @returns a new Color3 object
  6131. */
  6132. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6133. /**
  6134. * Check the content of a given array and convert it to an array containing RGBA data
  6135. * If the original array was already containing count * 4 values then it is returned directly
  6136. * @param colors defines the array to check
  6137. * @param count defines the number of RGBA data to expect
  6138. * @returns an array containing count * 4 values (RGBA)
  6139. */
  6140. static CheckColors4(colors: number[], count: number): number[];
  6141. }
  6142. /**
  6143. * @hidden
  6144. */
  6145. export class TmpColors {
  6146. static Color3: Color3[];
  6147. static Color4: Color4[];
  6148. }
  6149. }
  6150. declare module "babylonjs/Animations/animationKey" {
  6151. /**
  6152. * Defines an interface which represents an animation key frame
  6153. */
  6154. export interface IAnimationKey {
  6155. /**
  6156. * Frame of the key frame
  6157. */
  6158. frame: number;
  6159. /**
  6160. * Value at the specifies key frame
  6161. */
  6162. value: any;
  6163. /**
  6164. * The input tangent for the cubic hermite spline
  6165. */
  6166. inTangent?: any;
  6167. /**
  6168. * The output tangent for the cubic hermite spline
  6169. */
  6170. outTangent?: any;
  6171. /**
  6172. * The animation interpolation type
  6173. */
  6174. interpolation?: AnimationKeyInterpolation;
  6175. }
  6176. /**
  6177. * Enum for the animation key frame interpolation type
  6178. */
  6179. export enum AnimationKeyInterpolation {
  6180. /**
  6181. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6182. */
  6183. STEP = 1
  6184. }
  6185. }
  6186. declare module "babylonjs/Animations/animationRange" {
  6187. /**
  6188. * Represents the range of an animation
  6189. */
  6190. export class AnimationRange {
  6191. /**The name of the animation range**/
  6192. name: string;
  6193. /**The starting frame of the animation */
  6194. from: number;
  6195. /**The ending frame of the animation*/
  6196. to: number;
  6197. /**
  6198. * Initializes the range of an animation
  6199. * @param name The name of the animation range
  6200. * @param from The starting frame of the animation
  6201. * @param to The ending frame of the animation
  6202. */
  6203. constructor(
  6204. /**The name of the animation range**/
  6205. name: string,
  6206. /**The starting frame of the animation */
  6207. from: number,
  6208. /**The ending frame of the animation*/
  6209. to: number);
  6210. /**
  6211. * Makes a copy of the animation range
  6212. * @returns A copy of the animation range
  6213. */
  6214. clone(): AnimationRange;
  6215. }
  6216. }
  6217. declare module "babylonjs/Animations/animationEvent" {
  6218. /**
  6219. * Composed of a frame, and an action function
  6220. */
  6221. export class AnimationEvent {
  6222. /** The frame for which the event is triggered **/
  6223. frame: number;
  6224. /** The event to perform when triggered **/
  6225. action: (currentFrame: number) => void;
  6226. /** Specifies if the event should be triggered only once**/
  6227. onlyOnce?: boolean | undefined;
  6228. /**
  6229. * Specifies if the animation event is done
  6230. */
  6231. isDone: boolean;
  6232. /**
  6233. * Initializes the animation event
  6234. * @param frame The frame for which the event is triggered
  6235. * @param action The event to perform when triggered
  6236. * @param onlyOnce Specifies if the event should be triggered only once
  6237. */
  6238. constructor(
  6239. /** The frame for which the event is triggered **/
  6240. frame: number,
  6241. /** The event to perform when triggered **/
  6242. action: (currentFrame: number) => void,
  6243. /** Specifies if the event should be triggered only once**/
  6244. onlyOnce?: boolean | undefined);
  6245. /** @hidden */
  6246. _clone(): AnimationEvent;
  6247. }
  6248. }
  6249. declare module "babylonjs/Behaviors/behavior" {
  6250. import { Nullable } from "babylonjs/types";
  6251. /**
  6252. * Interface used to define a behavior
  6253. */
  6254. export interface Behavior<T> {
  6255. /** gets or sets behavior's name */
  6256. name: string;
  6257. /**
  6258. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6259. */
  6260. init(): void;
  6261. /**
  6262. * Called when the behavior is attached to a target
  6263. * @param target defines the target where the behavior is attached to
  6264. */
  6265. attach(target: T): void;
  6266. /**
  6267. * Called when the behavior is detached from its target
  6268. */
  6269. detach(): void;
  6270. }
  6271. /**
  6272. * Interface implemented by classes supporting behaviors
  6273. */
  6274. export interface IBehaviorAware<T> {
  6275. /**
  6276. * Attach a behavior
  6277. * @param behavior defines the behavior to attach
  6278. * @returns the current host
  6279. */
  6280. addBehavior(behavior: Behavior<T>): T;
  6281. /**
  6282. * Remove a behavior from the current object
  6283. * @param behavior defines the behavior to detach
  6284. * @returns the current host
  6285. */
  6286. removeBehavior(behavior: Behavior<T>): T;
  6287. /**
  6288. * Gets a behavior using its name to search
  6289. * @param name defines the name to search
  6290. * @returns the behavior or null if not found
  6291. */
  6292. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6293. }
  6294. }
  6295. declare module "babylonjs/Misc/smartArray" {
  6296. /**
  6297. * Defines an array and its length.
  6298. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6299. */
  6300. export interface ISmartArrayLike<T> {
  6301. /**
  6302. * The data of the array.
  6303. */
  6304. data: Array<T>;
  6305. /**
  6306. * The active length of the array.
  6307. */
  6308. length: number;
  6309. }
  6310. /**
  6311. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6312. */
  6313. export class SmartArray<T> implements ISmartArrayLike<T> {
  6314. /**
  6315. * The full set of data from the array.
  6316. */
  6317. data: Array<T>;
  6318. /**
  6319. * The active length of the array.
  6320. */
  6321. length: number;
  6322. protected _id: number;
  6323. /**
  6324. * Instantiates a Smart Array.
  6325. * @param capacity defines the default capacity of the array.
  6326. */
  6327. constructor(capacity: number);
  6328. /**
  6329. * Pushes a value at the end of the active data.
  6330. * @param value defines the object to push in the array.
  6331. */
  6332. push(value: T): void;
  6333. /**
  6334. * Iterates over the active data and apply the lambda to them.
  6335. * @param func defines the action to apply on each value.
  6336. */
  6337. forEach(func: (content: T) => void): void;
  6338. /**
  6339. * Sorts the full sets of data.
  6340. * @param compareFn defines the comparison function to apply.
  6341. */
  6342. sort(compareFn: (a: T, b: T) => number): void;
  6343. /**
  6344. * Resets the active data to an empty array.
  6345. */
  6346. reset(): void;
  6347. /**
  6348. * Releases all the data from the array as well as the array.
  6349. */
  6350. dispose(): void;
  6351. /**
  6352. * Concats the active data with a given array.
  6353. * @param array defines the data to concatenate with.
  6354. */
  6355. concat(array: any): void;
  6356. /**
  6357. * Returns the position of a value in the active data.
  6358. * @param value defines the value to find the index for
  6359. * @returns the index if found in the active data otherwise -1
  6360. */
  6361. indexOf(value: T): number;
  6362. /**
  6363. * Returns whether an element is part of the active data.
  6364. * @param value defines the value to look for
  6365. * @returns true if found in the active data otherwise false
  6366. */
  6367. contains(value: T): boolean;
  6368. private static _GlobalId;
  6369. }
  6370. /**
  6371. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6372. * The data in this array can only be present once
  6373. */
  6374. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6375. private _duplicateId;
  6376. /**
  6377. * Pushes a value at the end of the active data.
  6378. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6379. * @param value defines the object to push in the array.
  6380. */
  6381. push(value: T): void;
  6382. /**
  6383. * Pushes a value at the end of the active data.
  6384. * If the data is already present, it won t be added again
  6385. * @param value defines the object to push in the array.
  6386. * @returns true if added false if it was already present
  6387. */
  6388. pushNoDuplicate(value: T): boolean;
  6389. /**
  6390. * Resets the active data to an empty array.
  6391. */
  6392. reset(): void;
  6393. /**
  6394. * Concats the active data with a given array.
  6395. * This ensures no dupplicate will be present in the result.
  6396. * @param array defines the data to concatenate with.
  6397. */
  6398. concatWithNoDuplicate(array: any): void;
  6399. }
  6400. }
  6401. declare module "babylonjs/Cameras/cameraInputsManager" {
  6402. import { Nullable } from "babylonjs/types";
  6403. import { Camera } from "babylonjs/Cameras/camera";
  6404. /**
  6405. * @ignore
  6406. * This is a list of all the different input types that are available in the application.
  6407. * Fo instance: ArcRotateCameraGamepadInput...
  6408. */
  6409. export var CameraInputTypes: {};
  6410. /**
  6411. * This is the contract to implement in order to create a new input class.
  6412. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6413. */
  6414. export interface ICameraInput<TCamera extends Camera> {
  6415. /**
  6416. * Defines the camera the input is attached to.
  6417. */
  6418. camera: Nullable<TCamera>;
  6419. /**
  6420. * Gets the class name of the current intput.
  6421. * @returns the class name
  6422. */
  6423. getClassName(): string;
  6424. /**
  6425. * Get the friendly name associated with the input class.
  6426. * @returns the input friendly name
  6427. */
  6428. getSimpleName(): string;
  6429. /**
  6430. * Attach the input controls to a specific dom element to get the input from.
  6431. * @param element Defines the element the controls should be listened from
  6432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6433. */
  6434. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6435. /**
  6436. * Detach the current controls from the specified dom element.
  6437. * @param element Defines the element to stop listening the inputs from
  6438. */
  6439. detachControl(element: Nullable<HTMLElement>): void;
  6440. /**
  6441. * Update the current camera state depending on the inputs that have been used this frame.
  6442. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6443. */
  6444. checkInputs?: () => void;
  6445. }
  6446. /**
  6447. * Represents a map of input types to input instance or input index to input instance.
  6448. */
  6449. export interface CameraInputsMap<TCamera extends Camera> {
  6450. /**
  6451. * Accessor to the input by input type.
  6452. */
  6453. [name: string]: ICameraInput<TCamera>;
  6454. /**
  6455. * Accessor to the input by input index.
  6456. */
  6457. [idx: number]: ICameraInput<TCamera>;
  6458. }
  6459. /**
  6460. * This represents the input manager used within a camera.
  6461. * It helps dealing with all the different kind of input attached to a camera.
  6462. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6463. */
  6464. export class CameraInputsManager<TCamera extends Camera> {
  6465. /**
  6466. * Defines the list of inputs attahed to the camera.
  6467. */
  6468. attached: CameraInputsMap<TCamera>;
  6469. /**
  6470. * Defines the dom element the camera is collecting inputs from.
  6471. * This is null if the controls have not been attached.
  6472. */
  6473. attachedElement: Nullable<HTMLElement>;
  6474. /**
  6475. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6476. */
  6477. noPreventDefault: boolean;
  6478. /**
  6479. * Defined the camera the input manager belongs to.
  6480. */
  6481. camera: TCamera;
  6482. /**
  6483. * Update the current camera state depending on the inputs that have been used this frame.
  6484. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6485. */
  6486. checkInputs: () => void;
  6487. /**
  6488. * Instantiate a new Camera Input Manager.
  6489. * @param camera Defines the camera the input manager blongs to
  6490. */
  6491. constructor(camera: TCamera);
  6492. /**
  6493. * Add an input method to a camera
  6494. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6495. * @param input camera input method
  6496. */
  6497. add(input: ICameraInput<TCamera>): void;
  6498. /**
  6499. * Remove a specific input method from a camera
  6500. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6501. * @param inputToRemove camera input method
  6502. */
  6503. remove(inputToRemove: ICameraInput<TCamera>): void;
  6504. /**
  6505. * Remove a specific input type from a camera
  6506. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6507. * @param inputType the type of the input to remove
  6508. */
  6509. removeByType(inputType: string): void;
  6510. private _addCheckInputs;
  6511. /**
  6512. * Attach the input controls to the currently attached dom element to listen the events from.
  6513. * @param input Defines the input to attach
  6514. */
  6515. attachInput(input: ICameraInput<TCamera>): void;
  6516. /**
  6517. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6518. * @param element Defines the dom element to collect the events from
  6519. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6520. */
  6521. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6522. /**
  6523. * Detach the current manager inputs controls from a specific dom element.
  6524. * @param element Defines the dom element to collect the events from
  6525. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6526. */
  6527. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6528. /**
  6529. * Rebuild the dynamic inputCheck function from the current list of
  6530. * defined inputs in the manager.
  6531. */
  6532. rebuildInputCheck(): void;
  6533. /**
  6534. * Remove all attached input methods from a camera
  6535. */
  6536. clear(): void;
  6537. /**
  6538. * Serialize the current input manager attached to a camera.
  6539. * This ensures than once parsed,
  6540. * the input associated to the camera will be identical to the current ones
  6541. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6542. */
  6543. serialize(serializedCamera: any): void;
  6544. /**
  6545. * Parses an input manager serialized JSON to restore the previous list of inputs
  6546. * and states associated to a camera.
  6547. * @param parsedCamera Defines the JSON to parse
  6548. */
  6549. parse(parsedCamera: any): void;
  6550. }
  6551. }
  6552. declare module "babylonjs/Meshes/buffer" {
  6553. import { Nullable, DataArray } from "babylonjs/types";
  6554. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6555. /**
  6556. * Class used to store data that will be store in GPU memory
  6557. */
  6558. export class Buffer {
  6559. private _engine;
  6560. private _buffer;
  6561. /** @hidden */
  6562. _data: Nullable<DataArray>;
  6563. private _updatable;
  6564. private _instanced;
  6565. private _divisor;
  6566. /**
  6567. * Gets the byte stride.
  6568. */
  6569. readonly byteStride: number;
  6570. /**
  6571. * Constructor
  6572. * @param engine the engine
  6573. * @param data the data to use for this buffer
  6574. * @param updatable whether the data is updatable
  6575. * @param stride the stride (optional)
  6576. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6577. * @param instanced whether the buffer is instanced (optional)
  6578. * @param useBytes set to true if the stride in in bytes (optional)
  6579. * @param divisor sets an optional divisor for instances (1 by default)
  6580. */
  6581. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6582. /**
  6583. * Create a new VertexBuffer based on the current buffer
  6584. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6585. * @param offset defines offset in the buffer (0 by default)
  6586. * @param size defines the size in floats of attributes (position is 3 for instance)
  6587. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6588. * @param instanced defines if the vertex buffer contains indexed data
  6589. * @param useBytes defines if the offset and stride are in bytes *
  6590. * @param divisor sets an optional divisor for instances (1 by default)
  6591. * @returns the new vertex buffer
  6592. */
  6593. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6594. /**
  6595. * Gets a boolean indicating if the Buffer is updatable?
  6596. * @returns true if the buffer is updatable
  6597. */
  6598. isUpdatable(): boolean;
  6599. /**
  6600. * Gets current buffer's data
  6601. * @returns a DataArray or null
  6602. */
  6603. getData(): Nullable<DataArray>;
  6604. /**
  6605. * Gets underlying native buffer
  6606. * @returns underlying native buffer
  6607. */
  6608. getBuffer(): Nullable<DataBuffer>;
  6609. /**
  6610. * Gets the stride in float32 units (i.e. byte stride / 4).
  6611. * May not be an integer if the byte stride is not divisible by 4.
  6612. * @returns the stride in float32 units
  6613. * @deprecated Please use byteStride instead.
  6614. */
  6615. getStrideSize(): number;
  6616. /**
  6617. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6618. * @param data defines the data to store
  6619. */
  6620. create(data?: Nullable<DataArray>): void;
  6621. /** @hidden */
  6622. _rebuild(): void;
  6623. /**
  6624. * Update current buffer data
  6625. * @param data defines the data to store
  6626. */
  6627. update(data: DataArray): void;
  6628. /**
  6629. * Updates the data directly.
  6630. * @param data the new data
  6631. * @param offset the new offset
  6632. * @param vertexCount the vertex count (optional)
  6633. * @param useBytes set to true if the offset is in bytes
  6634. */
  6635. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6636. /**
  6637. * Release all resources
  6638. */
  6639. dispose(): void;
  6640. }
  6641. /**
  6642. * Specialized buffer used to store vertex data
  6643. */
  6644. export class VertexBuffer {
  6645. /** @hidden */
  6646. _buffer: Buffer;
  6647. private _kind;
  6648. private _size;
  6649. private _ownsBuffer;
  6650. private _instanced;
  6651. private _instanceDivisor;
  6652. /**
  6653. * The byte type.
  6654. */
  6655. static readonly BYTE: number;
  6656. /**
  6657. * The unsigned byte type.
  6658. */
  6659. static readonly UNSIGNED_BYTE: number;
  6660. /**
  6661. * The short type.
  6662. */
  6663. static readonly SHORT: number;
  6664. /**
  6665. * The unsigned short type.
  6666. */
  6667. static readonly UNSIGNED_SHORT: number;
  6668. /**
  6669. * The integer type.
  6670. */
  6671. static readonly INT: number;
  6672. /**
  6673. * The unsigned integer type.
  6674. */
  6675. static readonly UNSIGNED_INT: number;
  6676. /**
  6677. * The float type.
  6678. */
  6679. static readonly FLOAT: number;
  6680. /**
  6681. * Gets or sets the instance divisor when in instanced mode
  6682. */
  6683. get instanceDivisor(): number;
  6684. set instanceDivisor(value: number);
  6685. /**
  6686. * Gets the byte stride.
  6687. */
  6688. readonly byteStride: number;
  6689. /**
  6690. * Gets the byte offset.
  6691. */
  6692. readonly byteOffset: number;
  6693. /**
  6694. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6695. */
  6696. readonly normalized: boolean;
  6697. /**
  6698. * Gets the data type of each component in the array.
  6699. */
  6700. readonly type: number;
  6701. /**
  6702. * Constructor
  6703. * @param engine the engine
  6704. * @param data the data to use for this vertex buffer
  6705. * @param kind the vertex buffer kind
  6706. * @param updatable whether the data is updatable
  6707. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6708. * @param stride the stride (optional)
  6709. * @param instanced whether the buffer is instanced (optional)
  6710. * @param offset the offset of the data (optional)
  6711. * @param size the number of components (optional)
  6712. * @param type the type of the component (optional)
  6713. * @param normalized whether the data contains normalized data (optional)
  6714. * @param useBytes set to true if stride and offset are in bytes (optional)
  6715. * @param divisor defines the instance divisor to use (1 by default)
  6716. */
  6717. 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);
  6718. /** @hidden */
  6719. _rebuild(): void;
  6720. /**
  6721. * Returns the kind of the VertexBuffer (string)
  6722. * @returns a string
  6723. */
  6724. getKind(): string;
  6725. /**
  6726. * Gets a boolean indicating if the VertexBuffer is updatable?
  6727. * @returns true if the buffer is updatable
  6728. */
  6729. isUpdatable(): boolean;
  6730. /**
  6731. * Gets current buffer's data
  6732. * @returns a DataArray or null
  6733. */
  6734. getData(): Nullable<DataArray>;
  6735. /**
  6736. * Gets underlying native buffer
  6737. * @returns underlying native buffer
  6738. */
  6739. getBuffer(): Nullable<DataBuffer>;
  6740. /**
  6741. * Gets the stride in float32 units (i.e. byte stride / 4).
  6742. * May not be an integer if the byte stride is not divisible by 4.
  6743. * @returns the stride in float32 units
  6744. * @deprecated Please use byteStride instead.
  6745. */
  6746. getStrideSize(): number;
  6747. /**
  6748. * Returns the offset as a multiple of the type byte length.
  6749. * @returns the offset in bytes
  6750. * @deprecated Please use byteOffset instead.
  6751. */
  6752. getOffset(): number;
  6753. /**
  6754. * Returns the number of components per vertex attribute (integer)
  6755. * @returns the size in float
  6756. */
  6757. getSize(): number;
  6758. /**
  6759. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6760. * @returns true if this buffer is instanced
  6761. */
  6762. getIsInstanced(): boolean;
  6763. /**
  6764. * Returns the instancing divisor, zero for non-instanced (integer).
  6765. * @returns a number
  6766. */
  6767. getInstanceDivisor(): number;
  6768. /**
  6769. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6770. * @param data defines the data to store
  6771. */
  6772. create(data?: DataArray): void;
  6773. /**
  6774. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6775. * This function will create a new buffer if the current one is not updatable
  6776. * @param data defines the data to store
  6777. */
  6778. update(data: DataArray): void;
  6779. /**
  6780. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6781. * Returns the directly updated WebGLBuffer.
  6782. * @param data the new data
  6783. * @param offset the new offset
  6784. * @param useBytes set to true if the offset is in bytes
  6785. */
  6786. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6787. /**
  6788. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6789. */
  6790. dispose(): void;
  6791. /**
  6792. * Enumerates each value of this vertex buffer as numbers.
  6793. * @param count the number of values to enumerate
  6794. * @param callback the callback function called for each value
  6795. */
  6796. forEach(count: number, callback: (value: number, index: number) => void): void;
  6797. /**
  6798. * Positions
  6799. */
  6800. static readonly PositionKind: string;
  6801. /**
  6802. * Normals
  6803. */
  6804. static readonly NormalKind: string;
  6805. /**
  6806. * Tangents
  6807. */
  6808. static readonly TangentKind: string;
  6809. /**
  6810. * Texture coordinates
  6811. */
  6812. static readonly UVKind: string;
  6813. /**
  6814. * Texture coordinates 2
  6815. */
  6816. static readonly UV2Kind: string;
  6817. /**
  6818. * Texture coordinates 3
  6819. */
  6820. static readonly UV3Kind: string;
  6821. /**
  6822. * Texture coordinates 4
  6823. */
  6824. static readonly UV4Kind: string;
  6825. /**
  6826. * Texture coordinates 5
  6827. */
  6828. static readonly UV5Kind: string;
  6829. /**
  6830. * Texture coordinates 6
  6831. */
  6832. static readonly UV6Kind: string;
  6833. /**
  6834. * Colors
  6835. */
  6836. static readonly ColorKind: string;
  6837. /**
  6838. * Matrix indices (for bones)
  6839. */
  6840. static readonly MatricesIndicesKind: string;
  6841. /**
  6842. * Matrix weights (for bones)
  6843. */
  6844. static readonly MatricesWeightsKind: string;
  6845. /**
  6846. * Additional matrix indices (for bones)
  6847. */
  6848. static readonly MatricesIndicesExtraKind: string;
  6849. /**
  6850. * Additional matrix weights (for bones)
  6851. */
  6852. static readonly MatricesWeightsExtraKind: string;
  6853. /**
  6854. * Deduces the stride given a kind.
  6855. * @param kind The kind string to deduce
  6856. * @returns The deduced stride
  6857. */
  6858. static DeduceStride(kind: string): number;
  6859. /**
  6860. * Gets the byte length of the given type.
  6861. * @param type the type
  6862. * @returns the number of bytes
  6863. */
  6864. static GetTypeByteLength(type: number): number;
  6865. /**
  6866. * Enumerates each value of the given parameters as numbers.
  6867. * @param data the data to enumerate
  6868. * @param byteOffset the byte offset of the data
  6869. * @param byteStride the byte stride of the data
  6870. * @param componentCount the number of components per element
  6871. * @param componentType the type of the component
  6872. * @param count the number of values to enumerate
  6873. * @param normalized whether the data is normalized
  6874. * @param callback the callback function called for each value
  6875. */
  6876. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6877. private static _GetFloatValue;
  6878. }
  6879. }
  6880. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6881. import { Vector3 } from "babylonjs/Maths/math.vector";
  6882. import { Mesh } from "babylonjs/Meshes/mesh";
  6883. /**
  6884. * The options Interface for creating a Capsule Mesh
  6885. */
  6886. export interface ICreateCapsuleOptions {
  6887. /** The Orientation of the capsule. Default : Vector3.Up() */
  6888. orientation?: Vector3;
  6889. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6890. subdivisions: number;
  6891. /** Number of cylindrical segments on the capsule. */
  6892. tessellation: number;
  6893. /** Height or Length of the capsule. */
  6894. height: number;
  6895. /** Radius of the capsule. */
  6896. radius: number;
  6897. /** Height or Length of the capsule. */
  6898. capSubdivisions: number;
  6899. /** Overwrite for the top radius. */
  6900. radiusTop?: number;
  6901. /** Overwrite for the bottom radius. */
  6902. radiusBottom?: number;
  6903. /** Overwrite for the top capSubdivisions. */
  6904. topCapSubdivisions?: number;
  6905. /** Overwrite for the bottom capSubdivisions. */
  6906. bottomCapSubdivisions?: number;
  6907. }
  6908. /**
  6909. * Class containing static functions to help procedurally build meshes
  6910. */
  6911. export class CapsuleBuilder {
  6912. /**
  6913. * Creates a capsule or a pill mesh
  6914. * @param name defines the name of the mesh
  6915. * @param options The constructors options.
  6916. * @param scene The scene the mesh is scoped to.
  6917. * @returns Capsule Mesh
  6918. */
  6919. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6920. }
  6921. }
  6922. declare module "babylonjs/Collisions/intersectionInfo" {
  6923. import { Nullable } from "babylonjs/types";
  6924. /**
  6925. * @hidden
  6926. */
  6927. export class IntersectionInfo {
  6928. bu: Nullable<number>;
  6929. bv: Nullable<number>;
  6930. distance: number;
  6931. faceId: number;
  6932. subMeshId: number;
  6933. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6934. }
  6935. }
  6936. declare module "babylonjs/Culling/boundingSphere" {
  6937. import { DeepImmutable } from "babylonjs/types";
  6938. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6939. import { Plane } from "babylonjs/Maths/math.plane";
  6940. /**
  6941. * Class used to store bounding sphere information
  6942. */
  6943. export class BoundingSphere {
  6944. /**
  6945. * Gets the center of the bounding sphere in local space
  6946. */
  6947. readonly center: Vector3;
  6948. /**
  6949. * Radius of the bounding sphere in local space
  6950. */
  6951. radius: number;
  6952. /**
  6953. * Gets the center of the bounding sphere in world space
  6954. */
  6955. readonly centerWorld: Vector3;
  6956. /**
  6957. * Radius of the bounding sphere in world space
  6958. */
  6959. radiusWorld: number;
  6960. /**
  6961. * Gets the minimum vector in local space
  6962. */
  6963. readonly minimum: Vector3;
  6964. /**
  6965. * Gets the maximum vector in local space
  6966. */
  6967. readonly maximum: Vector3;
  6968. private _worldMatrix;
  6969. private static readonly TmpVector3;
  6970. /**
  6971. * Creates a new bounding sphere
  6972. * @param min defines the minimum vector (in local space)
  6973. * @param max defines the maximum vector (in local space)
  6974. * @param worldMatrix defines the new world matrix
  6975. */
  6976. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6977. /**
  6978. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6979. * @param min defines the new minimum vector (in local space)
  6980. * @param max defines the new maximum vector (in local space)
  6981. * @param worldMatrix defines the new world matrix
  6982. */
  6983. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6984. /**
  6985. * Scale the current bounding sphere by applying a scale factor
  6986. * @param factor defines the scale factor to apply
  6987. * @returns the current bounding box
  6988. */
  6989. scale(factor: number): BoundingSphere;
  6990. /**
  6991. * Gets the world matrix of the bounding box
  6992. * @returns a matrix
  6993. */
  6994. getWorldMatrix(): DeepImmutable<Matrix>;
  6995. /** @hidden */
  6996. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6997. /**
  6998. * Tests if the bounding sphere is intersecting the frustum planes
  6999. * @param frustumPlanes defines the frustum planes to test
  7000. * @returns true if there is an intersection
  7001. */
  7002. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7003. /**
  7004. * Tests if the bounding sphere center is in between the frustum planes.
  7005. * Used for optimistic fast inclusion.
  7006. * @param frustumPlanes defines the frustum planes to test
  7007. * @returns true if the sphere center is in between the frustum planes
  7008. */
  7009. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7010. /**
  7011. * Tests if a point is inside the bounding sphere
  7012. * @param point defines the point to test
  7013. * @returns true if the point is inside the bounding sphere
  7014. */
  7015. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7016. /**
  7017. * Checks if two sphere intersct
  7018. * @param sphere0 sphere 0
  7019. * @param sphere1 sphere 1
  7020. * @returns true if the speres intersect
  7021. */
  7022. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7023. }
  7024. }
  7025. declare module "babylonjs/Culling/boundingBox" {
  7026. import { DeepImmutable } from "babylonjs/types";
  7027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7028. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7029. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7030. import { Plane } from "babylonjs/Maths/math.plane";
  7031. /**
  7032. * Class used to store bounding box information
  7033. */
  7034. export class BoundingBox implements ICullable {
  7035. /**
  7036. * Gets the 8 vectors representing the bounding box in local space
  7037. */
  7038. readonly vectors: Vector3[];
  7039. /**
  7040. * Gets the center of the bounding box in local space
  7041. */
  7042. readonly center: Vector3;
  7043. /**
  7044. * Gets the center of the bounding box in world space
  7045. */
  7046. readonly centerWorld: Vector3;
  7047. /**
  7048. * Gets the extend size in local space
  7049. */
  7050. readonly extendSize: Vector3;
  7051. /**
  7052. * Gets the extend size in world space
  7053. */
  7054. readonly extendSizeWorld: Vector3;
  7055. /**
  7056. * Gets the OBB (object bounding box) directions
  7057. */
  7058. readonly directions: Vector3[];
  7059. /**
  7060. * Gets the 8 vectors representing the bounding box in world space
  7061. */
  7062. readonly vectorsWorld: Vector3[];
  7063. /**
  7064. * Gets the minimum vector in world space
  7065. */
  7066. readonly minimumWorld: Vector3;
  7067. /**
  7068. * Gets the maximum vector in world space
  7069. */
  7070. readonly maximumWorld: Vector3;
  7071. /**
  7072. * Gets the minimum vector in local space
  7073. */
  7074. readonly minimum: Vector3;
  7075. /**
  7076. * Gets the maximum vector in local space
  7077. */
  7078. readonly maximum: Vector3;
  7079. private _worldMatrix;
  7080. private static readonly TmpVector3;
  7081. /**
  7082. * @hidden
  7083. */
  7084. _tag: number;
  7085. /**
  7086. * Creates a new bounding box
  7087. * @param min defines the minimum vector (in local space)
  7088. * @param max defines the maximum vector (in local space)
  7089. * @param worldMatrix defines the new world matrix
  7090. */
  7091. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7092. /**
  7093. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7094. * @param min defines the new minimum vector (in local space)
  7095. * @param max defines the new maximum vector (in local space)
  7096. * @param worldMatrix defines the new world matrix
  7097. */
  7098. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7099. /**
  7100. * Scale the current bounding box by applying a scale factor
  7101. * @param factor defines the scale factor to apply
  7102. * @returns the current bounding box
  7103. */
  7104. scale(factor: number): BoundingBox;
  7105. /**
  7106. * Gets the world matrix of the bounding box
  7107. * @returns a matrix
  7108. */
  7109. getWorldMatrix(): DeepImmutable<Matrix>;
  7110. /** @hidden */
  7111. _update(world: DeepImmutable<Matrix>): void;
  7112. /**
  7113. * Tests if the bounding box is intersecting the frustum planes
  7114. * @param frustumPlanes defines the frustum planes to test
  7115. * @returns true if there is an intersection
  7116. */
  7117. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7118. /**
  7119. * Tests if the bounding box is entirely inside the frustum planes
  7120. * @param frustumPlanes defines the frustum planes to test
  7121. * @returns true if there is an inclusion
  7122. */
  7123. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7124. /**
  7125. * Tests if a point is inside the bounding box
  7126. * @param point defines the point to test
  7127. * @returns true if the point is inside the bounding box
  7128. */
  7129. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7130. /**
  7131. * Tests if the bounding box intersects with a bounding sphere
  7132. * @param sphere defines the sphere to test
  7133. * @returns true if there is an intersection
  7134. */
  7135. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7136. /**
  7137. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7138. * @param min defines the min vector to use
  7139. * @param max defines the max vector to use
  7140. * @returns true if there is an intersection
  7141. */
  7142. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7143. /**
  7144. * Tests if two bounding boxes are intersections
  7145. * @param box0 defines the first box to test
  7146. * @param box1 defines the second box to test
  7147. * @returns true if there is an intersection
  7148. */
  7149. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7150. /**
  7151. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7152. * @param minPoint defines the minimum vector of the bounding box
  7153. * @param maxPoint defines the maximum vector of the bounding box
  7154. * @param sphereCenter defines the sphere center
  7155. * @param sphereRadius defines the sphere radius
  7156. * @returns true if there is an intersection
  7157. */
  7158. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7159. /**
  7160. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7161. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7162. * @param frustumPlanes defines the frustum planes to test
  7163. * @return true if there is an inclusion
  7164. */
  7165. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7166. /**
  7167. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7168. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7169. * @param frustumPlanes defines the frustum planes to test
  7170. * @return true if there is an intersection
  7171. */
  7172. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7173. }
  7174. }
  7175. declare module "babylonjs/Collisions/collider" {
  7176. import { Nullable, IndicesArray } from "babylonjs/types";
  7177. import { Vector3 } from "babylonjs/Maths/math.vector";
  7178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7179. import { Plane } from "babylonjs/Maths/math.plane";
  7180. /** @hidden */
  7181. export class Collider {
  7182. /** Define if a collision was found */
  7183. collisionFound: boolean;
  7184. /**
  7185. * Define last intersection point in local space
  7186. */
  7187. intersectionPoint: Vector3;
  7188. /**
  7189. * Define last collided mesh
  7190. */
  7191. collidedMesh: Nullable<AbstractMesh>;
  7192. private _collisionPoint;
  7193. private _planeIntersectionPoint;
  7194. private _tempVector;
  7195. private _tempVector2;
  7196. private _tempVector3;
  7197. private _tempVector4;
  7198. private _edge;
  7199. private _baseToVertex;
  7200. private _destinationPoint;
  7201. private _slidePlaneNormal;
  7202. private _displacementVector;
  7203. /** @hidden */
  7204. _radius: Vector3;
  7205. /** @hidden */
  7206. _retry: number;
  7207. private _velocity;
  7208. private _basePoint;
  7209. private _epsilon;
  7210. /** @hidden */
  7211. _velocityWorldLength: number;
  7212. /** @hidden */
  7213. _basePointWorld: Vector3;
  7214. private _velocityWorld;
  7215. private _normalizedVelocity;
  7216. /** @hidden */
  7217. _initialVelocity: Vector3;
  7218. /** @hidden */
  7219. _initialPosition: Vector3;
  7220. private _nearestDistance;
  7221. private _collisionMask;
  7222. get collisionMask(): number;
  7223. set collisionMask(mask: number);
  7224. /**
  7225. * Gets the plane normal used to compute the sliding response (in local space)
  7226. */
  7227. get slidePlaneNormal(): Vector3;
  7228. /** @hidden */
  7229. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7230. /** @hidden */
  7231. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7232. /** @hidden */
  7233. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7234. /** @hidden */
  7235. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7236. /** @hidden */
  7237. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7238. /** @hidden */
  7239. _getResponse(pos: Vector3, vel: Vector3): void;
  7240. }
  7241. }
  7242. declare module "babylonjs/Culling/boundingInfo" {
  7243. import { DeepImmutable } from "babylonjs/types";
  7244. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7245. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7246. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7247. import { Plane } from "babylonjs/Maths/math.plane";
  7248. import { Collider } from "babylonjs/Collisions/collider";
  7249. /**
  7250. * Interface for cullable objects
  7251. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7252. */
  7253. export interface ICullable {
  7254. /**
  7255. * Checks if the object or part of the object is in the frustum
  7256. * @param frustumPlanes Camera near/planes
  7257. * @returns true if the object is in frustum otherwise false
  7258. */
  7259. isInFrustum(frustumPlanes: Plane[]): boolean;
  7260. /**
  7261. * Checks if a cullable object (mesh...) is in the camera frustum
  7262. * Unlike isInFrustum this cheks the full bounding box
  7263. * @param frustumPlanes Camera near/planes
  7264. * @returns true if the object is in frustum otherwise false
  7265. */
  7266. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7267. }
  7268. /**
  7269. * Info for a bounding data of a mesh
  7270. */
  7271. export class BoundingInfo implements ICullable {
  7272. /**
  7273. * Bounding box for the mesh
  7274. */
  7275. readonly boundingBox: BoundingBox;
  7276. /**
  7277. * Bounding sphere for the mesh
  7278. */
  7279. readonly boundingSphere: BoundingSphere;
  7280. private _isLocked;
  7281. private static readonly TmpVector3;
  7282. /**
  7283. * Constructs bounding info
  7284. * @param minimum min vector of the bounding box/sphere
  7285. * @param maximum max vector of the bounding box/sphere
  7286. * @param worldMatrix defines the new world matrix
  7287. */
  7288. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7289. /**
  7290. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7291. * @param min defines the new minimum vector (in local space)
  7292. * @param max defines the new maximum vector (in local space)
  7293. * @param worldMatrix defines the new world matrix
  7294. */
  7295. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7296. /**
  7297. * min vector of the bounding box/sphere
  7298. */
  7299. get minimum(): Vector3;
  7300. /**
  7301. * max vector of the bounding box/sphere
  7302. */
  7303. get maximum(): Vector3;
  7304. /**
  7305. * If the info is locked and won't be updated to avoid perf overhead
  7306. */
  7307. get isLocked(): boolean;
  7308. set isLocked(value: boolean);
  7309. /**
  7310. * Updates the bounding sphere and box
  7311. * @param world world matrix to be used to update
  7312. */
  7313. update(world: DeepImmutable<Matrix>): void;
  7314. /**
  7315. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7316. * @param center New center of the bounding info
  7317. * @param extend New extend of the bounding info
  7318. * @returns the current bounding info
  7319. */
  7320. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7321. /**
  7322. * Scale the current bounding info by applying a scale factor
  7323. * @param factor defines the scale factor to apply
  7324. * @returns the current bounding info
  7325. */
  7326. scale(factor: number): BoundingInfo;
  7327. /**
  7328. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7329. * @param frustumPlanes defines the frustum to test
  7330. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7331. * @returns true if the bounding info is in the frustum planes
  7332. */
  7333. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7334. /**
  7335. * Gets the world distance between the min and max points of the bounding box
  7336. */
  7337. get diagonalLength(): number;
  7338. /**
  7339. * Checks if a cullable object (mesh...) is in the camera frustum
  7340. * Unlike isInFrustum this cheks the full bounding box
  7341. * @param frustumPlanes Camera near/planes
  7342. * @returns true if the object is in frustum otherwise false
  7343. */
  7344. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7345. /** @hidden */
  7346. _checkCollision(collider: Collider): boolean;
  7347. /**
  7348. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7349. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7350. * @param point the point to check intersection with
  7351. * @returns if the point intersects
  7352. */
  7353. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7354. /**
  7355. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7356. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7357. * @param boundingInfo the bounding info to check intersection with
  7358. * @param precise if the intersection should be done using OBB
  7359. * @returns if the bounding info intersects
  7360. */
  7361. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7362. }
  7363. }
  7364. declare module "babylonjs/Maths/math.functions" {
  7365. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7366. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7367. /**
  7368. * Extracts minimum and maximum values from a list of indexed positions
  7369. * @param positions defines the positions to use
  7370. * @param indices defines the indices to the positions
  7371. * @param indexStart defines the start index
  7372. * @param indexCount defines the end index
  7373. * @param bias defines bias value to add to the result
  7374. * @return minimum and maximum values
  7375. */
  7376. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7377. minimum: Vector3;
  7378. maximum: Vector3;
  7379. };
  7380. /**
  7381. * Extracts minimum and maximum values from a list of positions
  7382. * @param positions defines the positions to use
  7383. * @param start defines the start index in the positions array
  7384. * @param count defines the number of positions to handle
  7385. * @param bias defines bias value to add to the result
  7386. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7387. * @return minimum and maximum values
  7388. */
  7389. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7390. minimum: Vector3;
  7391. maximum: Vector3;
  7392. };
  7393. }
  7394. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7395. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7396. /** @hidden */
  7397. export class WebGLDataBuffer extends DataBuffer {
  7398. private _buffer;
  7399. constructor(resource: WebGLBuffer);
  7400. get underlyingResource(): any;
  7401. }
  7402. }
  7403. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7404. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7405. import { Nullable } from "babylonjs/types";
  7406. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7407. /** @hidden */
  7408. export class WebGLPipelineContext implements IPipelineContext {
  7409. engine: ThinEngine;
  7410. program: Nullable<WebGLProgram>;
  7411. context?: WebGLRenderingContext;
  7412. vertexShader?: WebGLShader;
  7413. fragmentShader?: WebGLShader;
  7414. isParallelCompiled: boolean;
  7415. onCompiled?: () => void;
  7416. transformFeedback?: WebGLTransformFeedback | null;
  7417. vertexCompilationError: Nullable<string>;
  7418. fragmentCompilationError: Nullable<string>;
  7419. programLinkError: Nullable<string>;
  7420. programValidationError: Nullable<string>;
  7421. get isAsync(): boolean;
  7422. get isReady(): boolean;
  7423. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7424. _getVertexShaderCode(): string | null;
  7425. _getFragmentShaderCode(): string | null;
  7426. }
  7427. }
  7428. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7429. import { FloatArray, Nullable } from "babylonjs/types";
  7430. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7431. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7432. module "babylonjs/Engines/thinEngine" {
  7433. interface ThinEngine {
  7434. /**
  7435. * Create an uniform buffer
  7436. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7437. * @param elements defines the content of the uniform buffer
  7438. * @returns the webGL uniform buffer
  7439. */
  7440. createUniformBuffer(elements: FloatArray): DataBuffer;
  7441. /**
  7442. * Create a dynamic uniform buffer
  7443. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7444. * @param elements defines the content of the uniform buffer
  7445. * @returns the webGL uniform buffer
  7446. */
  7447. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7448. /**
  7449. * Update an existing uniform buffer
  7450. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7451. * @param uniformBuffer defines the target uniform buffer
  7452. * @param elements defines the content to update
  7453. * @param offset defines the offset in the uniform buffer where update should start
  7454. * @param count defines the size of the data to update
  7455. */
  7456. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7457. /**
  7458. * Bind an uniform buffer to the current webGL context
  7459. * @param buffer defines the buffer to bind
  7460. */
  7461. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7462. /**
  7463. * Bind a buffer to the current webGL context at a given location
  7464. * @param buffer defines the buffer to bind
  7465. * @param location defines the index where to bind the buffer
  7466. */
  7467. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7468. /**
  7469. * Bind a specific block at a given index in a specific shader program
  7470. * @param pipelineContext defines the pipeline context to use
  7471. * @param blockName defines the block name
  7472. * @param index defines the index where to bind the block
  7473. */
  7474. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7475. }
  7476. }
  7477. }
  7478. declare module "babylonjs/Materials/uniformBuffer" {
  7479. import { Nullable, FloatArray } from "babylonjs/types";
  7480. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7481. import { Engine } from "babylonjs/Engines/engine";
  7482. import { Effect } from "babylonjs/Materials/effect";
  7483. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7484. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7485. import { Color3 } from "babylonjs/Maths/math.color";
  7486. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7487. /**
  7488. * Uniform buffer objects.
  7489. *
  7490. * Handles blocks of uniform on the GPU.
  7491. *
  7492. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7493. *
  7494. * For more information, please refer to :
  7495. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7496. */
  7497. export class UniformBuffer {
  7498. private _engine;
  7499. private _buffer;
  7500. private _data;
  7501. private _bufferData;
  7502. private _dynamic?;
  7503. private _uniformLocations;
  7504. private _uniformSizes;
  7505. private _uniformLocationPointer;
  7506. private _needSync;
  7507. private _noUBO;
  7508. private _currentEffect;
  7509. /** @hidden */
  7510. _alreadyBound: boolean;
  7511. private static _MAX_UNIFORM_SIZE;
  7512. private static _tempBuffer;
  7513. /**
  7514. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7515. * This is dynamic to allow compat with webgl 1 and 2.
  7516. * You will need to pass the name of the uniform as well as the value.
  7517. */
  7518. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7519. /**
  7520. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7521. * This is dynamic to allow compat with webgl 1 and 2.
  7522. * You will need to pass the name of the uniform as well as the value.
  7523. */
  7524. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7525. /**
  7526. * Lambda to Update a single float in a uniform buffer.
  7527. * This is dynamic to allow compat with webgl 1 and 2.
  7528. * You will need to pass the name of the uniform as well as the value.
  7529. */
  7530. updateFloat: (name: string, x: number) => void;
  7531. /**
  7532. * Lambda to Update a vec2 of float in a uniform buffer.
  7533. * This is dynamic to allow compat with webgl 1 and 2.
  7534. * You will need to pass the name of the uniform as well as the value.
  7535. */
  7536. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7537. /**
  7538. * Lambda to Update a vec3 of float in a uniform buffer.
  7539. * This is dynamic to allow compat with webgl 1 and 2.
  7540. * You will need to pass the name of the uniform as well as the value.
  7541. */
  7542. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7543. /**
  7544. * Lambda to Update a vec4 of float in a uniform buffer.
  7545. * This is dynamic to allow compat with webgl 1 and 2.
  7546. * You will need to pass the name of the uniform as well as the value.
  7547. */
  7548. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7549. /**
  7550. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7551. * This is dynamic to allow compat with webgl 1 and 2.
  7552. * You will need to pass the name of the uniform as well as the value.
  7553. */
  7554. updateMatrix: (name: string, mat: Matrix) => void;
  7555. /**
  7556. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7557. * This is dynamic to allow compat with webgl 1 and 2.
  7558. * You will need to pass the name of the uniform as well as the value.
  7559. */
  7560. updateVector3: (name: string, vector: Vector3) => void;
  7561. /**
  7562. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7563. * This is dynamic to allow compat with webgl 1 and 2.
  7564. * You will need to pass the name of the uniform as well as the value.
  7565. */
  7566. updateVector4: (name: string, vector: Vector4) => void;
  7567. /**
  7568. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7569. * This is dynamic to allow compat with webgl 1 and 2.
  7570. * You will need to pass the name of the uniform as well as the value.
  7571. */
  7572. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7573. /**
  7574. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7575. * This is dynamic to allow compat with webgl 1 and 2.
  7576. * You will need to pass the name of the uniform as well as the value.
  7577. */
  7578. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7579. /**
  7580. * Instantiates a new Uniform buffer objects.
  7581. *
  7582. * Handles blocks of uniform on the GPU.
  7583. *
  7584. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7585. *
  7586. * For more information, please refer to :
  7587. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7588. * @param engine Define the engine the buffer is associated with
  7589. * @param data Define the data contained in the buffer
  7590. * @param dynamic Define if the buffer is updatable
  7591. */
  7592. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7593. /**
  7594. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7595. * or just falling back on setUniformXXX calls.
  7596. */
  7597. get useUbo(): boolean;
  7598. /**
  7599. * Indicates if the WebGL underlying uniform buffer is in sync
  7600. * with the javascript cache data.
  7601. */
  7602. get isSync(): boolean;
  7603. /**
  7604. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7605. * Also, a dynamic UniformBuffer will disable cache verification and always
  7606. * update the underlying WebGL uniform buffer to the GPU.
  7607. * @returns if Dynamic, otherwise false
  7608. */
  7609. isDynamic(): boolean;
  7610. /**
  7611. * The data cache on JS side.
  7612. * @returns the underlying data as a float array
  7613. */
  7614. getData(): Float32Array;
  7615. /**
  7616. * The underlying WebGL Uniform buffer.
  7617. * @returns the webgl buffer
  7618. */
  7619. getBuffer(): Nullable<DataBuffer>;
  7620. /**
  7621. * std140 layout specifies how to align data within an UBO structure.
  7622. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7623. * for specs.
  7624. */
  7625. private _fillAlignment;
  7626. /**
  7627. * Adds an uniform in the buffer.
  7628. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7629. * for the layout to be correct !
  7630. * @param name Name of the uniform, as used in the uniform block in the shader.
  7631. * @param size Data size, or data directly.
  7632. */
  7633. addUniform(name: string, size: number | number[]): void;
  7634. /**
  7635. * Adds a Matrix 4x4 to the uniform buffer.
  7636. * @param name Name of the uniform, as used in the uniform block in the shader.
  7637. * @param mat A 4x4 matrix.
  7638. */
  7639. addMatrix(name: string, mat: Matrix): void;
  7640. /**
  7641. * Adds a vec2 to the uniform buffer.
  7642. * @param name Name of the uniform, as used in the uniform block in the shader.
  7643. * @param x Define the x component value of the vec2
  7644. * @param y Define the y component value of the vec2
  7645. */
  7646. addFloat2(name: string, x: number, y: number): void;
  7647. /**
  7648. * Adds a vec3 to the uniform buffer.
  7649. * @param name Name of the uniform, as used in the uniform block in the shader.
  7650. * @param x Define the x component value of the vec3
  7651. * @param y Define the y component value of the vec3
  7652. * @param z Define the z component value of the vec3
  7653. */
  7654. addFloat3(name: string, x: number, y: number, z: number): void;
  7655. /**
  7656. * Adds a vec3 to the uniform buffer.
  7657. * @param name Name of the uniform, as used in the uniform block in the shader.
  7658. * @param color Define the vec3 from a Color
  7659. */
  7660. addColor3(name: string, color: Color3): void;
  7661. /**
  7662. * Adds a vec4 to the uniform buffer.
  7663. * @param name Name of the uniform, as used in the uniform block in the shader.
  7664. * @param color Define the rgb components from a Color
  7665. * @param alpha Define the a component of the vec4
  7666. */
  7667. addColor4(name: string, color: Color3, alpha: number): void;
  7668. /**
  7669. * Adds a vec3 to the uniform buffer.
  7670. * @param name Name of the uniform, as used in the uniform block in the shader.
  7671. * @param vector Define the vec3 components from a Vector
  7672. */
  7673. addVector3(name: string, vector: Vector3): void;
  7674. /**
  7675. * Adds a Matrix 3x3 to the uniform buffer.
  7676. * @param name Name of the uniform, as used in the uniform block in the shader.
  7677. */
  7678. addMatrix3x3(name: string): void;
  7679. /**
  7680. * Adds a Matrix 2x2 to the uniform buffer.
  7681. * @param name Name of the uniform, as used in the uniform block in the shader.
  7682. */
  7683. addMatrix2x2(name: string): void;
  7684. /**
  7685. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7686. */
  7687. create(): void;
  7688. /** @hidden */
  7689. _rebuild(): void;
  7690. /**
  7691. * Updates the WebGL Uniform Buffer on the GPU.
  7692. * If the `dynamic` flag is set to true, no cache comparison is done.
  7693. * Otherwise, the buffer will be updated only if the cache differs.
  7694. */
  7695. update(): void;
  7696. /**
  7697. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7698. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7699. * @param data Define the flattened data
  7700. * @param size Define the size of the data.
  7701. */
  7702. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7703. private _valueCache;
  7704. private _cacheMatrix;
  7705. private _updateMatrix3x3ForUniform;
  7706. private _updateMatrix3x3ForEffect;
  7707. private _updateMatrix2x2ForEffect;
  7708. private _updateMatrix2x2ForUniform;
  7709. private _updateFloatForEffect;
  7710. private _updateFloatForUniform;
  7711. private _updateFloat2ForEffect;
  7712. private _updateFloat2ForUniform;
  7713. private _updateFloat3ForEffect;
  7714. private _updateFloat3ForUniform;
  7715. private _updateFloat4ForEffect;
  7716. private _updateFloat4ForUniform;
  7717. private _updateMatrixForEffect;
  7718. private _updateMatrixForUniform;
  7719. private _updateVector3ForEffect;
  7720. private _updateVector3ForUniform;
  7721. private _updateVector4ForEffect;
  7722. private _updateVector4ForUniform;
  7723. private _updateColor3ForEffect;
  7724. private _updateColor3ForUniform;
  7725. private _updateColor4ForEffect;
  7726. private _updateColor4ForUniform;
  7727. /**
  7728. * Sets a sampler uniform on the effect.
  7729. * @param name Define the name of the sampler.
  7730. * @param texture Define the texture to set in the sampler
  7731. */
  7732. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7733. /**
  7734. * Directly updates the value of the uniform in the cache AND on the GPU.
  7735. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7736. * @param data Define the flattened data
  7737. */
  7738. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7739. /**
  7740. * Binds this uniform buffer to an effect.
  7741. * @param effect Define the effect to bind the buffer to
  7742. * @param name Name of the uniform block in the shader.
  7743. */
  7744. bindToEffect(effect: Effect, name: string): void;
  7745. /**
  7746. * Disposes the uniform buffer.
  7747. */
  7748. dispose(): void;
  7749. }
  7750. }
  7751. declare module "babylonjs/Misc/iInspectable" {
  7752. /**
  7753. * Enum that determines the text-wrapping mode to use.
  7754. */
  7755. export enum InspectableType {
  7756. /**
  7757. * Checkbox for booleans
  7758. */
  7759. Checkbox = 0,
  7760. /**
  7761. * Sliders for numbers
  7762. */
  7763. Slider = 1,
  7764. /**
  7765. * Vector3
  7766. */
  7767. Vector3 = 2,
  7768. /**
  7769. * Quaternions
  7770. */
  7771. Quaternion = 3,
  7772. /**
  7773. * Color3
  7774. */
  7775. Color3 = 4,
  7776. /**
  7777. * String
  7778. */
  7779. String = 5
  7780. }
  7781. /**
  7782. * Interface used to define custom inspectable properties.
  7783. * This interface is used by the inspector to display custom property grids
  7784. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7785. */
  7786. export interface IInspectable {
  7787. /**
  7788. * Gets the label to display
  7789. */
  7790. label: string;
  7791. /**
  7792. * Gets the name of the property to edit
  7793. */
  7794. propertyName: string;
  7795. /**
  7796. * Gets the type of the editor to use
  7797. */
  7798. type: InspectableType;
  7799. /**
  7800. * Gets the minimum value of the property when using in "slider" mode
  7801. */
  7802. min?: number;
  7803. /**
  7804. * Gets the maximum value of the property when using in "slider" mode
  7805. */
  7806. max?: number;
  7807. /**
  7808. * Gets the setp to use when using in "slider" mode
  7809. */
  7810. step?: number;
  7811. }
  7812. }
  7813. declare module "babylonjs/Misc/timingTools" {
  7814. /**
  7815. * Class used to provide helper for timing
  7816. */
  7817. export class TimingTools {
  7818. /**
  7819. * Polyfill for setImmediate
  7820. * @param action defines the action to execute after the current execution block
  7821. */
  7822. static SetImmediate(action: () => void): void;
  7823. }
  7824. }
  7825. declare module "babylonjs/Misc/instantiationTools" {
  7826. /**
  7827. * Class used to enable instatition of objects by class name
  7828. */
  7829. export class InstantiationTools {
  7830. /**
  7831. * Use this object to register external classes like custom textures or material
  7832. * to allow the laoders to instantiate them
  7833. */
  7834. static RegisteredExternalClasses: {
  7835. [key: string]: Object;
  7836. };
  7837. /**
  7838. * Tries to instantiate a new object from a given class name
  7839. * @param className defines the class name to instantiate
  7840. * @returns the new object or null if the system was not able to do the instantiation
  7841. */
  7842. static Instantiate(className: string): any;
  7843. }
  7844. }
  7845. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7846. /**
  7847. * Define options used to create a depth texture
  7848. */
  7849. export class DepthTextureCreationOptions {
  7850. /** Specifies whether or not a stencil should be allocated in the texture */
  7851. generateStencil?: boolean;
  7852. /** Specifies whether or not bilinear filtering is enable on the texture */
  7853. bilinearFiltering?: boolean;
  7854. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7855. comparisonFunction?: number;
  7856. /** Specifies if the created texture is a cube texture */
  7857. isCube?: boolean;
  7858. }
  7859. }
  7860. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7861. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7862. import { Nullable } from "babylonjs/types";
  7863. import { Scene } from "babylonjs/scene";
  7864. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7865. module "babylonjs/Engines/thinEngine" {
  7866. interface ThinEngine {
  7867. /**
  7868. * Creates a depth stencil cube texture.
  7869. * This is only available in WebGL 2.
  7870. * @param size The size of face edge in the cube texture.
  7871. * @param options The options defining the cube texture.
  7872. * @returns The cube texture
  7873. */
  7874. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7875. /**
  7876. * Creates a cube texture
  7877. * @param rootUrl defines the url where the files to load is located
  7878. * @param scene defines the current scene
  7879. * @param files defines the list of files to load (1 per face)
  7880. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7881. * @param onLoad defines an optional callback raised when the texture is loaded
  7882. * @param onError defines an optional callback raised if there is an issue to load the texture
  7883. * @param format defines the format of the data
  7884. * @param forcedExtension defines the extension to use to pick the right loader
  7885. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7886. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7887. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7888. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7889. * @returns the cube texture as an InternalTexture
  7890. */
  7891. 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;
  7892. /**
  7893. * Creates a cube texture
  7894. * @param rootUrl defines the url where the files to load is located
  7895. * @param scene defines the current scene
  7896. * @param files defines the list of files to load (1 per face)
  7897. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7898. * @param onLoad defines an optional callback raised when the texture is loaded
  7899. * @param onError defines an optional callback raised if there is an issue to load the texture
  7900. * @param format defines the format of the data
  7901. * @param forcedExtension defines the extension to use to pick the right loader
  7902. * @returns the cube texture as an InternalTexture
  7903. */
  7904. 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;
  7905. /**
  7906. * Creates a cube texture
  7907. * @param rootUrl defines the url where the files to load is located
  7908. * @param scene defines the current scene
  7909. * @param files defines the list of files to load (1 per face)
  7910. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7911. * @param onLoad defines an optional callback raised when the texture is loaded
  7912. * @param onError defines an optional callback raised if there is an issue to load the texture
  7913. * @param format defines the format of the data
  7914. * @param forcedExtension defines the extension to use to pick the right loader
  7915. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7916. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7917. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7918. * @returns the cube texture as an InternalTexture
  7919. */
  7920. 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;
  7921. /** @hidden */
  7922. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7923. /** @hidden */
  7924. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7925. /** @hidden */
  7926. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7927. /** @hidden */
  7928. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7929. /**
  7930. * @hidden
  7931. */
  7932. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7933. }
  7934. }
  7935. }
  7936. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7937. import { Nullable } from "babylonjs/types";
  7938. import { Scene } from "babylonjs/scene";
  7939. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7940. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7941. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7942. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7943. import { Observable } from "babylonjs/Misc/observable";
  7944. /**
  7945. * Class for creating a cube texture
  7946. */
  7947. export class CubeTexture extends BaseTexture {
  7948. private _delayedOnLoad;
  7949. /**
  7950. * Observable triggered once the texture has been loaded.
  7951. */
  7952. onLoadObservable: Observable<CubeTexture>;
  7953. /**
  7954. * The url of the texture
  7955. */
  7956. url: string;
  7957. /**
  7958. * Gets or sets the center of the bounding box associated with the cube texture.
  7959. * It must define where the camera used to render the texture was set
  7960. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7961. */
  7962. boundingBoxPosition: Vector3;
  7963. private _boundingBoxSize;
  7964. /**
  7965. * Gets or sets the size of the bounding box associated with the cube texture
  7966. * When defined, the cubemap will switch to local mode
  7967. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7968. * @example https://www.babylonjs-playground.com/#RNASML
  7969. */
  7970. set boundingBoxSize(value: Vector3);
  7971. /**
  7972. * Returns the bounding box size
  7973. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7974. */
  7975. get boundingBoxSize(): Vector3;
  7976. protected _rotationY: number;
  7977. /**
  7978. * Sets texture matrix rotation angle around Y axis in radians.
  7979. */
  7980. set rotationY(value: number);
  7981. /**
  7982. * Gets texture matrix rotation angle around Y axis radians.
  7983. */
  7984. get rotationY(): number;
  7985. /**
  7986. * Are mip maps generated for this texture or not.
  7987. */
  7988. get noMipmap(): boolean;
  7989. private _noMipmap;
  7990. private _files;
  7991. protected _forcedExtension: Nullable<string>;
  7992. private _extensions;
  7993. private _textureMatrix;
  7994. private _format;
  7995. private _createPolynomials;
  7996. /**
  7997. * Creates a cube texture from an array of image urls
  7998. * @param files defines an array of image urls
  7999. * @param scene defines the hosting scene
  8000. * @param noMipmap specifies if mip maps are not used
  8001. * @returns a cube texture
  8002. */
  8003. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8004. /**
  8005. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8006. * @param url defines the url of the prefiltered texture
  8007. * @param scene defines the scene the texture is attached to
  8008. * @param forcedExtension defines the extension of the file if different from the url
  8009. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8010. * @return the prefiltered texture
  8011. */
  8012. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8013. /**
  8014. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8015. * as prefiltered data.
  8016. * @param rootUrl defines the url of the texture or the root name of the six images
  8017. * @param null defines the scene or engine the texture is attached to
  8018. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8019. * @param noMipmap defines if mipmaps should be created or not
  8020. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8021. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8022. * @param onError defines a callback triggered in case of error during load
  8023. * @param format defines the internal format to use for the texture once loaded
  8024. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8025. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8026. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8027. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8028. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8029. * @return the cube texture
  8030. */
  8031. 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);
  8032. /**
  8033. * Get the current class name of the texture useful for serialization or dynamic coding.
  8034. * @returns "CubeTexture"
  8035. */
  8036. getClassName(): string;
  8037. /**
  8038. * Update the url (and optional buffer) of this texture if url was null during construction.
  8039. * @param url the url of the texture
  8040. * @param forcedExtension defines the extension to use
  8041. * @param onLoad callback called when the texture is loaded (defaults to null)
  8042. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8043. */
  8044. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8045. /**
  8046. * Delays loading of the cube texture
  8047. * @param forcedExtension defines the extension to use
  8048. */
  8049. delayLoad(forcedExtension?: string): void;
  8050. /**
  8051. * Returns the reflection texture matrix
  8052. * @returns the reflection texture matrix
  8053. */
  8054. getReflectionTextureMatrix(): Matrix;
  8055. /**
  8056. * Sets the reflection texture matrix
  8057. * @param value Reflection texture matrix
  8058. */
  8059. setReflectionTextureMatrix(value: Matrix): void;
  8060. /**
  8061. * Parses text to create a cube texture
  8062. * @param parsedTexture define the serialized text to read from
  8063. * @param scene defines the hosting scene
  8064. * @param rootUrl defines the root url of the cube texture
  8065. * @returns a cube texture
  8066. */
  8067. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8068. /**
  8069. * Makes a clone, or deep copy, of the cube texture
  8070. * @returns a new cube texture
  8071. */
  8072. clone(): CubeTexture;
  8073. }
  8074. }
  8075. declare module "babylonjs/Materials/materialDefines" {
  8076. /**
  8077. * Manages the defines for the Material
  8078. */
  8079. export class MaterialDefines {
  8080. /** @hidden */
  8081. protected _keys: string[];
  8082. private _isDirty;
  8083. /** @hidden */
  8084. _renderId: number;
  8085. /** @hidden */
  8086. _areLightsDirty: boolean;
  8087. /** @hidden */
  8088. _areLightsDisposed: boolean;
  8089. /** @hidden */
  8090. _areAttributesDirty: boolean;
  8091. /** @hidden */
  8092. _areTexturesDirty: boolean;
  8093. /** @hidden */
  8094. _areFresnelDirty: boolean;
  8095. /** @hidden */
  8096. _areMiscDirty: boolean;
  8097. /** @hidden */
  8098. _areImageProcessingDirty: boolean;
  8099. /** @hidden */
  8100. _normals: boolean;
  8101. /** @hidden */
  8102. _uvs: boolean;
  8103. /** @hidden */
  8104. _needNormals: boolean;
  8105. /** @hidden */
  8106. _needUVs: boolean;
  8107. [id: string]: any;
  8108. /**
  8109. * Specifies if the material needs to be re-calculated
  8110. */
  8111. get isDirty(): boolean;
  8112. /**
  8113. * Marks the material to indicate that it has been re-calculated
  8114. */
  8115. markAsProcessed(): void;
  8116. /**
  8117. * Marks the material to indicate that it needs to be re-calculated
  8118. */
  8119. markAsUnprocessed(): void;
  8120. /**
  8121. * Marks the material to indicate all of its defines need to be re-calculated
  8122. */
  8123. markAllAsDirty(): void;
  8124. /**
  8125. * Marks the material to indicate that image processing needs to be re-calculated
  8126. */
  8127. markAsImageProcessingDirty(): void;
  8128. /**
  8129. * Marks the material to indicate the lights need to be re-calculated
  8130. * @param disposed Defines whether the light is dirty due to dispose or not
  8131. */
  8132. markAsLightDirty(disposed?: boolean): void;
  8133. /**
  8134. * Marks the attribute state as changed
  8135. */
  8136. markAsAttributesDirty(): void;
  8137. /**
  8138. * Marks the texture state as changed
  8139. */
  8140. markAsTexturesDirty(): void;
  8141. /**
  8142. * Marks the fresnel state as changed
  8143. */
  8144. markAsFresnelDirty(): void;
  8145. /**
  8146. * Marks the misc state as changed
  8147. */
  8148. markAsMiscDirty(): void;
  8149. /**
  8150. * Rebuilds the material defines
  8151. */
  8152. rebuild(): void;
  8153. /**
  8154. * Specifies if two material defines are equal
  8155. * @param other - A material define instance to compare to
  8156. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8157. */
  8158. isEqual(other: MaterialDefines): boolean;
  8159. /**
  8160. * Clones this instance's defines to another instance
  8161. * @param other - material defines to clone values to
  8162. */
  8163. cloneTo(other: MaterialDefines): void;
  8164. /**
  8165. * Resets the material define values
  8166. */
  8167. reset(): void;
  8168. /**
  8169. * Converts the material define values to a string
  8170. * @returns - String of material define information
  8171. */
  8172. toString(): string;
  8173. }
  8174. }
  8175. declare module "babylonjs/Materials/colorCurves" {
  8176. import { Effect } from "babylonjs/Materials/effect";
  8177. /**
  8178. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8179. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8180. * 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;
  8181. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8182. */
  8183. export class ColorCurves {
  8184. private _dirty;
  8185. private _tempColor;
  8186. private _globalCurve;
  8187. private _highlightsCurve;
  8188. private _midtonesCurve;
  8189. private _shadowsCurve;
  8190. private _positiveCurve;
  8191. private _negativeCurve;
  8192. private _globalHue;
  8193. private _globalDensity;
  8194. private _globalSaturation;
  8195. private _globalExposure;
  8196. /**
  8197. * Gets the global Hue value.
  8198. * 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).
  8199. */
  8200. get globalHue(): number;
  8201. /**
  8202. * Sets the global Hue value.
  8203. * 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).
  8204. */
  8205. set globalHue(value: number);
  8206. /**
  8207. * Gets the global Density value.
  8208. * 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.
  8209. * Values less than zero provide a filter of opposite hue.
  8210. */
  8211. get globalDensity(): number;
  8212. /**
  8213. * Sets the global Density value.
  8214. * 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.
  8215. * Values less than zero provide a filter of opposite hue.
  8216. */
  8217. set globalDensity(value: number);
  8218. /**
  8219. * Gets the global Saturation value.
  8220. * 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.
  8221. */
  8222. get globalSaturation(): number;
  8223. /**
  8224. * Sets the global Saturation value.
  8225. * 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.
  8226. */
  8227. set globalSaturation(value: number);
  8228. /**
  8229. * Gets the global Exposure value.
  8230. * 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.
  8231. */
  8232. get globalExposure(): number;
  8233. /**
  8234. * Sets the global Exposure value.
  8235. * 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.
  8236. */
  8237. set globalExposure(value: number);
  8238. private _highlightsHue;
  8239. private _highlightsDensity;
  8240. private _highlightsSaturation;
  8241. private _highlightsExposure;
  8242. /**
  8243. * Gets the highlights Hue value.
  8244. * 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).
  8245. */
  8246. get highlightsHue(): number;
  8247. /**
  8248. * Sets the highlights Hue value.
  8249. * 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).
  8250. */
  8251. set highlightsHue(value: number);
  8252. /**
  8253. * Gets the highlights Density value.
  8254. * 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.
  8255. * Values less than zero provide a filter of opposite hue.
  8256. */
  8257. get highlightsDensity(): number;
  8258. /**
  8259. * Sets the highlights Density value.
  8260. * 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.
  8261. * Values less than zero provide a filter of opposite hue.
  8262. */
  8263. set highlightsDensity(value: number);
  8264. /**
  8265. * Gets the highlights Saturation value.
  8266. * 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.
  8267. */
  8268. get highlightsSaturation(): number;
  8269. /**
  8270. * Sets the highlights Saturation value.
  8271. * 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.
  8272. */
  8273. set highlightsSaturation(value: number);
  8274. /**
  8275. * Gets the highlights Exposure value.
  8276. * 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.
  8277. */
  8278. get highlightsExposure(): number;
  8279. /**
  8280. * Sets the highlights Exposure value.
  8281. * 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.
  8282. */
  8283. set highlightsExposure(value: number);
  8284. private _midtonesHue;
  8285. private _midtonesDensity;
  8286. private _midtonesSaturation;
  8287. private _midtonesExposure;
  8288. /**
  8289. * Gets the midtones Hue value.
  8290. * 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).
  8291. */
  8292. get midtonesHue(): number;
  8293. /**
  8294. * Sets the midtones Hue value.
  8295. * 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).
  8296. */
  8297. set midtonesHue(value: number);
  8298. /**
  8299. * Gets the midtones Density value.
  8300. * 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.
  8301. * Values less than zero provide a filter of opposite hue.
  8302. */
  8303. get midtonesDensity(): number;
  8304. /**
  8305. * Sets the midtones Density value.
  8306. * 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.
  8307. * Values less than zero provide a filter of opposite hue.
  8308. */
  8309. set midtonesDensity(value: number);
  8310. /**
  8311. * Gets the midtones Saturation value.
  8312. * 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.
  8313. */
  8314. get midtonesSaturation(): number;
  8315. /**
  8316. * Sets the midtones Saturation value.
  8317. * 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.
  8318. */
  8319. set midtonesSaturation(value: number);
  8320. /**
  8321. * Gets the midtones Exposure value.
  8322. * 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.
  8323. */
  8324. get midtonesExposure(): number;
  8325. /**
  8326. * Sets the midtones Exposure value.
  8327. * 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.
  8328. */
  8329. set midtonesExposure(value: number);
  8330. private _shadowsHue;
  8331. private _shadowsDensity;
  8332. private _shadowsSaturation;
  8333. private _shadowsExposure;
  8334. /**
  8335. * Gets the shadows Hue value.
  8336. * 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).
  8337. */
  8338. get shadowsHue(): number;
  8339. /**
  8340. * Sets the shadows Hue value.
  8341. * 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).
  8342. */
  8343. set shadowsHue(value: number);
  8344. /**
  8345. * Gets the shadows Density value.
  8346. * 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.
  8347. * Values less than zero provide a filter of opposite hue.
  8348. */
  8349. get shadowsDensity(): number;
  8350. /**
  8351. * Sets the shadows Density value.
  8352. * 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.
  8353. * Values less than zero provide a filter of opposite hue.
  8354. */
  8355. set shadowsDensity(value: number);
  8356. /**
  8357. * Gets the shadows Saturation value.
  8358. * 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.
  8359. */
  8360. get shadowsSaturation(): number;
  8361. /**
  8362. * Sets the shadows Saturation value.
  8363. * 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.
  8364. */
  8365. set shadowsSaturation(value: number);
  8366. /**
  8367. * Gets the shadows Exposure value.
  8368. * 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.
  8369. */
  8370. get shadowsExposure(): number;
  8371. /**
  8372. * Sets the shadows Exposure value.
  8373. * 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.
  8374. */
  8375. set shadowsExposure(value: number);
  8376. /**
  8377. * Returns the class name
  8378. * @returns The class name
  8379. */
  8380. getClassName(): string;
  8381. /**
  8382. * Binds the color curves to the shader.
  8383. * @param colorCurves The color curve to bind
  8384. * @param effect The effect to bind to
  8385. * @param positiveUniform The positive uniform shader parameter
  8386. * @param neutralUniform The neutral uniform shader parameter
  8387. * @param negativeUniform The negative uniform shader parameter
  8388. */
  8389. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8390. /**
  8391. * Prepare the list of uniforms associated with the ColorCurves effects.
  8392. * @param uniformsList The list of uniforms used in the effect
  8393. */
  8394. static PrepareUniforms(uniformsList: string[]): void;
  8395. /**
  8396. * Returns color grading data based on a hue, density, saturation and exposure value.
  8397. * @param filterHue The hue of the color filter.
  8398. * @param filterDensity The density of the color filter.
  8399. * @param saturation The saturation.
  8400. * @param exposure The exposure.
  8401. * @param result The result data container.
  8402. */
  8403. private getColorGradingDataToRef;
  8404. /**
  8405. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8406. * @param value The input slider value in range [-100,100].
  8407. * @returns Adjusted value.
  8408. */
  8409. private static applyColorGradingSliderNonlinear;
  8410. /**
  8411. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8412. * @param hue The hue (H) input.
  8413. * @param saturation The saturation (S) input.
  8414. * @param brightness The brightness (B) input.
  8415. * @result An RGBA color represented as Vector4.
  8416. */
  8417. private static fromHSBToRef;
  8418. /**
  8419. * Returns a value clamped between min and max
  8420. * @param value The value to clamp
  8421. * @param min The minimum of value
  8422. * @param max The maximum of value
  8423. * @returns The clamped value.
  8424. */
  8425. private static clamp;
  8426. /**
  8427. * Clones the current color curve instance.
  8428. * @return The cloned curves
  8429. */
  8430. clone(): ColorCurves;
  8431. /**
  8432. * Serializes the current color curve instance to a json representation.
  8433. * @return a JSON representation
  8434. */
  8435. serialize(): any;
  8436. /**
  8437. * Parses the color curve from a json representation.
  8438. * @param source the JSON source to parse
  8439. * @return The parsed curves
  8440. */
  8441. static Parse(source: any): ColorCurves;
  8442. }
  8443. }
  8444. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8445. import { Observable } from "babylonjs/Misc/observable";
  8446. import { Nullable } from "babylonjs/types";
  8447. import { Color4 } from "babylonjs/Maths/math.color";
  8448. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8449. import { Effect } from "babylonjs/Materials/effect";
  8450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8451. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8452. /**
  8453. * Interface to follow in your material defines to integrate easily the
  8454. * Image proccessing functions.
  8455. * @hidden
  8456. */
  8457. export interface IImageProcessingConfigurationDefines {
  8458. IMAGEPROCESSING: boolean;
  8459. VIGNETTE: boolean;
  8460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8461. VIGNETTEBLENDMODEOPAQUE: boolean;
  8462. TONEMAPPING: boolean;
  8463. TONEMAPPING_ACES: boolean;
  8464. CONTRAST: boolean;
  8465. EXPOSURE: boolean;
  8466. COLORCURVES: boolean;
  8467. COLORGRADING: boolean;
  8468. COLORGRADING3D: boolean;
  8469. SAMPLER3DGREENDEPTH: boolean;
  8470. SAMPLER3DBGRMAP: boolean;
  8471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8472. }
  8473. /**
  8474. * @hidden
  8475. */
  8476. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8477. IMAGEPROCESSING: boolean;
  8478. VIGNETTE: boolean;
  8479. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8480. VIGNETTEBLENDMODEOPAQUE: boolean;
  8481. TONEMAPPING: boolean;
  8482. TONEMAPPING_ACES: boolean;
  8483. CONTRAST: boolean;
  8484. COLORCURVES: boolean;
  8485. COLORGRADING: boolean;
  8486. COLORGRADING3D: boolean;
  8487. SAMPLER3DGREENDEPTH: boolean;
  8488. SAMPLER3DBGRMAP: boolean;
  8489. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8490. EXPOSURE: boolean;
  8491. constructor();
  8492. }
  8493. /**
  8494. * This groups together the common properties used for image processing either in direct forward pass
  8495. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8496. * or not.
  8497. */
  8498. export class ImageProcessingConfiguration {
  8499. /**
  8500. * Default tone mapping applied in BabylonJS.
  8501. */
  8502. static readonly TONEMAPPING_STANDARD: number;
  8503. /**
  8504. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8505. * to other engines rendering to increase portability.
  8506. */
  8507. static readonly TONEMAPPING_ACES: number;
  8508. /**
  8509. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8510. */
  8511. colorCurves: Nullable<ColorCurves>;
  8512. private _colorCurvesEnabled;
  8513. /**
  8514. * Gets wether the color curves effect is enabled.
  8515. */
  8516. get colorCurvesEnabled(): boolean;
  8517. /**
  8518. * Sets wether the color curves effect is enabled.
  8519. */
  8520. set colorCurvesEnabled(value: boolean);
  8521. private _colorGradingTexture;
  8522. /**
  8523. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8524. */
  8525. get colorGradingTexture(): Nullable<BaseTexture>;
  8526. /**
  8527. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8528. */
  8529. set colorGradingTexture(value: Nullable<BaseTexture>);
  8530. private _colorGradingEnabled;
  8531. /**
  8532. * Gets wether the color grading effect is enabled.
  8533. */
  8534. get colorGradingEnabled(): boolean;
  8535. /**
  8536. * Sets wether the color grading effect is enabled.
  8537. */
  8538. set colorGradingEnabled(value: boolean);
  8539. private _colorGradingWithGreenDepth;
  8540. /**
  8541. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8542. */
  8543. get colorGradingWithGreenDepth(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8546. */
  8547. set colorGradingWithGreenDepth(value: boolean);
  8548. private _colorGradingBGR;
  8549. /**
  8550. * Gets wether the color grading texture contains BGR values.
  8551. */
  8552. get colorGradingBGR(): boolean;
  8553. /**
  8554. * Sets wether the color grading texture contains BGR values.
  8555. */
  8556. set colorGradingBGR(value: boolean);
  8557. /** @hidden */
  8558. _exposure: number;
  8559. /**
  8560. * Gets the Exposure used in the effect.
  8561. */
  8562. get exposure(): number;
  8563. /**
  8564. * Sets the Exposure used in the effect.
  8565. */
  8566. set exposure(value: number);
  8567. private _toneMappingEnabled;
  8568. /**
  8569. * Gets wether the tone mapping effect is enabled.
  8570. */
  8571. get toneMappingEnabled(): boolean;
  8572. /**
  8573. * Sets wether the tone mapping effect is enabled.
  8574. */
  8575. set toneMappingEnabled(value: boolean);
  8576. private _toneMappingType;
  8577. /**
  8578. * Gets the type of tone mapping effect.
  8579. */
  8580. get toneMappingType(): number;
  8581. /**
  8582. * Sets the type of tone mapping effect used in BabylonJS.
  8583. */
  8584. set toneMappingType(value: number);
  8585. protected _contrast: number;
  8586. /**
  8587. * Gets the contrast used in the effect.
  8588. */
  8589. get contrast(): number;
  8590. /**
  8591. * Sets the contrast used in the effect.
  8592. */
  8593. set contrast(value: number);
  8594. /**
  8595. * Vignette stretch size.
  8596. */
  8597. vignetteStretch: number;
  8598. /**
  8599. * Vignette centre X Offset.
  8600. */
  8601. vignetteCentreX: number;
  8602. /**
  8603. * Vignette centre Y Offset.
  8604. */
  8605. vignetteCentreY: number;
  8606. /**
  8607. * Vignette weight or intensity of the vignette effect.
  8608. */
  8609. vignetteWeight: number;
  8610. /**
  8611. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8612. * if vignetteEnabled is set to true.
  8613. */
  8614. vignetteColor: Color4;
  8615. /**
  8616. * Camera field of view used by the Vignette effect.
  8617. */
  8618. vignetteCameraFov: number;
  8619. private _vignetteBlendMode;
  8620. /**
  8621. * Gets the vignette blend mode allowing different kind of effect.
  8622. */
  8623. get vignetteBlendMode(): number;
  8624. /**
  8625. * Sets the vignette blend mode allowing different kind of effect.
  8626. */
  8627. set vignetteBlendMode(value: number);
  8628. private _vignetteEnabled;
  8629. /**
  8630. * Gets wether the vignette effect is enabled.
  8631. */
  8632. get vignetteEnabled(): boolean;
  8633. /**
  8634. * Sets wether the vignette effect is enabled.
  8635. */
  8636. set vignetteEnabled(value: boolean);
  8637. private _applyByPostProcess;
  8638. /**
  8639. * Gets wether the image processing is applied through a post process or not.
  8640. */
  8641. get applyByPostProcess(): boolean;
  8642. /**
  8643. * Sets wether the image processing is applied through a post process or not.
  8644. */
  8645. set applyByPostProcess(value: boolean);
  8646. private _isEnabled;
  8647. /**
  8648. * Gets wether the image processing is enabled or not.
  8649. */
  8650. get isEnabled(): boolean;
  8651. /**
  8652. * Sets wether the image processing is enabled or not.
  8653. */
  8654. set isEnabled(value: boolean);
  8655. /**
  8656. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8657. */
  8658. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8659. /**
  8660. * Method called each time the image processing information changes requires to recompile the effect.
  8661. */
  8662. protected _updateParameters(): void;
  8663. /**
  8664. * Gets the current class name.
  8665. * @return "ImageProcessingConfiguration"
  8666. */
  8667. getClassName(): string;
  8668. /**
  8669. * Prepare the list of uniforms associated with the Image Processing effects.
  8670. * @param uniforms The list of uniforms used in the effect
  8671. * @param defines the list of defines currently in use
  8672. */
  8673. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8674. /**
  8675. * Prepare the list of samplers associated with the Image Processing effects.
  8676. * @param samplersList The list of uniforms used in the effect
  8677. * @param defines the list of defines currently in use
  8678. */
  8679. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8680. /**
  8681. * Prepare the list of defines associated to the shader.
  8682. * @param defines the list of defines to complete
  8683. * @param forPostProcess Define if we are currently in post process mode or not
  8684. */
  8685. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8686. /**
  8687. * Returns true if all the image processing information are ready.
  8688. * @returns True if ready, otherwise, false
  8689. */
  8690. isReady(): boolean;
  8691. /**
  8692. * Binds the image processing to the shader.
  8693. * @param effect The effect to bind to
  8694. * @param overrideAspectRatio Override the aspect ratio of the effect
  8695. */
  8696. bind(effect: Effect, overrideAspectRatio?: number): void;
  8697. /**
  8698. * Clones the current image processing instance.
  8699. * @return The cloned image processing
  8700. */
  8701. clone(): ImageProcessingConfiguration;
  8702. /**
  8703. * Serializes the current image processing instance to a json representation.
  8704. * @return a JSON representation
  8705. */
  8706. serialize(): any;
  8707. /**
  8708. * Parses the image processing from a json representation.
  8709. * @param source the JSON source to parse
  8710. * @return The parsed image processing
  8711. */
  8712. static Parse(source: any): ImageProcessingConfiguration;
  8713. private static _VIGNETTEMODE_MULTIPLY;
  8714. private static _VIGNETTEMODE_OPAQUE;
  8715. /**
  8716. * Used to apply the vignette as a mix with the pixel color.
  8717. */
  8718. static get VIGNETTEMODE_MULTIPLY(): number;
  8719. /**
  8720. * Used to apply the vignette as a replacement of the pixel color.
  8721. */
  8722. static get VIGNETTEMODE_OPAQUE(): number;
  8723. }
  8724. }
  8725. declare module "babylonjs/Shaders/postprocess.vertex" {
  8726. /** @hidden */
  8727. export var postprocessVertexShader: {
  8728. name: string;
  8729. shader: string;
  8730. };
  8731. }
  8732. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8733. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8734. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8735. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8736. /**
  8737. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8738. */
  8739. export type RenderTargetTextureSize = number | {
  8740. width: number;
  8741. height: number;
  8742. layers?: number;
  8743. };
  8744. module "babylonjs/Engines/thinEngine" {
  8745. interface ThinEngine {
  8746. /**
  8747. * Creates a new render target texture
  8748. * @param size defines the size of the texture
  8749. * @param options defines the options used to create the texture
  8750. * @returns a new render target texture stored in an InternalTexture
  8751. */
  8752. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8753. /**
  8754. * Creates a depth stencil texture.
  8755. * This is only available in WebGL 2 or with the depth texture extension available.
  8756. * @param size The size of face edge in the texture.
  8757. * @param options The options defining the texture.
  8758. * @returns The texture
  8759. */
  8760. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8761. /** @hidden */
  8762. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8763. }
  8764. }
  8765. }
  8766. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8767. /**
  8768. * Defines the kind of connection point for node based material
  8769. */
  8770. export enum NodeMaterialBlockConnectionPointTypes {
  8771. /** Float */
  8772. Float = 1,
  8773. /** Int */
  8774. Int = 2,
  8775. /** Vector2 */
  8776. Vector2 = 4,
  8777. /** Vector3 */
  8778. Vector3 = 8,
  8779. /** Vector4 */
  8780. Vector4 = 16,
  8781. /** Color3 */
  8782. Color3 = 32,
  8783. /** Color4 */
  8784. Color4 = 64,
  8785. /** Matrix */
  8786. Matrix = 128,
  8787. /** Custom object */
  8788. Object = 256,
  8789. /** Detect type based on connection */
  8790. AutoDetect = 1024,
  8791. /** Output type that will be defined by input type */
  8792. BasedOnInput = 2048
  8793. }
  8794. }
  8795. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8796. /**
  8797. * Enum used to define the target of a block
  8798. */
  8799. export enum NodeMaterialBlockTargets {
  8800. /** Vertex shader */
  8801. Vertex = 1,
  8802. /** Fragment shader */
  8803. Fragment = 2,
  8804. /** Neutral */
  8805. Neutral = 4,
  8806. /** Vertex and Fragment */
  8807. VertexAndFragment = 3
  8808. }
  8809. }
  8810. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8811. /**
  8812. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8813. */
  8814. export enum NodeMaterialBlockConnectionPointMode {
  8815. /** Value is an uniform */
  8816. Uniform = 0,
  8817. /** Value is a mesh attribute */
  8818. Attribute = 1,
  8819. /** Value is a varying between vertex and fragment shaders */
  8820. Varying = 2,
  8821. /** Mode is undefined */
  8822. Undefined = 3
  8823. }
  8824. }
  8825. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8826. /**
  8827. * Enum used to define system values e.g. values automatically provided by the system
  8828. */
  8829. export enum NodeMaterialSystemValues {
  8830. /** World */
  8831. World = 1,
  8832. /** View */
  8833. View = 2,
  8834. /** Projection */
  8835. Projection = 3,
  8836. /** ViewProjection */
  8837. ViewProjection = 4,
  8838. /** WorldView */
  8839. WorldView = 5,
  8840. /** WorldViewProjection */
  8841. WorldViewProjection = 6,
  8842. /** CameraPosition */
  8843. CameraPosition = 7,
  8844. /** Fog Color */
  8845. FogColor = 8,
  8846. /** Delta time */
  8847. DeltaTime = 9
  8848. }
  8849. }
  8850. declare module "babylonjs/Maths/math.axis" {
  8851. import { Vector3 } from "babylonjs/Maths/math.vector";
  8852. /** Defines supported spaces */
  8853. export enum Space {
  8854. /** Local (object) space */
  8855. LOCAL = 0,
  8856. /** World space */
  8857. WORLD = 1,
  8858. /** Bone space */
  8859. BONE = 2
  8860. }
  8861. /** Defines the 3 main axes */
  8862. export class Axis {
  8863. /** X axis */
  8864. static X: Vector3;
  8865. /** Y axis */
  8866. static Y: Vector3;
  8867. /** Z axis */
  8868. static Z: Vector3;
  8869. }
  8870. }
  8871. declare module "babylonjs/Maths/math.frustum" {
  8872. import { Matrix } from "babylonjs/Maths/math.vector";
  8873. import { DeepImmutable } from "babylonjs/types";
  8874. import { Plane } from "babylonjs/Maths/math.plane";
  8875. /**
  8876. * Represents a camera frustum
  8877. */
  8878. export class Frustum {
  8879. /**
  8880. * Gets the planes representing the frustum
  8881. * @param transform matrix to be applied to the returned planes
  8882. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8883. */
  8884. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8885. /**
  8886. * Gets the near frustum plane transformed by the transform matrix
  8887. * @param transform transformation matrix to be applied to the resulting frustum plane
  8888. * @param frustumPlane the resuling frustum plane
  8889. */
  8890. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8891. /**
  8892. * Gets the far frustum plane transformed by the transform matrix
  8893. * @param transform transformation matrix to be applied to the resulting frustum plane
  8894. * @param frustumPlane the resuling frustum plane
  8895. */
  8896. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8897. /**
  8898. * Gets the left frustum plane transformed by the transform matrix
  8899. * @param transform transformation matrix to be applied to the resulting frustum plane
  8900. * @param frustumPlane the resuling frustum plane
  8901. */
  8902. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8903. /**
  8904. * Gets the right frustum plane transformed by the transform matrix
  8905. * @param transform transformation matrix to be applied to the resulting frustum plane
  8906. * @param frustumPlane the resuling frustum plane
  8907. */
  8908. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8909. /**
  8910. * Gets the top frustum plane transformed by the transform matrix
  8911. * @param transform transformation matrix to be applied to the resulting frustum plane
  8912. * @param frustumPlane the resuling frustum plane
  8913. */
  8914. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8915. /**
  8916. * Gets the bottom frustum plane transformed by the transform matrix
  8917. * @param transform transformation matrix to be applied to the resulting frustum plane
  8918. * @param frustumPlane the resuling frustum plane
  8919. */
  8920. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8921. /**
  8922. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8923. * @param transform transformation matrix to be applied to the resulting frustum planes
  8924. * @param frustumPlanes the resuling frustum planes
  8925. */
  8926. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8927. }
  8928. }
  8929. declare module "babylonjs/Maths/math.size" {
  8930. /**
  8931. * Interface for the size containing width and height
  8932. */
  8933. export interface ISize {
  8934. /**
  8935. * Width
  8936. */
  8937. width: number;
  8938. /**
  8939. * Heighht
  8940. */
  8941. height: number;
  8942. }
  8943. /**
  8944. * Size containing widht and height
  8945. */
  8946. export class Size implements ISize {
  8947. /**
  8948. * Width
  8949. */
  8950. width: number;
  8951. /**
  8952. * Height
  8953. */
  8954. height: number;
  8955. /**
  8956. * Creates a Size object from the given width and height (floats).
  8957. * @param width width of the new size
  8958. * @param height height of the new size
  8959. */
  8960. constructor(width: number, height: number);
  8961. /**
  8962. * Returns a string with the Size width and height
  8963. * @returns a string with the Size width and height
  8964. */
  8965. toString(): string;
  8966. /**
  8967. * "Size"
  8968. * @returns the string "Size"
  8969. */
  8970. getClassName(): string;
  8971. /**
  8972. * Returns the Size hash code.
  8973. * @returns a hash code for a unique width and height
  8974. */
  8975. getHashCode(): number;
  8976. /**
  8977. * Updates the current size from the given one.
  8978. * @param src the given size
  8979. */
  8980. copyFrom(src: Size): void;
  8981. /**
  8982. * Updates in place the current Size from the given floats.
  8983. * @param width width of the new size
  8984. * @param height height of the new size
  8985. * @returns the updated Size.
  8986. */
  8987. copyFromFloats(width: number, height: number): Size;
  8988. /**
  8989. * Updates in place the current Size from the given floats.
  8990. * @param width width to set
  8991. * @param height height to set
  8992. * @returns the updated Size.
  8993. */
  8994. set(width: number, height: number): Size;
  8995. /**
  8996. * Multiplies the width and height by numbers
  8997. * @param w factor to multiple the width by
  8998. * @param h factor to multiple the height by
  8999. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9000. */
  9001. multiplyByFloats(w: number, h: number): Size;
  9002. /**
  9003. * Clones the size
  9004. * @returns a new Size copied from the given one.
  9005. */
  9006. clone(): Size;
  9007. /**
  9008. * True if the current Size and the given one width and height are strictly equal.
  9009. * @param other the other size to compare against
  9010. * @returns True if the current Size and the given one width and height are strictly equal.
  9011. */
  9012. equals(other: Size): boolean;
  9013. /**
  9014. * The surface of the Size : width * height (float).
  9015. */
  9016. get surface(): number;
  9017. /**
  9018. * Create a new size of zero
  9019. * @returns a new Size set to (0.0, 0.0)
  9020. */
  9021. static Zero(): Size;
  9022. /**
  9023. * Sums the width and height of two sizes
  9024. * @param otherSize size to add to this size
  9025. * @returns a new Size set as the addition result of the current Size and the given one.
  9026. */
  9027. add(otherSize: Size): Size;
  9028. /**
  9029. * Subtracts the width and height of two
  9030. * @param otherSize size to subtract to this size
  9031. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9032. */
  9033. subtract(otherSize: Size): Size;
  9034. /**
  9035. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9036. * @param start starting size to lerp between
  9037. * @param end end size to lerp between
  9038. * @param amount amount to lerp between the start and end values
  9039. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9040. */
  9041. static Lerp(start: Size, end: Size, amount: number): Size;
  9042. }
  9043. }
  9044. declare module "babylonjs/Maths/math.vertexFormat" {
  9045. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9046. /**
  9047. * Contains position and normal vectors for a vertex
  9048. */
  9049. export class PositionNormalVertex {
  9050. /** the position of the vertex (defaut: 0,0,0) */
  9051. position: Vector3;
  9052. /** the normal of the vertex (defaut: 0,1,0) */
  9053. normal: Vector3;
  9054. /**
  9055. * Creates a PositionNormalVertex
  9056. * @param position the position of the vertex (defaut: 0,0,0)
  9057. * @param normal the normal of the vertex (defaut: 0,1,0)
  9058. */
  9059. constructor(
  9060. /** the position of the vertex (defaut: 0,0,0) */
  9061. position?: Vector3,
  9062. /** the normal of the vertex (defaut: 0,1,0) */
  9063. normal?: Vector3);
  9064. /**
  9065. * Clones the PositionNormalVertex
  9066. * @returns the cloned PositionNormalVertex
  9067. */
  9068. clone(): PositionNormalVertex;
  9069. }
  9070. /**
  9071. * Contains position, normal and uv vectors for a vertex
  9072. */
  9073. export class PositionNormalTextureVertex {
  9074. /** the position of the vertex (defaut: 0,0,0) */
  9075. position: Vector3;
  9076. /** the normal of the vertex (defaut: 0,1,0) */
  9077. normal: Vector3;
  9078. /** the uv of the vertex (default: 0,0) */
  9079. uv: Vector2;
  9080. /**
  9081. * Creates a PositionNormalTextureVertex
  9082. * @param position the position of the vertex (defaut: 0,0,0)
  9083. * @param normal the normal of the vertex (defaut: 0,1,0)
  9084. * @param uv the uv of the vertex (default: 0,0)
  9085. */
  9086. constructor(
  9087. /** the position of the vertex (defaut: 0,0,0) */
  9088. position?: Vector3,
  9089. /** the normal of the vertex (defaut: 0,1,0) */
  9090. normal?: Vector3,
  9091. /** the uv of the vertex (default: 0,0) */
  9092. uv?: Vector2);
  9093. /**
  9094. * Clones the PositionNormalTextureVertex
  9095. * @returns the cloned PositionNormalTextureVertex
  9096. */
  9097. clone(): PositionNormalTextureVertex;
  9098. }
  9099. }
  9100. declare module "babylonjs/Maths/math" {
  9101. export * from "babylonjs/Maths/math.axis";
  9102. export * from "babylonjs/Maths/math.color";
  9103. export * from "babylonjs/Maths/math.constants";
  9104. export * from "babylonjs/Maths/math.frustum";
  9105. export * from "babylonjs/Maths/math.path";
  9106. export * from "babylonjs/Maths/math.plane";
  9107. export * from "babylonjs/Maths/math.size";
  9108. export * from "babylonjs/Maths/math.vector";
  9109. export * from "babylonjs/Maths/math.vertexFormat";
  9110. export * from "babylonjs/Maths/math.viewport";
  9111. }
  9112. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9113. /**
  9114. * Enum defining the type of animations supported by InputBlock
  9115. */
  9116. export enum AnimatedInputBlockTypes {
  9117. /** No animation */
  9118. None = 0,
  9119. /** Time based animation. Will only work for floats */
  9120. Time = 1
  9121. }
  9122. }
  9123. declare module "babylonjs/Lights/shadowLight" {
  9124. import { Camera } from "babylonjs/Cameras/camera";
  9125. import { Scene } from "babylonjs/scene";
  9126. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9127. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9128. import { Light } from "babylonjs/Lights/light";
  9129. /**
  9130. * Interface describing all the common properties and methods a shadow light needs to implement.
  9131. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9132. * as well as binding the different shadow properties to the effects.
  9133. */
  9134. export interface IShadowLight extends Light {
  9135. /**
  9136. * The light id in the scene (used in scene.findLighById for instance)
  9137. */
  9138. id: string;
  9139. /**
  9140. * The position the shdow will be casted from.
  9141. */
  9142. position: Vector3;
  9143. /**
  9144. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9145. */
  9146. direction: Vector3;
  9147. /**
  9148. * The transformed position. Position of the light in world space taking parenting in account.
  9149. */
  9150. transformedPosition: Vector3;
  9151. /**
  9152. * The transformed direction. Direction of the light in world space taking parenting in account.
  9153. */
  9154. transformedDirection: Vector3;
  9155. /**
  9156. * The friendly name of the light in the scene.
  9157. */
  9158. name: string;
  9159. /**
  9160. * Defines the shadow projection clipping minimum z value.
  9161. */
  9162. shadowMinZ: number;
  9163. /**
  9164. * Defines the shadow projection clipping maximum z value.
  9165. */
  9166. shadowMaxZ: number;
  9167. /**
  9168. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9169. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9170. */
  9171. computeTransformedInformation(): boolean;
  9172. /**
  9173. * Gets the scene the light belongs to.
  9174. * @returns The scene
  9175. */
  9176. getScene(): Scene;
  9177. /**
  9178. * Callback defining a custom Projection Matrix Builder.
  9179. * This can be used to override the default projection matrix computation.
  9180. */
  9181. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9182. /**
  9183. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9184. * @param matrix The materix to updated with the projection information
  9185. * @param viewMatrix The transform matrix of the light
  9186. * @param renderList The list of mesh to render in the map
  9187. * @returns The current light
  9188. */
  9189. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9190. /**
  9191. * Gets the current depth scale used in ESM.
  9192. * @returns The scale
  9193. */
  9194. getDepthScale(): number;
  9195. /**
  9196. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9197. * @returns true if a cube texture needs to be use
  9198. */
  9199. needCube(): boolean;
  9200. /**
  9201. * Detects if the projection matrix requires to be recomputed this frame.
  9202. * @returns true if it requires to be recomputed otherwise, false.
  9203. */
  9204. needProjectionMatrixCompute(): boolean;
  9205. /**
  9206. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9207. */
  9208. forceProjectionMatrixCompute(): void;
  9209. /**
  9210. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9211. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9212. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9213. */
  9214. getShadowDirection(faceIndex?: number): Vector3;
  9215. /**
  9216. * Gets the minZ used for shadow according to both the scene and the light.
  9217. * @param activeCamera The camera we are returning the min for
  9218. * @returns the depth min z
  9219. */
  9220. getDepthMinZ(activeCamera: Camera): number;
  9221. /**
  9222. * Gets the maxZ used for shadow according to both the scene and the light.
  9223. * @param activeCamera The camera we are returning the max for
  9224. * @returns the depth max z
  9225. */
  9226. getDepthMaxZ(activeCamera: Camera): number;
  9227. }
  9228. /**
  9229. * Base implementation IShadowLight
  9230. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9231. */
  9232. export abstract class ShadowLight extends Light implements IShadowLight {
  9233. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9234. protected _position: Vector3;
  9235. protected _setPosition(value: Vector3): void;
  9236. /**
  9237. * Sets the position the shadow will be casted from. Also use as the light position for both
  9238. * point and spot lights.
  9239. */
  9240. get position(): Vector3;
  9241. /**
  9242. * Sets the position the shadow will be casted from. Also use as the light position for both
  9243. * point and spot lights.
  9244. */
  9245. set position(value: Vector3);
  9246. protected _direction: Vector3;
  9247. protected _setDirection(value: Vector3): void;
  9248. /**
  9249. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9250. * Also use as the light direction on spot and directional lights.
  9251. */
  9252. get direction(): Vector3;
  9253. /**
  9254. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9255. * Also use as the light direction on spot and directional lights.
  9256. */
  9257. set direction(value: Vector3);
  9258. protected _shadowMinZ: number;
  9259. /**
  9260. * Gets the shadow projection clipping minimum z value.
  9261. */
  9262. get shadowMinZ(): number;
  9263. /**
  9264. * Sets the shadow projection clipping minimum z value.
  9265. */
  9266. set shadowMinZ(value: number);
  9267. protected _shadowMaxZ: number;
  9268. /**
  9269. * Sets the shadow projection clipping maximum z value.
  9270. */
  9271. get shadowMaxZ(): number;
  9272. /**
  9273. * Gets the shadow projection clipping maximum z value.
  9274. */
  9275. set shadowMaxZ(value: number);
  9276. /**
  9277. * Callback defining a custom Projection Matrix Builder.
  9278. * This can be used to override the default projection matrix computation.
  9279. */
  9280. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9281. /**
  9282. * The transformed position. Position of the light in world space taking parenting in account.
  9283. */
  9284. transformedPosition: Vector3;
  9285. /**
  9286. * The transformed direction. Direction of the light in world space taking parenting in account.
  9287. */
  9288. transformedDirection: Vector3;
  9289. private _needProjectionMatrixCompute;
  9290. /**
  9291. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9292. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9293. */
  9294. computeTransformedInformation(): boolean;
  9295. /**
  9296. * Return the depth scale used for the shadow map.
  9297. * @returns the depth scale.
  9298. */
  9299. getDepthScale(): number;
  9300. /**
  9301. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9302. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9303. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9304. */
  9305. getShadowDirection(faceIndex?: number): Vector3;
  9306. /**
  9307. * Returns the ShadowLight absolute position in the World.
  9308. * @returns the position vector in world space
  9309. */
  9310. getAbsolutePosition(): Vector3;
  9311. /**
  9312. * Sets the ShadowLight direction toward the passed target.
  9313. * @param target The point to target in local space
  9314. * @returns the updated ShadowLight direction
  9315. */
  9316. setDirectionToTarget(target: Vector3): Vector3;
  9317. /**
  9318. * Returns the light rotation in euler definition.
  9319. * @returns the x y z rotation in local space.
  9320. */
  9321. getRotation(): Vector3;
  9322. /**
  9323. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9324. * @returns true if a cube texture needs to be use
  9325. */
  9326. needCube(): boolean;
  9327. /**
  9328. * Detects if the projection matrix requires to be recomputed this frame.
  9329. * @returns true if it requires to be recomputed otherwise, false.
  9330. */
  9331. needProjectionMatrixCompute(): boolean;
  9332. /**
  9333. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9334. */
  9335. forceProjectionMatrixCompute(): void;
  9336. /** @hidden */
  9337. _initCache(): void;
  9338. /** @hidden */
  9339. _isSynchronized(): boolean;
  9340. /**
  9341. * Computes the world matrix of the node
  9342. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9343. * @returns the world matrix
  9344. */
  9345. computeWorldMatrix(force?: boolean): Matrix;
  9346. /**
  9347. * Gets the minZ used for shadow according to both the scene and the light.
  9348. * @param activeCamera The camera we are returning the min for
  9349. * @returns the depth min z
  9350. */
  9351. getDepthMinZ(activeCamera: Camera): number;
  9352. /**
  9353. * Gets the maxZ used for shadow according to both the scene and the light.
  9354. * @param activeCamera The camera we are returning the max for
  9355. * @returns the depth max z
  9356. */
  9357. getDepthMaxZ(activeCamera: Camera): number;
  9358. /**
  9359. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9360. * @param matrix The materix to updated with the projection information
  9361. * @param viewMatrix The transform matrix of the light
  9362. * @param renderList The list of mesh to render in the map
  9363. * @returns The current light
  9364. */
  9365. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9366. }
  9367. }
  9368. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9369. /** @hidden */
  9370. export var packingFunctions: {
  9371. name: string;
  9372. shader: string;
  9373. };
  9374. }
  9375. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9376. /** @hidden */
  9377. export var bayerDitherFunctions: {
  9378. name: string;
  9379. shader: string;
  9380. };
  9381. }
  9382. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9383. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9384. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9385. /** @hidden */
  9386. export var shadowMapFragmentDeclaration: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9392. /** @hidden */
  9393. export var clipPlaneFragmentDeclaration: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9399. /** @hidden */
  9400. export var clipPlaneFragment: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9406. /** @hidden */
  9407. export var shadowMapFragment: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9413. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9414. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9415. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9416. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9417. /** @hidden */
  9418. export var shadowMapPixelShader: {
  9419. name: string;
  9420. shader: string;
  9421. };
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9424. /** @hidden */
  9425. export var bonesDeclaration: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9431. /** @hidden */
  9432. export var morphTargetsVertexGlobalDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9438. /** @hidden */
  9439. export var morphTargetsVertexDeclaration: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9445. /** @hidden */
  9446. export var instancesDeclaration: {
  9447. name: string;
  9448. shader: string;
  9449. };
  9450. }
  9451. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9452. /** @hidden */
  9453. export var helperFunctions: {
  9454. name: string;
  9455. shader: string;
  9456. };
  9457. }
  9458. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9459. /** @hidden */
  9460. export var shadowMapVertexDeclaration: {
  9461. name: string;
  9462. shader: string;
  9463. };
  9464. }
  9465. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9466. /** @hidden */
  9467. export var clipPlaneVertexDeclaration: {
  9468. name: string;
  9469. shader: string;
  9470. };
  9471. }
  9472. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9473. /** @hidden */
  9474. export var morphTargetsVertex: {
  9475. name: string;
  9476. shader: string;
  9477. };
  9478. }
  9479. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9480. /** @hidden */
  9481. export var instancesVertex: {
  9482. name: string;
  9483. shader: string;
  9484. };
  9485. }
  9486. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9487. /** @hidden */
  9488. export var bonesVertex: {
  9489. name: string;
  9490. shader: string;
  9491. };
  9492. }
  9493. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9494. /** @hidden */
  9495. export var shadowMapVertexNormalBias: {
  9496. name: string;
  9497. shader: string;
  9498. };
  9499. }
  9500. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9501. /** @hidden */
  9502. export var shadowMapVertexMetric: {
  9503. name: string;
  9504. shader: string;
  9505. };
  9506. }
  9507. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9508. /** @hidden */
  9509. export var clipPlaneVertex: {
  9510. name: string;
  9511. shader: string;
  9512. };
  9513. }
  9514. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9515. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9516. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9517. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9518. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9519. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9520. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9521. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9523. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9524. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9525. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9526. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9527. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9528. /** @hidden */
  9529. export var shadowMapVertexShader: {
  9530. name: string;
  9531. shader: string;
  9532. };
  9533. }
  9534. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9535. /** @hidden */
  9536. export var depthBoxBlurPixelShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9542. /** @hidden */
  9543. export var shadowMapFragmentSoftTransparentShadow: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Materials/effectFallbacks" {
  9549. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9550. import { Effect } from "babylonjs/Materials/effect";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. /**
  9553. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9554. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9555. */
  9556. export class EffectFallbacks implements IEffectFallbacks {
  9557. private _defines;
  9558. private _currentRank;
  9559. private _maxRank;
  9560. private _mesh;
  9561. /**
  9562. * Removes the fallback from the bound mesh.
  9563. */
  9564. unBindMesh(): void;
  9565. /**
  9566. * Adds a fallback on the specified property.
  9567. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9568. * @param define The name of the define in the shader
  9569. */
  9570. addFallback(rank: number, define: string): void;
  9571. /**
  9572. * Sets the mesh to use CPU skinning when needing to fallback.
  9573. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9574. * @param mesh The mesh to use the fallbacks.
  9575. */
  9576. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9577. /**
  9578. * Checks to see if more fallbacks are still availible.
  9579. */
  9580. get hasMoreFallbacks(): boolean;
  9581. /**
  9582. * Removes the defines that should be removed when falling back.
  9583. * @param currentDefines defines the current define statements for the shader.
  9584. * @param effect defines the current effect we try to compile
  9585. * @returns The resulting defines with defines of the current rank removed.
  9586. */
  9587. reduce(currentDefines: string, effect: Effect): string;
  9588. }
  9589. }
  9590. declare module "babylonjs/Actions/action" {
  9591. import { Observable } from "babylonjs/Misc/observable";
  9592. import { Condition } from "babylonjs/Actions/condition";
  9593. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9594. import { Nullable } from "babylonjs/types";
  9595. import { Scene } from "babylonjs/scene";
  9596. import { ActionManager } from "babylonjs/Actions/actionManager";
  9597. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9598. import { Node } from "babylonjs/node";
  9599. /**
  9600. * Interface used to define Action
  9601. */
  9602. export interface IAction {
  9603. /**
  9604. * Trigger for the action
  9605. */
  9606. trigger: number;
  9607. /** Options of the trigger */
  9608. triggerOptions: any;
  9609. /**
  9610. * Gets the trigger parameters
  9611. * @returns the trigger parameters
  9612. */
  9613. getTriggerParameter(): any;
  9614. /**
  9615. * Internal only - executes current action event
  9616. * @hidden
  9617. */
  9618. _executeCurrent(evt?: ActionEvent): void;
  9619. /**
  9620. * Serialize placeholder for child classes
  9621. * @param parent of child
  9622. * @returns the serialized object
  9623. */
  9624. serialize(parent: any): any;
  9625. /**
  9626. * Internal only
  9627. * @hidden
  9628. */
  9629. _prepare(): void;
  9630. /**
  9631. * Internal only - manager for action
  9632. * @hidden
  9633. */
  9634. _actionManager: Nullable<AbstractActionManager>;
  9635. /**
  9636. * Adds action to chain of actions, may be a DoNothingAction
  9637. * @param action defines the next action to execute
  9638. * @returns The action passed in
  9639. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9640. */
  9641. then(action: IAction): IAction;
  9642. }
  9643. /**
  9644. * The action to be carried out following a trigger
  9645. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9646. */
  9647. export class Action implements IAction {
  9648. /** the trigger, with or without parameters, for the action */
  9649. triggerOptions: any;
  9650. /**
  9651. * Trigger for the action
  9652. */
  9653. trigger: number;
  9654. /**
  9655. * Internal only - manager for action
  9656. * @hidden
  9657. */
  9658. _actionManager: ActionManager;
  9659. private _nextActiveAction;
  9660. private _child;
  9661. private _condition?;
  9662. private _triggerParameter;
  9663. /**
  9664. * An event triggered prior to action being executed.
  9665. */
  9666. onBeforeExecuteObservable: Observable<Action>;
  9667. /**
  9668. * Creates a new Action
  9669. * @param triggerOptions the trigger, with or without parameters, for the action
  9670. * @param condition an optional determinant of action
  9671. */
  9672. constructor(
  9673. /** the trigger, with or without parameters, for the action */
  9674. triggerOptions: any, condition?: Condition);
  9675. /**
  9676. * Internal only
  9677. * @hidden
  9678. */
  9679. _prepare(): void;
  9680. /**
  9681. * Gets the trigger parameters
  9682. * @returns the trigger parameters
  9683. */
  9684. getTriggerParameter(): any;
  9685. /**
  9686. * Internal only - executes current action event
  9687. * @hidden
  9688. */
  9689. _executeCurrent(evt?: ActionEvent): void;
  9690. /**
  9691. * Execute placeholder for child classes
  9692. * @param evt optional action event
  9693. */
  9694. execute(evt?: ActionEvent): void;
  9695. /**
  9696. * Skips to next active action
  9697. */
  9698. skipToNextActiveAction(): void;
  9699. /**
  9700. * Adds action to chain of actions, may be a DoNothingAction
  9701. * @param action defines the next action to execute
  9702. * @returns The action passed in
  9703. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9704. */
  9705. then(action: Action): Action;
  9706. /**
  9707. * Internal only
  9708. * @hidden
  9709. */
  9710. _getProperty(propertyPath: string): string;
  9711. /**
  9712. * Internal only
  9713. * @hidden
  9714. */
  9715. _getEffectiveTarget(target: any, propertyPath: string): any;
  9716. /**
  9717. * Serialize placeholder for child classes
  9718. * @param parent of child
  9719. * @returns the serialized object
  9720. */
  9721. serialize(parent: any): any;
  9722. /**
  9723. * Internal only called by serialize
  9724. * @hidden
  9725. */
  9726. protected _serialize(serializedAction: any, parent?: any): any;
  9727. /**
  9728. * Internal only
  9729. * @hidden
  9730. */
  9731. static _SerializeValueAsString: (value: any) => string;
  9732. /**
  9733. * Internal only
  9734. * @hidden
  9735. */
  9736. static _GetTargetProperty: (target: Scene | Node) => {
  9737. name: string;
  9738. targetType: string;
  9739. value: string;
  9740. };
  9741. }
  9742. }
  9743. declare module "babylonjs/Actions/condition" {
  9744. import { ActionManager } from "babylonjs/Actions/actionManager";
  9745. /**
  9746. * A Condition applied to an Action
  9747. */
  9748. export class Condition {
  9749. /**
  9750. * Internal only - manager for action
  9751. * @hidden
  9752. */
  9753. _actionManager: ActionManager;
  9754. /**
  9755. * Internal only
  9756. * @hidden
  9757. */
  9758. _evaluationId: number;
  9759. /**
  9760. * Internal only
  9761. * @hidden
  9762. */
  9763. _currentResult: boolean;
  9764. /**
  9765. * Creates a new Condition
  9766. * @param actionManager the manager of the action the condition is applied to
  9767. */
  9768. constructor(actionManager: ActionManager);
  9769. /**
  9770. * Check if the current condition is valid
  9771. * @returns a boolean
  9772. */
  9773. isValid(): boolean;
  9774. /**
  9775. * Internal only
  9776. * @hidden
  9777. */
  9778. _getProperty(propertyPath: string): string;
  9779. /**
  9780. * Internal only
  9781. * @hidden
  9782. */
  9783. _getEffectiveTarget(target: any, propertyPath: string): any;
  9784. /**
  9785. * Serialize placeholder for child classes
  9786. * @returns the serialized object
  9787. */
  9788. serialize(): any;
  9789. /**
  9790. * Internal only
  9791. * @hidden
  9792. */
  9793. protected _serialize(serializedCondition: any): any;
  9794. }
  9795. /**
  9796. * Defines specific conditional operators as extensions of Condition
  9797. */
  9798. export class ValueCondition extends Condition {
  9799. /** path to specify the property of the target the conditional operator uses */
  9800. propertyPath: string;
  9801. /** the value compared by the conditional operator against the current value of the property */
  9802. value: any;
  9803. /** the conditional operator, default ValueCondition.IsEqual */
  9804. operator: number;
  9805. /**
  9806. * Internal only
  9807. * @hidden
  9808. */
  9809. private static _IsEqual;
  9810. /**
  9811. * Internal only
  9812. * @hidden
  9813. */
  9814. private static _IsDifferent;
  9815. /**
  9816. * Internal only
  9817. * @hidden
  9818. */
  9819. private static _IsGreater;
  9820. /**
  9821. * Internal only
  9822. * @hidden
  9823. */
  9824. private static _IsLesser;
  9825. /**
  9826. * returns the number for IsEqual
  9827. */
  9828. static get IsEqual(): number;
  9829. /**
  9830. * Returns the number for IsDifferent
  9831. */
  9832. static get IsDifferent(): number;
  9833. /**
  9834. * Returns the number for IsGreater
  9835. */
  9836. static get IsGreater(): number;
  9837. /**
  9838. * Returns the number for IsLesser
  9839. */
  9840. static get IsLesser(): number;
  9841. /**
  9842. * Internal only The action manager for the condition
  9843. * @hidden
  9844. */
  9845. _actionManager: ActionManager;
  9846. /**
  9847. * Internal only
  9848. * @hidden
  9849. */
  9850. private _target;
  9851. /**
  9852. * Internal only
  9853. * @hidden
  9854. */
  9855. private _effectiveTarget;
  9856. /**
  9857. * Internal only
  9858. * @hidden
  9859. */
  9860. private _property;
  9861. /**
  9862. * Creates a new ValueCondition
  9863. * @param actionManager manager for the action the condition applies to
  9864. * @param target for the action
  9865. * @param propertyPath path to specify the property of the target the conditional operator uses
  9866. * @param value the value compared by the conditional operator against the current value of the property
  9867. * @param operator the conditional operator, default ValueCondition.IsEqual
  9868. */
  9869. constructor(actionManager: ActionManager, target: any,
  9870. /** path to specify the property of the target the conditional operator uses */
  9871. propertyPath: string,
  9872. /** the value compared by the conditional operator against the current value of the property */
  9873. value: any,
  9874. /** the conditional operator, default ValueCondition.IsEqual */
  9875. operator?: number);
  9876. /**
  9877. * Compares the given value with the property value for the specified conditional operator
  9878. * @returns the result of the comparison
  9879. */
  9880. isValid(): boolean;
  9881. /**
  9882. * Serialize the ValueCondition into a JSON compatible object
  9883. * @returns serialization object
  9884. */
  9885. serialize(): any;
  9886. /**
  9887. * Gets the name of the conditional operator for the ValueCondition
  9888. * @param operator the conditional operator
  9889. * @returns the name
  9890. */
  9891. static GetOperatorName(operator: number): string;
  9892. }
  9893. /**
  9894. * Defines a predicate condition as an extension of Condition
  9895. */
  9896. export class PredicateCondition extends Condition {
  9897. /** defines the predicate function used to validate the condition */
  9898. predicate: () => boolean;
  9899. /**
  9900. * Internal only - manager for action
  9901. * @hidden
  9902. */
  9903. _actionManager: ActionManager;
  9904. /**
  9905. * Creates a new PredicateCondition
  9906. * @param actionManager manager for the action the condition applies to
  9907. * @param predicate defines the predicate function used to validate the condition
  9908. */
  9909. constructor(actionManager: ActionManager,
  9910. /** defines the predicate function used to validate the condition */
  9911. predicate: () => boolean);
  9912. /**
  9913. * @returns the validity of the predicate condition
  9914. */
  9915. isValid(): boolean;
  9916. }
  9917. /**
  9918. * Defines a state condition as an extension of Condition
  9919. */
  9920. export class StateCondition extends Condition {
  9921. /** Value to compare with target state */
  9922. value: string;
  9923. /**
  9924. * Internal only - manager for action
  9925. * @hidden
  9926. */
  9927. _actionManager: ActionManager;
  9928. /**
  9929. * Internal only
  9930. * @hidden
  9931. */
  9932. private _target;
  9933. /**
  9934. * Creates a new StateCondition
  9935. * @param actionManager manager for the action the condition applies to
  9936. * @param target of the condition
  9937. * @param value to compare with target state
  9938. */
  9939. constructor(actionManager: ActionManager, target: any,
  9940. /** Value to compare with target state */
  9941. value: string);
  9942. /**
  9943. * Gets a boolean indicating if the current condition is met
  9944. * @returns the validity of the state
  9945. */
  9946. isValid(): boolean;
  9947. /**
  9948. * Serialize the StateCondition into a JSON compatible object
  9949. * @returns serialization object
  9950. */
  9951. serialize(): any;
  9952. }
  9953. }
  9954. declare module "babylonjs/Actions/directActions" {
  9955. import { Action } from "babylonjs/Actions/action";
  9956. import { Condition } from "babylonjs/Actions/condition";
  9957. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9958. /**
  9959. * This defines an action responsible to toggle a boolean once triggered.
  9960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9961. */
  9962. export class SwitchBooleanAction extends Action {
  9963. /**
  9964. * The path to the boolean property in the target object
  9965. */
  9966. propertyPath: string;
  9967. private _target;
  9968. private _effectiveTarget;
  9969. private _property;
  9970. /**
  9971. * Instantiate the action
  9972. * @param triggerOptions defines the trigger options
  9973. * @param target defines the object containing the boolean
  9974. * @param propertyPath defines the path to the boolean property in the target object
  9975. * @param condition defines the trigger related conditions
  9976. */
  9977. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9978. /** @hidden */
  9979. _prepare(): void;
  9980. /**
  9981. * Execute the action toggle the boolean value.
  9982. */
  9983. execute(): void;
  9984. /**
  9985. * Serializes the actions and its related information.
  9986. * @param parent defines the object to serialize in
  9987. * @returns the serialized object
  9988. */
  9989. serialize(parent: any): any;
  9990. }
  9991. /**
  9992. * This defines an action responsible to set a the state field of the target
  9993. * to a desired value once triggered.
  9994. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9995. */
  9996. export class SetStateAction extends Action {
  9997. /**
  9998. * The value to store in the state field.
  9999. */
  10000. value: string;
  10001. private _target;
  10002. /**
  10003. * Instantiate the action
  10004. * @param triggerOptions defines the trigger options
  10005. * @param target defines the object containing the state property
  10006. * @param value defines the value to store in the state field
  10007. * @param condition defines the trigger related conditions
  10008. */
  10009. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10010. /**
  10011. * Execute the action and store the value on the target state property.
  10012. */
  10013. execute(): void;
  10014. /**
  10015. * Serializes the actions and its related information.
  10016. * @param parent defines the object to serialize in
  10017. * @returns the serialized object
  10018. */
  10019. serialize(parent: any): any;
  10020. }
  10021. /**
  10022. * This defines an action responsible to set a property of the target
  10023. * to a desired value once triggered.
  10024. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10025. */
  10026. export class SetValueAction extends Action {
  10027. /**
  10028. * The path of the property to set in the target.
  10029. */
  10030. propertyPath: string;
  10031. /**
  10032. * The value to set in the property
  10033. */
  10034. value: any;
  10035. private _target;
  10036. private _effectiveTarget;
  10037. private _property;
  10038. /**
  10039. * Instantiate the action
  10040. * @param triggerOptions defines the trigger options
  10041. * @param target defines the object containing the property
  10042. * @param propertyPath defines the path of the property to set in the target
  10043. * @param value defines the value to set in the property
  10044. * @param condition defines the trigger related conditions
  10045. */
  10046. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10047. /** @hidden */
  10048. _prepare(): void;
  10049. /**
  10050. * Execute the action and set the targetted property to the desired value.
  10051. */
  10052. execute(): void;
  10053. /**
  10054. * Serializes the actions and its related information.
  10055. * @param parent defines the object to serialize in
  10056. * @returns the serialized object
  10057. */
  10058. serialize(parent: any): any;
  10059. }
  10060. /**
  10061. * This defines an action responsible to increment the target value
  10062. * to a desired value once triggered.
  10063. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10064. */
  10065. export class IncrementValueAction extends Action {
  10066. /**
  10067. * The path of the property to increment in the target.
  10068. */
  10069. propertyPath: string;
  10070. /**
  10071. * The value we should increment the property by.
  10072. */
  10073. value: any;
  10074. private _target;
  10075. private _effectiveTarget;
  10076. private _property;
  10077. /**
  10078. * Instantiate the action
  10079. * @param triggerOptions defines the trigger options
  10080. * @param target defines the object containing the property
  10081. * @param propertyPath defines the path of the property to increment in the target
  10082. * @param value defines the value value we should increment the property by
  10083. * @param condition defines the trigger related conditions
  10084. */
  10085. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10086. /** @hidden */
  10087. _prepare(): void;
  10088. /**
  10089. * Execute the action and increment the target of the value amount.
  10090. */
  10091. execute(): void;
  10092. /**
  10093. * Serializes the actions and its related information.
  10094. * @param parent defines the object to serialize in
  10095. * @returns the serialized object
  10096. */
  10097. serialize(parent: any): any;
  10098. }
  10099. /**
  10100. * This defines an action responsible to start an animation once triggered.
  10101. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10102. */
  10103. export class PlayAnimationAction extends Action {
  10104. /**
  10105. * Where the animation should start (animation frame)
  10106. */
  10107. from: number;
  10108. /**
  10109. * Where the animation should stop (animation frame)
  10110. */
  10111. to: number;
  10112. /**
  10113. * Define if the animation should loop or stop after the first play.
  10114. */
  10115. loop?: boolean;
  10116. private _target;
  10117. /**
  10118. * Instantiate the action
  10119. * @param triggerOptions defines the trigger options
  10120. * @param target defines the target animation or animation name
  10121. * @param from defines from where the animation should start (animation frame)
  10122. * @param end defines where the animation should stop (animation frame)
  10123. * @param loop defines if the animation should loop or stop after the first play
  10124. * @param condition defines the trigger related conditions
  10125. */
  10126. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10127. /** @hidden */
  10128. _prepare(): void;
  10129. /**
  10130. * Execute the action and play the animation.
  10131. */
  10132. execute(): void;
  10133. /**
  10134. * Serializes the actions and its related information.
  10135. * @param parent defines the object to serialize in
  10136. * @returns the serialized object
  10137. */
  10138. serialize(parent: any): any;
  10139. }
  10140. /**
  10141. * This defines an action responsible to stop an animation once triggered.
  10142. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10143. */
  10144. export class StopAnimationAction extends Action {
  10145. private _target;
  10146. /**
  10147. * Instantiate the action
  10148. * @param triggerOptions defines the trigger options
  10149. * @param target defines the target animation or animation name
  10150. * @param condition defines the trigger related conditions
  10151. */
  10152. constructor(triggerOptions: any, target: any, condition?: Condition);
  10153. /** @hidden */
  10154. _prepare(): void;
  10155. /**
  10156. * Execute the action and stop the animation.
  10157. */
  10158. execute(): void;
  10159. /**
  10160. * Serializes the actions and its related information.
  10161. * @param parent defines the object to serialize in
  10162. * @returns the serialized object
  10163. */
  10164. serialize(parent: any): any;
  10165. }
  10166. /**
  10167. * This defines an action responsible that does nothing once triggered.
  10168. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10169. */
  10170. export class DoNothingAction extends Action {
  10171. /**
  10172. * Instantiate the action
  10173. * @param triggerOptions defines the trigger options
  10174. * @param condition defines the trigger related conditions
  10175. */
  10176. constructor(triggerOptions?: any, condition?: Condition);
  10177. /**
  10178. * Execute the action and do nothing.
  10179. */
  10180. execute(): void;
  10181. /**
  10182. * Serializes the actions and its related information.
  10183. * @param parent defines the object to serialize in
  10184. * @returns the serialized object
  10185. */
  10186. serialize(parent: any): any;
  10187. }
  10188. /**
  10189. * This defines an action responsible to trigger several actions once triggered.
  10190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10191. */
  10192. export class CombineAction extends Action {
  10193. /**
  10194. * The list of aggregated animations to run.
  10195. */
  10196. children: Action[];
  10197. /**
  10198. * Instantiate the action
  10199. * @param triggerOptions defines the trigger options
  10200. * @param children defines the list of aggregated animations to run
  10201. * @param condition defines the trigger related conditions
  10202. */
  10203. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10204. /** @hidden */
  10205. _prepare(): void;
  10206. /**
  10207. * Execute the action and executes all the aggregated actions.
  10208. */
  10209. execute(evt: ActionEvent): void;
  10210. /**
  10211. * Serializes the actions and its related information.
  10212. * @param parent defines the object to serialize in
  10213. * @returns the serialized object
  10214. */
  10215. serialize(parent: any): any;
  10216. }
  10217. /**
  10218. * This defines an action responsible to run code (external event) once triggered.
  10219. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10220. */
  10221. export class ExecuteCodeAction extends Action {
  10222. /**
  10223. * The callback function to run.
  10224. */
  10225. func: (evt: ActionEvent) => void;
  10226. /**
  10227. * Instantiate the action
  10228. * @param triggerOptions defines the trigger options
  10229. * @param func defines the callback function to run
  10230. * @param condition defines the trigger related conditions
  10231. */
  10232. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10233. /**
  10234. * Execute the action and run the attached code.
  10235. */
  10236. execute(evt: ActionEvent): void;
  10237. }
  10238. /**
  10239. * This defines an action responsible to set the parent property of the target once triggered.
  10240. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10241. */
  10242. export class SetParentAction extends Action {
  10243. private _parent;
  10244. private _target;
  10245. /**
  10246. * Instantiate the action
  10247. * @param triggerOptions defines the trigger options
  10248. * @param target defines the target containing the parent property
  10249. * @param parent defines from where the animation should start (animation frame)
  10250. * @param condition defines the trigger related conditions
  10251. */
  10252. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10253. /** @hidden */
  10254. _prepare(): void;
  10255. /**
  10256. * Execute the action and set the parent property.
  10257. */
  10258. execute(): void;
  10259. /**
  10260. * Serializes the actions and its related information.
  10261. * @param parent defines the object to serialize in
  10262. * @returns the serialized object
  10263. */
  10264. serialize(parent: any): any;
  10265. }
  10266. }
  10267. declare module "babylonjs/Actions/actionManager" {
  10268. import { Nullable } from "babylonjs/types";
  10269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10270. import { Scene } from "babylonjs/scene";
  10271. import { IAction } from "babylonjs/Actions/action";
  10272. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10273. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10274. /**
  10275. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10276. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10277. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10278. */
  10279. export class ActionManager extends AbstractActionManager {
  10280. /**
  10281. * Nothing
  10282. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10283. */
  10284. static readonly NothingTrigger: number;
  10285. /**
  10286. * On pick
  10287. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10288. */
  10289. static readonly OnPickTrigger: number;
  10290. /**
  10291. * On left pick
  10292. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10293. */
  10294. static readonly OnLeftPickTrigger: number;
  10295. /**
  10296. * On right pick
  10297. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10298. */
  10299. static readonly OnRightPickTrigger: number;
  10300. /**
  10301. * On center pick
  10302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10303. */
  10304. static readonly OnCenterPickTrigger: number;
  10305. /**
  10306. * On pick down
  10307. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10308. */
  10309. static readonly OnPickDownTrigger: number;
  10310. /**
  10311. * On double pick
  10312. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10313. */
  10314. static readonly OnDoublePickTrigger: number;
  10315. /**
  10316. * On pick up
  10317. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10318. */
  10319. static readonly OnPickUpTrigger: number;
  10320. /**
  10321. * On pick out.
  10322. * This trigger will only be raised if you also declared a OnPickDown
  10323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10324. */
  10325. static readonly OnPickOutTrigger: number;
  10326. /**
  10327. * On long press
  10328. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10329. */
  10330. static readonly OnLongPressTrigger: number;
  10331. /**
  10332. * On pointer over
  10333. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10334. */
  10335. static readonly OnPointerOverTrigger: number;
  10336. /**
  10337. * On pointer out
  10338. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10339. */
  10340. static readonly OnPointerOutTrigger: number;
  10341. /**
  10342. * On every frame
  10343. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10344. */
  10345. static readonly OnEveryFrameTrigger: number;
  10346. /**
  10347. * On intersection enter
  10348. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10349. */
  10350. static readonly OnIntersectionEnterTrigger: number;
  10351. /**
  10352. * On intersection exit
  10353. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10354. */
  10355. static readonly OnIntersectionExitTrigger: number;
  10356. /**
  10357. * On key down
  10358. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10359. */
  10360. static readonly OnKeyDownTrigger: number;
  10361. /**
  10362. * On key up
  10363. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10364. */
  10365. static readonly OnKeyUpTrigger: number;
  10366. private _scene;
  10367. /**
  10368. * Creates a new action manager
  10369. * @param scene defines the hosting scene
  10370. */
  10371. constructor(scene: Scene);
  10372. /**
  10373. * Releases all associated resources
  10374. */
  10375. dispose(): void;
  10376. /**
  10377. * Gets hosting scene
  10378. * @returns the hosting scene
  10379. */
  10380. getScene(): Scene;
  10381. /**
  10382. * Does this action manager handles actions of any of the given triggers
  10383. * @param triggers defines the triggers to be tested
  10384. * @return a boolean indicating whether one (or more) of the triggers is handled
  10385. */
  10386. hasSpecificTriggers(triggers: number[]): boolean;
  10387. /**
  10388. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10389. * speed.
  10390. * @param triggerA defines the trigger to be tested
  10391. * @param triggerB defines the trigger to be tested
  10392. * @return a boolean indicating whether one (or more) of the triggers is handled
  10393. */
  10394. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10395. /**
  10396. * Does this action manager handles actions of a given trigger
  10397. * @param trigger defines the trigger to be tested
  10398. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10399. * @return whether the trigger is handled
  10400. */
  10401. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10402. /**
  10403. * Does this action manager has pointer triggers
  10404. */
  10405. get hasPointerTriggers(): boolean;
  10406. /**
  10407. * Does this action manager has pick triggers
  10408. */
  10409. get hasPickTriggers(): boolean;
  10410. /**
  10411. * Registers an action to this action manager
  10412. * @param action defines the action to be registered
  10413. * @return the action amended (prepared) after registration
  10414. */
  10415. registerAction(action: IAction): Nullable<IAction>;
  10416. /**
  10417. * Unregisters an action to this action manager
  10418. * @param action defines the action to be unregistered
  10419. * @return a boolean indicating whether the action has been unregistered
  10420. */
  10421. unregisterAction(action: IAction): Boolean;
  10422. /**
  10423. * Process a specific trigger
  10424. * @param trigger defines the trigger to process
  10425. * @param evt defines the event details to be processed
  10426. */
  10427. processTrigger(trigger: number, evt?: IActionEvent): void;
  10428. /** @hidden */
  10429. _getEffectiveTarget(target: any, propertyPath: string): any;
  10430. /** @hidden */
  10431. _getProperty(propertyPath: string): string;
  10432. /**
  10433. * Serialize this manager to a JSON object
  10434. * @param name defines the property name to store this manager
  10435. * @returns a JSON representation of this manager
  10436. */
  10437. serialize(name: string): any;
  10438. /**
  10439. * Creates a new ActionManager from a JSON data
  10440. * @param parsedActions defines the JSON data to read from
  10441. * @param object defines the hosting mesh
  10442. * @param scene defines the hosting scene
  10443. */
  10444. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10445. /**
  10446. * Get a trigger name by index
  10447. * @param trigger defines the trigger index
  10448. * @returns a trigger name
  10449. */
  10450. static GetTriggerName(trigger: number): string;
  10451. }
  10452. }
  10453. declare module "babylonjs/Sprites/sprite" {
  10454. import { Vector3 } from "babylonjs/Maths/math.vector";
  10455. import { Nullable } from "babylonjs/types";
  10456. import { ActionManager } from "babylonjs/Actions/actionManager";
  10457. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10458. import { Color4 } from "babylonjs/Maths/math.color";
  10459. import { Observable } from "babylonjs/Misc/observable";
  10460. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10461. import { Animation } from "babylonjs/Animations/animation";
  10462. /**
  10463. * Class used to represent a sprite
  10464. * @see https://doc.babylonjs.com/babylon101/sprites
  10465. */
  10466. export class Sprite implements IAnimatable {
  10467. /** defines the name */
  10468. name: string;
  10469. /** Gets or sets the current world position */
  10470. position: Vector3;
  10471. /** Gets or sets the main color */
  10472. color: Color4;
  10473. /** Gets or sets the width */
  10474. width: number;
  10475. /** Gets or sets the height */
  10476. height: number;
  10477. /** Gets or sets rotation angle */
  10478. angle: number;
  10479. /** Gets or sets the cell index in the sprite sheet */
  10480. cellIndex: number;
  10481. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10482. cellRef: string;
  10483. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10484. invertU: boolean;
  10485. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10486. invertV: boolean;
  10487. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10488. disposeWhenFinishedAnimating: boolean;
  10489. /** Gets the list of attached animations */
  10490. animations: Nullable<Array<Animation>>;
  10491. /** Gets or sets a boolean indicating if the sprite can be picked */
  10492. isPickable: boolean;
  10493. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10494. useAlphaForPicking: boolean;
  10495. /** @hidden */
  10496. _xOffset: number;
  10497. /** @hidden */
  10498. _yOffset: number;
  10499. /** @hidden */
  10500. _xSize: number;
  10501. /** @hidden */
  10502. _ySize: number;
  10503. /**
  10504. * Gets or sets the associated action manager
  10505. */
  10506. actionManager: Nullable<ActionManager>;
  10507. /**
  10508. * An event triggered when the control has been disposed
  10509. */
  10510. onDisposeObservable: Observable<Sprite>;
  10511. private _animationStarted;
  10512. private _loopAnimation;
  10513. private _fromIndex;
  10514. private _toIndex;
  10515. private _delay;
  10516. private _direction;
  10517. private _manager;
  10518. private _time;
  10519. private _onAnimationEnd;
  10520. /**
  10521. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10522. */
  10523. isVisible: boolean;
  10524. /**
  10525. * Gets or sets the sprite size
  10526. */
  10527. get size(): number;
  10528. set size(value: number);
  10529. /**
  10530. * Returns a boolean indicating if the animation is started
  10531. */
  10532. get animationStarted(): boolean;
  10533. /**
  10534. * Gets or sets the unique id of the sprite
  10535. */
  10536. uniqueId: number;
  10537. /**
  10538. * Gets the manager of this sprite
  10539. */
  10540. get manager(): ISpriteManager;
  10541. /**
  10542. * Creates a new Sprite
  10543. * @param name defines the name
  10544. * @param manager defines the manager
  10545. */
  10546. constructor(
  10547. /** defines the name */
  10548. name: string, manager: ISpriteManager);
  10549. /**
  10550. * Returns the string "Sprite"
  10551. * @returns "Sprite"
  10552. */
  10553. getClassName(): string;
  10554. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10555. get fromIndex(): number;
  10556. set fromIndex(value: number);
  10557. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10558. get toIndex(): number;
  10559. set toIndex(value: number);
  10560. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10561. get loopAnimation(): boolean;
  10562. set loopAnimation(value: boolean);
  10563. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10564. get delay(): number;
  10565. set delay(value: number);
  10566. /**
  10567. * Starts an animation
  10568. * @param from defines the initial key
  10569. * @param to defines the end key
  10570. * @param loop defines if the animation must loop
  10571. * @param delay defines the start delay (in ms)
  10572. * @param onAnimationEnd defines a callback to call when animation ends
  10573. */
  10574. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10575. /** Stops current animation (if any) */
  10576. stopAnimation(): void;
  10577. /** @hidden */
  10578. _animate(deltaTime: number): void;
  10579. /** Release associated resources */
  10580. dispose(): void;
  10581. /**
  10582. * Serializes the sprite to a JSON object
  10583. * @returns the JSON object
  10584. */
  10585. serialize(): any;
  10586. /**
  10587. * Parses a JSON object to create a new sprite
  10588. * @param parsedSprite The JSON object to parse
  10589. * @param manager defines the hosting manager
  10590. * @returns the new sprite
  10591. */
  10592. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10593. }
  10594. }
  10595. declare module "babylonjs/Collisions/pickingInfo" {
  10596. import { Nullable } from "babylonjs/types";
  10597. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10599. import { Sprite } from "babylonjs/Sprites/sprite";
  10600. import { Ray } from "babylonjs/Culling/ray";
  10601. /**
  10602. * Information about the result of picking within a scene
  10603. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10604. */
  10605. export class PickingInfo {
  10606. /** @hidden */
  10607. _pickingUnavailable: boolean;
  10608. /**
  10609. * If the pick collided with an object
  10610. */
  10611. hit: boolean;
  10612. /**
  10613. * Distance away where the pick collided
  10614. */
  10615. distance: number;
  10616. /**
  10617. * The location of pick collision
  10618. */
  10619. pickedPoint: Nullable<Vector3>;
  10620. /**
  10621. * The mesh corresponding the the pick collision
  10622. */
  10623. pickedMesh: Nullable<AbstractMesh>;
  10624. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10625. bu: number;
  10626. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10627. bv: number;
  10628. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10629. faceId: number;
  10630. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10631. subMeshFaceId: number;
  10632. /** Id of the the submesh that was picked */
  10633. subMeshId: number;
  10634. /** If a sprite was picked, this will be the sprite the pick collided with */
  10635. pickedSprite: Nullable<Sprite>;
  10636. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10637. thinInstanceIndex: number;
  10638. /**
  10639. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10640. */
  10641. originMesh: Nullable<AbstractMesh>;
  10642. /**
  10643. * The ray that was used to perform the picking.
  10644. */
  10645. ray: Nullable<Ray>;
  10646. /**
  10647. * Gets the normal correspodning to the face the pick collided with
  10648. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10649. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10650. * @returns The normal correspodning to the face the pick collided with
  10651. */
  10652. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10653. /**
  10654. * Gets the texture coordinates of where the pick occured
  10655. * @returns the vector containing the coordnates of the texture
  10656. */
  10657. getTextureCoordinates(): Nullable<Vector2>;
  10658. }
  10659. }
  10660. declare module "babylonjs/Culling/ray" {
  10661. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10662. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10664. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10665. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10666. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10667. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10668. import { Plane } from "babylonjs/Maths/math.plane";
  10669. /**
  10670. * Class representing a ray with position and direction
  10671. */
  10672. export class Ray {
  10673. /** origin point */
  10674. origin: Vector3;
  10675. /** direction */
  10676. direction: Vector3;
  10677. /** length of the ray */
  10678. length: number;
  10679. private static readonly _TmpVector3;
  10680. private _tmpRay;
  10681. /**
  10682. * Creates a new ray
  10683. * @param origin origin point
  10684. * @param direction direction
  10685. * @param length length of the ray
  10686. */
  10687. constructor(
  10688. /** origin point */
  10689. origin: Vector3,
  10690. /** direction */
  10691. direction: Vector3,
  10692. /** length of the ray */
  10693. length?: number);
  10694. /**
  10695. * Checks if the ray intersects a box
  10696. * This does not account for the ray lenght by design to improve perfs.
  10697. * @param minimum bound of the box
  10698. * @param maximum bound of the box
  10699. * @param intersectionTreshold extra extend to be added to the box in all direction
  10700. * @returns if the box was hit
  10701. */
  10702. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10703. /**
  10704. * Checks if the ray intersects a box
  10705. * This does not account for the ray lenght by design to improve perfs.
  10706. * @param box the bounding box to check
  10707. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10708. * @returns if the box was hit
  10709. */
  10710. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10711. /**
  10712. * If the ray hits a sphere
  10713. * @param sphere the bounding sphere to check
  10714. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10715. * @returns true if it hits the sphere
  10716. */
  10717. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10718. /**
  10719. * If the ray hits a triange
  10720. * @param vertex0 triangle vertex
  10721. * @param vertex1 triangle vertex
  10722. * @param vertex2 triangle vertex
  10723. * @returns intersection information if hit
  10724. */
  10725. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10726. /**
  10727. * Checks if ray intersects a plane
  10728. * @param plane the plane to check
  10729. * @returns the distance away it was hit
  10730. */
  10731. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10732. /**
  10733. * Calculate the intercept of a ray on a given axis
  10734. * @param axis to check 'x' | 'y' | 'z'
  10735. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10736. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10737. */
  10738. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10739. /**
  10740. * Checks if ray intersects a mesh
  10741. * @param mesh the mesh to check
  10742. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10743. * @returns picking info of the intersecton
  10744. */
  10745. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10746. /**
  10747. * Checks if ray intersects a mesh
  10748. * @param meshes the meshes to check
  10749. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10750. * @param results array to store result in
  10751. * @returns Array of picking infos
  10752. */
  10753. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10754. private _comparePickingInfo;
  10755. private static smallnum;
  10756. private static rayl;
  10757. /**
  10758. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10759. * @param sega the first point of the segment to test the intersection against
  10760. * @param segb the second point of the segment to test the intersection against
  10761. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10762. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10763. */
  10764. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10765. /**
  10766. * Update the ray from viewport position
  10767. * @param x position
  10768. * @param y y position
  10769. * @param viewportWidth viewport width
  10770. * @param viewportHeight viewport height
  10771. * @param world world matrix
  10772. * @param view view matrix
  10773. * @param projection projection matrix
  10774. * @returns this ray updated
  10775. */
  10776. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10777. /**
  10778. * Creates a ray with origin and direction of 0,0,0
  10779. * @returns the new ray
  10780. */
  10781. static Zero(): Ray;
  10782. /**
  10783. * Creates a new ray from screen space and viewport
  10784. * @param x position
  10785. * @param y y position
  10786. * @param viewportWidth viewport width
  10787. * @param viewportHeight viewport height
  10788. * @param world world matrix
  10789. * @param view view matrix
  10790. * @param projection projection matrix
  10791. * @returns new ray
  10792. */
  10793. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10794. /**
  10795. * 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
  10796. * transformed to the given world matrix.
  10797. * @param origin The origin point
  10798. * @param end The end point
  10799. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10800. * @returns the new ray
  10801. */
  10802. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * Transforms a ray by a matrix
  10805. * @param ray ray to transform
  10806. * @param matrix matrix to apply
  10807. * @returns the resulting new ray
  10808. */
  10809. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10810. /**
  10811. * Transforms a ray by a matrix
  10812. * @param ray ray to transform
  10813. * @param matrix matrix to apply
  10814. * @param result ray to store result in
  10815. */
  10816. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10817. /**
  10818. * Unproject a ray from screen space to object space
  10819. * @param sourceX defines the screen space x coordinate to use
  10820. * @param sourceY defines the screen space y coordinate to use
  10821. * @param viewportWidth defines the current width of the viewport
  10822. * @param viewportHeight defines the current height of the viewport
  10823. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10824. * @param view defines the view matrix to use
  10825. * @param projection defines the projection matrix to use
  10826. */
  10827. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10828. }
  10829. /**
  10830. * Type used to define predicate used to select faces when a mesh intersection is detected
  10831. */
  10832. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10833. module "babylonjs/scene" {
  10834. interface Scene {
  10835. /** @hidden */
  10836. _tempPickingRay: Nullable<Ray>;
  10837. /** @hidden */
  10838. _cachedRayForTransform: Ray;
  10839. /** @hidden */
  10840. _pickWithRayInverseMatrix: Matrix;
  10841. /** @hidden */
  10842. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10843. /** @hidden */
  10844. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10845. /** @hidden */
  10846. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10847. }
  10848. }
  10849. }
  10850. declare module "babylonjs/sceneComponent" {
  10851. import { Scene } from "babylonjs/scene";
  10852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10853. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10854. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10855. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10856. import { Nullable } from "babylonjs/types";
  10857. import { Camera } from "babylonjs/Cameras/camera";
  10858. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10859. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10860. import { AbstractScene } from "babylonjs/abstractScene";
  10861. import { Mesh } from "babylonjs/Meshes/mesh";
  10862. /**
  10863. * Groups all the scene component constants in one place to ease maintenance.
  10864. * @hidden
  10865. */
  10866. export class SceneComponentConstants {
  10867. static readonly NAME_EFFECTLAYER: string;
  10868. static readonly NAME_LAYER: string;
  10869. static readonly NAME_LENSFLARESYSTEM: string;
  10870. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10871. static readonly NAME_PARTICLESYSTEM: string;
  10872. static readonly NAME_GAMEPAD: string;
  10873. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10874. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10875. static readonly NAME_PREPASSRENDERER: string;
  10876. static readonly NAME_DEPTHRENDERER: string;
  10877. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10878. static readonly NAME_SPRITE: string;
  10879. static readonly NAME_SUBSURFACE: string;
  10880. static readonly NAME_OUTLINERENDERER: string;
  10881. static readonly NAME_PROCEDURALTEXTURE: string;
  10882. static readonly NAME_SHADOWGENERATOR: string;
  10883. static readonly NAME_OCTREE: string;
  10884. static readonly NAME_PHYSICSENGINE: string;
  10885. static readonly NAME_AUDIO: string;
  10886. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10887. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10888. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10889. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10890. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10891. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10892. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10893. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10894. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10895. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10896. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10897. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10898. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10900. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10901. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10902. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10903. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10904. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10905. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10906. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10907. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10908. static readonly STEP_AFTERRENDER_AUDIO: number;
  10909. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10910. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10911. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10912. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10913. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10914. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10915. static readonly STEP_POINTERMOVE_SPRITE: number;
  10916. static readonly STEP_POINTERDOWN_SPRITE: number;
  10917. static readonly STEP_POINTERUP_SPRITE: number;
  10918. }
  10919. /**
  10920. * This represents a scene component.
  10921. *
  10922. * This is used to decouple the dependency the scene is having on the different workloads like
  10923. * layers, post processes...
  10924. */
  10925. export interface ISceneComponent {
  10926. /**
  10927. * The name of the component. Each component must have a unique name.
  10928. */
  10929. name: string;
  10930. /**
  10931. * The scene the component belongs to.
  10932. */
  10933. scene: Scene;
  10934. /**
  10935. * Register the component to one instance of a scene.
  10936. */
  10937. register(): void;
  10938. /**
  10939. * Rebuilds the elements related to this component in case of
  10940. * context lost for instance.
  10941. */
  10942. rebuild(): void;
  10943. /**
  10944. * Disposes the component and the associated ressources.
  10945. */
  10946. dispose(): void;
  10947. }
  10948. /**
  10949. * This represents a SERIALIZABLE scene component.
  10950. *
  10951. * This extends Scene Component to add Serialization methods on top.
  10952. */
  10953. export interface ISceneSerializableComponent extends ISceneComponent {
  10954. /**
  10955. * Adds all the elements from the container to the scene
  10956. * @param container the container holding the elements
  10957. */
  10958. addFromContainer(container: AbstractScene): void;
  10959. /**
  10960. * Removes all the elements in the container from the scene
  10961. * @param container contains the elements to remove
  10962. * @param dispose if the removed element should be disposed (default: false)
  10963. */
  10964. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10965. /**
  10966. * Serializes the component data to the specified json object
  10967. * @param serializationObject The object to serialize to
  10968. */
  10969. serialize(serializationObject: any): void;
  10970. }
  10971. /**
  10972. * Strong typing of a Mesh related stage step action
  10973. */
  10974. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10975. /**
  10976. * Strong typing of a Evaluate Sub Mesh related stage step action
  10977. */
  10978. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10979. /**
  10980. * Strong typing of a Active Mesh related stage step action
  10981. */
  10982. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10983. /**
  10984. * Strong typing of a Camera related stage step action
  10985. */
  10986. export type CameraStageAction = (camera: Camera) => void;
  10987. /**
  10988. * Strong typing of a Camera Frame buffer related stage step action
  10989. */
  10990. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10991. /**
  10992. * Strong typing of a Render Target related stage step action
  10993. */
  10994. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10995. /**
  10996. * Strong typing of a RenderingGroup related stage step action
  10997. */
  10998. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10999. /**
  11000. * Strong typing of a Mesh Render related stage step action
  11001. */
  11002. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11003. /**
  11004. * Strong typing of a simple stage step action
  11005. */
  11006. export type SimpleStageAction = () => void;
  11007. /**
  11008. * Strong typing of a render target action.
  11009. */
  11010. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11011. /**
  11012. * Strong typing of a pointer move action.
  11013. */
  11014. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11015. /**
  11016. * Strong typing of a pointer up/down action.
  11017. */
  11018. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11019. /**
  11020. * Representation of a stage in the scene (Basically a list of ordered steps)
  11021. * @hidden
  11022. */
  11023. export class Stage<T extends Function> extends Array<{
  11024. index: number;
  11025. component: ISceneComponent;
  11026. action: T;
  11027. }> {
  11028. /**
  11029. * Hide ctor from the rest of the world.
  11030. * @param items The items to add.
  11031. */
  11032. private constructor();
  11033. /**
  11034. * Creates a new Stage.
  11035. * @returns A new instance of a Stage
  11036. */
  11037. static Create<T extends Function>(): Stage<T>;
  11038. /**
  11039. * Registers a step in an ordered way in the targeted stage.
  11040. * @param index Defines the position to register the step in
  11041. * @param component Defines the component attached to the step
  11042. * @param action Defines the action to launch during the step
  11043. */
  11044. registerStep(index: number, component: ISceneComponent, action: T): void;
  11045. /**
  11046. * Clears all the steps from the stage.
  11047. */
  11048. clear(): void;
  11049. }
  11050. }
  11051. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11052. import { Nullable } from "babylonjs/types";
  11053. import { Observable } from "babylonjs/Misc/observable";
  11054. import { Scene } from "babylonjs/scene";
  11055. import { Sprite } from "babylonjs/Sprites/sprite";
  11056. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11057. import { Ray } from "babylonjs/Culling/ray";
  11058. import { Camera } from "babylonjs/Cameras/camera";
  11059. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11060. import { ISceneComponent } from "babylonjs/sceneComponent";
  11061. module "babylonjs/scene" {
  11062. interface Scene {
  11063. /** @hidden */
  11064. _pointerOverSprite: Nullable<Sprite>;
  11065. /** @hidden */
  11066. _pickedDownSprite: Nullable<Sprite>;
  11067. /** @hidden */
  11068. _tempSpritePickingRay: Nullable<Ray>;
  11069. /**
  11070. * All of the sprite managers added to this scene
  11071. * @see https://doc.babylonjs.com/babylon101/sprites
  11072. */
  11073. spriteManagers: Array<ISpriteManager>;
  11074. /**
  11075. * An event triggered when sprites rendering is about to start
  11076. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11077. */
  11078. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11079. /**
  11080. * An event triggered when sprites rendering is done
  11081. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11082. */
  11083. onAfterSpritesRenderingObservable: Observable<Scene>;
  11084. /** @hidden */
  11085. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11086. /** Launch a ray to try to pick a sprite in the scene
  11087. * @param x position on screen
  11088. * @param y position on screen
  11089. * @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
  11090. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11091. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11092. * @returns a PickingInfo
  11093. */
  11094. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Use the given ray to pick a sprite in the scene
  11096. * @param ray The ray (in world space) to use to pick meshes
  11097. * @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
  11098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11099. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11100. * @returns a PickingInfo
  11101. */
  11102. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11103. /** @hidden */
  11104. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11105. /** Launch a ray to try to pick sprites in the scene
  11106. * @param x position on screen
  11107. * @param y position on screen
  11108. * @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
  11109. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11110. * @returns a PickingInfo array
  11111. */
  11112. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11113. /** Use the given ray to pick sprites in the scene
  11114. * @param ray The ray (in world space) to use to pick meshes
  11115. * @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
  11116. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11117. * @returns a PickingInfo array
  11118. */
  11119. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11120. /**
  11121. * Force the sprite under the pointer
  11122. * @param sprite defines the sprite to use
  11123. */
  11124. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11125. /**
  11126. * Gets the sprite under the pointer
  11127. * @returns a Sprite or null if no sprite is under the pointer
  11128. */
  11129. getPointerOverSprite(): Nullable<Sprite>;
  11130. }
  11131. }
  11132. /**
  11133. * Defines the sprite scene component responsible to manage sprites
  11134. * in a given scene.
  11135. */
  11136. export class SpriteSceneComponent implements ISceneComponent {
  11137. /**
  11138. * The component name helpfull to identify the component in the list of scene components.
  11139. */
  11140. readonly name: string;
  11141. /**
  11142. * The scene the component belongs to.
  11143. */
  11144. scene: Scene;
  11145. /** @hidden */
  11146. private _spritePredicate;
  11147. /**
  11148. * Creates a new instance of the component for the given scene
  11149. * @param scene Defines the scene to register the component in
  11150. */
  11151. constructor(scene: Scene);
  11152. /**
  11153. * Registers the component in a given scene
  11154. */
  11155. register(): void;
  11156. /**
  11157. * Rebuilds the elements related to this component in case of
  11158. * context lost for instance.
  11159. */
  11160. rebuild(): void;
  11161. /**
  11162. * Disposes the component and the associated ressources.
  11163. */
  11164. dispose(): void;
  11165. private _pickSpriteButKeepRay;
  11166. private _pointerMove;
  11167. private _pointerDown;
  11168. private _pointerUp;
  11169. }
  11170. }
  11171. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11172. /** @hidden */
  11173. export var fogFragmentDeclaration: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11179. /** @hidden */
  11180. export var fogFragment: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module "babylonjs/Shaders/sprites.fragment" {
  11186. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11187. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11188. /** @hidden */
  11189. export var spritesPixelShader: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11195. /** @hidden */
  11196. export var fogVertexDeclaration: {
  11197. name: string;
  11198. shader: string;
  11199. };
  11200. }
  11201. declare module "babylonjs/Shaders/sprites.vertex" {
  11202. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11203. /** @hidden */
  11204. export var spritesVertexShader: {
  11205. name: string;
  11206. shader: string;
  11207. };
  11208. }
  11209. declare module "babylonjs/Sprites/spriteManager" {
  11210. import { IDisposable, Scene } from "babylonjs/scene";
  11211. import { Nullable } from "babylonjs/types";
  11212. import { Observable } from "babylonjs/Misc/observable";
  11213. import { Sprite } from "babylonjs/Sprites/sprite";
  11214. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11215. import { Camera } from "babylonjs/Cameras/camera";
  11216. import { Texture } from "babylonjs/Materials/Textures/texture";
  11217. import "babylonjs/Shaders/sprites.fragment";
  11218. import "babylonjs/Shaders/sprites.vertex";
  11219. import { Ray } from "babylonjs/Culling/ray";
  11220. /**
  11221. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11222. */
  11223. export interface ISpriteManager extends IDisposable {
  11224. /**
  11225. * Gets manager's name
  11226. */
  11227. name: string;
  11228. /**
  11229. * Restricts the camera to viewing objects with the same layerMask.
  11230. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11231. */
  11232. layerMask: number;
  11233. /**
  11234. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11235. */
  11236. isPickable: boolean;
  11237. /**
  11238. * Gets the hosting scene
  11239. */
  11240. scene: Scene;
  11241. /**
  11242. * Specifies the rendering group id for this mesh (0 by default)
  11243. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11244. */
  11245. renderingGroupId: number;
  11246. /**
  11247. * Defines the list of sprites managed by the manager.
  11248. */
  11249. sprites: Array<Sprite>;
  11250. /**
  11251. * Gets or sets the spritesheet texture
  11252. */
  11253. texture: Texture;
  11254. /** Defines the default width of a cell in the spritesheet */
  11255. cellWidth: number;
  11256. /** Defines the default height of a cell in the spritesheet */
  11257. cellHeight: number;
  11258. /**
  11259. * Tests the intersection of a sprite with a specific ray.
  11260. * @param ray The ray we are sending to test the collision
  11261. * @param camera The camera space we are sending rays in
  11262. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11263. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11264. * @returns picking info or null.
  11265. */
  11266. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11267. /**
  11268. * Intersects the sprites with a ray
  11269. * @param ray defines the ray to intersect with
  11270. * @param camera defines the current active camera
  11271. * @param predicate defines a predicate used to select candidate sprites
  11272. * @returns null if no hit or a PickingInfo array
  11273. */
  11274. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11275. /**
  11276. * Renders the list of sprites on screen.
  11277. */
  11278. render(): void;
  11279. }
  11280. /**
  11281. * Class used to manage multiple sprites on the same spritesheet
  11282. * @see https://doc.babylonjs.com/babylon101/sprites
  11283. */
  11284. export class SpriteManager implements ISpriteManager {
  11285. /** defines the manager's name */
  11286. name: string;
  11287. /** Define the Url to load snippets */
  11288. static SnippetUrl: string;
  11289. /** Snippet ID if the manager was created from the snippet server */
  11290. snippetId: string;
  11291. /** Gets the list of sprites */
  11292. sprites: Sprite[];
  11293. /** Gets or sets the rendering group id (0 by default) */
  11294. renderingGroupId: number;
  11295. /** Gets or sets camera layer mask */
  11296. layerMask: number;
  11297. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11298. fogEnabled: boolean;
  11299. /** Gets or sets a boolean indicating if the sprites are pickable */
  11300. isPickable: boolean;
  11301. /** Defines the default width of a cell in the spritesheet */
  11302. cellWidth: number;
  11303. /** Defines the default height of a cell in the spritesheet */
  11304. cellHeight: number;
  11305. /** Associative array from JSON sprite data file */
  11306. private _cellData;
  11307. /** Array of sprite names from JSON sprite data file */
  11308. private _spriteMap;
  11309. /** True when packed cell data from JSON file is ready*/
  11310. private _packedAndReady;
  11311. private _textureContent;
  11312. private _useInstancing;
  11313. /**
  11314. * An event triggered when the manager is disposed.
  11315. */
  11316. onDisposeObservable: Observable<SpriteManager>;
  11317. private _onDisposeObserver;
  11318. /**
  11319. * Callback called when the manager is disposed
  11320. */
  11321. set onDispose(callback: () => void);
  11322. private _capacity;
  11323. private _fromPacked;
  11324. private _spriteTexture;
  11325. private _epsilon;
  11326. private _scene;
  11327. private _vertexData;
  11328. private _buffer;
  11329. private _vertexBuffers;
  11330. private _spriteBuffer;
  11331. private _indexBuffer;
  11332. private _effectBase;
  11333. private _effectFog;
  11334. private _vertexBufferSize;
  11335. /**
  11336. * Gets or sets the unique id of the sprite
  11337. */
  11338. uniqueId: number;
  11339. /**
  11340. * Gets the array of sprites
  11341. */
  11342. get children(): Sprite[];
  11343. /**
  11344. * Gets the hosting scene
  11345. */
  11346. get scene(): Scene;
  11347. /**
  11348. * Gets the capacity of the manager
  11349. */
  11350. get capacity(): number;
  11351. /**
  11352. * Gets or sets the spritesheet texture
  11353. */
  11354. get texture(): Texture;
  11355. set texture(value: Texture);
  11356. private _blendMode;
  11357. /**
  11358. * Blend mode use to render the particle, it can be any of
  11359. * the static Constants.ALPHA_x properties provided in this class.
  11360. * Default value is Constants.ALPHA_COMBINE
  11361. */
  11362. get blendMode(): number;
  11363. set blendMode(blendMode: number);
  11364. /** Disables writing to the depth buffer when rendering the sprites.
  11365. * It can be handy to disable depth writing when using textures without alpha channel
  11366. * and setting some specific blend modes.
  11367. */
  11368. disableDepthWrite: boolean;
  11369. /**
  11370. * Creates a new sprite manager
  11371. * @param name defines the manager's name
  11372. * @param imgUrl defines the sprite sheet url
  11373. * @param capacity defines the maximum allowed number of sprites
  11374. * @param cellSize defines the size of a sprite cell
  11375. * @param scene defines the hosting scene
  11376. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11377. * @param samplingMode defines the smapling mode to use with spritesheet
  11378. * @param fromPacked set to false; do not alter
  11379. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11380. */
  11381. constructor(
  11382. /** defines the manager's name */
  11383. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11384. /**
  11385. * Returns the string "SpriteManager"
  11386. * @returns "SpriteManager"
  11387. */
  11388. getClassName(): string;
  11389. private _makePacked;
  11390. private _appendSpriteVertex;
  11391. private _checkTextureAlpha;
  11392. /**
  11393. * Intersects the sprites with a ray
  11394. * @param ray defines the ray to intersect with
  11395. * @param camera defines the current active camera
  11396. * @param predicate defines a predicate used to select candidate sprites
  11397. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11398. * @returns null if no hit or a PickingInfo
  11399. */
  11400. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11401. /**
  11402. * Intersects the sprites with a ray
  11403. * @param ray defines the ray to intersect with
  11404. * @param camera defines the current active camera
  11405. * @param predicate defines a predicate used to select candidate sprites
  11406. * @returns null if no hit or a PickingInfo array
  11407. */
  11408. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11409. /**
  11410. * Render all child sprites
  11411. */
  11412. render(): void;
  11413. /**
  11414. * Release associated resources
  11415. */
  11416. dispose(): void;
  11417. /**
  11418. * Serializes the sprite manager to a JSON object
  11419. * @param serializeTexture defines if the texture must be serialized as well
  11420. * @returns the JSON object
  11421. */
  11422. serialize(serializeTexture?: boolean): any;
  11423. /**
  11424. * Parses a JSON object to create a new sprite manager.
  11425. * @param parsedManager The JSON object to parse
  11426. * @param scene The scene to create the sprite managerin
  11427. * @param rootUrl The root url to use to load external dependencies like texture
  11428. * @returns the new sprite manager
  11429. */
  11430. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11431. /**
  11432. * Creates a sprite manager from a snippet saved in a remote file
  11433. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11434. * @param url defines the url to load from
  11435. * @param scene defines the hosting scene
  11436. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11437. * @returns a promise that will resolve to the new sprite manager
  11438. */
  11439. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11440. /**
  11441. * Creates a sprite manager from a snippet saved by the sprite editor
  11442. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11443. * @param scene defines the hosting scene
  11444. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11445. * @returns a promise that will resolve to the new sprite manager
  11446. */
  11447. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11448. }
  11449. }
  11450. declare module "babylonjs/Misc/gradients" {
  11451. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11452. /** Interface used by value gradients (color, factor, ...) */
  11453. export interface IValueGradient {
  11454. /**
  11455. * Gets or sets the gradient value (between 0 and 1)
  11456. */
  11457. gradient: number;
  11458. }
  11459. /** Class used to store color4 gradient */
  11460. export class ColorGradient implements IValueGradient {
  11461. /**
  11462. * Gets or sets the gradient value (between 0 and 1)
  11463. */
  11464. gradient: number;
  11465. /**
  11466. * Gets or sets first associated color
  11467. */
  11468. color1: Color4;
  11469. /**
  11470. * Gets or sets second associated color
  11471. */
  11472. color2?: Color4 | undefined;
  11473. /**
  11474. * Creates a new color4 gradient
  11475. * @param gradient gets or sets the gradient value (between 0 and 1)
  11476. * @param color1 gets or sets first associated color
  11477. * @param color2 gets or sets first second color
  11478. */
  11479. constructor(
  11480. /**
  11481. * Gets or sets the gradient value (between 0 and 1)
  11482. */
  11483. gradient: number,
  11484. /**
  11485. * Gets or sets first associated color
  11486. */
  11487. color1: Color4,
  11488. /**
  11489. * Gets or sets second associated color
  11490. */
  11491. color2?: Color4 | undefined);
  11492. /**
  11493. * Will get a color picked randomly between color1 and color2.
  11494. * If color2 is undefined then color1 will be used
  11495. * @param result defines the target Color4 to store the result in
  11496. */
  11497. getColorToRef(result: Color4): void;
  11498. }
  11499. /** Class used to store color 3 gradient */
  11500. export class Color3Gradient implements IValueGradient {
  11501. /**
  11502. * Gets or sets the gradient value (between 0 and 1)
  11503. */
  11504. gradient: number;
  11505. /**
  11506. * Gets or sets the associated color
  11507. */
  11508. color: Color3;
  11509. /**
  11510. * Creates a new color3 gradient
  11511. * @param gradient gets or sets the gradient value (between 0 and 1)
  11512. * @param color gets or sets associated color
  11513. */
  11514. constructor(
  11515. /**
  11516. * Gets or sets the gradient value (between 0 and 1)
  11517. */
  11518. gradient: number,
  11519. /**
  11520. * Gets or sets the associated color
  11521. */
  11522. color: Color3);
  11523. }
  11524. /** Class used to store factor gradient */
  11525. export class FactorGradient implements IValueGradient {
  11526. /**
  11527. * Gets or sets the gradient value (between 0 and 1)
  11528. */
  11529. gradient: number;
  11530. /**
  11531. * Gets or sets first associated factor
  11532. */
  11533. factor1: number;
  11534. /**
  11535. * Gets or sets second associated factor
  11536. */
  11537. factor2?: number | undefined;
  11538. /**
  11539. * Creates a new factor gradient
  11540. * @param gradient gets or sets the gradient value (between 0 and 1)
  11541. * @param factor1 gets or sets first associated factor
  11542. * @param factor2 gets or sets second associated factor
  11543. */
  11544. constructor(
  11545. /**
  11546. * Gets or sets the gradient value (between 0 and 1)
  11547. */
  11548. gradient: number,
  11549. /**
  11550. * Gets or sets first associated factor
  11551. */
  11552. factor1: number,
  11553. /**
  11554. * Gets or sets second associated factor
  11555. */
  11556. factor2?: number | undefined);
  11557. /**
  11558. * Will get a number picked randomly between factor1 and factor2.
  11559. * If factor2 is undefined then factor1 will be used
  11560. * @returns the picked number
  11561. */
  11562. getFactor(): number;
  11563. }
  11564. /**
  11565. * Helper used to simplify some generic gradient tasks
  11566. */
  11567. export class GradientHelper {
  11568. /**
  11569. * Gets the current gradient from an array of IValueGradient
  11570. * @param ratio defines the current ratio to get
  11571. * @param gradients defines the array of IValueGradient
  11572. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11573. */
  11574. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11575. }
  11576. }
  11577. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11578. import { Nullable } from "babylonjs/types";
  11579. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11580. import { Scene } from "babylonjs/scene";
  11581. module "babylonjs/Engines/thinEngine" {
  11582. interface ThinEngine {
  11583. /**
  11584. * Creates a raw texture
  11585. * @param data defines the data to store in the texture
  11586. * @param width defines the width of the texture
  11587. * @param height defines the height of the texture
  11588. * @param format defines the format of the data
  11589. * @param generateMipMaps defines if the engine should generate the mip levels
  11590. * @param invertY defines if data must be stored with Y axis inverted
  11591. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11592. * @param compression defines the compression used (null by default)
  11593. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11594. * @returns the raw texture inside an InternalTexture
  11595. */
  11596. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11597. /**
  11598. * Update a raw texture
  11599. * @param texture defines the texture to update
  11600. * @param data defines the data to store in the texture
  11601. * @param format defines the format of the data
  11602. * @param invertY defines if data must be stored with Y axis inverted
  11603. */
  11604. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11605. /**
  11606. * Update a raw texture
  11607. * @param texture defines the texture to update
  11608. * @param data defines the data to store in the texture
  11609. * @param format defines the format of the data
  11610. * @param invertY defines if data must be stored with Y axis inverted
  11611. * @param compression defines the compression used (null by default)
  11612. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11613. */
  11614. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11615. /**
  11616. * Creates a new raw cube texture
  11617. * @param data defines the array of data to use to create each face
  11618. * @param size defines the size of the textures
  11619. * @param format defines the format of the data
  11620. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11621. * @param generateMipMaps defines if the engine should generate the mip levels
  11622. * @param invertY defines if data must be stored with Y axis inverted
  11623. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11624. * @param compression defines the compression used (null by default)
  11625. * @returns the cube texture as an InternalTexture
  11626. */
  11627. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11628. /**
  11629. * Update a raw cube texture
  11630. * @param texture defines the texture to udpdate
  11631. * @param data defines the data to store
  11632. * @param format defines the data format
  11633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11634. * @param invertY defines if data must be stored with Y axis inverted
  11635. */
  11636. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11637. /**
  11638. * Update a raw cube texture
  11639. * @param texture defines the texture to udpdate
  11640. * @param data defines the data to store
  11641. * @param format defines the data format
  11642. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11643. * @param invertY defines if data must be stored with Y axis inverted
  11644. * @param compression defines the compression used (null by default)
  11645. */
  11646. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11647. /**
  11648. * Update a raw cube texture
  11649. * @param texture defines the texture to udpdate
  11650. * @param data defines the data to store
  11651. * @param format defines the data format
  11652. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11653. * @param invertY defines if data must be stored with Y axis inverted
  11654. * @param compression defines the compression used (null by default)
  11655. * @param level defines which level of the texture to update
  11656. */
  11657. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11658. /**
  11659. * Creates a new raw cube texture from a specified url
  11660. * @param url defines the url where the data is located
  11661. * @param scene defines the current scene
  11662. * @param size defines the size of the textures
  11663. * @param format defines the format of the data
  11664. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11665. * @param noMipmap defines if the engine should avoid generating the mip levels
  11666. * @param callback defines a callback used to extract texture data from loaded data
  11667. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11668. * @param onLoad defines a callback called when texture is loaded
  11669. * @param onError defines a callback called if there is an error
  11670. * @returns the cube texture as an InternalTexture
  11671. */
  11672. 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;
  11673. /**
  11674. * Creates a new raw cube texture from a specified url
  11675. * @param url defines the url where the data is located
  11676. * @param scene defines the current scene
  11677. * @param size defines the size of the textures
  11678. * @param format defines the format of the data
  11679. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11680. * @param noMipmap defines if the engine should avoid generating the mip levels
  11681. * @param callback defines a callback used to extract texture data from loaded data
  11682. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11683. * @param onLoad defines a callback called when texture is loaded
  11684. * @param onError defines a callback called if there is an error
  11685. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11686. * @param invertY defines if data must be stored with Y axis inverted
  11687. * @returns the cube texture as an InternalTexture
  11688. */
  11689. 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;
  11690. /**
  11691. * Creates a new raw 3D texture
  11692. * @param data defines the data used to create the texture
  11693. * @param width defines the width of the texture
  11694. * @param height defines the height of the texture
  11695. * @param depth defines the depth of the texture
  11696. * @param format defines the format of the texture
  11697. * @param generateMipMaps defines if the engine must generate mip levels
  11698. * @param invertY defines if data must be stored with Y axis inverted
  11699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11700. * @param compression defines the compressed used (can be null)
  11701. * @param textureType defines the compressed used (can be null)
  11702. * @returns a new raw 3D texture (stored in an InternalTexture)
  11703. */
  11704. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11705. /**
  11706. * Update a raw 3D texture
  11707. * @param texture defines the texture to update
  11708. * @param data defines the data to store
  11709. * @param format defines the data format
  11710. * @param invertY defines if data must be stored with Y axis inverted
  11711. */
  11712. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11713. /**
  11714. * Update a raw 3D texture
  11715. * @param texture defines the texture to update
  11716. * @param data defines the data to store
  11717. * @param format defines the data format
  11718. * @param invertY defines if data must be stored with Y axis inverted
  11719. * @param compression defines the used compression (can be null)
  11720. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11721. */
  11722. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11723. /**
  11724. * Creates a new raw 2D array texture
  11725. * @param data defines the data used to create the texture
  11726. * @param width defines the width of the texture
  11727. * @param height defines the height of the texture
  11728. * @param depth defines the number of layers of the texture
  11729. * @param format defines the format of the texture
  11730. * @param generateMipMaps defines if the engine must generate mip levels
  11731. * @param invertY defines if data must be stored with Y axis inverted
  11732. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11733. * @param compression defines the compressed used (can be null)
  11734. * @param textureType defines the compressed used (can be null)
  11735. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11736. */
  11737. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11738. /**
  11739. * Update a raw 2D array texture
  11740. * @param texture defines the texture to update
  11741. * @param data defines the data to store
  11742. * @param format defines the data format
  11743. * @param invertY defines if data must be stored with Y axis inverted
  11744. */
  11745. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11746. /**
  11747. * Update a raw 2D array texture
  11748. * @param texture defines the texture to update
  11749. * @param data defines the data to store
  11750. * @param format defines the data format
  11751. * @param invertY defines if data must be stored with Y axis inverted
  11752. * @param compression defines the used compression (can be null)
  11753. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11754. */
  11755. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11756. }
  11757. }
  11758. }
  11759. declare module "babylonjs/Materials/Textures/rawTexture" {
  11760. import { Texture } from "babylonjs/Materials/Textures/texture";
  11761. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11762. import { Nullable } from "babylonjs/types";
  11763. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11764. import { Scene } from "babylonjs/scene";
  11765. /**
  11766. * Raw texture can help creating a texture directly from an array of data.
  11767. * This can be super useful if you either get the data from an uncompressed source or
  11768. * if you wish to create your texture pixel by pixel.
  11769. */
  11770. export class RawTexture extends Texture {
  11771. /**
  11772. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11773. */
  11774. format: number;
  11775. /**
  11776. * Instantiates a new RawTexture.
  11777. * Raw texture can help creating a texture directly from an array of data.
  11778. * This can be super useful if you either get the data from an uncompressed source or
  11779. * if you wish to create your texture pixel by pixel.
  11780. * @param data define the array of data to use to create the texture
  11781. * @param width define the width of the texture
  11782. * @param height define the height of the texture
  11783. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11784. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11785. * @param generateMipMaps define whether mip maps should be generated or not
  11786. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11787. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11788. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11789. */
  11790. constructor(data: ArrayBufferView, width: number, height: number,
  11791. /**
  11792. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11793. */
  11794. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11795. /**
  11796. * Updates the texture underlying data.
  11797. * @param data Define the new data of the texture
  11798. */
  11799. update(data: ArrayBufferView): void;
  11800. /**
  11801. * Creates a luminance texture from some data.
  11802. * @param data Define the texture data
  11803. * @param width Define the width of the texture
  11804. * @param height Define the height of the texture
  11805. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11806. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11807. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11808. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11809. * @returns the luminance texture
  11810. */
  11811. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11812. /**
  11813. * Creates a luminance alpha texture from some data.
  11814. * @param data Define the texture data
  11815. * @param width Define the width of the texture
  11816. * @param height Define the height of the texture
  11817. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11818. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11819. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11820. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11821. * @returns the luminance alpha texture
  11822. */
  11823. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11824. /**
  11825. * Creates an alpha texture from some data.
  11826. * @param data Define the texture data
  11827. * @param width Define the width of the texture
  11828. * @param height Define the height of the texture
  11829. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11830. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11831. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11832. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11833. * @returns the alpha texture
  11834. */
  11835. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11836. /**
  11837. * Creates a RGB texture from some data.
  11838. * @param data Define the texture data
  11839. * @param width Define the width of the texture
  11840. * @param height Define the height of the texture
  11841. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11842. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11843. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11844. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11845. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11846. * @returns the RGB alpha texture
  11847. */
  11848. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11849. /**
  11850. * Creates a RGBA texture from some data.
  11851. * @param data Define the texture data
  11852. * @param width Define the width of the texture
  11853. * @param height Define the height of the texture
  11854. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11855. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11856. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11857. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11858. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11859. * @returns the RGBA texture
  11860. */
  11861. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11862. /**
  11863. * Creates a R texture from some data.
  11864. * @param data Define the texture data
  11865. * @param width Define the width of the texture
  11866. * @param height Define the height of the texture
  11867. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11868. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11869. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11870. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11871. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11872. * @returns the R texture
  11873. */
  11874. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11875. }
  11876. }
  11877. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11878. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11879. import { IndicesArray, DataArray } from "babylonjs/types";
  11880. module "babylonjs/Engines/thinEngine" {
  11881. interface ThinEngine {
  11882. /**
  11883. * Update a dynamic index buffer
  11884. * @param indexBuffer defines the target index buffer
  11885. * @param indices defines the data to update
  11886. * @param offset defines the offset in the target index buffer where update should start
  11887. */
  11888. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11889. /**
  11890. * Updates a dynamic vertex buffer.
  11891. * @param vertexBuffer the vertex buffer to update
  11892. * @param data the data used to update the vertex buffer
  11893. * @param byteOffset the byte offset of the data
  11894. * @param byteLength the byte length of the data
  11895. */
  11896. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11897. }
  11898. }
  11899. }
  11900. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11901. import { Scene } from "babylonjs/scene";
  11902. import { ISceneComponent } from "babylonjs/sceneComponent";
  11903. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11904. module "babylonjs/abstractScene" {
  11905. interface AbstractScene {
  11906. /**
  11907. * The list of procedural textures added to the scene
  11908. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11909. */
  11910. proceduralTextures: Array<ProceduralTexture>;
  11911. }
  11912. }
  11913. /**
  11914. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11915. * in a given scene.
  11916. */
  11917. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11918. /**
  11919. * The component name helpfull to identify the component in the list of scene components.
  11920. */
  11921. readonly name: string;
  11922. /**
  11923. * The scene the component belongs to.
  11924. */
  11925. scene: Scene;
  11926. /**
  11927. * Creates a new instance of the component for the given scene
  11928. * @param scene Defines the scene to register the component in
  11929. */
  11930. constructor(scene: Scene);
  11931. /**
  11932. * Registers the component in a given scene
  11933. */
  11934. register(): void;
  11935. /**
  11936. * Rebuilds the elements related to this component in case of
  11937. * context lost for instance.
  11938. */
  11939. rebuild(): void;
  11940. /**
  11941. * Disposes the component and the associated ressources.
  11942. */
  11943. dispose(): void;
  11944. private _beforeClear;
  11945. }
  11946. }
  11947. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11948. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11949. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11950. module "babylonjs/Engines/thinEngine" {
  11951. interface ThinEngine {
  11952. /**
  11953. * Creates a new render target cube texture
  11954. * @param size defines the size of the texture
  11955. * @param options defines the options used to create the texture
  11956. * @returns a new render target cube texture stored in an InternalTexture
  11957. */
  11958. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11959. }
  11960. }
  11961. }
  11962. declare module "babylonjs/Shaders/procedural.vertex" {
  11963. /** @hidden */
  11964. export var proceduralVertexShader: {
  11965. name: string;
  11966. shader: string;
  11967. };
  11968. }
  11969. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11970. import { Observable } from "babylonjs/Misc/observable";
  11971. import { Nullable } from "babylonjs/types";
  11972. import { Scene } from "babylonjs/scene";
  11973. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11974. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11975. import { Effect } from "babylonjs/Materials/effect";
  11976. import { Texture } from "babylonjs/Materials/Textures/texture";
  11977. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11978. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11979. import "babylonjs/Shaders/procedural.vertex";
  11980. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11981. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11982. /**
  11983. * 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.
  11984. * This is the base class of any Procedural texture and contains most of the shareable code.
  11985. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11986. */
  11987. export class ProceduralTexture extends Texture {
  11988. /**
  11989. * Define if the texture is enabled or not (disabled texture will not render)
  11990. */
  11991. isEnabled: boolean;
  11992. /**
  11993. * Define if the texture must be cleared before rendering (default is true)
  11994. */
  11995. autoClear: boolean;
  11996. /**
  11997. * Callback called when the texture is generated
  11998. */
  11999. onGenerated: () => void;
  12000. /**
  12001. * Event raised when the texture is generated
  12002. */
  12003. onGeneratedObservable: Observable<ProceduralTexture>;
  12004. /**
  12005. * Event raised before the texture is generated
  12006. */
  12007. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12008. /**
  12009. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12010. */
  12011. nodeMaterialSource: Nullable<NodeMaterial>;
  12012. /** @hidden */
  12013. _generateMipMaps: boolean;
  12014. /** @hidden **/
  12015. _effect: Effect;
  12016. /** @hidden */
  12017. _textures: {
  12018. [key: string]: Texture;
  12019. };
  12020. /** @hidden */
  12021. protected _fallbackTexture: Nullable<Texture>;
  12022. private _size;
  12023. private _currentRefreshId;
  12024. private _frameId;
  12025. private _refreshRate;
  12026. private _vertexBuffers;
  12027. private _indexBuffer;
  12028. private _uniforms;
  12029. private _samplers;
  12030. private _fragment;
  12031. private _floats;
  12032. private _ints;
  12033. private _floatsArrays;
  12034. private _colors3;
  12035. private _colors4;
  12036. private _vectors2;
  12037. private _vectors3;
  12038. private _matrices;
  12039. private _fallbackTextureUsed;
  12040. private _fullEngine;
  12041. private _cachedDefines;
  12042. private _contentUpdateId;
  12043. private _contentData;
  12044. /**
  12045. * Instantiates a new procedural texture.
  12046. * 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.
  12047. * This is the base class of any Procedural texture and contains most of the shareable code.
  12048. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12049. * @param name Define the name of the texture
  12050. * @param size Define the size of the texture to create
  12051. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12052. * @param scene Define the scene the texture belongs to
  12053. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12054. * @param generateMipMaps Define if the texture should creates mip maps or not
  12055. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12056. */
  12057. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  12058. /**
  12059. * The effect that is created when initializing the post process.
  12060. * @returns The created effect corresponding the the postprocess.
  12061. */
  12062. getEffect(): Effect;
  12063. /**
  12064. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12065. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12066. */
  12067. getContent(): Nullable<ArrayBufferView>;
  12068. private _createIndexBuffer;
  12069. /** @hidden */
  12070. _rebuild(): void;
  12071. /**
  12072. * Resets the texture in order to recreate its associated resources.
  12073. * This can be called in case of context loss
  12074. */
  12075. reset(): void;
  12076. protected _getDefines(): string;
  12077. /**
  12078. * Is the texture ready to be used ? (rendered at least once)
  12079. * @returns true if ready, otherwise, false.
  12080. */
  12081. isReady(): boolean;
  12082. /**
  12083. * Resets the refresh counter of the texture and start bak from scratch.
  12084. * Could be useful to regenerate the texture if it is setup to render only once.
  12085. */
  12086. resetRefreshCounter(): void;
  12087. /**
  12088. * Set the fragment shader to use in order to render the texture.
  12089. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12090. */
  12091. setFragment(fragment: any): void;
  12092. /**
  12093. * Define the refresh rate of the texture or the rendering frequency.
  12094. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12095. */
  12096. get refreshRate(): number;
  12097. set refreshRate(value: number);
  12098. /** @hidden */
  12099. _shouldRender(): boolean;
  12100. /**
  12101. * Get the size the texture is rendering at.
  12102. * @returns the size (on cube texture it is always squared)
  12103. */
  12104. getRenderSize(): RenderTargetTextureSize;
  12105. /**
  12106. * Resize the texture to new value.
  12107. * @param size Define the new size the texture should have
  12108. * @param generateMipMaps Define whether the new texture should create mip maps
  12109. */
  12110. resize(size: number, generateMipMaps: boolean): void;
  12111. private _checkUniform;
  12112. /**
  12113. * Set a texture in the shader program used to render.
  12114. * @param name Define the name of the uniform samplers as defined in the shader
  12115. * @param texture Define the texture to bind to this sampler
  12116. * @return the texture itself allowing "fluent" like uniform updates
  12117. */
  12118. setTexture(name: string, texture: Texture): ProceduralTexture;
  12119. /**
  12120. * Set a float in the shader.
  12121. * @param name Define the name of the uniform as defined in the shader
  12122. * @param value Define the value to give to the uniform
  12123. * @return the texture itself allowing "fluent" like uniform updates
  12124. */
  12125. setFloat(name: string, value: number): ProceduralTexture;
  12126. /**
  12127. * Set a int in the shader.
  12128. * @param name Define the name of the uniform as defined in the shader
  12129. * @param value Define the value to give to the uniform
  12130. * @return the texture itself allowing "fluent" like uniform updates
  12131. */
  12132. setInt(name: string, value: number): ProceduralTexture;
  12133. /**
  12134. * Set an array of floats in the shader.
  12135. * @param name Define the name of the uniform as defined in the shader
  12136. * @param value Define the value to give to the uniform
  12137. * @return the texture itself allowing "fluent" like uniform updates
  12138. */
  12139. setFloats(name: string, value: number[]): ProceduralTexture;
  12140. /**
  12141. * Set a vec3 in the shader from a Color3.
  12142. * @param name Define the name of the uniform as defined in the shader
  12143. * @param value Define the value to give to the uniform
  12144. * @return the texture itself allowing "fluent" like uniform updates
  12145. */
  12146. setColor3(name: string, value: Color3): ProceduralTexture;
  12147. /**
  12148. * Set a vec4 in the shader from a Color4.
  12149. * @param name Define the name of the uniform as defined in the shader
  12150. * @param value Define the value to give to the uniform
  12151. * @return the texture itself allowing "fluent" like uniform updates
  12152. */
  12153. setColor4(name: string, value: Color4): ProceduralTexture;
  12154. /**
  12155. * Set a vec2 in the shader from a Vector2.
  12156. * @param name Define the name of the uniform as defined in the shader
  12157. * @param value Define the value to give to the uniform
  12158. * @return the texture itself allowing "fluent" like uniform updates
  12159. */
  12160. setVector2(name: string, value: Vector2): ProceduralTexture;
  12161. /**
  12162. * Set a vec3 in the shader from a Vector3.
  12163. * @param name Define the name of the uniform as defined in the shader
  12164. * @param value Define the value to give to the uniform
  12165. * @return the texture itself allowing "fluent" like uniform updates
  12166. */
  12167. setVector3(name: string, value: Vector3): ProceduralTexture;
  12168. /**
  12169. * Set a mat4 in the shader from a MAtrix.
  12170. * @param name Define the name of the uniform as defined in the shader
  12171. * @param value Define the value to give to the uniform
  12172. * @return the texture itself allowing "fluent" like uniform updates
  12173. */
  12174. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12175. /**
  12176. * Render the texture to its associated render target.
  12177. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12178. */
  12179. render(useCameraPostProcess?: boolean): void;
  12180. /**
  12181. * Clone the texture.
  12182. * @returns the cloned texture
  12183. */
  12184. clone(): ProceduralTexture;
  12185. /**
  12186. * Dispose the texture and release its asoociated resources.
  12187. */
  12188. dispose(): void;
  12189. }
  12190. }
  12191. declare module "babylonjs/Particles/baseParticleSystem" {
  12192. import { Nullable } from "babylonjs/types";
  12193. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12194. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12195. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12196. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12197. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12198. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12199. import { Color4 } from "babylonjs/Maths/math.color";
  12200. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12201. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12202. import { Animation } from "babylonjs/Animations/animation";
  12203. import { Scene } from "babylonjs/scene";
  12204. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12205. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12206. /**
  12207. * This represents the base class for particle system in Babylon.
  12208. * 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.
  12209. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12210. * @example https://doc.babylonjs.com/babylon101/particles
  12211. */
  12212. export class BaseParticleSystem {
  12213. /**
  12214. * Source color is added to the destination color without alpha affecting the result
  12215. */
  12216. static BLENDMODE_ONEONE: number;
  12217. /**
  12218. * Blend current color and particle color using particle’s alpha
  12219. */
  12220. static BLENDMODE_STANDARD: number;
  12221. /**
  12222. * Add current color and particle color multiplied by particle’s alpha
  12223. */
  12224. static BLENDMODE_ADD: number;
  12225. /**
  12226. * Multiply current color with particle color
  12227. */
  12228. static BLENDMODE_MULTIPLY: number;
  12229. /**
  12230. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12231. */
  12232. static BLENDMODE_MULTIPLYADD: number;
  12233. /**
  12234. * List of animations used by the particle system.
  12235. */
  12236. animations: Animation[];
  12237. /**
  12238. * Gets or sets the unique id of the particle system
  12239. */
  12240. uniqueId: number;
  12241. /**
  12242. * The id of the Particle system.
  12243. */
  12244. id: string;
  12245. /**
  12246. * The friendly name of the Particle system.
  12247. */
  12248. name: string;
  12249. /**
  12250. * Snippet ID if the particle system was created from the snippet server
  12251. */
  12252. snippetId: string;
  12253. /**
  12254. * The rendering group used by the Particle system to chose when to render.
  12255. */
  12256. renderingGroupId: number;
  12257. /**
  12258. * The emitter represents the Mesh or position we are attaching the particle system to.
  12259. */
  12260. emitter: Nullable<AbstractMesh | Vector3>;
  12261. /**
  12262. * The maximum number of particles to emit per frame
  12263. */
  12264. emitRate: number;
  12265. /**
  12266. * If you want to launch only a few particles at once, that can be done, as well.
  12267. */
  12268. manualEmitCount: number;
  12269. /**
  12270. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12271. */
  12272. updateSpeed: number;
  12273. /**
  12274. * The amount of time the particle system is running (depends of the overall update speed).
  12275. */
  12276. targetStopDuration: number;
  12277. /**
  12278. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12279. */
  12280. disposeOnStop: boolean;
  12281. /**
  12282. * Minimum power of emitting particles.
  12283. */
  12284. minEmitPower: number;
  12285. /**
  12286. * Maximum power of emitting particles.
  12287. */
  12288. maxEmitPower: number;
  12289. /**
  12290. * Minimum life time of emitting particles.
  12291. */
  12292. minLifeTime: number;
  12293. /**
  12294. * Maximum life time of emitting particles.
  12295. */
  12296. maxLifeTime: number;
  12297. /**
  12298. * Minimum Size of emitting particles.
  12299. */
  12300. minSize: number;
  12301. /**
  12302. * Maximum Size of emitting particles.
  12303. */
  12304. maxSize: number;
  12305. /**
  12306. * Minimum scale of emitting particles on X axis.
  12307. */
  12308. minScaleX: number;
  12309. /**
  12310. * Maximum scale of emitting particles on X axis.
  12311. */
  12312. maxScaleX: number;
  12313. /**
  12314. * Minimum scale of emitting particles on Y axis.
  12315. */
  12316. minScaleY: number;
  12317. /**
  12318. * Maximum scale of emitting particles on Y axis.
  12319. */
  12320. maxScaleY: number;
  12321. /**
  12322. * Gets or sets the minimal initial rotation in radians.
  12323. */
  12324. minInitialRotation: number;
  12325. /**
  12326. * Gets or sets the maximal initial rotation in radians.
  12327. */
  12328. maxInitialRotation: number;
  12329. /**
  12330. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12331. */
  12332. minAngularSpeed: number;
  12333. /**
  12334. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12335. */
  12336. maxAngularSpeed: number;
  12337. /**
  12338. * The texture used to render each particle. (this can be a spritesheet)
  12339. */
  12340. particleTexture: Nullable<BaseTexture>;
  12341. /**
  12342. * The layer mask we are rendering the particles through.
  12343. */
  12344. layerMask: number;
  12345. /**
  12346. * This can help using your own shader to render the particle system.
  12347. * The according effect will be created
  12348. */
  12349. customShader: any;
  12350. /**
  12351. * By default particle system starts as soon as they are created. This prevents the
  12352. * automatic start to happen and let you decide when to start emitting particles.
  12353. */
  12354. preventAutoStart: boolean;
  12355. private _noiseTexture;
  12356. /**
  12357. * Gets or sets a texture used to add random noise to particle positions
  12358. */
  12359. get noiseTexture(): Nullable<ProceduralTexture>;
  12360. set noiseTexture(value: Nullable<ProceduralTexture>);
  12361. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12362. noiseStrength: Vector3;
  12363. /**
  12364. * Callback triggered when the particle animation is ending.
  12365. */
  12366. onAnimationEnd: Nullable<() => void>;
  12367. /**
  12368. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12369. */
  12370. blendMode: number;
  12371. /**
  12372. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12373. * to override the particles.
  12374. */
  12375. forceDepthWrite: boolean;
  12376. /** 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 */
  12377. preWarmCycles: number;
  12378. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12379. preWarmStepOffset: number;
  12380. /**
  12381. * 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)
  12382. */
  12383. spriteCellChangeSpeed: number;
  12384. /**
  12385. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12386. */
  12387. startSpriteCellID: number;
  12388. /**
  12389. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12390. */
  12391. endSpriteCellID: number;
  12392. /**
  12393. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12394. */
  12395. spriteCellWidth: number;
  12396. /**
  12397. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12398. */
  12399. spriteCellHeight: number;
  12400. /**
  12401. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12402. */
  12403. spriteRandomStartCell: boolean;
  12404. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12405. translationPivot: Vector2;
  12406. /** @hidden */
  12407. protected _isAnimationSheetEnabled: boolean;
  12408. /**
  12409. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12410. */
  12411. beginAnimationOnStart: boolean;
  12412. /**
  12413. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12414. */
  12415. beginAnimationFrom: number;
  12416. /**
  12417. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12418. */
  12419. beginAnimationTo: number;
  12420. /**
  12421. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12422. */
  12423. beginAnimationLoop: boolean;
  12424. /**
  12425. * Gets or sets a world offset applied to all particles
  12426. */
  12427. worldOffset: Vector3;
  12428. /**
  12429. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12430. */
  12431. get isAnimationSheetEnabled(): boolean;
  12432. set isAnimationSheetEnabled(value: boolean);
  12433. /**
  12434. * Get hosting scene
  12435. * @returns the scene
  12436. */
  12437. getScene(): Nullable<Scene>;
  12438. /**
  12439. * You can use gravity if you want to give an orientation to your particles.
  12440. */
  12441. gravity: Vector3;
  12442. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12443. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12444. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12445. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12446. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12447. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12448. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12449. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12450. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12451. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12452. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12453. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12454. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12455. /**
  12456. * Defines the delay in milliseconds before starting the system (0 by default)
  12457. */
  12458. startDelay: number;
  12459. /**
  12460. * Gets the current list of drag gradients.
  12461. * You must use addDragGradient and removeDragGradient to udpate this list
  12462. * @returns the list of drag gradients
  12463. */
  12464. getDragGradients(): Nullable<Array<FactorGradient>>;
  12465. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12466. limitVelocityDamping: number;
  12467. /**
  12468. * Gets the current list of limit velocity gradients.
  12469. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12470. * @returns the list of limit velocity gradients
  12471. */
  12472. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12473. /**
  12474. * Gets the current list of color gradients.
  12475. * You must use addColorGradient and removeColorGradient to udpate this list
  12476. * @returns the list of color gradients
  12477. */
  12478. getColorGradients(): Nullable<Array<ColorGradient>>;
  12479. /**
  12480. * Gets the current list of size gradients.
  12481. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12482. * @returns the list of size gradients
  12483. */
  12484. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12485. /**
  12486. * Gets the current list of color remap gradients.
  12487. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12488. * @returns the list of color remap gradients
  12489. */
  12490. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12491. /**
  12492. * Gets the current list of alpha remap gradients.
  12493. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12494. * @returns the list of alpha remap gradients
  12495. */
  12496. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12497. /**
  12498. * Gets the current list of life time gradients.
  12499. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12500. * @returns the list of life time gradients
  12501. */
  12502. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12503. /**
  12504. * Gets the current list of angular speed gradients.
  12505. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12506. * @returns the list of angular speed gradients
  12507. */
  12508. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12509. /**
  12510. * Gets the current list of velocity gradients.
  12511. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12512. * @returns the list of velocity gradients
  12513. */
  12514. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12515. /**
  12516. * Gets the current list of start size gradients.
  12517. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12518. * @returns the list of start size gradients
  12519. */
  12520. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12521. /**
  12522. * Gets the current list of emit rate gradients.
  12523. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12524. * @returns the list of emit rate gradients
  12525. */
  12526. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12527. /**
  12528. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12529. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12530. */
  12531. get direction1(): Vector3;
  12532. set direction1(value: Vector3);
  12533. /**
  12534. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12535. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12536. */
  12537. get direction2(): Vector3;
  12538. set direction2(value: Vector3);
  12539. /**
  12540. * 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.
  12541. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12542. */
  12543. get minEmitBox(): Vector3;
  12544. set minEmitBox(value: Vector3);
  12545. /**
  12546. * 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.
  12547. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12548. */
  12549. get maxEmitBox(): Vector3;
  12550. set maxEmitBox(value: Vector3);
  12551. /**
  12552. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12553. */
  12554. color1: Color4;
  12555. /**
  12556. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12557. */
  12558. color2: Color4;
  12559. /**
  12560. * Color the particle will have at the end of its lifetime
  12561. */
  12562. colorDead: Color4;
  12563. /**
  12564. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12565. */
  12566. textureMask: Color4;
  12567. /**
  12568. * The particle emitter type defines the emitter used by the particle system.
  12569. * It can be for example box, sphere, or cone...
  12570. */
  12571. particleEmitterType: IParticleEmitterType;
  12572. /** @hidden */
  12573. _isSubEmitter: boolean;
  12574. /**
  12575. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12576. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12577. */
  12578. billboardMode: number;
  12579. protected _isBillboardBased: boolean;
  12580. /**
  12581. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12582. */
  12583. get isBillboardBased(): boolean;
  12584. set isBillboardBased(value: boolean);
  12585. /**
  12586. * The scene the particle system belongs to.
  12587. */
  12588. protected _scene: Nullable<Scene>;
  12589. /**
  12590. * The engine the particle system belongs to.
  12591. */
  12592. protected _engine: ThinEngine;
  12593. /**
  12594. * Local cache of defines for image processing.
  12595. */
  12596. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12597. /**
  12598. * Default configuration related to image processing available in the standard Material.
  12599. */
  12600. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12601. /**
  12602. * Gets the image processing configuration used either in this material.
  12603. */
  12604. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12605. /**
  12606. * Sets the Default image processing configuration used either in the this material.
  12607. *
  12608. * If sets to null, the scene one is in use.
  12609. */
  12610. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12611. /**
  12612. * Attaches a new image processing configuration to the Standard Material.
  12613. * @param configuration
  12614. */
  12615. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12616. /** @hidden */
  12617. protected _reset(): void;
  12618. /** @hidden */
  12619. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12620. /**
  12621. * Instantiates a particle system.
  12622. * 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.
  12623. * @param name The name of the particle system
  12624. */
  12625. constructor(name: string);
  12626. /**
  12627. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12628. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12629. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12630. * @returns the emitter
  12631. */
  12632. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12633. /**
  12634. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12635. * @param radius The radius of the hemisphere to emit from
  12636. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12637. * @returns the emitter
  12638. */
  12639. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12640. /**
  12641. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12642. * @param radius The radius of the sphere to emit from
  12643. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12644. * @returns the emitter
  12645. */
  12646. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12647. /**
  12648. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12649. * @param radius The radius of the sphere to emit from
  12650. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12651. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12652. * @returns the emitter
  12653. */
  12654. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12655. /**
  12656. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12657. * @param radius The radius of the emission cylinder
  12658. * @param height The height of the emission cylinder
  12659. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12660. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12661. * @returns the emitter
  12662. */
  12663. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12664. /**
  12665. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12666. * @param radius The radius of the cylinder to emit from
  12667. * @param height The height of the emission cylinder
  12668. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12669. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12670. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12671. * @returns the emitter
  12672. */
  12673. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12674. /**
  12675. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12676. * @param radius The radius of the cone to emit from
  12677. * @param angle The base angle of the cone
  12678. * @returns the emitter
  12679. */
  12680. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12681. /**
  12682. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12683. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12684. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12685. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12686. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12687. * @returns the emitter
  12688. */
  12689. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12690. }
  12691. }
  12692. declare module "babylonjs/Particles/subEmitter" {
  12693. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12694. import { Scene } from "babylonjs/scene";
  12695. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12696. /**
  12697. * Type of sub emitter
  12698. */
  12699. export enum SubEmitterType {
  12700. /**
  12701. * Attached to the particle over it's lifetime
  12702. */
  12703. ATTACHED = 0,
  12704. /**
  12705. * Created when the particle dies
  12706. */
  12707. END = 1
  12708. }
  12709. /**
  12710. * Sub emitter class used to emit particles from an existing particle
  12711. */
  12712. export class SubEmitter {
  12713. /**
  12714. * the particle system to be used by the sub emitter
  12715. */
  12716. particleSystem: ParticleSystem;
  12717. /**
  12718. * Type of the submitter (Default: END)
  12719. */
  12720. type: SubEmitterType;
  12721. /**
  12722. * 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)
  12723. * Note: This only is supported when using an emitter of type Mesh
  12724. */
  12725. inheritDirection: boolean;
  12726. /**
  12727. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12728. */
  12729. inheritedVelocityAmount: number;
  12730. /**
  12731. * Creates a sub emitter
  12732. * @param particleSystem the particle system to be used by the sub emitter
  12733. */
  12734. constructor(
  12735. /**
  12736. * the particle system to be used by the sub emitter
  12737. */
  12738. particleSystem: ParticleSystem);
  12739. /**
  12740. * Clones the sub emitter
  12741. * @returns the cloned sub emitter
  12742. */
  12743. clone(): SubEmitter;
  12744. /**
  12745. * Serialize current object to a JSON object
  12746. * @returns the serialized object
  12747. */
  12748. serialize(): any;
  12749. /** @hidden */
  12750. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12751. /**
  12752. * Creates a new SubEmitter from a serialized JSON version
  12753. * @param serializationObject defines the JSON object to read from
  12754. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12755. * @param rootUrl defines the rootUrl for data loading
  12756. * @returns a new SubEmitter
  12757. */
  12758. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12759. /** Release associated resources */
  12760. dispose(): void;
  12761. }
  12762. }
  12763. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12764. /** @hidden */
  12765. export var imageProcessingDeclaration: {
  12766. name: string;
  12767. shader: string;
  12768. };
  12769. }
  12770. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12771. /** @hidden */
  12772. export var imageProcessingFunctions: {
  12773. name: string;
  12774. shader: string;
  12775. };
  12776. }
  12777. declare module "babylonjs/Shaders/particles.fragment" {
  12778. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12779. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12780. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12781. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12782. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12783. /** @hidden */
  12784. export var particlesPixelShader: {
  12785. name: string;
  12786. shader: string;
  12787. };
  12788. }
  12789. declare module "babylonjs/Shaders/particles.vertex" {
  12790. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12791. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12792. /** @hidden */
  12793. export var particlesVertexShader: {
  12794. name: string;
  12795. shader: string;
  12796. };
  12797. }
  12798. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12799. import { Nullable } from "babylonjs/types";
  12800. import { Plane } from "babylonjs/Maths/math";
  12801. /**
  12802. * Interface used to define entities containing multiple clip planes
  12803. */
  12804. export interface IClipPlanesHolder {
  12805. /**
  12806. * Gets or sets the active clipplane 1
  12807. */
  12808. clipPlane: Nullable<Plane>;
  12809. /**
  12810. * Gets or sets the active clipplane 2
  12811. */
  12812. clipPlane2: Nullable<Plane>;
  12813. /**
  12814. * Gets or sets the active clipplane 3
  12815. */
  12816. clipPlane3: Nullable<Plane>;
  12817. /**
  12818. * Gets or sets the active clipplane 4
  12819. */
  12820. clipPlane4: Nullable<Plane>;
  12821. /**
  12822. * Gets or sets the active clipplane 5
  12823. */
  12824. clipPlane5: Nullable<Plane>;
  12825. /**
  12826. * Gets or sets the active clipplane 6
  12827. */
  12828. clipPlane6: Nullable<Plane>;
  12829. }
  12830. }
  12831. declare module "babylonjs/Materials/thinMaterialHelper" {
  12832. import { Effect } from "babylonjs/Materials/effect";
  12833. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12834. /**
  12835. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12836. *
  12837. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12838. *
  12839. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12840. */
  12841. export class ThinMaterialHelper {
  12842. /**
  12843. * Binds the clip plane information from the holder to the effect.
  12844. * @param effect The effect we are binding the data to
  12845. * @param holder The entity containing the clip plane information
  12846. */
  12847. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12848. }
  12849. }
  12850. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12851. module "babylonjs/Engines/thinEngine" {
  12852. interface ThinEngine {
  12853. /**
  12854. * Sets alpha constants used by some alpha blending modes
  12855. * @param r defines the red component
  12856. * @param g defines the green component
  12857. * @param b defines the blue component
  12858. * @param a defines the alpha component
  12859. */
  12860. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12861. /**
  12862. * Sets the current alpha mode
  12863. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12864. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12865. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12866. */
  12867. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12868. /**
  12869. * Gets the current alpha mode
  12870. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12871. * @returns the current alpha mode
  12872. */
  12873. getAlphaMode(): number;
  12874. /**
  12875. * Sets the current alpha equation
  12876. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12877. */
  12878. setAlphaEquation(equation: number): void;
  12879. /**
  12880. * Gets the current alpha equation.
  12881. * @returns the current alpha equation
  12882. */
  12883. getAlphaEquation(): number;
  12884. }
  12885. }
  12886. }
  12887. declare module "babylonjs/Particles/particleSystem" {
  12888. import { Nullable } from "babylonjs/types";
  12889. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12890. import { Observable } from "babylonjs/Misc/observable";
  12891. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12892. import { Effect } from "babylonjs/Materials/effect";
  12893. import { IDisposable } from "babylonjs/scene";
  12894. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12895. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12896. import { Particle } from "babylonjs/Particles/particle";
  12897. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12898. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12899. import "babylonjs/Shaders/particles.fragment";
  12900. import "babylonjs/Shaders/particles.vertex";
  12901. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12902. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12903. import "babylonjs/Engines/Extensions/engine.alpha";
  12904. import { Scene } from "babylonjs/scene";
  12905. /**
  12906. * This represents a particle system in Babylon.
  12907. * 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.
  12908. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12909. * @example https://doc.babylonjs.com/babylon101/particles
  12910. */
  12911. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12912. /**
  12913. * Billboard mode will only apply to Y axis
  12914. */
  12915. static readonly BILLBOARDMODE_Y: number;
  12916. /**
  12917. * Billboard mode will apply to all axes
  12918. */
  12919. static readonly BILLBOARDMODE_ALL: number;
  12920. /**
  12921. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12922. */
  12923. static readonly BILLBOARDMODE_STRETCHED: number;
  12924. /**
  12925. * This function can be defined to provide custom update for active particles.
  12926. * This function will be called instead of regular update (age, position, color, etc.).
  12927. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12928. */
  12929. updateFunction: (particles: Particle[]) => void;
  12930. private _emitterWorldMatrix;
  12931. /**
  12932. * This function can be defined to specify initial direction for every new particle.
  12933. * It by default use the emitterType defined function
  12934. */
  12935. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12936. /**
  12937. * This function can be defined to specify initial position for every new particle.
  12938. * It by default use the emitterType defined function
  12939. */
  12940. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12941. /**
  12942. * @hidden
  12943. */
  12944. _inheritedVelocityOffset: Vector3;
  12945. /**
  12946. * An event triggered when the system is disposed
  12947. */
  12948. onDisposeObservable: Observable<IParticleSystem>;
  12949. private _onDisposeObserver;
  12950. /**
  12951. * Sets a callback that will be triggered when the system is disposed
  12952. */
  12953. set onDispose(callback: () => void);
  12954. private _particles;
  12955. private _epsilon;
  12956. private _capacity;
  12957. private _stockParticles;
  12958. private _newPartsExcess;
  12959. private _vertexData;
  12960. private _vertexBuffer;
  12961. private _vertexBuffers;
  12962. private _spriteBuffer;
  12963. private _indexBuffer;
  12964. private _effect;
  12965. private _customEffect;
  12966. private _cachedDefines;
  12967. private _scaledColorStep;
  12968. private _colorDiff;
  12969. private _scaledDirection;
  12970. private _scaledGravity;
  12971. private _currentRenderId;
  12972. private _alive;
  12973. private _useInstancing;
  12974. private _started;
  12975. private _stopped;
  12976. private _actualFrame;
  12977. private _scaledUpdateSpeed;
  12978. private _vertexBufferSize;
  12979. /** @hidden */
  12980. _currentEmitRateGradient: Nullable<FactorGradient>;
  12981. /** @hidden */
  12982. _currentEmitRate1: number;
  12983. /** @hidden */
  12984. _currentEmitRate2: number;
  12985. /** @hidden */
  12986. _currentStartSizeGradient: Nullable<FactorGradient>;
  12987. /** @hidden */
  12988. _currentStartSize1: number;
  12989. /** @hidden */
  12990. _currentStartSize2: number;
  12991. private readonly _rawTextureWidth;
  12992. private _rampGradientsTexture;
  12993. private _useRampGradients;
  12994. /** Gets or sets a matrix to use to compute projection */
  12995. defaultProjectionMatrix: Matrix;
  12996. /** Gets or sets a matrix to use to compute view */
  12997. defaultViewMatrix: Matrix;
  12998. /** Gets or sets a boolean indicating that ramp gradients must be used
  12999. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13000. */
  13001. get useRampGradients(): boolean;
  13002. set useRampGradients(value: boolean);
  13003. /**
  13004. * 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.
  13005. * 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: [])
  13006. */
  13007. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13008. private _subEmitters;
  13009. /**
  13010. * @hidden
  13011. * If the particle systems emitter should be disposed when the particle system is disposed
  13012. */
  13013. _disposeEmitterOnDispose: boolean;
  13014. /**
  13015. * The current active Sub-systems, this property is used by the root particle system only.
  13016. */
  13017. activeSubSystems: Array<ParticleSystem>;
  13018. /**
  13019. * Specifies if the particles are updated in emitter local space or world space
  13020. */
  13021. isLocal: boolean;
  13022. private _rootParticleSystem;
  13023. /**
  13024. * Gets the current list of active particles
  13025. */
  13026. get particles(): Particle[];
  13027. /**
  13028. * Gets the number of particles active at the same time.
  13029. * @returns The number of active particles.
  13030. */
  13031. getActiveCount(): number;
  13032. /**
  13033. * Returns the string "ParticleSystem"
  13034. * @returns a string containing the class name
  13035. */
  13036. getClassName(): string;
  13037. /**
  13038. * Gets a boolean indicating that the system is stopping
  13039. * @returns true if the system is currently stopping
  13040. */
  13041. isStopping(): boolean;
  13042. /**
  13043. * Gets the custom effect used to render the particles
  13044. * @param blendMode Blend mode for which the effect should be retrieved
  13045. * @returns The effect
  13046. */
  13047. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13048. /**
  13049. * Sets the custom effect used to render the particles
  13050. * @param effect The effect to set
  13051. * @param blendMode Blend mode for which the effect should be set
  13052. */
  13053. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13054. /** @hidden */
  13055. private _onBeforeDrawParticlesObservable;
  13056. /**
  13057. * Observable that will be called just before the particles are drawn
  13058. */
  13059. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13060. /**
  13061. * Gets the name of the particle vertex shader
  13062. */
  13063. get vertexShaderName(): string;
  13064. /**
  13065. * Instantiates a particle system.
  13066. * 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.
  13067. * @param name The name of the particle system
  13068. * @param capacity The max number of particles alive at the same time
  13069. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13070. * @param customEffect a custom effect used to change the way particles are rendered by default
  13071. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13072. * @param epsilon Offset used to render the particles
  13073. */
  13074. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13075. private _addFactorGradient;
  13076. private _removeFactorGradient;
  13077. /**
  13078. * Adds a new life time gradient
  13079. * @param gradient defines the gradient to use (between 0 and 1)
  13080. * @param factor defines the life time factor to affect to the specified gradient
  13081. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13082. * @returns the current particle system
  13083. */
  13084. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13085. /**
  13086. * Remove a specific life time gradient
  13087. * @param gradient defines the gradient to remove
  13088. * @returns the current particle system
  13089. */
  13090. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13091. /**
  13092. * Adds a new size gradient
  13093. * @param gradient defines the gradient to use (between 0 and 1)
  13094. * @param factor defines the size factor to affect to the specified gradient
  13095. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13096. * @returns the current particle system
  13097. */
  13098. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13099. /**
  13100. * Remove a specific size gradient
  13101. * @param gradient defines the gradient to remove
  13102. * @returns the current particle system
  13103. */
  13104. removeSizeGradient(gradient: number): IParticleSystem;
  13105. /**
  13106. * Adds a new color remap gradient
  13107. * @param gradient defines the gradient to use (between 0 and 1)
  13108. * @param min defines the color remap minimal range
  13109. * @param max defines the color remap maximal range
  13110. * @returns the current particle system
  13111. */
  13112. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13113. /**
  13114. * Remove a specific color remap gradient
  13115. * @param gradient defines the gradient to remove
  13116. * @returns the current particle system
  13117. */
  13118. removeColorRemapGradient(gradient: number): IParticleSystem;
  13119. /**
  13120. * Adds a new alpha remap gradient
  13121. * @param gradient defines the gradient to use (between 0 and 1)
  13122. * @param min defines the alpha remap minimal range
  13123. * @param max defines the alpha remap maximal range
  13124. * @returns the current particle system
  13125. */
  13126. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13127. /**
  13128. * Remove a specific alpha remap gradient
  13129. * @param gradient defines the gradient to remove
  13130. * @returns the current particle system
  13131. */
  13132. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13133. /**
  13134. * Adds a new angular speed gradient
  13135. * @param gradient defines the gradient to use (between 0 and 1)
  13136. * @param factor defines the angular speed to affect to the specified gradient
  13137. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13138. * @returns the current particle system
  13139. */
  13140. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13141. /**
  13142. * Remove a specific angular speed gradient
  13143. * @param gradient defines the gradient to remove
  13144. * @returns the current particle system
  13145. */
  13146. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13147. /**
  13148. * Adds a new velocity gradient
  13149. * @param gradient defines the gradient to use (between 0 and 1)
  13150. * @param factor defines the velocity to affect to the specified gradient
  13151. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13152. * @returns the current particle system
  13153. */
  13154. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13155. /**
  13156. * Remove a specific velocity gradient
  13157. * @param gradient defines the gradient to remove
  13158. * @returns the current particle system
  13159. */
  13160. removeVelocityGradient(gradient: number): IParticleSystem;
  13161. /**
  13162. * Adds a new limit velocity gradient
  13163. * @param gradient defines the gradient to use (between 0 and 1)
  13164. * @param factor defines the limit velocity value to affect to the specified gradient
  13165. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13166. * @returns the current particle system
  13167. */
  13168. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13169. /**
  13170. * Remove a specific limit velocity gradient
  13171. * @param gradient defines the gradient to remove
  13172. * @returns the current particle system
  13173. */
  13174. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13175. /**
  13176. * Adds a new drag gradient
  13177. * @param gradient defines the gradient to use (between 0 and 1)
  13178. * @param factor defines the drag value to affect to the specified gradient
  13179. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13180. * @returns the current particle system
  13181. */
  13182. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13183. /**
  13184. * Remove a specific drag gradient
  13185. * @param gradient defines the gradient to remove
  13186. * @returns the current particle system
  13187. */
  13188. removeDragGradient(gradient: number): IParticleSystem;
  13189. /**
  13190. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13191. * @param gradient defines the gradient to use (between 0 and 1)
  13192. * @param factor defines the emit rate value to affect to the specified gradient
  13193. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13194. * @returns the current particle system
  13195. */
  13196. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13197. /**
  13198. * Remove a specific emit rate gradient
  13199. * @param gradient defines the gradient to remove
  13200. * @returns the current particle system
  13201. */
  13202. removeEmitRateGradient(gradient: number): IParticleSystem;
  13203. /**
  13204. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13205. * @param gradient defines the gradient to use (between 0 and 1)
  13206. * @param factor defines the start size value to affect to the specified gradient
  13207. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13208. * @returns the current particle system
  13209. */
  13210. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13211. /**
  13212. * Remove a specific start size gradient
  13213. * @param gradient defines the gradient to remove
  13214. * @returns the current particle system
  13215. */
  13216. removeStartSizeGradient(gradient: number): IParticleSystem;
  13217. private _createRampGradientTexture;
  13218. /**
  13219. * Gets the current list of ramp gradients.
  13220. * You must use addRampGradient and removeRampGradient to udpate this list
  13221. * @returns the list of ramp gradients
  13222. */
  13223. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13224. /** Force the system to rebuild all gradients that need to be resync */
  13225. forceRefreshGradients(): void;
  13226. private _syncRampGradientTexture;
  13227. /**
  13228. * Adds a new ramp gradient used to remap particle colors
  13229. * @param gradient defines the gradient to use (between 0 and 1)
  13230. * @param color defines the color to affect to the specified gradient
  13231. * @returns the current particle system
  13232. */
  13233. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13234. /**
  13235. * Remove a specific ramp gradient
  13236. * @param gradient defines the gradient to remove
  13237. * @returns the current particle system
  13238. */
  13239. removeRampGradient(gradient: number): ParticleSystem;
  13240. /**
  13241. * Adds a new color gradient
  13242. * @param gradient defines the gradient to use (between 0 and 1)
  13243. * @param color1 defines the color to affect to the specified gradient
  13244. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13245. * @returns this particle system
  13246. */
  13247. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13248. /**
  13249. * Remove a specific color gradient
  13250. * @param gradient defines the gradient to remove
  13251. * @returns this particle system
  13252. */
  13253. removeColorGradient(gradient: number): IParticleSystem;
  13254. private _fetchR;
  13255. protected _reset(): void;
  13256. private _resetEffect;
  13257. private _createVertexBuffers;
  13258. private _createIndexBuffer;
  13259. /**
  13260. * Gets the maximum number of particles active at the same time.
  13261. * @returns The max number of active particles.
  13262. */
  13263. getCapacity(): number;
  13264. /**
  13265. * Gets whether there are still active particles in the system.
  13266. * @returns True if it is alive, otherwise false.
  13267. */
  13268. isAlive(): boolean;
  13269. /**
  13270. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13271. * @returns True if it has been started, otherwise false.
  13272. */
  13273. isStarted(): boolean;
  13274. private _prepareSubEmitterInternalArray;
  13275. /**
  13276. * Starts the particle system and begins to emit
  13277. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13278. */
  13279. start(delay?: number): void;
  13280. /**
  13281. * Stops the particle system.
  13282. * @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.
  13283. */
  13284. stop(stopSubEmitters?: boolean): void;
  13285. /**
  13286. * Remove all active particles
  13287. */
  13288. reset(): void;
  13289. /**
  13290. * @hidden (for internal use only)
  13291. */
  13292. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13293. /**
  13294. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13295. * Its lifetime will start back at 0.
  13296. */
  13297. recycleParticle: (particle: Particle) => void;
  13298. private _stopSubEmitters;
  13299. private _createParticle;
  13300. private _removeFromRoot;
  13301. private _emitFromParticle;
  13302. private _update;
  13303. /** @hidden */
  13304. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13305. /** @hidden */
  13306. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13307. /**
  13308. * Fill the defines array according to the current settings of the particle system
  13309. * @param defines Array to be updated
  13310. * @param blendMode blend mode to take into account when updating the array
  13311. */
  13312. fillDefines(defines: Array<string>, blendMode: number): void;
  13313. /**
  13314. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13315. * @param uniforms Uniforms array to fill
  13316. * @param attributes Attributes array to fill
  13317. * @param samplers Samplers array to fill
  13318. */
  13319. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13320. /** @hidden */
  13321. private _getEffect;
  13322. /**
  13323. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13324. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13325. */
  13326. animate(preWarmOnly?: boolean): void;
  13327. private _appendParticleVertices;
  13328. /**
  13329. * Rebuilds the particle system.
  13330. */
  13331. rebuild(): void;
  13332. /**
  13333. * Is this system ready to be used/rendered
  13334. * @return true if the system is ready
  13335. */
  13336. isReady(): boolean;
  13337. private _render;
  13338. /**
  13339. * Renders the particle system in its current state.
  13340. * @returns the current number of particles
  13341. */
  13342. render(): number;
  13343. /**
  13344. * Disposes the particle system and free the associated resources
  13345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13346. */
  13347. dispose(disposeTexture?: boolean): void;
  13348. /**
  13349. * Clones the particle system.
  13350. * @param name The name of the cloned object
  13351. * @param newEmitter The new emitter to use
  13352. * @returns the cloned particle system
  13353. */
  13354. clone(name: string, newEmitter: any): ParticleSystem;
  13355. /**
  13356. * Serializes the particle system to a JSON object
  13357. * @param serializeTexture defines if the texture must be serialized as well
  13358. * @returns the JSON object
  13359. */
  13360. serialize(serializeTexture?: boolean): any;
  13361. /** @hidden */
  13362. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13363. /** @hidden */
  13364. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13365. /**
  13366. * Parses a JSON object to create a particle system.
  13367. * @param parsedParticleSystem The JSON object to parse
  13368. * @param sceneOrEngine The scene or the engine to create the particle system in
  13369. * @param rootUrl The root url to use to load external dependencies like texture
  13370. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13371. * @returns the Parsed particle system
  13372. */
  13373. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13374. }
  13375. }
  13376. declare module "babylonjs/Particles/particle" {
  13377. import { Nullable } from "babylonjs/types";
  13378. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13379. import { Color4 } from "babylonjs/Maths/math.color";
  13380. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13381. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13382. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13383. /**
  13384. * A particle represents one of the element emitted by a particle system.
  13385. * This is mainly define by its coordinates, direction, velocity and age.
  13386. */
  13387. export class Particle {
  13388. /**
  13389. * The particle system the particle belongs to.
  13390. */
  13391. particleSystem: ParticleSystem;
  13392. private static _Count;
  13393. /**
  13394. * Unique ID of the particle
  13395. */
  13396. id: number;
  13397. /**
  13398. * The world position of the particle in the scene.
  13399. */
  13400. position: Vector3;
  13401. /**
  13402. * The world direction of the particle in the scene.
  13403. */
  13404. direction: Vector3;
  13405. /**
  13406. * The color of the particle.
  13407. */
  13408. color: Color4;
  13409. /**
  13410. * The color change of the particle per step.
  13411. */
  13412. colorStep: Color4;
  13413. /**
  13414. * Defines how long will the life of the particle be.
  13415. */
  13416. lifeTime: number;
  13417. /**
  13418. * The current age of the particle.
  13419. */
  13420. age: number;
  13421. /**
  13422. * The current size of the particle.
  13423. */
  13424. size: number;
  13425. /**
  13426. * The current scale of the particle.
  13427. */
  13428. scale: Vector2;
  13429. /**
  13430. * The current angle of the particle.
  13431. */
  13432. angle: number;
  13433. /**
  13434. * Defines how fast is the angle changing.
  13435. */
  13436. angularSpeed: number;
  13437. /**
  13438. * Defines the cell index used by the particle to be rendered from a sprite.
  13439. */
  13440. cellIndex: number;
  13441. /**
  13442. * The information required to support color remapping
  13443. */
  13444. remapData: Vector4;
  13445. /** @hidden */
  13446. _randomCellOffset?: number;
  13447. /** @hidden */
  13448. _initialDirection: Nullable<Vector3>;
  13449. /** @hidden */
  13450. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13451. /** @hidden */
  13452. _initialStartSpriteCellID: number;
  13453. /** @hidden */
  13454. _initialEndSpriteCellID: number;
  13455. /** @hidden */
  13456. _currentColorGradient: Nullable<ColorGradient>;
  13457. /** @hidden */
  13458. _currentColor1: Color4;
  13459. /** @hidden */
  13460. _currentColor2: Color4;
  13461. /** @hidden */
  13462. _currentSizeGradient: Nullable<FactorGradient>;
  13463. /** @hidden */
  13464. _currentSize1: number;
  13465. /** @hidden */
  13466. _currentSize2: number;
  13467. /** @hidden */
  13468. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13469. /** @hidden */
  13470. _currentAngularSpeed1: number;
  13471. /** @hidden */
  13472. _currentAngularSpeed2: number;
  13473. /** @hidden */
  13474. _currentVelocityGradient: Nullable<FactorGradient>;
  13475. /** @hidden */
  13476. _currentVelocity1: number;
  13477. /** @hidden */
  13478. _currentVelocity2: number;
  13479. /** @hidden */
  13480. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13481. /** @hidden */
  13482. _currentLimitVelocity1: number;
  13483. /** @hidden */
  13484. _currentLimitVelocity2: number;
  13485. /** @hidden */
  13486. _currentDragGradient: Nullable<FactorGradient>;
  13487. /** @hidden */
  13488. _currentDrag1: number;
  13489. /** @hidden */
  13490. _currentDrag2: number;
  13491. /** @hidden */
  13492. _randomNoiseCoordinates1: Vector3;
  13493. /** @hidden */
  13494. _randomNoiseCoordinates2: Vector3;
  13495. /** @hidden */
  13496. _localPosition?: Vector3;
  13497. /**
  13498. * Creates a new instance Particle
  13499. * @param particleSystem the particle system the particle belongs to
  13500. */
  13501. constructor(
  13502. /**
  13503. * The particle system the particle belongs to.
  13504. */
  13505. particleSystem: ParticleSystem);
  13506. private updateCellInfoFromSystem;
  13507. /**
  13508. * Defines how the sprite cell index is updated for the particle
  13509. */
  13510. updateCellIndex(): void;
  13511. /** @hidden */
  13512. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13513. /** @hidden */
  13514. _inheritParticleInfoToSubEmitters(): void;
  13515. /** @hidden */
  13516. _reset(): void;
  13517. /**
  13518. * Copy the properties of particle to another one.
  13519. * @param other the particle to copy the information to.
  13520. */
  13521. copyTo(other: Particle): void;
  13522. }
  13523. }
  13524. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13525. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13526. import { Effect } from "babylonjs/Materials/effect";
  13527. import { Particle } from "babylonjs/Particles/particle";
  13528. import { Nullable } from "babylonjs/types";
  13529. import { Scene } from "babylonjs/scene";
  13530. /**
  13531. * Particle emitter represents a volume emitting particles.
  13532. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13533. */
  13534. export interface IParticleEmitterType {
  13535. /**
  13536. * Called by the particle System when the direction is computed for the created particle.
  13537. * @param worldMatrix is the world matrix of the particle system
  13538. * @param directionToUpdate is the direction vector to update with the result
  13539. * @param particle is the particle we are computed the direction for
  13540. * @param isLocal defines if the direction should be set in local space
  13541. */
  13542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13543. /**
  13544. * Called by the particle System when the position is computed for the created particle.
  13545. * @param worldMatrix is the world matrix of the particle system
  13546. * @param positionToUpdate is the position vector to update with the result
  13547. * @param particle is the particle we are computed the position for
  13548. * @param isLocal defines if the position should be set in local space
  13549. */
  13550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13551. /**
  13552. * Clones the current emitter and returns a copy of it
  13553. * @returns the new emitter
  13554. */
  13555. clone(): IParticleEmitterType;
  13556. /**
  13557. * Called by the GPUParticleSystem to setup the update shader
  13558. * @param effect defines the update shader
  13559. */
  13560. applyToShader(effect: Effect): void;
  13561. /**
  13562. * Returns a string to use to update the GPU particles update shader
  13563. * @returns the effect defines string
  13564. */
  13565. getEffectDefines(): string;
  13566. /**
  13567. * Returns a string representing the class name
  13568. * @returns a string containing the class name
  13569. */
  13570. getClassName(): string;
  13571. /**
  13572. * Serializes the particle system to a JSON object.
  13573. * @returns the JSON object
  13574. */
  13575. serialize(): any;
  13576. /**
  13577. * Parse properties from a JSON object
  13578. * @param serializationObject defines the JSON object
  13579. * @param scene defines the hosting scene
  13580. */
  13581. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13582. }
  13583. }
  13584. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13585. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13586. import { Effect } from "babylonjs/Materials/effect";
  13587. import { Particle } from "babylonjs/Particles/particle";
  13588. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13589. /**
  13590. * Particle emitter emitting particles from the inside of a box.
  13591. * It emits the particles randomly between 2 given directions.
  13592. */
  13593. export class BoxParticleEmitter implements IParticleEmitterType {
  13594. /**
  13595. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13596. */
  13597. direction1: Vector3;
  13598. /**
  13599. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13600. */
  13601. direction2: Vector3;
  13602. /**
  13603. * 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.
  13604. */
  13605. minEmitBox: Vector3;
  13606. /**
  13607. * 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.
  13608. */
  13609. maxEmitBox: Vector3;
  13610. /**
  13611. * Creates a new instance BoxParticleEmitter
  13612. */
  13613. constructor();
  13614. /**
  13615. * Called by the particle System when the direction is computed for the created particle.
  13616. * @param worldMatrix is the world matrix of the particle system
  13617. * @param directionToUpdate is the direction vector to update with the result
  13618. * @param particle is the particle we are computed the direction for
  13619. * @param isLocal defines if the direction should be set in local space
  13620. */
  13621. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13622. /**
  13623. * Called by the particle System when the position is computed for the created particle.
  13624. * @param worldMatrix is the world matrix of the particle system
  13625. * @param positionToUpdate is the position vector to update with the result
  13626. * @param particle is the particle we are computed the position for
  13627. * @param isLocal defines if the position should be set in local space
  13628. */
  13629. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13630. /**
  13631. * Clones the current emitter and returns a copy of it
  13632. * @returns the new emitter
  13633. */
  13634. clone(): BoxParticleEmitter;
  13635. /**
  13636. * Called by the GPUParticleSystem to setup the update shader
  13637. * @param effect defines the update shader
  13638. */
  13639. applyToShader(effect: Effect): void;
  13640. /**
  13641. * Returns a string to use to update the GPU particles update shader
  13642. * @returns a string containng the defines string
  13643. */
  13644. getEffectDefines(): string;
  13645. /**
  13646. * Returns the string "BoxParticleEmitter"
  13647. * @returns a string containing the class name
  13648. */
  13649. getClassName(): string;
  13650. /**
  13651. * Serializes the particle system to a JSON object.
  13652. * @returns the JSON object
  13653. */
  13654. serialize(): any;
  13655. /**
  13656. * Parse properties from a JSON object
  13657. * @param serializationObject defines the JSON object
  13658. */
  13659. parse(serializationObject: any): void;
  13660. }
  13661. }
  13662. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13663. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13664. import { Effect } from "babylonjs/Materials/effect";
  13665. import { Particle } from "babylonjs/Particles/particle";
  13666. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13667. /**
  13668. * Particle emitter emitting particles from the inside of a cone.
  13669. * It emits the particles alongside the cone volume from the base to the particle.
  13670. * The emission direction might be randomized.
  13671. */
  13672. export class ConeParticleEmitter implements IParticleEmitterType {
  13673. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13674. directionRandomizer: number;
  13675. private _radius;
  13676. private _angle;
  13677. private _height;
  13678. /**
  13679. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13680. */
  13681. radiusRange: number;
  13682. /**
  13683. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13684. */
  13685. heightRange: number;
  13686. /**
  13687. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13688. */
  13689. emitFromSpawnPointOnly: boolean;
  13690. /**
  13691. * Gets or sets the radius of the emission cone
  13692. */
  13693. get radius(): number;
  13694. set radius(value: number);
  13695. /**
  13696. * Gets or sets the angle of the emission cone
  13697. */
  13698. get angle(): number;
  13699. set angle(value: number);
  13700. private _buildHeight;
  13701. /**
  13702. * Creates a new instance ConeParticleEmitter
  13703. * @param radius the radius of the emission cone (1 by default)
  13704. * @param angle the cone base angle (PI by default)
  13705. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13706. */
  13707. constructor(radius?: number, angle?: number,
  13708. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13709. directionRandomizer?: number);
  13710. /**
  13711. * Called by the particle System when the direction is computed for the created particle.
  13712. * @param worldMatrix is the world matrix of the particle system
  13713. * @param directionToUpdate is the direction vector to update with the result
  13714. * @param particle is the particle we are computed the direction for
  13715. * @param isLocal defines if the direction should be set in local space
  13716. */
  13717. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13718. /**
  13719. * Called by the particle System when the position is computed for the created particle.
  13720. * @param worldMatrix is the world matrix of the particle system
  13721. * @param positionToUpdate is the position vector to update with the result
  13722. * @param particle is the particle we are computed the position for
  13723. * @param isLocal defines if the position should be set in local space
  13724. */
  13725. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13726. /**
  13727. * Clones the current emitter and returns a copy of it
  13728. * @returns the new emitter
  13729. */
  13730. clone(): ConeParticleEmitter;
  13731. /**
  13732. * Called by the GPUParticleSystem to setup the update shader
  13733. * @param effect defines the update shader
  13734. */
  13735. applyToShader(effect: Effect): void;
  13736. /**
  13737. * Returns a string to use to update the GPU particles update shader
  13738. * @returns a string containng the defines string
  13739. */
  13740. getEffectDefines(): string;
  13741. /**
  13742. * Returns the string "ConeParticleEmitter"
  13743. * @returns a string containing the class name
  13744. */
  13745. getClassName(): string;
  13746. /**
  13747. * Serializes the particle system to a JSON object.
  13748. * @returns the JSON object
  13749. */
  13750. serialize(): any;
  13751. /**
  13752. * Parse properties from a JSON object
  13753. * @param serializationObject defines the JSON object
  13754. */
  13755. parse(serializationObject: any): void;
  13756. }
  13757. }
  13758. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13759. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13760. import { Effect } from "babylonjs/Materials/effect";
  13761. import { Particle } from "babylonjs/Particles/particle";
  13762. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13763. /**
  13764. * Particle emitter emitting particles from the inside of a cylinder.
  13765. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13766. */
  13767. export class CylinderParticleEmitter implements IParticleEmitterType {
  13768. /**
  13769. * The radius of the emission cylinder.
  13770. */
  13771. radius: number;
  13772. /**
  13773. * The height of the emission cylinder.
  13774. */
  13775. height: number;
  13776. /**
  13777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13778. */
  13779. radiusRange: number;
  13780. /**
  13781. * How much to randomize the particle direction [0-1].
  13782. */
  13783. directionRandomizer: number;
  13784. /**
  13785. * Creates a new instance CylinderParticleEmitter
  13786. * @param radius the radius of the emission cylinder (1 by default)
  13787. * @param height the height of the emission cylinder (1 by default)
  13788. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13789. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13790. */
  13791. constructor(
  13792. /**
  13793. * The radius of the emission cylinder.
  13794. */
  13795. radius?: number,
  13796. /**
  13797. * The height of the emission cylinder.
  13798. */
  13799. height?: number,
  13800. /**
  13801. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13802. */
  13803. radiusRange?: number,
  13804. /**
  13805. * How much to randomize the particle direction [0-1].
  13806. */
  13807. directionRandomizer?: number);
  13808. /**
  13809. * Called by the particle System when the direction is computed for the created particle.
  13810. * @param worldMatrix is the world matrix of the particle system
  13811. * @param directionToUpdate is the direction vector to update with the result
  13812. * @param particle is the particle we are computed the direction for
  13813. * @param isLocal defines if the direction should be set in local space
  13814. */
  13815. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13816. /**
  13817. * Called by the particle System when the position is computed for the created particle.
  13818. * @param worldMatrix is the world matrix of the particle system
  13819. * @param positionToUpdate is the position vector to update with the result
  13820. * @param particle is the particle we are computed the position for
  13821. * @param isLocal defines if the position should be set in local space
  13822. */
  13823. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13824. /**
  13825. * Clones the current emitter and returns a copy of it
  13826. * @returns the new emitter
  13827. */
  13828. clone(): CylinderParticleEmitter;
  13829. /**
  13830. * Called by the GPUParticleSystem to setup the update shader
  13831. * @param effect defines the update shader
  13832. */
  13833. applyToShader(effect: Effect): void;
  13834. /**
  13835. * Returns a string to use to update the GPU particles update shader
  13836. * @returns a string containng the defines string
  13837. */
  13838. getEffectDefines(): string;
  13839. /**
  13840. * Returns the string "CylinderParticleEmitter"
  13841. * @returns a string containing the class name
  13842. */
  13843. getClassName(): string;
  13844. /**
  13845. * Serializes the particle system to a JSON object.
  13846. * @returns the JSON object
  13847. */
  13848. serialize(): any;
  13849. /**
  13850. * Parse properties from a JSON object
  13851. * @param serializationObject defines the JSON object
  13852. */
  13853. parse(serializationObject: any): void;
  13854. }
  13855. /**
  13856. * Particle emitter emitting particles from the inside of a cylinder.
  13857. * It emits the particles randomly between two vectors.
  13858. */
  13859. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13860. /**
  13861. * The min limit of the emission direction.
  13862. */
  13863. direction1: Vector3;
  13864. /**
  13865. * The max limit of the emission direction.
  13866. */
  13867. direction2: Vector3;
  13868. /**
  13869. * Creates a new instance CylinderDirectedParticleEmitter
  13870. * @param radius the radius of the emission cylinder (1 by default)
  13871. * @param height the height of the emission cylinder (1 by default)
  13872. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13873. * @param direction1 the min limit of the emission direction (up vector by default)
  13874. * @param direction2 the max limit of the emission direction (up vector by default)
  13875. */
  13876. constructor(radius?: number, height?: number, radiusRange?: number,
  13877. /**
  13878. * The min limit of the emission direction.
  13879. */
  13880. direction1?: Vector3,
  13881. /**
  13882. * The max limit of the emission direction.
  13883. */
  13884. direction2?: Vector3);
  13885. /**
  13886. * Called by the particle System when the direction is computed for the created particle.
  13887. * @param worldMatrix is the world matrix of the particle system
  13888. * @param directionToUpdate is the direction vector to update with the result
  13889. * @param particle is the particle we are computed the direction for
  13890. */
  13891. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13892. /**
  13893. * Clones the current emitter and returns a copy of it
  13894. * @returns the new emitter
  13895. */
  13896. clone(): CylinderDirectedParticleEmitter;
  13897. /**
  13898. * Called by the GPUParticleSystem to setup the update shader
  13899. * @param effect defines the update shader
  13900. */
  13901. applyToShader(effect: Effect): void;
  13902. /**
  13903. * Returns a string to use to update the GPU particles update shader
  13904. * @returns a string containng the defines string
  13905. */
  13906. getEffectDefines(): string;
  13907. /**
  13908. * Returns the string "CylinderDirectedParticleEmitter"
  13909. * @returns a string containing the class name
  13910. */
  13911. getClassName(): string;
  13912. /**
  13913. * Serializes the particle system to a JSON object.
  13914. * @returns the JSON object
  13915. */
  13916. serialize(): any;
  13917. /**
  13918. * Parse properties from a JSON object
  13919. * @param serializationObject defines the JSON object
  13920. */
  13921. parse(serializationObject: any): void;
  13922. }
  13923. }
  13924. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13925. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13926. import { Effect } from "babylonjs/Materials/effect";
  13927. import { Particle } from "babylonjs/Particles/particle";
  13928. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13929. /**
  13930. * Particle emitter emitting particles from the inside of a hemisphere.
  13931. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13932. */
  13933. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13934. /**
  13935. * The radius of the emission hemisphere.
  13936. */
  13937. radius: number;
  13938. /**
  13939. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13940. */
  13941. radiusRange: number;
  13942. /**
  13943. * How much to randomize the particle direction [0-1].
  13944. */
  13945. directionRandomizer: number;
  13946. /**
  13947. * Creates a new instance HemisphericParticleEmitter
  13948. * @param radius the radius of the emission hemisphere (1 by default)
  13949. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13950. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13951. */
  13952. constructor(
  13953. /**
  13954. * The radius of the emission hemisphere.
  13955. */
  13956. radius?: number,
  13957. /**
  13958. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13959. */
  13960. radiusRange?: number,
  13961. /**
  13962. * How much to randomize the particle direction [0-1].
  13963. */
  13964. directionRandomizer?: number);
  13965. /**
  13966. * Called by the particle System when the direction is computed for the created particle.
  13967. * @param worldMatrix is the world matrix of the particle system
  13968. * @param directionToUpdate is the direction vector to update with the result
  13969. * @param particle is the particle we are computed the direction for
  13970. * @param isLocal defines if the direction should be set in local space
  13971. */
  13972. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13973. /**
  13974. * Called by the particle System when the position is computed for the created particle.
  13975. * @param worldMatrix is the world matrix of the particle system
  13976. * @param positionToUpdate is the position vector to update with the result
  13977. * @param particle is the particle we are computed the position for
  13978. * @param isLocal defines if the position should be set in local space
  13979. */
  13980. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13981. /**
  13982. * Clones the current emitter and returns a copy of it
  13983. * @returns the new emitter
  13984. */
  13985. clone(): HemisphericParticleEmitter;
  13986. /**
  13987. * Called by the GPUParticleSystem to setup the update shader
  13988. * @param effect defines the update shader
  13989. */
  13990. applyToShader(effect: Effect): void;
  13991. /**
  13992. * Returns a string to use to update the GPU particles update shader
  13993. * @returns a string containng the defines string
  13994. */
  13995. getEffectDefines(): string;
  13996. /**
  13997. * Returns the string "HemisphericParticleEmitter"
  13998. * @returns a string containing the class name
  13999. */
  14000. getClassName(): string;
  14001. /**
  14002. * Serializes the particle system to a JSON object.
  14003. * @returns the JSON object
  14004. */
  14005. serialize(): any;
  14006. /**
  14007. * Parse properties from a JSON object
  14008. * @param serializationObject defines the JSON object
  14009. */
  14010. parse(serializationObject: any): void;
  14011. }
  14012. }
  14013. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14014. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14015. import { Effect } from "babylonjs/Materials/effect";
  14016. import { Particle } from "babylonjs/Particles/particle";
  14017. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14018. /**
  14019. * Particle emitter emitting particles from a point.
  14020. * It emits the particles randomly between 2 given directions.
  14021. */
  14022. export class PointParticleEmitter implements IParticleEmitterType {
  14023. /**
  14024. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14025. */
  14026. direction1: Vector3;
  14027. /**
  14028. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14029. */
  14030. direction2: Vector3;
  14031. /**
  14032. * Creates a new instance PointParticleEmitter
  14033. */
  14034. constructor();
  14035. /**
  14036. * Called by the particle System when the direction is computed for the created particle.
  14037. * @param worldMatrix is the world matrix of the particle system
  14038. * @param directionToUpdate is the direction vector to update with the result
  14039. * @param particle is the particle we are computed the direction for
  14040. * @param isLocal defines if the direction should be set in local space
  14041. */
  14042. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14043. /**
  14044. * Called by the particle System when the position is computed for the created particle.
  14045. * @param worldMatrix is the world matrix of the particle system
  14046. * @param positionToUpdate is the position vector to update with the result
  14047. * @param particle is the particle we are computed the position for
  14048. * @param isLocal defines if the position should be set in local space
  14049. */
  14050. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14051. /**
  14052. * Clones the current emitter and returns a copy of it
  14053. * @returns the new emitter
  14054. */
  14055. clone(): PointParticleEmitter;
  14056. /**
  14057. * Called by the GPUParticleSystem to setup the update shader
  14058. * @param effect defines the update shader
  14059. */
  14060. applyToShader(effect: Effect): void;
  14061. /**
  14062. * Returns a string to use to update the GPU particles update shader
  14063. * @returns a string containng the defines string
  14064. */
  14065. getEffectDefines(): string;
  14066. /**
  14067. * Returns the string "PointParticleEmitter"
  14068. * @returns a string containing the class name
  14069. */
  14070. getClassName(): string;
  14071. /**
  14072. * Serializes the particle system to a JSON object.
  14073. * @returns the JSON object
  14074. */
  14075. serialize(): any;
  14076. /**
  14077. * Parse properties from a JSON object
  14078. * @param serializationObject defines the JSON object
  14079. */
  14080. parse(serializationObject: any): void;
  14081. }
  14082. }
  14083. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14084. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14085. import { Effect } from "babylonjs/Materials/effect";
  14086. import { Particle } from "babylonjs/Particles/particle";
  14087. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14088. /**
  14089. * Particle emitter emitting particles from the inside of a sphere.
  14090. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14091. */
  14092. export class SphereParticleEmitter implements IParticleEmitterType {
  14093. /**
  14094. * The radius of the emission sphere.
  14095. */
  14096. radius: number;
  14097. /**
  14098. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14099. */
  14100. radiusRange: number;
  14101. /**
  14102. * How much to randomize the particle direction [0-1].
  14103. */
  14104. directionRandomizer: number;
  14105. /**
  14106. * Creates a new instance SphereParticleEmitter
  14107. * @param radius the radius of the emission sphere (1 by default)
  14108. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14109. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14110. */
  14111. constructor(
  14112. /**
  14113. * The radius of the emission sphere.
  14114. */
  14115. radius?: number,
  14116. /**
  14117. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14118. */
  14119. radiusRange?: number,
  14120. /**
  14121. * How much to randomize the particle direction [0-1].
  14122. */
  14123. directionRandomizer?: number);
  14124. /**
  14125. * Called by the particle System when the direction is computed for the created particle.
  14126. * @param worldMatrix is the world matrix of the particle system
  14127. * @param directionToUpdate is the direction vector to update with the result
  14128. * @param particle is the particle we are computed the direction for
  14129. * @param isLocal defines if the direction should be set in local space
  14130. */
  14131. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14132. /**
  14133. * Called by the particle System when the position is computed for the created particle.
  14134. * @param worldMatrix is the world matrix of the particle system
  14135. * @param positionToUpdate is the position vector to update with the result
  14136. * @param particle is the particle we are computed the position for
  14137. * @param isLocal defines if the position should be set in local space
  14138. */
  14139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14140. /**
  14141. * Clones the current emitter and returns a copy of it
  14142. * @returns the new emitter
  14143. */
  14144. clone(): SphereParticleEmitter;
  14145. /**
  14146. * Called by the GPUParticleSystem to setup the update shader
  14147. * @param effect defines the update shader
  14148. */
  14149. applyToShader(effect: Effect): void;
  14150. /**
  14151. * Returns a string to use to update the GPU particles update shader
  14152. * @returns a string containng the defines string
  14153. */
  14154. getEffectDefines(): string;
  14155. /**
  14156. * Returns the string "SphereParticleEmitter"
  14157. * @returns a string containing the class name
  14158. */
  14159. getClassName(): string;
  14160. /**
  14161. * Serializes the particle system to a JSON object.
  14162. * @returns the JSON object
  14163. */
  14164. serialize(): any;
  14165. /**
  14166. * Parse properties from a JSON object
  14167. * @param serializationObject defines the JSON object
  14168. */
  14169. parse(serializationObject: any): void;
  14170. }
  14171. /**
  14172. * Particle emitter emitting particles from the inside of a sphere.
  14173. * It emits the particles randomly between two vectors.
  14174. */
  14175. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14176. /**
  14177. * The min limit of the emission direction.
  14178. */
  14179. direction1: Vector3;
  14180. /**
  14181. * The max limit of the emission direction.
  14182. */
  14183. direction2: Vector3;
  14184. /**
  14185. * Creates a new instance SphereDirectedParticleEmitter
  14186. * @param radius the radius of the emission sphere (1 by default)
  14187. * @param direction1 the min limit of the emission direction (up vector by default)
  14188. * @param direction2 the max limit of the emission direction (up vector by default)
  14189. */
  14190. constructor(radius?: number,
  14191. /**
  14192. * The min limit of the emission direction.
  14193. */
  14194. direction1?: Vector3,
  14195. /**
  14196. * The max limit of the emission direction.
  14197. */
  14198. direction2?: Vector3);
  14199. /**
  14200. * Called by the particle System when the direction is computed for the created particle.
  14201. * @param worldMatrix is the world matrix of the particle system
  14202. * @param directionToUpdate is the direction vector to update with the result
  14203. * @param particle is the particle we are computed the direction for
  14204. */
  14205. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14206. /**
  14207. * Clones the current emitter and returns a copy of it
  14208. * @returns the new emitter
  14209. */
  14210. clone(): SphereDirectedParticleEmitter;
  14211. /**
  14212. * Called by the GPUParticleSystem to setup the update shader
  14213. * @param effect defines the update shader
  14214. */
  14215. applyToShader(effect: Effect): void;
  14216. /**
  14217. * Returns a string to use to update the GPU particles update shader
  14218. * @returns a string containng the defines string
  14219. */
  14220. getEffectDefines(): string;
  14221. /**
  14222. * Returns the string "SphereDirectedParticleEmitter"
  14223. * @returns a string containing the class name
  14224. */
  14225. getClassName(): string;
  14226. /**
  14227. * Serializes the particle system to a JSON object.
  14228. * @returns the JSON object
  14229. */
  14230. serialize(): any;
  14231. /**
  14232. * Parse properties from a JSON object
  14233. * @param serializationObject defines the JSON object
  14234. */
  14235. parse(serializationObject: any): void;
  14236. }
  14237. }
  14238. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14240. import { Effect } from "babylonjs/Materials/effect";
  14241. import { Particle } from "babylonjs/Particles/particle";
  14242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14243. import { Nullable } from "babylonjs/types";
  14244. /**
  14245. * Particle emitter emitting particles from a custom list of positions.
  14246. */
  14247. export class CustomParticleEmitter implements IParticleEmitterType {
  14248. /**
  14249. * Gets or sets the position generator that will create the inital position of each particle.
  14250. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14251. */
  14252. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14253. /**
  14254. * Gets or sets the destination generator that will create the final destination of each particle.
  14255. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14256. */
  14257. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14258. /**
  14259. * Creates a new instance CustomParticleEmitter
  14260. */
  14261. constructor();
  14262. /**
  14263. * Called by the particle System when the direction is computed for the created particle.
  14264. * @param worldMatrix is the world matrix of the particle system
  14265. * @param directionToUpdate is the direction vector to update with the result
  14266. * @param particle is the particle we are computed the direction for
  14267. * @param isLocal defines if the direction should be set in local space
  14268. */
  14269. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14270. /**
  14271. * Called by the particle System when the position is computed for the created particle.
  14272. * @param worldMatrix is the world matrix of the particle system
  14273. * @param positionToUpdate is the position vector to update with the result
  14274. * @param particle is the particle we are computed the position for
  14275. * @param isLocal defines if the position should be set in local space
  14276. */
  14277. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14278. /**
  14279. * Clones the current emitter and returns a copy of it
  14280. * @returns the new emitter
  14281. */
  14282. clone(): CustomParticleEmitter;
  14283. /**
  14284. * Called by the GPUParticleSystem to setup the update shader
  14285. * @param effect defines the update shader
  14286. */
  14287. applyToShader(effect: Effect): void;
  14288. /**
  14289. * Returns a string to use to update the GPU particles update shader
  14290. * @returns a string containng the defines string
  14291. */
  14292. getEffectDefines(): string;
  14293. /**
  14294. * Returns the string "PointParticleEmitter"
  14295. * @returns a string containing the class name
  14296. */
  14297. getClassName(): string;
  14298. /**
  14299. * Serializes the particle system to a JSON object.
  14300. * @returns the JSON object
  14301. */
  14302. serialize(): any;
  14303. /**
  14304. * Parse properties from a JSON object
  14305. * @param serializationObject defines the JSON object
  14306. */
  14307. parse(serializationObject: any): void;
  14308. }
  14309. }
  14310. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14311. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14312. import { Effect } from "babylonjs/Materials/effect";
  14313. import { Particle } from "babylonjs/Particles/particle";
  14314. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14315. import { Nullable } from "babylonjs/types";
  14316. import { Scene } from "babylonjs/scene";
  14317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14318. /**
  14319. * Particle emitter emitting particles from the inside of a box.
  14320. * It emits the particles randomly between 2 given directions.
  14321. */
  14322. export class MeshParticleEmitter implements IParticleEmitterType {
  14323. private _indices;
  14324. private _positions;
  14325. private _normals;
  14326. private _storedNormal;
  14327. private _mesh;
  14328. /**
  14329. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14330. */
  14331. direction1: Vector3;
  14332. /**
  14333. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14334. */
  14335. direction2: Vector3;
  14336. /**
  14337. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14338. */
  14339. useMeshNormalsForDirection: boolean;
  14340. /** Defines the mesh to use as source */
  14341. get mesh(): Nullable<AbstractMesh>;
  14342. set mesh(value: Nullable<AbstractMesh>);
  14343. /**
  14344. * Creates a new instance MeshParticleEmitter
  14345. * @param mesh defines the mesh to use as source
  14346. */
  14347. constructor(mesh?: Nullable<AbstractMesh>);
  14348. /**
  14349. * Called by the particle System when the direction is computed for the created particle.
  14350. * @param worldMatrix is the world matrix of the particle system
  14351. * @param directionToUpdate is the direction vector to update with the result
  14352. * @param particle is the particle we are computed the direction for
  14353. * @param isLocal defines if the direction should be set in local space
  14354. */
  14355. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14356. /**
  14357. * Called by the particle System when the position is computed for the created particle.
  14358. * @param worldMatrix is the world matrix of the particle system
  14359. * @param positionToUpdate is the position vector to update with the result
  14360. * @param particle is the particle we are computed the position for
  14361. * @param isLocal defines if the position should be set in local space
  14362. */
  14363. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14364. /**
  14365. * Clones the current emitter and returns a copy of it
  14366. * @returns the new emitter
  14367. */
  14368. clone(): MeshParticleEmitter;
  14369. /**
  14370. * Called by the GPUParticleSystem to setup the update shader
  14371. * @param effect defines the update shader
  14372. */
  14373. applyToShader(effect: Effect): void;
  14374. /**
  14375. * Returns a string to use to update the GPU particles update shader
  14376. * @returns a string containng the defines string
  14377. */
  14378. getEffectDefines(): string;
  14379. /**
  14380. * Returns the string "BoxParticleEmitter"
  14381. * @returns a string containing the class name
  14382. */
  14383. getClassName(): string;
  14384. /**
  14385. * Serializes the particle system to a JSON object.
  14386. * @returns the JSON object
  14387. */
  14388. serialize(): any;
  14389. /**
  14390. * Parse properties from a JSON object
  14391. * @param serializationObject defines the JSON object
  14392. * @param scene defines the hosting scene
  14393. */
  14394. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14395. }
  14396. }
  14397. declare module "babylonjs/Particles/EmitterTypes/index" {
  14398. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14399. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14400. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14401. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14402. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14403. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14404. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14405. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14406. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14407. }
  14408. declare module "babylonjs/Particles/IParticleSystem" {
  14409. import { Nullable } from "babylonjs/types";
  14410. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14411. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14413. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14414. import { Scene } from "babylonjs/scene";
  14415. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14416. import { Effect } from "babylonjs/Materials/effect";
  14417. import { Observable } from "babylonjs/Misc/observable";
  14418. import { Animation } from "babylonjs/Animations/animation";
  14419. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14420. /**
  14421. * Interface representing a particle system in Babylon.js.
  14422. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14423. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14424. */
  14425. export interface IParticleSystem {
  14426. /**
  14427. * List of animations used by the particle system.
  14428. */
  14429. animations: Animation[];
  14430. /**
  14431. * The id of the Particle system.
  14432. */
  14433. id: string;
  14434. /**
  14435. * The name of the Particle system.
  14436. */
  14437. name: string;
  14438. /**
  14439. * The emitter represents the Mesh or position we are attaching the particle system to.
  14440. */
  14441. emitter: Nullable<AbstractMesh | Vector3>;
  14442. /**
  14443. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14444. */
  14445. isBillboardBased: boolean;
  14446. /**
  14447. * The rendering group used by the Particle system to chose when to render.
  14448. */
  14449. renderingGroupId: number;
  14450. /**
  14451. * The layer mask we are rendering the particles through.
  14452. */
  14453. layerMask: number;
  14454. /**
  14455. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14456. */
  14457. updateSpeed: number;
  14458. /**
  14459. * The amount of time the particle system is running (depends of the overall update speed).
  14460. */
  14461. targetStopDuration: number;
  14462. /**
  14463. * The texture used to render each particle. (this can be a spritesheet)
  14464. */
  14465. particleTexture: Nullable<BaseTexture>;
  14466. /**
  14467. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14468. */
  14469. blendMode: number;
  14470. /**
  14471. * Minimum life time of emitting particles.
  14472. */
  14473. minLifeTime: number;
  14474. /**
  14475. * Maximum life time of emitting particles.
  14476. */
  14477. maxLifeTime: number;
  14478. /**
  14479. * Minimum Size of emitting particles.
  14480. */
  14481. minSize: number;
  14482. /**
  14483. * Maximum Size of emitting particles.
  14484. */
  14485. maxSize: number;
  14486. /**
  14487. * Minimum scale of emitting particles on X axis.
  14488. */
  14489. minScaleX: number;
  14490. /**
  14491. * Maximum scale of emitting particles on X axis.
  14492. */
  14493. maxScaleX: number;
  14494. /**
  14495. * Minimum scale of emitting particles on Y axis.
  14496. */
  14497. minScaleY: number;
  14498. /**
  14499. * Maximum scale of emitting particles on Y axis.
  14500. */
  14501. maxScaleY: number;
  14502. /**
  14503. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14504. */
  14505. color1: Color4;
  14506. /**
  14507. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14508. */
  14509. color2: Color4;
  14510. /**
  14511. * Color the particle will have at the end of its lifetime.
  14512. */
  14513. colorDead: Color4;
  14514. /**
  14515. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14516. */
  14517. emitRate: number;
  14518. /**
  14519. * You can use gravity if you want to give an orientation to your particles.
  14520. */
  14521. gravity: Vector3;
  14522. /**
  14523. * Minimum power of emitting particles.
  14524. */
  14525. minEmitPower: number;
  14526. /**
  14527. * Maximum power of emitting particles.
  14528. */
  14529. maxEmitPower: number;
  14530. /**
  14531. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. minAngularSpeed: number;
  14534. /**
  14535. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14536. */
  14537. maxAngularSpeed: number;
  14538. /**
  14539. * Gets or sets the minimal initial rotation in radians.
  14540. */
  14541. minInitialRotation: number;
  14542. /**
  14543. * Gets or sets the maximal initial rotation in radians.
  14544. */
  14545. maxInitialRotation: number;
  14546. /**
  14547. * The particle emitter type defines the emitter used by the particle system.
  14548. * It can be for example box, sphere, or cone...
  14549. */
  14550. particleEmitterType: Nullable<IParticleEmitterType>;
  14551. /**
  14552. * Defines the delay in milliseconds before starting the system (0 by default)
  14553. */
  14554. startDelay: number;
  14555. /**
  14556. * 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
  14557. */
  14558. preWarmCycles: number;
  14559. /**
  14560. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14561. */
  14562. preWarmStepOffset: number;
  14563. /**
  14564. * 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)
  14565. */
  14566. spriteCellChangeSpeed: number;
  14567. /**
  14568. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14569. */
  14570. startSpriteCellID: number;
  14571. /**
  14572. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14573. */
  14574. endSpriteCellID: number;
  14575. /**
  14576. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14577. */
  14578. spriteCellWidth: number;
  14579. /**
  14580. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14581. */
  14582. spriteCellHeight: number;
  14583. /**
  14584. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14585. */
  14586. spriteRandomStartCell: boolean;
  14587. /**
  14588. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14589. */
  14590. isAnimationSheetEnabled: boolean;
  14591. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14592. translationPivot: Vector2;
  14593. /**
  14594. * Gets or sets a texture used to add random noise to particle positions
  14595. */
  14596. noiseTexture: Nullable<BaseTexture>;
  14597. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14598. noiseStrength: Vector3;
  14599. /**
  14600. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14601. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14602. */
  14603. billboardMode: number;
  14604. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14605. limitVelocityDamping: number;
  14606. /**
  14607. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14608. */
  14609. beginAnimationOnStart: boolean;
  14610. /**
  14611. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14612. */
  14613. beginAnimationFrom: number;
  14614. /**
  14615. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14616. */
  14617. beginAnimationTo: number;
  14618. /**
  14619. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14620. */
  14621. beginAnimationLoop: boolean;
  14622. /**
  14623. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14624. */
  14625. disposeOnStop: boolean;
  14626. /**
  14627. * Specifies if the particles are updated in emitter local space or world space
  14628. */
  14629. isLocal: boolean;
  14630. /** Snippet ID if the particle system was created from the snippet server */
  14631. snippetId: string;
  14632. /** Gets or sets a matrix to use to compute projection */
  14633. defaultProjectionMatrix: Matrix;
  14634. /**
  14635. * Gets the maximum number of particles active at the same time.
  14636. * @returns The max number of active particles.
  14637. */
  14638. getCapacity(): number;
  14639. /**
  14640. * Gets the number of particles active at the same time.
  14641. * @returns The number of active particles.
  14642. */
  14643. getActiveCount(): number;
  14644. /**
  14645. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14646. * @returns True if it has been started, otherwise false.
  14647. */
  14648. isStarted(): boolean;
  14649. /**
  14650. * Animates the particle system for this frame.
  14651. */
  14652. animate(): void;
  14653. /**
  14654. * Renders the particle system in its current state.
  14655. * @returns the current number of particles
  14656. */
  14657. render(): number;
  14658. /**
  14659. * Dispose the particle system and frees its associated resources.
  14660. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14661. */
  14662. dispose(disposeTexture?: boolean): void;
  14663. /**
  14664. * An event triggered when the system is disposed
  14665. */
  14666. onDisposeObservable: Observable<IParticleSystem>;
  14667. /**
  14668. * Clones the particle system.
  14669. * @param name The name of the cloned object
  14670. * @param newEmitter The new emitter to use
  14671. * @returns the cloned particle system
  14672. */
  14673. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14674. /**
  14675. * Serializes the particle system to a JSON object
  14676. * @param serializeTexture defines if the texture must be serialized as well
  14677. * @returns the JSON object
  14678. */
  14679. serialize(serializeTexture: boolean): any;
  14680. /**
  14681. * Rebuild the particle system
  14682. */
  14683. rebuild(): void;
  14684. /** Force the system to rebuild all gradients that need to be resync */
  14685. forceRefreshGradients(): void;
  14686. /**
  14687. * Starts the particle system and begins to emit
  14688. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14689. */
  14690. start(delay?: number): void;
  14691. /**
  14692. * Stops the particle system.
  14693. */
  14694. stop(): void;
  14695. /**
  14696. * Remove all active particles
  14697. */
  14698. reset(): void;
  14699. /**
  14700. * Gets a boolean indicating that the system is stopping
  14701. * @returns true if the system is currently stopping
  14702. */
  14703. isStopping(): boolean;
  14704. /**
  14705. * Is this system ready to be used/rendered
  14706. * @return true if the system is ready
  14707. */
  14708. isReady(): boolean;
  14709. /**
  14710. * Returns the string "ParticleSystem"
  14711. * @returns a string containing the class name
  14712. */
  14713. getClassName(): string;
  14714. /**
  14715. * Gets the custom effect used to render the particles
  14716. * @param blendMode Blend mode for which the effect should be retrieved
  14717. * @returns The effect
  14718. */
  14719. getCustomEffect(blendMode: number): Nullable<Effect>;
  14720. /**
  14721. * Sets the custom effect used to render the particles
  14722. * @param effect The effect to set
  14723. * @param blendMode Blend mode for which the effect should be set
  14724. */
  14725. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14726. /**
  14727. * Fill the defines array according to the current settings of the particle system
  14728. * @param defines Array to be updated
  14729. * @param blendMode blend mode to take into account when updating the array
  14730. */
  14731. fillDefines(defines: Array<string>, blendMode: number): void;
  14732. /**
  14733. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14734. * @param uniforms Uniforms array to fill
  14735. * @param attributes Attributes array to fill
  14736. * @param samplers Samplers array to fill
  14737. */
  14738. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14739. /**
  14740. * Observable that will be called just before the particles are drawn
  14741. */
  14742. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14743. /**
  14744. * Gets the name of the particle vertex shader
  14745. */
  14746. vertexShaderName: string;
  14747. /**
  14748. * Adds a new color gradient
  14749. * @param gradient defines the gradient to use (between 0 and 1)
  14750. * @param color1 defines the color to affect to the specified gradient
  14751. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14752. * @returns the current particle system
  14753. */
  14754. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14755. /**
  14756. * Remove a specific color gradient
  14757. * @param gradient defines the gradient to remove
  14758. * @returns the current particle system
  14759. */
  14760. removeColorGradient(gradient: number): IParticleSystem;
  14761. /**
  14762. * Adds a new size gradient
  14763. * @param gradient defines the gradient to use (between 0 and 1)
  14764. * @param factor defines the size factor to affect to the specified gradient
  14765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14766. * @returns the current particle system
  14767. */
  14768. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14769. /**
  14770. * Remove a specific size gradient
  14771. * @param gradient defines the gradient to remove
  14772. * @returns the current particle system
  14773. */
  14774. removeSizeGradient(gradient: number): IParticleSystem;
  14775. /**
  14776. * Gets the current list of color gradients.
  14777. * You must use addColorGradient and removeColorGradient to udpate this list
  14778. * @returns the list of color gradients
  14779. */
  14780. getColorGradients(): Nullable<Array<ColorGradient>>;
  14781. /**
  14782. * Gets the current list of size gradients.
  14783. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14784. * @returns the list of size gradients
  14785. */
  14786. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14787. /**
  14788. * Gets the current list of angular speed gradients.
  14789. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14790. * @returns the list of angular speed gradients
  14791. */
  14792. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14793. /**
  14794. * Adds a new angular speed gradient
  14795. * @param gradient defines the gradient to use (between 0 and 1)
  14796. * @param factor defines the angular speed to affect to the specified gradient
  14797. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14798. * @returns the current particle system
  14799. */
  14800. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14801. /**
  14802. * Remove a specific angular speed gradient
  14803. * @param gradient defines the gradient to remove
  14804. * @returns the current particle system
  14805. */
  14806. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14807. /**
  14808. * Gets the current list of velocity gradients.
  14809. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14810. * @returns the list of velocity gradients
  14811. */
  14812. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14813. /**
  14814. * Adds a new velocity gradient
  14815. * @param gradient defines the gradient to use (between 0 and 1)
  14816. * @param factor defines the velocity to affect to the specified gradient
  14817. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14818. * @returns the current particle system
  14819. */
  14820. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14821. /**
  14822. * Remove a specific velocity gradient
  14823. * @param gradient defines the gradient to remove
  14824. * @returns the current particle system
  14825. */
  14826. removeVelocityGradient(gradient: number): IParticleSystem;
  14827. /**
  14828. * Gets the current list of limit velocity gradients.
  14829. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14830. * @returns the list of limit velocity gradients
  14831. */
  14832. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14833. /**
  14834. * Adds a new limit velocity gradient
  14835. * @param gradient defines the gradient to use (between 0 and 1)
  14836. * @param factor defines the limit velocity to affect to the specified gradient
  14837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14838. * @returns the current particle system
  14839. */
  14840. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14841. /**
  14842. * Remove a specific limit velocity gradient
  14843. * @param gradient defines the gradient to remove
  14844. * @returns the current particle system
  14845. */
  14846. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14847. /**
  14848. * Adds a new drag gradient
  14849. * @param gradient defines the gradient to use (between 0 and 1)
  14850. * @param factor defines the drag to affect to the specified gradient
  14851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14852. * @returns the current particle system
  14853. */
  14854. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14855. /**
  14856. * Remove a specific drag gradient
  14857. * @param gradient defines the gradient to remove
  14858. * @returns the current particle system
  14859. */
  14860. removeDragGradient(gradient: number): IParticleSystem;
  14861. /**
  14862. * Gets the current list of drag gradients.
  14863. * You must use addDragGradient and removeDragGradient to udpate this list
  14864. * @returns the list of drag gradients
  14865. */
  14866. getDragGradients(): Nullable<Array<FactorGradient>>;
  14867. /**
  14868. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14869. * @param gradient defines the gradient to use (between 0 and 1)
  14870. * @param factor defines the emit rate to affect to the specified gradient
  14871. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14872. * @returns the current particle system
  14873. */
  14874. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14875. /**
  14876. * Remove a specific emit rate gradient
  14877. * @param gradient defines the gradient to remove
  14878. * @returns the current particle system
  14879. */
  14880. removeEmitRateGradient(gradient: number): IParticleSystem;
  14881. /**
  14882. * Gets the current list of emit rate gradients.
  14883. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14884. * @returns the list of emit rate gradients
  14885. */
  14886. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14887. /**
  14888. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14889. * @param gradient defines the gradient to use (between 0 and 1)
  14890. * @param factor defines the start size to affect to the specified gradient
  14891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14892. * @returns the current particle system
  14893. */
  14894. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14895. /**
  14896. * Remove a specific start size gradient
  14897. * @param gradient defines the gradient to remove
  14898. * @returns the current particle system
  14899. */
  14900. removeStartSizeGradient(gradient: number): IParticleSystem;
  14901. /**
  14902. * Gets the current list of start size gradients.
  14903. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14904. * @returns the list of start size gradients
  14905. */
  14906. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14907. /**
  14908. * Adds a new life time gradient
  14909. * @param gradient defines the gradient to use (between 0 and 1)
  14910. * @param factor defines the life time factor to affect to the specified gradient
  14911. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14912. * @returns the current particle system
  14913. */
  14914. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14915. /**
  14916. * Remove a specific life time gradient
  14917. * @param gradient defines the gradient to remove
  14918. * @returns the current particle system
  14919. */
  14920. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14921. /**
  14922. * Gets the current list of life time gradients.
  14923. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14924. * @returns the list of life time gradients
  14925. */
  14926. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14927. /**
  14928. * Gets the current list of color gradients.
  14929. * You must use addColorGradient and removeColorGradient to udpate this list
  14930. * @returns the list of color gradients
  14931. */
  14932. getColorGradients(): Nullable<Array<ColorGradient>>;
  14933. /**
  14934. * Adds a new ramp gradient used to remap particle colors
  14935. * @param gradient defines the gradient to use (between 0 and 1)
  14936. * @param color defines the color to affect to the specified gradient
  14937. * @returns the current particle system
  14938. */
  14939. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14940. /**
  14941. * Gets the current list of ramp gradients.
  14942. * You must use addRampGradient and removeRampGradient to udpate this list
  14943. * @returns the list of ramp gradients
  14944. */
  14945. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14946. /** Gets or sets a boolean indicating that ramp gradients must be used
  14947. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14948. */
  14949. useRampGradients: boolean;
  14950. /**
  14951. * Adds a new color remap gradient
  14952. * @param gradient defines the gradient to use (between 0 and 1)
  14953. * @param min defines the color remap minimal range
  14954. * @param max defines the color remap maximal range
  14955. * @returns the current particle system
  14956. */
  14957. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14958. /**
  14959. * Gets the current list of color remap gradients.
  14960. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14961. * @returns the list of color remap gradients
  14962. */
  14963. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14964. /**
  14965. * Adds a new alpha remap gradient
  14966. * @param gradient defines the gradient to use (between 0 and 1)
  14967. * @param min defines the alpha remap minimal range
  14968. * @param max defines the alpha remap maximal range
  14969. * @returns the current particle system
  14970. */
  14971. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14972. /**
  14973. * Gets the current list of alpha remap gradients.
  14974. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14975. * @returns the list of alpha remap gradients
  14976. */
  14977. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14978. /**
  14979. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14980. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14981. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14982. * @returns the emitter
  14983. */
  14984. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14985. /**
  14986. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14987. * @param radius The radius of the hemisphere to emit from
  14988. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14989. * @returns the emitter
  14990. */
  14991. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14992. /**
  14993. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14994. * @param radius The radius of the sphere to emit from
  14995. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14996. * @returns the emitter
  14997. */
  14998. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14999. /**
  15000. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15001. * @param radius The radius of the sphere to emit from
  15002. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15003. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15004. * @returns the emitter
  15005. */
  15006. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15007. /**
  15008. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15009. * @param radius The radius of the emission cylinder
  15010. * @param height The height of the emission cylinder
  15011. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15012. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15013. * @returns the emitter
  15014. */
  15015. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15016. /**
  15017. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15018. * @param radius The radius of the cylinder to emit from
  15019. * @param height The height of the emission cylinder
  15020. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15021. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15022. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15023. * @returns the emitter
  15024. */
  15025. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15026. /**
  15027. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15028. * @param radius The radius of the cone to emit from
  15029. * @param angle The base angle of the cone
  15030. * @returns the emitter
  15031. */
  15032. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15033. /**
  15034. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15035. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15036. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15037. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15038. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15039. * @returns the emitter
  15040. */
  15041. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15042. /**
  15043. * Get hosting scene
  15044. * @returns the scene
  15045. */
  15046. getScene(): Nullable<Scene>;
  15047. }
  15048. }
  15049. declare module "babylonjs/Meshes/transformNode" {
  15050. import { DeepImmutable } from "babylonjs/types";
  15051. import { Observable } from "babylonjs/Misc/observable";
  15052. import { Nullable } from "babylonjs/types";
  15053. import { Camera } from "babylonjs/Cameras/camera";
  15054. import { Scene } from "babylonjs/scene";
  15055. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15056. import { Node } from "babylonjs/node";
  15057. import { Bone } from "babylonjs/Bones/bone";
  15058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15059. import { Space } from "babylonjs/Maths/math.axis";
  15060. /**
  15061. * 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.
  15062. * @see https://doc.babylonjs.com/how_to/transformnode
  15063. */
  15064. export class TransformNode extends Node {
  15065. /**
  15066. * Object will not rotate to face the camera
  15067. */
  15068. static BILLBOARDMODE_NONE: number;
  15069. /**
  15070. * Object will rotate to face the camera but only on the x axis
  15071. */
  15072. static BILLBOARDMODE_X: number;
  15073. /**
  15074. * Object will rotate to face the camera but only on the y axis
  15075. */
  15076. static BILLBOARDMODE_Y: number;
  15077. /**
  15078. * Object will rotate to face the camera but only on the z axis
  15079. */
  15080. static BILLBOARDMODE_Z: number;
  15081. /**
  15082. * Object will rotate to face the camera
  15083. */
  15084. static BILLBOARDMODE_ALL: number;
  15085. /**
  15086. * Object will rotate to face the camera's position instead of orientation
  15087. */
  15088. static BILLBOARDMODE_USE_POSITION: number;
  15089. private static _TmpRotation;
  15090. private static _TmpScaling;
  15091. private static _TmpTranslation;
  15092. private _forward;
  15093. private _forwardInverted;
  15094. private _up;
  15095. private _right;
  15096. private _rightInverted;
  15097. private _position;
  15098. private _rotation;
  15099. private _rotationQuaternion;
  15100. protected _scaling: Vector3;
  15101. protected _isDirty: boolean;
  15102. private _transformToBoneReferal;
  15103. private _isAbsoluteSynced;
  15104. private _billboardMode;
  15105. /**
  15106. * Gets or sets the billboard mode. Default is 0.
  15107. *
  15108. * | Value | Type | Description |
  15109. * | --- | --- | --- |
  15110. * | 0 | BILLBOARDMODE_NONE | |
  15111. * | 1 | BILLBOARDMODE_X | |
  15112. * | 2 | BILLBOARDMODE_Y | |
  15113. * | 4 | BILLBOARDMODE_Z | |
  15114. * | 7 | BILLBOARDMODE_ALL | |
  15115. *
  15116. */
  15117. get billboardMode(): number;
  15118. set billboardMode(value: number);
  15119. private _preserveParentRotationForBillboard;
  15120. /**
  15121. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15122. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15123. */
  15124. get preserveParentRotationForBillboard(): boolean;
  15125. set preserveParentRotationForBillboard(value: boolean);
  15126. /**
  15127. * 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
  15128. */
  15129. scalingDeterminant: number;
  15130. private _infiniteDistance;
  15131. /**
  15132. * Gets or sets the distance of the object to max, often used by skybox
  15133. */
  15134. get infiniteDistance(): boolean;
  15135. set infiniteDistance(value: boolean);
  15136. /**
  15137. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15138. * By default the system will update normals to compensate
  15139. */
  15140. ignoreNonUniformScaling: boolean;
  15141. /**
  15142. * 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
  15143. */
  15144. reIntegrateRotationIntoRotationQuaternion: boolean;
  15145. /** @hidden */
  15146. _poseMatrix: Nullable<Matrix>;
  15147. /** @hidden */
  15148. _localMatrix: Matrix;
  15149. private _usePivotMatrix;
  15150. private _absolutePosition;
  15151. private _absoluteScaling;
  15152. private _absoluteRotationQuaternion;
  15153. private _pivotMatrix;
  15154. private _pivotMatrixInverse;
  15155. /** @hidden */
  15156. _postMultiplyPivotMatrix: boolean;
  15157. protected _isWorldMatrixFrozen: boolean;
  15158. /** @hidden */
  15159. _indexInSceneTransformNodesArray: number;
  15160. /**
  15161. * An event triggered after the world matrix is updated
  15162. */
  15163. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15164. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15165. /**
  15166. * Gets a string identifying the name of the class
  15167. * @returns "TransformNode" string
  15168. */
  15169. getClassName(): string;
  15170. /**
  15171. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15172. */
  15173. get position(): Vector3;
  15174. set position(newPosition: Vector3);
  15175. /**
  15176. * 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)).
  15177. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15178. */
  15179. get rotation(): Vector3;
  15180. set rotation(newRotation: Vector3);
  15181. /**
  15182. * 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)).
  15183. */
  15184. get scaling(): Vector3;
  15185. set scaling(newScaling: Vector3);
  15186. /**
  15187. * 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).
  15188. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15189. */
  15190. get rotationQuaternion(): Nullable<Quaternion>;
  15191. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15192. /**
  15193. * The forward direction of that transform in world space.
  15194. */
  15195. get forward(): Vector3;
  15196. /**
  15197. * The up direction of that transform in world space.
  15198. */
  15199. get up(): Vector3;
  15200. /**
  15201. * The right direction of that transform in world space.
  15202. */
  15203. get right(): Vector3;
  15204. /**
  15205. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15206. * @param matrix the matrix to copy the pose from
  15207. * @returns this TransformNode.
  15208. */
  15209. updatePoseMatrix(matrix: Matrix): TransformNode;
  15210. /**
  15211. * Returns the mesh Pose matrix.
  15212. * @returns the pose matrix
  15213. */
  15214. getPoseMatrix(): Matrix;
  15215. /** @hidden */
  15216. _isSynchronized(): boolean;
  15217. /** @hidden */
  15218. _initCache(): void;
  15219. /**
  15220. * Flag the transform node as dirty (Forcing it to update everything)
  15221. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15222. * @returns this transform node
  15223. */
  15224. markAsDirty(property: string): TransformNode;
  15225. /**
  15226. * Returns the current mesh absolute position.
  15227. * Returns a Vector3.
  15228. */
  15229. get absolutePosition(): Vector3;
  15230. /**
  15231. * Returns the current mesh absolute scaling.
  15232. * Returns a Vector3.
  15233. */
  15234. get absoluteScaling(): Vector3;
  15235. /**
  15236. * Returns the current mesh absolute rotation.
  15237. * Returns a Quaternion.
  15238. */
  15239. get absoluteRotationQuaternion(): Quaternion;
  15240. /**
  15241. * Sets a new matrix to apply before all other transformation
  15242. * @param matrix defines the transform matrix
  15243. * @returns the current TransformNode
  15244. */
  15245. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15246. /**
  15247. * Sets a new pivot matrix to the current node
  15248. * @param matrix defines the new pivot matrix to use
  15249. * @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
  15250. * @returns the current TransformNode
  15251. */
  15252. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15253. /**
  15254. * Returns the mesh pivot matrix.
  15255. * Default : Identity.
  15256. * @returns the matrix
  15257. */
  15258. getPivotMatrix(): Matrix;
  15259. /**
  15260. * Instantiate (when possible) or clone that node with its hierarchy
  15261. * @param newParent defines the new parent to use for the instance (or clone)
  15262. * @param options defines options to configure how copy is done
  15263. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15264. * @returns an instance (or a clone) of the current node with its hiearchy
  15265. */
  15266. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15267. doNotInstantiate: boolean;
  15268. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15269. /**
  15270. * Prevents the World matrix to be computed any longer
  15271. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15272. * @returns the TransformNode.
  15273. */
  15274. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15275. /**
  15276. * Allows back the World matrix computation.
  15277. * @returns the TransformNode.
  15278. */
  15279. unfreezeWorldMatrix(): this;
  15280. /**
  15281. * True if the World matrix has been frozen.
  15282. */
  15283. get isWorldMatrixFrozen(): boolean;
  15284. /**
  15285. * Retuns the mesh absolute position in the World.
  15286. * @returns a Vector3.
  15287. */
  15288. getAbsolutePosition(): Vector3;
  15289. /**
  15290. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15291. * @param absolutePosition the absolute position to set
  15292. * @returns the TransformNode.
  15293. */
  15294. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15295. /**
  15296. * Sets the mesh position in its local space.
  15297. * @param vector3 the position to set in localspace
  15298. * @returns the TransformNode.
  15299. */
  15300. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15301. /**
  15302. * Returns the mesh position in the local space from the current World matrix values.
  15303. * @returns a new Vector3.
  15304. */
  15305. getPositionExpressedInLocalSpace(): Vector3;
  15306. /**
  15307. * Translates the mesh along the passed Vector3 in its local space.
  15308. * @param vector3 the distance to translate in localspace
  15309. * @returns the TransformNode.
  15310. */
  15311. locallyTranslate(vector3: Vector3): TransformNode;
  15312. private static _lookAtVectorCache;
  15313. /**
  15314. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15315. * @param targetPoint the position (must be in same space as current mesh) to look at
  15316. * @param yawCor optional yaw (y-axis) correction in radians
  15317. * @param pitchCor optional pitch (x-axis) correction in radians
  15318. * @param rollCor optional roll (z-axis) correction in radians
  15319. * @param space the choosen space of the target
  15320. * @returns the TransformNode.
  15321. */
  15322. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15323. /**
  15324. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15325. * This Vector3 is expressed in the World space.
  15326. * @param localAxis axis to rotate
  15327. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15328. */
  15329. getDirection(localAxis: Vector3): Vector3;
  15330. /**
  15331. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15332. * localAxis is expressed in the mesh local space.
  15333. * result is computed in the Wordl space from the mesh World matrix.
  15334. * @param localAxis axis to rotate
  15335. * @param result the resulting transformnode
  15336. * @returns this TransformNode.
  15337. */
  15338. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15339. /**
  15340. * Sets this transform node rotation to the given local axis.
  15341. * @param localAxis the axis in local space
  15342. * @param yawCor optional yaw (y-axis) correction in radians
  15343. * @param pitchCor optional pitch (x-axis) correction in radians
  15344. * @param rollCor optional roll (z-axis) correction in radians
  15345. * @returns this TransformNode
  15346. */
  15347. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15348. /**
  15349. * Sets a new pivot point to the current node
  15350. * @param point defines the new pivot point to use
  15351. * @param space defines if the point is in world or local space (local by default)
  15352. * @returns the current TransformNode
  15353. */
  15354. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15355. /**
  15356. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15357. * @returns the pivot point
  15358. */
  15359. getPivotPoint(): Vector3;
  15360. /**
  15361. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15362. * @param result the vector3 to store the result
  15363. * @returns this TransformNode.
  15364. */
  15365. getPivotPointToRef(result: Vector3): TransformNode;
  15366. /**
  15367. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15368. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15369. */
  15370. getAbsolutePivotPoint(): Vector3;
  15371. /**
  15372. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15373. * @param result vector3 to store the result
  15374. * @returns this TransformNode.
  15375. */
  15376. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15377. /**
  15378. * Defines the passed node as the parent of the current node.
  15379. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15380. * @see https://doc.babylonjs.com/how_to/parenting
  15381. * @param node the node ot set as the parent
  15382. * @returns this TransformNode.
  15383. */
  15384. setParent(node: Nullable<Node>): TransformNode;
  15385. private _nonUniformScaling;
  15386. /**
  15387. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15388. */
  15389. get nonUniformScaling(): boolean;
  15390. /** @hidden */
  15391. _updateNonUniformScalingState(value: boolean): boolean;
  15392. /**
  15393. * Attach the current TransformNode to another TransformNode associated with a bone
  15394. * @param bone Bone affecting the TransformNode
  15395. * @param affectedTransformNode TransformNode associated with the bone
  15396. * @returns this object
  15397. */
  15398. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15399. /**
  15400. * Detach the transform node if its associated with a bone
  15401. * @returns this object
  15402. */
  15403. detachFromBone(): TransformNode;
  15404. private static _rotationAxisCache;
  15405. /**
  15406. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15407. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15408. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15409. * The passed axis is also normalized.
  15410. * @param axis the axis to rotate around
  15411. * @param amount the amount to rotate in radians
  15412. * @param space Space to rotate in (Default: local)
  15413. * @returns the TransformNode.
  15414. */
  15415. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15416. /**
  15417. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15418. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15419. * The passed axis is also normalized. .
  15420. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15421. * @param point the point to rotate around
  15422. * @param axis the axis to rotate around
  15423. * @param amount the amount to rotate in radians
  15424. * @returns the TransformNode
  15425. */
  15426. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15427. /**
  15428. * Translates the mesh along the axis vector for the passed distance in the given space.
  15429. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15430. * @param axis the axis to translate in
  15431. * @param distance the distance to translate
  15432. * @param space Space to rotate in (Default: local)
  15433. * @returns the TransformNode.
  15434. */
  15435. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15436. /**
  15437. * Adds a rotation step to the mesh current rotation.
  15438. * x, y, z are Euler angles expressed in radians.
  15439. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15440. * This means this rotation is made in the mesh local space only.
  15441. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15442. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15443. * ```javascript
  15444. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15445. * ```
  15446. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15447. * 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.
  15448. * @param x Rotation to add
  15449. * @param y Rotation to add
  15450. * @param z Rotation to add
  15451. * @returns the TransformNode.
  15452. */
  15453. addRotation(x: number, y: number, z: number): TransformNode;
  15454. /**
  15455. * @hidden
  15456. */
  15457. protected _getEffectiveParent(): Nullable<Node>;
  15458. /**
  15459. * Computes the world matrix of the node
  15460. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15461. * @returns the world matrix
  15462. */
  15463. computeWorldMatrix(force?: boolean): Matrix;
  15464. /**
  15465. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15466. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15467. */
  15468. resetLocalMatrix(independentOfChildren?: boolean): void;
  15469. protected _afterComputeWorldMatrix(): void;
  15470. /**
  15471. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15472. * @param func callback function to add
  15473. *
  15474. * @returns the TransformNode.
  15475. */
  15476. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15477. /**
  15478. * Removes a registered callback function.
  15479. * @param func callback function to remove
  15480. * @returns the TransformNode.
  15481. */
  15482. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15483. /**
  15484. * Gets the position of the current mesh in camera space
  15485. * @param camera defines the camera to use
  15486. * @returns a position
  15487. */
  15488. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15489. /**
  15490. * Returns the distance from the mesh to the active camera
  15491. * @param camera defines the camera to use
  15492. * @returns the distance
  15493. */
  15494. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15495. /**
  15496. * Clone the current transform node
  15497. * @param name Name of the new clone
  15498. * @param newParent New parent for the clone
  15499. * @param doNotCloneChildren Do not clone children hierarchy
  15500. * @returns the new transform node
  15501. */
  15502. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15503. /**
  15504. * Serializes the objects information.
  15505. * @param currentSerializationObject defines the object to serialize in
  15506. * @returns the serialized object
  15507. */
  15508. serialize(currentSerializationObject?: any): any;
  15509. /**
  15510. * Returns a new TransformNode object parsed from the source provided.
  15511. * @param parsedTransformNode is the source.
  15512. * @param scene the scne the object belongs to
  15513. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15514. * @returns a new TransformNode object parsed from the source provided.
  15515. */
  15516. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15517. /**
  15518. * Get all child-transformNodes of this node
  15519. * @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
  15520. * @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
  15521. * @returns an array of TransformNode
  15522. */
  15523. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15524. /**
  15525. * Releases resources associated with this transform node.
  15526. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15527. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15528. */
  15529. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15530. /**
  15531. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15532. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15533. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15534. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15535. * @returns the current mesh
  15536. */
  15537. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15538. private _syncAbsoluteScalingAndRotation;
  15539. }
  15540. }
  15541. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15542. /**
  15543. * Class used to override all child animations of a given target
  15544. */
  15545. export class AnimationPropertiesOverride {
  15546. /**
  15547. * Gets or sets a value indicating if animation blending must be used
  15548. */
  15549. enableBlending: boolean;
  15550. /**
  15551. * Gets or sets the blending speed to use when enableBlending is true
  15552. */
  15553. blendingSpeed: number;
  15554. /**
  15555. * Gets or sets the default loop mode to use
  15556. */
  15557. loopMode: number;
  15558. }
  15559. }
  15560. declare module "babylonjs/Bones/bone" {
  15561. import { Skeleton } from "babylonjs/Bones/skeleton";
  15562. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15563. import { Nullable } from "babylonjs/types";
  15564. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15566. import { Node } from "babylonjs/node";
  15567. import { Space } from "babylonjs/Maths/math.axis";
  15568. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15569. /**
  15570. * Class used to store bone information
  15571. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15572. */
  15573. export class Bone extends Node {
  15574. /**
  15575. * defines the bone name
  15576. */
  15577. name: string;
  15578. private static _tmpVecs;
  15579. private static _tmpQuat;
  15580. private static _tmpMats;
  15581. /**
  15582. * Gets the list of child bones
  15583. */
  15584. children: Bone[];
  15585. /** Gets the animations associated with this bone */
  15586. animations: import("babylonjs/Animations/animation").Animation[];
  15587. /**
  15588. * Gets or sets bone length
  15589. */
  15590. length: number;
  15591. /**
  15592. * @hidden Internal only
  15593. * Set this value to map this bone to a different index in the transform matrices
  15594. * Set this value to -1 to exclude the bone from the transform matrices
  15595. */
  15596. _index: Nullable<number>;
  15597. private _skeleton;
  15598. private _localMatrix;
  15599. private _restPose;
  15600. private _bindPose;
  15601. private _baseMatrix;
  15602. private _absoluteTransform;
  15603. private _invertedAbsoluteTransform;
  15604. private _parent;
  15605. private _scalingDeterminant;
  15606. private _worldTransform;
  15607. private _localScaling;
  15608. private _localRotation;
  15609. private _localPosition;
  15610. private _needToDecompose;
  15611. private _needToCompose;
  15612. /** @hidden */
  15613. _linkedTransformNode: Nullable<TransformNode>;
  15614. /** @hidden */
  15615. _waitingTransformNodeId: Nullable<string>;
  15616. /** @hidden */
  15617. get _matrix(): Matrix;
  15618. /** @hidden */
  15619. set _matrix(value: Matrix);
  15620. /**
  15621. * Create a new bone
  15622. * @param name defines the bone name
  15623. * @param skeleton defines the parent skeleton
  15624. * @param parentBone defines the parent (can be null if the bone is the root)
  15625. * @param localMatrix defines the local matrix
  15626. * @param restPose defines the rest pose matrix
  15627. * @param baseMatrix defines the base matrix
  15628. * @param index defines index of the bone in the hiearchy
  15629. */
  15630. constructor(
  15631. /**
  15632. * defines the bone name
  15633. */
  15634. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15635. /**
  15636. * Gets the current object class name.
  15637. * @return the class name
  15638. */
  15639. getClassName(): string;
  15640. /**
  15641. * Gets the parent skeleton
  15642. * @returns a skeleton
  15643. */
  15644. getSkeleton(): Skeleton;
  15645. /**
  15646. * Gets parent bone
  15647. * @returns a bone or null if the bone is the root of the bone hierarchy
  15648. */
  15649. getParent(): Nullable<Bone>;
  15650. /**
  15651. * Returns an array containing the root bones
  15652. * @returns an array containing the root bones
  15653. */
  15654. getChildren(): Array<Bone>;
  15655. /**
  15656. * Gets the node index in matrix array generated for rendering
  15657. * @returns the node index
  15658. */
  15659. getIndex(): number;
  15660. /**
  15661. * Sets the parent bone
  15662. * @param parent defines the parent (can be null if the bone is the root)
  15663. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15664. */
  15665. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15666. /**
  15667. * Gets the local matrix
  15668. * @returns a matrix
  15669. */
  15670. getLocalMatrix(): Matrix;
  15671. /**
  15672. * Gets the base matrix (initial matrix which remains unchanged)
  15673. * @returns a matrix
  15674. */
  15675. getBaseMatrix(): Matrix;
  15676. /**
  15677. * Gets the rest pose matrix
  15678. * @returns a matrix
  15679. */
  15680. getRestPose(): Matrix;
  15681. /**
  15682. * Sets the rest pose matrix
  15683. * @param matrix the local-space rest pose to set for this bone
  15684. */
  15685. setRestPose(matrix: Matrix): void;
  15686. /**
  15687. * Gets the bind pose matrix
  15688. * @returns the bind pose matrix
  15689. */
  15690. getBindPose(): Matrix;
  15691. /**
  15692. * Sets the bind pose matrix
  15693. * @param matrix the local-space bind pose to set for this bone
  15694. */
  15695. setBindPose(matrix: Matrix): void;
  15696. /**
  15697. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15698. */
  15699. getWorldMatrix(): Matrix;
  15700. /**
  15701. * Sets the local matrix to rest pose matrix
  15702. */
  15703. returnToRest(): void;
  15704. /**
  15705. * Gets the inverse of the absolute transform matrix.
  15706. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15707. * @returns a matrix
  15708. */
  15709. getInvertedAbsoluteTransform(): Matrix;
  15710. /**
  15711. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15712. * @returns a matrix
  15713. */
  15714. getAbsoluteTransform(): Matrix;
  15715. /**
  15716. * Links with the given transform node.
  15717. * The local matrix of this bone is copied from the transform node every frame.
  15718. * @param transformNode defines the transform node to link to
  15719. */
  15720. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15721. /**
  15722. * Gets the node used to drive the bone's transformation
  15723. * @returns a transform node or null
  15724. */
  15725. getTransformNode(): Nullable<TransformNode>;
  15726. /** Gets or sets current position (in local space) */
  15727. get position(): Vector3;
  15728. set position(newPosition: Vector3);
  15729. /** Gets or sets current rotation (in local space) */
  15730. get rotation(): Vector3;
  15731. set rotation(newRotation: Vector3);
  15732. /** Gets or sets current rotation quaternion (in local space) */
  15733. get rotationQuaternion(): Quaternion;
  15734. set rotationQuaternion(newRotation: Quaternion);
  15735. /** Gets or sets current scaling (in local space) */
  15736. get scaling(): Vector3;
  15737. set scaling(newScaling: Vector3);
  15738. /**
  15739. * Gets the animation properties override
  15740. */
  15741. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15742. private _decompose;
  15743. private _compose;
  15744. /**
  15745. * Update the base and local matrices
  15746. * @param matrix defines the new base or local matrix
  15747. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15748. * @param updateLocalMatrix defines if the local matrix should be updated
  15749. */
  15750. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15751. /** @hidden */
  15752. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15753. /**
  15754. * Flag the bone as dirty (Forcing it to update everything)
  15755. */
  15756. markAsDirty(): void;
  15757. /** @hidden */
  15758. _markAsDirtyAndCompose(): void;
  15759. private _markAsDirtyAndDecompose;
  15760. /**
  15761. * Translate the bone in local or world space
  15762. * @param vec The amount to translate the bone
  15763. * @param space The space that the translation is in
  15764. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15765. */
  15766. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15767. /**
  15768. * Set the postion of the bone in local or world space
  15769. * @param position The position to set the bone
  15770. * @param space The space that the position is in
  15771. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15772. */
  15773. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15774. /**
  15775. * Set the absolute position of the bone (world space)
  15776. * @param position The position to set the bone
  15777. * @param mesh The mesh that this bone is attached to
  15778. */
  15779. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15780. /**
  15781. * Scale the bone on the x, y and z axes (in local space)
  15782. * @param x The amount to scale the bone on the x axis
  15783. * @param y The amount to scale the bone on the y axis
  15784. * @param z The amount to scale the bone on the z axis
  15785. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15786. */
  15787. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15788. /**
  15789. * Set the bone scaling in local space
  15790. * @param scale defines the scaling vector
  15791. */
  15792. setScale(scale: Vector3): void;
  15793. /**
  15794. * Gets the current scaling in local space
  15795. * @returns the current scaling vector
  15796. */
  15797. getScale(): Vector3;
  15798. /**
  15799. * Gets the current scaling in local space and stores it in a target vector
  15800. * @param result defines the target vector
  15801. */
  15802. getScaleToRef(result: Vector3): void;
  15803. /**
  15804. * Set the yaw, pitch, and roll of the bone in local or world space
  15805. * @param yaw The rotation of the bone on the y axis
  15806. * @param pitch The rotation of the bone on the x axis
  15807. * @param roll The rotation of the bone on the z axis
  15808. * @param space The space that the axes of rotation are in
  15809. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15810. */
  15811. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15812. /**
  15813. * Add a rotation to the bone on an axis in local or world space
  15814. * @param axis The axis to rotate the bone on
  15815. * @param amount The amount to rotate the bone
  15816. * @param space The space that the axis is in
  15817. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15818. */
  15819. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15820. /**
  15821. * Set the rotation of the bone to a particular axis angle in local or world space
  15822. * @param axis The axis to rotate the bone on
  15823. * @param angle The angle that the bone should be rotated to
  15824. * @param space The space that the axis is in
  15825. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15826. */
  15827. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15828. /**
  15829. * Set the euler rotation of the bone in local or world space
  15830. * @param rotation The euler rotation that the bone should be set to
  15831. * @param space The space that the rotation is in
  15832. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15833. */
  15834. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15835. /**
  15836. * Set the quaternion rotation of the bone in local or world space
  15837. * @param quat The quaternion rotation that the bone should be set to
  15838. * @param space The space that the rotation is in
  15839. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15840. */
  15841. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15842. /**
  15843. * Set the rotation matrix of the bone in local or world space
  15844. * @param rotMat The rotation matrix that the bone should be set to
  15845. * @param space The space that the rotation is in
  15846. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15847. */
  15848. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15849. private _rotateWithMatrix;
  15850. private _getNegativeRotationToRef;
  15851. /**
  15852. * Get the position of the bone in local or world space
  15853. * @param space The space that the returned position is in
  15854. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15855. * @returns The position of the bone
  15856. */
  15857. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15858. /**
  15859. * Copy the position of the bone to a vector3 in local or world space
  15860. * @param space The space that the returned position is in
  15861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15862. * @param result The vector3 to copy the position to
  15863. */
  15864. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15865. /**
  15866. * Get the absolute position of the bone (world space)
  15867. * @param mesh The mesh that this bone is attached to
  15868. * @returns The absolute position of the bone
  15869. */
  15870. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15871. /**
  15872. * Copy the absolute position of the bone (world space) to the result param
  15873. * @param mesh The mesh that this bone is attached to
  15874. * @param result The vector3 to copy the absolute position to
  15875. */
  15876. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15877. /**
  15878. * Compute the absolute transforms of this bone and its children
  15879. */
  15880. computeAbsoluteTransforms(): void;
  15881. /**
  15882. * Get the world direction from an axis that is in the local space of the bone
  15883. * @param localAxis The local direction that is used to compute the world direction
  15884. * @param mesh The mesh that this bone is attached to
  15885. * @returns The world direction
  15886. */
  15887. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15888. /**
  15889. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15890. * @param localAxis The local direction that is used to compute the world direction
  15891. * @param mesh The mesh that this bone is attached to
  15892. * @param result The vector3 that the world direction will be copied to
  15893. */
  15894. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15895. /**
  15896. * Get the euler rotation of the bone in local or world space
  15897. * @param space The space that the rotation should be in
  15898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15899. * @returns The euler rotation
  15900. */
  15901. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15902. /**
  15903. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15904. * @param space The space that the rotation should be in
  15905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15906. * @param result The vector3 that the rotation should be copied to
  15907. */
  15908. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15909. /**
  15910. * Get the quaternion rotation of the bone in either local or world space
  15911. * @param space The space that the rotation should be in
  15912. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15913. * @returns The quaternion rotation
  15914. */
  15915. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15916. /**
  15917. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15918. * @param space The space that the rotation should be in
  15919. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15920. * @param result The quaternion that the rotation should be copied to
  15921. */
  15922. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15923. /**
  15924. * Get the rotation matrix of the bone in local or world space
  15925. * @param space The space that the rotation should be in
  15926. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15927. * @returns The rotation matrix
  15928. */
  15929. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15930. /**
  15931. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15932. * @param space The space that the rotation should be in
  15933. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15934. * @param result The quaternion that the rotation should be copied to
  15935. */
  15936. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15937. /**
  15938. * Get the world position of a point that is in the local space of the bone
  15939. * @param position The local position
  15940. * @param mesh The mesh that this bone is attached to
  15941. * @returns The world position
  15942. */
  15943. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15944. /**
  15945. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15946. * @param position The local position
  15947. * @param mesh The mesh that this bone is attached to
  15948. * @param result The vector3 that the world position should be copied to
  15949. */
  15950. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15951. /**
  15952. * Get the local position of a point that is in world space
  15953. * @param position The world position
  15954. * @param mesh The mesh that this bone is attached to
  15955. * @returns The local position
  15956. */
  15957. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15958. /**
  15959. * Get the local position of a point that is in world space and copy it to the result param
  15960. * @param position The world position
  15961. * @param mesh The mesh that this bone is attached to
  15962. * @param result The vector3 that the local position should be copied to
  15963. */
  15964. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15965. /**
  15966. * Set the current local matrix as the restPose for this bone.
  15967. */
  15968. setCurrentPoseAsRest(): void;
  15969. }
  15970. }
  15971. declare module "babylonjs/Animations/runtimeAnimation" {
  15972. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15973. import { Animatable } from "babylonjs/Animations/animatable";
  15974. import { Scene } from "babylonjs/scene";
  15975. /**
  15976. * Defines a runtime animation
  15977. */
  15978. export class RuntimeAnimation {
  15979. private _events;
  15980. /**
  15981. * The current frame of the runtime animation
  15982. */
  15983. private _currentFrame;
  15984. /**
  15985. * The animation used by the runtime animation
  15986. */
  15987. private _animation;
  15988. /**
  15989. * The target of the runtime animation
  15990. */
  15991. private _target;
  15992. /**
  15993. * The initiating animatable
  15994. */
  15995. private _host;
  15996. /**
  15997. * The original value of the runtime animation
  15998. */
  15999. private _originalValue;
  16000. /**
  16001. * The original blend value of the runtime animation
  16002. */
  16003. private _originalBlendValue;
  16004. /**
  16005. * The offsets cache of the runtime animation
  16006. */
  16007. private _offsetsCache;
  16008. /**
  16009. * The high limits cache of the runtime animation
  16010. */
  16011. private _highLimitsCache;
  16012. /**
  16013. * Specifies if the runtime animation has been stopped
  16014. */
  16015. private _stopped;
  16016. /**
  16017. * The blending factor of the runtime animation
  16018. */
  16019. private _blendingFactor;
  16020. /**
  16021. * The BabylonJS scene
  16022. */
  16023. private _scene;
  16024. /**
  16025. * The current value of the runtime animation
  16026. */
  16027. private _currentValue;
  16028. /** @hidden */
  16029. _animationState: _IAnimationState;
  16030. /**
  16031. * The active target of the runtime animation
  16032. */
  16033. private _activeTargets;
  16034. private _currentActiveTarget;
  16035. private _directTarget;
  16036. /**
  16037. * The target path of the runtime animation
  16038. */
  16039. private _targetPath;
  16040. /**
  16041. * The weight of the runtime animation
  16042. */
  16043. private _weight;
  16044. /**
  16045. * The ratio offset of the runtime animation
  16046. */
  16047. private _ratioOffset;
  16048. /**
  16049. * The previous delay of the runtime animation
  16050. */
  16051. private _previousDelay;
  16052. /**
  16053. * The previous ratio of the runtime animation
  16054. */
  16055. private _previousRatio;
  16056. private _enableBlending;
  16057. private _keys;
  16058. private _minFrame;
  16059. private _maxFrame;
  16060. private _minValue;
  16061. private _maxValue;
  16062. private _targetIsArray;
  16063. /**
  16064. * Gets the current frame of the runtime animation
  16065. */
  16066. get currentFrame(): number;
  16067. /**
  16068. * Gets the weight of the runtime animation
  16069. */
  16070. get weight(): number;
  16071. /**
  16072. * Gets the current value of the runtime animation
  16073. */
  16074. get currentValue(): any;
  16075. /**
  16076. * Gets the target path of the runtime animation
  16077. */
  16078. get targetPath(): string;
  16079. /**
  16080. * Gets the actual target of the runtime animation
  16081. */
  16082. get target(): any;
  16083. /**
  16084. * Gets the additive state of the runtime animation
  16085. */
  16086. get isAdditive(): boolean;
  16087. /** @hidden */
  16088. _onLoop: () => void;
  16089. /**
  16090. * Create a new RuntimeAnimation object
  16091. * @param target defines the target of the animation
  16092. * @param animation defines the source animation object
  16093. * @param scene defines the hosting scene
  16094. * @param host defines the initiating Animatable
  16095. */
  16096. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16097. private _preparePath;
  16098. /**
  16099. * Gets the animation from the runtime animation
  16100. */
  16101. get animation(): Animation;
  16102. /**
  16103. * Resets the runtime animation to the beginning
  16104. * @param restoreOriginal defines whether to restore the target property to the original value
  16105. */
  16106. reset(restoreOriginal?: boolean): void;
  16107. /**
  16108. * Specifies if the runtime animation is stopped
  16109. * @returns Boolean specifying if the runtime animation is stopped
  16110. */
  16111. isStopped(): boolean;
  16112. /**
  16113. * Disposes of the runtime animation
  16114. */
  16115. dispose(): void;
  16116. /**
  16117. * Apply the interpolated value to the target
  16118. * @param currentValue defines the value computed by the animation
  16119. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16120. */
  16121. setValue(currentValue: any, weight: number): void;
  16122. private _getOriginalValues;
  16123. private _setValue;
  16124. /**
  16125. * Gets the loop pmode of the runtime animation
  16126. * @returns Loop Mode
  16127. */
  16128. private _getCorrectLoopMode;
  16129. /**
  16130. * Move the current animation to a given frame
  16131. * @param frame defines the frame to move to
  16132. */
  16133. goToFrame(frame: number): void;
  16134. /**
  16135. * @hidden Internal use only
  16136. */
  16137. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16138. /**
  16139. * Execute the current animation
  16140. * @param delay defines the delay to add to the current frame
  16141. * @param from defines the lower bound of the animation range
  16142. * @param to defines the upper bound of the animation range
  16143. * @param loop defines if the current animation must loop
  16144. * @param speedRatio defines the current speed ratio
  16145. * @param weight defines the weight of the animation (default is -1 so no weight)
  16146. * @param onLoop optional callback called when animation loops
  16147. * @returns a boolean indicating if the animation is running
  16148. */
  16149. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16150. }
  16151. }
  16152. declare module "babylonjs/Animations/animatable" {
  16153. import { Animation } from "babylonjs/Animations/animation";
  16154. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16155. import { Nullable } from "babylonjs/types";
  16156. import { Observable } from "babylonjs/Misc/observable";
  16157. import { Scene } from "babylonjs/scene";
  16158. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16159. import { Node } from "babylonjs/node";
  16160. /**
  16161. * Class used to store an actual running animation
  16162. */
  16163. export class Animatable {
  16164. /** defines the target object */
  16165. target: any;
  16166. /** defines the starting frame number (default is 0) */
  16167. fromFrame: number;
  16168. /** defines the ending frame number (default is 100) */
  16169. toFrame: number;
  16170. /** defines if the animation must loop (default is false) */
  16171. loopAnimation: boolean;
  16172. /** defines a callback to call when animation ends if it is not looping */
  16173. onAnimationEnd?: (() => void) | null | undefined;
  16174. /** defines a callback to call when animation loops */
  16175. onAnimationLoop?: (() => void) | null | undefined;
  16176. /** defines whether the animation should be evaluated additively */
  16177. isAdditive: boolean;
  16178. private _localDelayOffset;
  16179. private _pausedDelay;
  16180. private _runtimeAnimations;
  16181. private _paused;
  16182. private _scene;
  16183. private _speedRatio;
  16184. private _weight;
  16185. private _syncRoot;
  16186. /**
  16187. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16188. * This will only apply for non looping animation (default is true)
  16189. */
  16190. disposeOnEnd: boolean;
  16191. /**
  16192. * Gets a boolean indicating if the animation has started
  16193. */
  16194. animationStarted: boolean;
  16195. /**
  16196. * Observer raised when the animation ends
  16197. */
  16198. onAnimationEndObservable: Observable<Animatable>;
  16199. /**
  16200. * Observer raised when the animation loops
  16201. */
  16202. onAnimationLoopObservable: Observable<Animatable>;
  16203. /**
  16204. * Gets the root Animatable used to synchronize and normalize animations
  16205. */
  16206. get syncRoot(): Nullable<Animatable>;
  16207. /**
  16208. * Gets the current frame of the first RuntimeAnimation
  16209. * Used to synchronize Animatables
  16210. */
  16211. get masterFrame(): number;
  16212. /**
  16213. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16214. */
  16215. get weight(): number;
  16216. set weight(value: number);
  16217. /**
  16218. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16219. */
  16220. get speedRatio(): number;
  16221. set speedRatio(value: number);
  16222. /**
  16223. * Creates a new Animatable
  16224. * @param scene defines the hosting scene
  16225. * @param target defines the target object
  16226. * @param fromFrame defines the starting frame number (default is 0)
  16227. * @param toFrame defines the ending frame number (default is 100)
  16228. * @param loopAnimation defines if the animation must loop (default is false)
  16229. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16230. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16231. * @param animations defines a group of animation to add to the new Animatable
  16232. * @param onAnimationLoop defines a callback to call when animation loops
  16233. * @param isAdditive defines whether the animation should be evaluated additively
  16234. */
  16235. constructor(scene: Scene,
  16236. /** defines the target object */
  16237. target: any,
  16238. /** defines the starting frame number (default is 0) */
  16239. fromFrame?: number,
  16240. /** defines the ending frame number (default is 100) */
  16241. toFrame?: number,
  16242. /** defines if the animation must loop (default is false) */
  16243. loopAnimation?: boolean, speedRatio?: number,
  16244. /** defines a callback to call when animation ends if it is not looping */
  16245. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16246. /** defines a callback to call when animation loops */
  16247. onAnimationLoop?: (() => void) | null | undefined,
  16248. /** defines whether the animation should be evaluated additively */
  16249. isAdditive?: boolean);
  16250. /**
  16251. * Synchronize and normalize current Animatable with a source Animatable
  16252. * This is useful when using animation weights and when animations are not of the same length
  16253. * @param root defines the root Animatable to synchronize with
  16254. * @returns the current Animatable
  16255. */
  16256. syncWith(root: Animatable): Animatable;
  16257. /**
  16258. * Gets the list of runtime animations
  16259. * @returns an array of RuntimeAnimation
  16260. */
  16261. getAnimations(): RuntimeAnimation[];
  16262. /**
  16263. * Adds more animations to the current animatable
  16264. * @param target defines the target of the animations
  16265. * @param animations defines the new animations to add
  16266. */
  16267. appendAnimations(target: any, animations: Animation[]): void;
  16268. /**
  16269. * Gets the source animation for a specific property
  16270. * @param property defines the propertyu to look for
  16271. * @returns null or the source animation for the given property
  16272. */
  16273. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16274. /**
  16275. * Gets the runtime animation for a specific property
  16276. * @param property defines the propertyu to look for
  16277. * @returns null or the runtime animation for the given property
  16278. */
  16279. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16280. /**
  16281. * Resets the animatable to its original state
  16282. */
  16283. reset(): void;
  16284. /**
  16285. * Allows the animatable to blend with current running animations
  16286. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16287. * @param blendingSpeed defines the blending speed to use
  16288. */
  16289. enableBlending(blendingSpeed: number): void;
  16290. /**
  16291. * Disable animation blending
  16292. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16293. */
  16294. disableBlending(): void;
  16295. /**
  16296. * Jump directly to a given frame
  16297. * @param frame defines the frame to jump to
  16298. */
  16299. goToFrame(frame: number): void;
  16300. /**
  16301. * Pause the animation
  16302. */
  16303. pause(): void;
  16304. /**
  16305. * Restart the animation
  16306. */
  16307. restart(): void;
  16308. private _raiseOnAnimationEnd;
  16309. /**
  16310. * Stop and delete the current animation
  16311. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16312. * @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)
  16313. */
  16314. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16315. /**
  16316. * Wait asynchronously for the animation to end
  16317. * @returns a promise which will be fullfilled when the animation ends
  16318. */
  16319. waitAsync(): Promise<Animatable>;
  16320. /** @hidden */
  16321. _animate(delay: number): boolean;
  16322. }
  16323. module "babylonjs/scene" {
  16324. interface Scene {
  16325. /** @hidden */
  16326. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16327. /** @hidden */
  16328. _processLateAnimationBindingsForMatrices(holder: {
  16329. totalWeight: number;
  16330. totalAdditiveWeight: number;
  16331. animations: RuntimeAnimation[];
  16332. additiveAnimations: RuntimeAnimation[];
  16333. originalValue: Matrix;
  16334. }): any;
  16335. /** @hidden */
  16336. _processLateAnimationBindingsForQuaternions(holder: {
  16337. totalWeight: number;
  16338. totalAdditiveWeight: number;
  16339. animations: RuntimeAnimation[];
  16340. additiveAnimations: RuntimeAnimation[];
  16341. originalValue: Quaternion;
  16342. }, refQuaternion: Quaternion): Quaternion;
  16343. /** @hidden */
  16344. _processLateAnimationBindings(): void;
  16345. /**
  16346. * Will start the animation sequence of a given target
  16347. * @param target defines the target
  16348. * @param from defines from which frame should animation start
  16349. * @param to defines until which frame should animation run.
  16350. * @param weight defines the weight to apply to the animation (1.0 by default)
  16351. * @param loop defines if the animation loops
  16352. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16353. * @param onAnimationEnd defines the function to be executed when the animation ends
  16354. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16355. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16356. * @param onAnimationLoop defines the callback to call when an animation loops
  16357. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16358. * @returns the animatable object created for this animation
  16359. */
  16360. 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;
  16361. /**
  16362. * Will start the animation sequence of a given target
  16363. * @param target defines the target
  16364. * @param from defines from which frame should animation start
  16365. * @param to defines until which frame should animation run.
  16366. * @param loop defines if the animation loops
  16367. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16368. * @param onAnimationEnd defines the function to be executed when the animation ends
  16369. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16370. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16371. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16372. * @param onAnimationLoop defines the callback to call when an animation loops
  16373. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16374. * @returns the animatable object created for this animation
  16375. */
  16376. 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;
  16377. /**
  16378. * Will start the animation sequence of a given target and its hierarchy
  16379. * @param target defines the target
  16380. * @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.
  16381. * @param from defines from which frame should animation start
  16382. * @param to defines until which frame should animation run.
  16383. * @param loop defines if the animation loops
  16384. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16385. * @param onAnimationEnd defines the function to be executed when the animation ends
  16386. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16387. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16388. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16389. * @param onAnimationLoop defines the callback to call when an animation loops
  16390. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16391. * @returns the list of created animatables
  16392. */
  16393. 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[];
  16394. /**
  16395. * Begin a new animation on a given node
  16396. * @param target defines the target where the animation will take place
  16397. * @param animations defines the list of animations to start
  16398. * @param from defines the initial value
  16399. * @param to defines the final value
  16400. * @param loop defines if you want animation to loop (off by default)
  16401. * @param speedRatio defines the speed ratio to apply to all animations
  16402. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16403. * @param onAnimationLoop defines the callback to call when an animation loops
  16404. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16405. * @returns the list of created animatables
  16406. */
  16407. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16408. /**
  16409. * Begin a new animation on a given node and its hierarchy
  16410. * @param target defines the root node where the animation will take place
  16411. * @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.
  16412. * @param animations defines the list of animations to start
  16413. * @param from defines the initial value
  16414. * @param to defines the final value
  16415. * @param loop defines if you want animation to loop (off by default)
  16416. * @param speedRatio defines the speed ratio to apply to all animations
  16417. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16418. * @param onAnimationLoop defines the callback to call when an animation loops
  16419. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16420. * @returns the list of animatables created for all nodes
  16421. */
  16422. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16423. /**
  16424. * Gets the animatable associated with a specific target
  16425. * @param target defines the target of the animatable
  16426. * @returns the required animatable if found
  16427. */
  16428. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16429. /**
  16430. * Gets all animatables associated with a given target
  16431. * @param target defines the target to look animatables for
  16432. * @returns an array of Animatables
  16433. */
  16434. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16435. /**
  16436. * Stops and removes all animations that have been applied to the scene
  16437. */
  16438. stopAllAnimations(): void;
  16439. /**
  16440. * Gets the current delta time used by animation engine
  16441. */
  16442. deltaTime: number;
  16443. }
  16444. }
  16445. module "babylonjs/Bones/bone" {
  16446. interface Bone {
  16447. /**
  16448. * Copy an animation range from another bone
  16449. * @param source defines the source bone
  16450. * @param rangeName defines the range name to copy
  16451. * @param frameOffset defines the frame offset
  16452. * @param rescaleAsRequired defines if rescaling must be applied if required
  16453. * @param skelDimensionsRatio defines the scaling ratio
  16454. * @returns true if operation was successful
  16455. */
  16456. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16457. }
  16458. }
  16459. }
  16460. declare module "babylonjs/Bones/skeleton" {
  16461. import { Bone } from "babylonjs/Bones/bone";
  16462. import { Observable } from "babylonjs/Misc/observable";
  16463. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16464. import { Scene } from "babylonjs/scene";
  16465. import { Nullable } from "babylonjs/types";
  16466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16467. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16468. import { Animatable } from "babylonjs/Animations/animatable";
  16469. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16470. import { Animation } from "babylonjs/Animations/animation";
  16471. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16472. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16473. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16474. /**
  16475. * Class used to handle skinning animations
  16476. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16477. */
  16478. export class Skeleton implements IAnimatable {
  16479. /** defines the skeleton name */
  16480. name: string;
  16481. /** defines the skeleton Id */
  16482. id: string;
  16483. /**
  16484. * Defines the list of child bones
  16485. */
  16486. bones: Bone[];
  16487. /**
  16488. * Defines an estimate of the dimension of the skeleton at rest
  16489. */
  16490. dimensionsAtRest: Vector3;
  16491. /**
  16492. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16493. */
  16494. needInitialSkinMatrix: boolean;
  16495. /**
  16496. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16497. */
  16498. overrideMesh: Nullable<AbstractMesh>;
  16499. /**
  16500. * Gets the list of animations attached to this skeleton
  16501. */
  16502. animations: Array<Animation>;
  16503. private _scene;
  16504. private _isDirty;
  16505. private _transformMatrices;
  16506. private _transformMatrixTexture;
  16507. private _meshesWithPoseMatrix;
  16508. private _animatables;
  16509. private _identity;
  16510. private _synchronizedWithMesh;
  16511. private _ranges;
  16512. private _lastAbsoluteTransformsUpdateId;
  16513. private _canUseTextureForBones;
  16514. private _uniqueId;
  16515. /** @hidden */
  16516. _numBonesWithLinkedTransformNode: number;
  16517. /** @hidden */
  16518. _hasWaitingData: Nullable<boolean>;
  16519. /** @hidden */
  16520. _waitingOverrideMeshId: Nullable<string>;
  16521. /**
  16522. * Specifies if the skeleton should be serialized
  16523. */
  16524. doNotSerialize: boolean;
  16525. private _useTextureToStoreBoneMatrices;
  16526. /**
  16527. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16528. * Please note that this option is not available if the hardware does not support it
  16529. */
  16530. get useTextureToStoreBoneMatrices(): boolean;
  16531. set useTextureToStoreBoneMatrices(value: boolean);
  16532. private _animationPropertiesOverride;
  16533. /**
  16534. * Gets or sets the animation properties override
  16535. */
  16536. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16537. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16538. /**
  16539. * List of inspectable custom properties (used by the Inspector)
  16540. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16541. */
  16542. inspectableCustomProperties: IInspectable[];
  16543. /**
  16544. * An observable triggered before computing the skeleton's matrices
  16545. */
  16546. onBeforeComputeObservable: Observable<Skeleton>;
  16547. /**
  16548. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16549. */
  16550. get isUsingTextureForMatrices(): boolean;
  16551. /**
  16552. * Gets the unique ID of this skeleton
  16553. */
  16554. get uniqueId(): number;
  16555. /**
  16556. * Creates a new skeleton
  16557. * @param name defines the skeleton name
  16558. * @param id defines the skeleton Id
  16559. * @param scene defines the hosting scene
  16560. */
  16561. constructor(
  16562. /** defines the skeleton name */
  16563. name: string,
  16564. /** defines the skeleton Id */
  16565. id: string, scene: Scene);
  16566. /**
  16567. * Gets the current object class name.
  16568. * @return the class name
  16569. */
  16570. getClassName(): string;
  16571. /**
  16572. * Returns an array containing the root bones
  16573. * @returns an array containing the root bones
  16574. */
  16575. getChildren(): Array<Bone>;
  16576. /**
  16577. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16578. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16579. * @returns a Float32Array containing matrices data
  16580. */
  16581. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16582. /**
  16583. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16584. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16585. * @returns a raw texture containing the data
  16586. */
  16587. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16588. /**
  16589. * Gets the current hosting scene
  16590. * @returns a scene object
  16591. */
  16592. getScene(): Scene;
  16593. /**
  16594. * Gets a string representing the current skeleton data
  16595. * @param fullDetails defines a boolean indicating if we want a verbose version
  16596. * @returns a string representing the current skeleton data
  16597. */
  16598. toString(fullDetails?: boolean): string;
  16599. /**
  16600. * Get bone's index searching by name
  16601. * @param name defines bone's name to search for
  16602. * @return the indice of the bone. Returns -1 if not found
  16603. */
  16604. getBoneIndexByName(name: string): number;
  16605. /**
  16606. * Creater a new animation range
  16607. * @param name defines the name of the range
  16608. * @param from defines the start key
  16609. * @param to defines the end key
  16610. */
  16611. createAnimationRange(name: string, from: number, to: number): void;
  16612. /**
  16613. * Delete a specific animation range
  16614. * @param name defines the name of the range
  16615. * @param deleteFrames defines if frames must be removed as well
  16616. */
  16617. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16618. /**
  16619. * Gets a specific animation range
  16620. * @param name defines the name of the range to look for
  16621. * @returns the requested animation range or null if not found
  16622. */
  16623. getAnimationRange(name: string): Nullable<AnimationRange>;
  16624. /**
  16625. * Gets the list of all animation ranges defined on this skeleton
  16626. * @returns an array
  16627. */
  16628. getAnimationRanges(): Nullable<AnimationRange>[];
  16629. /**
  16630. * Copy animation range from a source skeleton.
  16631. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16632. * @param source defines the source skeleton
  16633. * @param name defines the name of the range to copy
  16634. * @param rescaleAsRequired defines if rescaling must be applied if required
  16635. * @returns true if operation was successful
  16636. */
  16637. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16638. /**
  16639. * Forces the skeleton to go to rest pose
  16640. */
  16641. returnToRest(): void;
  16642. private _getHighestAnimationFrame;
  16643. /**
  16644. * Begin a specific animation range
  16645. * @param name defines the name of the range to start
  16646. * @param loop defines if looping must be turned on (false by default)
  16647. * @param speedRatio defines the speed ratio to apply (1 by default)
  16648. * @param onAnimationEnd defines a callback which will be called when animation will end
  16649. * @returns a new animatable
  16650. */
  16651. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16652. /**
  16653. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16654. * @param skeleton defines the Skeleton containing the animation range to convert
  16655. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16656. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16657. * @returns the original skeleton
  16658. */
  16659. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16660. /** @hidden */
  16661. _markAsDirty(): void;
  16662. /** @hidden */
  16663. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16664. /** @hidden */
  16665. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16666. private _computeTransformMatrices;
  16667. /**
  16668. * Build all resources required to render a skeleton
  16669. */
  16670. prepare(): void;
  16671. /**
  16672. * Gets the list of animatables currently running for this skeleton
  16673. * @returns an array of animatables
  16674. */
  16675. getAnimatables(): IAnimatable[];
  16676. /**
  16677. * Clone the current skeleton
  16678. * @param name defines the name of the new skeleton
  16679. * @param id defines the id of the new skeleton
  16680. * @returns the new skeleton
  16681. */
  16682. clone(name: string, id?: string): Skeleton;
  16683. /**
  16684. * Enable animation blending for this skeleton
  16685. * @param blendingSpeed defines the blending speed to apply
  16686. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16687. */
  16688. enableBlending(blendingSpeed?: number): void;
  16689. /**
  16690. * Releases all resources associated with the current skeleton
  16691. */
  16692. dispose(): void;
  16693. /**
  16694. * Serialize the skeleton in a JSON object
  16695. * @returns a JSON object
  16696. */
  16697. serialize(): any;
  16698. /**
  16699. * Creates a new skeleton from serialized data
  16700. * @param parsedSkeleton defines the serialized data
  16701. * @param scene defines the hosting scene
  16702. * @returns a new skeleton
  16703. */
  16704. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16705. /**
  16706. * Compute all node absolute transforms
  16707. * @param forceUpdate defines if computation must be done even if cache is up to date
  16708. */
  16709. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16710. /**
  16711. * Gets the root pose matrix
  16712. * @returns a matrix
  16713. */
  16714. getPoseMatrix(): Nullable<Matrix>;
  16715. /**
  16716. * Sorts bones per internal index
  16717. */
  16718. sortBones(): void;
  16719. private _sortBones;
  16720. /**
  16721. * Set the current local matrix as the restPose for all bones in the skeleton.
  16722. */
  16723. setCurrentPoseAsRest(): void;
  16724. }
  16725. }
  16726. declare module "babylonjs/Meshes/instancedMesh" {
  16727. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16728. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16729. import { Camera } from "babylonjs/Cameras/camera";
  16730. import { Node } from "babylonjs/node";
  16731. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16732. import { Mesh } from "babylonjs/Meshes/mesh";
  16733. import { Material } from "babylonjs/Materials/material";
  16734. import { Skeleton } from "babylonjs/Bones/skeleton";
  16735. import { Light } from "babylonjs/Lights/light";
  16736. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16737. /**
  16738. * Creates an instance based on a source mesh.
  16739. */
  16740. export class InstancedMesh extends AbstractMesh {
  16741. private _sourceMesh;
  16742. private _currentLOD;
  16743. /** @hidden */
  16744. _indexInSourceMeshInstanceArray: number;
  16745. constructor(name: string, source: Mesh);
  16746. /**
  16747. * Returns the string "InstancedMesh".
  16748. */
  16749. getClassName(): string;
  16750. /** Gets the list of lights affecting that mesh */
  16751. get lightSources(): Light[];
  16752. _resyncLightSources(): void;
  16753. _resyncLightSource(light: Light): void;
  16754. _removeLightSource(light: Light, dispose: boolean): void;
  16755. /**
  16756. * If the source mesh receives shadows
  16757. */
  16758. get receiveShadows(): boolean;
  16759. /**
  16760. * The material of the source mesh
  16761. */
  16762. get material(): Nullable<Material>;
  16763. /**
  16764. * Visibility of the source mesh
  16765. */
  16766. get visibility(): number;
  16767. /**
  16768. * Skeleton of the source mesh
  16769. */
  16770. get skeleton(): Nullable<Skeleton>;
  16771. /**
  16772. * Rendering ground id of the source mesh
  16773. */
  16774. get renderingGroupId(): number;
  16775. set renderingGroupId(value: number);
  16776. /**
  16777. * Returns the total number of vertices (integer).
  16778. */
  16779. getTotalVertices(): number;
  16780. /**
  16781. * Returns a positive integer : the total number of indices in this mesh geometry.
  16782. * @returns the numner of indices or zero if the mesh has no geometry.
  16783. */
  16784. getTotalIndices(): number;
  16785. /**
  16786. * The source mesh of the instance
  16787. */
  16788. get sourceMesh(): Mesh;
  16789. /**
  16790. * Creates a new InstancedMesh object from the mesh model.
  16791. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16792. * @param name defines the name of the new instance
  16793. * @returns a new InstancedMesh
  16794. */
  16795. createInstance(name: string): InstancedMesh;
  16796. /**
  16797. * Is this node ready to be used/rendered
  16798. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16799. * @return {boolean} is it ready
  16800. */
  16801. isReady(completeCheck?: boolean): boolean;
  16802. /**
  16803. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16804. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16805. * @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.
  16806. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16807. */
  16808. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16809. /**
  16810. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16811. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16812. * The `data` are either a numeric array either a Float32Array.
  16813. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16814. * 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).
  16815. * Note that a new underlying VertexBuffer object is created each call.
  16816. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16817. *
  16818. * Possible `kind` values :
  16819. * - VertexBuffer.PositionKind
  16820. * - VertexBuffer.UVKind
  16821. * - VertexBuffer.UV2Kind
  16822. * - VertexBuffer.UV3Kind
  16823. * - VertexBuffer.UV4Kind
  16824. * - VertexBuffer.UV5Kind
  16825. * - VertexBuffer.UV6Kind
  16826. * - VertexBuffer.ColorKind
  16827. * - VertexBuffer.MatricesIndicesKind
  16828. * - VertexBuffer.MatricesIndicesExtraKind
  16829. * - VertexBuffer.MatricesWeightsKind
  16830. * - VertexBuffer.MatricesWeightsExtraKind
  16831. *
  16832. * Returns the Mesh.
  16833. */
  16834. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16835. /**
  16836. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16837. * If the mesh has no geometry, it is simply returned as it is.
  16838. * The `data` are either a numeric array either a Float32Array.
  16839. * No new underlying VertexBuffer object is created.
  16840. * 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.
  16841. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16842. *
  16843. * Possible `kind` values :
  16844. * - VertexBuffer.PositionKind
  16845. * - VertexBuffer.UVKind
  16846. * - VertexBuffer.UV2Kind
  16847. * - VertexBuffer.UV3Kind
  16848. * - VertexBuffer.UV4Kind
  16849. * - VertexBuffer.UV5Kind
  16850. * - VertexBuffer.UV6Kind
  16851. * - VertexBuffer.ColorKind
  16852. * - VertexBuffer.MatricesIndicesKind
  16853. * - VertexBuffer.MatricesIndicesExtraKind
  16854. * - VertexBuffer.MatricesWeightsKind
  16855. * - VertexBuffer.MatricesWeightsExtraKind
  16856. *
  16857. * Returns the Mesh.
  16858. */
  16859. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16860. /**
  16861. * Sets the mesh indices.
  16862. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16863. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16864. * This method creates a new index buffer each call.
  16865. * Returns the Mesh.
  16866. */
  16867. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16868. /**
  16869. * Boolean : True if the mesh owns the requested kind of data.
  16870. */
  16871. isVerticesDataPresent(kind: string): boolean;
  16872. /**
  16873. * Returns an array of indices (IndicesArray).
  16874. */
  16875. getIndices(): Nullable<IndicesArray>;
  16876. get _positions(): Nullable<Vector3[]>;
  16877. /**
  16878. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16879. * This means the mesh underlying bounding box and sphere are recomputed.
  16880. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16881. * @returns the current mesh
  16882. */
  16883. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16884. /** @hidden */
  16885. _preActivate(): InstancedMesh;
  16886. /** @hidden */
  16887. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16888. /** @hidden */
  16889. _postActivate(): void;
  16890. getWorldMatrix(): Matrix;
  16891. get isAnInstance(): boolean;
  16892. /**
  16893. * Returns the current associated LOD AbstractMesh.
  16894. */
  16895. getLOD(camera: Camera): AbstractMesh;
  16896. /** @hidden */
  16897. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16898. /** @hidden */
  16899. _syncSubMeshes(): InstancedMesh;
  16900. /** @hidden */
  16901. _generatePointsArray(): boolean;
  16902. /** @hidden */
  16903. _updateBoundingInfo(): AbstractMesh;
  16904. /**
  16905. * Creates a new InstancedMesh from the current mesh.
  16906. * - name (string) : the cloned mesh name
  16907. * - newParent (optional Node) : the optional Node to parent the clone to.
  16908. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16909. *
  16910. * Returns the clone.
  16911. */
  16912. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16913. /**
  16914. * Disposes the InstancedMesh.
  16915. * Returns nothing.
  16916. */
  16917. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16918. }
  16919. module "babylonjs/Meshes/mesh" {
  16920. interface Mesh {
  16921. /**
  16922. * Register a custom buffer that will be instanced
  16923. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16924. * @param kind defines the buffer kind
  16925. * @param stride defines the stride in floats
  16926. */
  16927. registerInstancedBuffer(kind: string, stride: number): void;
  16928. /**
  16929. * true to use the edge renderer for all instances of this mesh
  16930. */
  16931. edgesShareWithInstances: boolean;
  16932. /** @hidden */
  16933. _userInstancedBuffersStorage: {
  16934. data: {
  16935. [key: string]: Float32Array;
  16936. };
  16937. sizes: {
  16938. [key: string]: number;
  16939. };
  16940. vertexBuffers: {
  16941. [key: string]: Nullable<VertexBuffer>;
  16942. };
  16943. strides: {
  16944. [key: string]: number;
  16945. };
  16946. };
  16947. }
  16948. }
  16949. module "babylonjs/Meshes/abstractMesh" {
  16950. interface AbstractMesh {
  16951. /**
  16952. * Object used to store instanced buffers defined by user
  16953. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16954. */
  16955. instancedBuffers: {
  16956. [key: string]: any;
  16957. };
  16958. }
  16959. }
  16960. }
  16961. declare module "babylonjs/Materials/shaderMaterial" {
  16962. import { Nullable } from "babylonjs/types";
  16963. import { Scene } from "babylonjs/scene";
  16964. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16966. import { Mesh } from "babylonjs/Meshes/mesh";
  16967. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16968. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16969. import { Effect } from "babylonjs/Materials/effect";
  16970. import { Material } from "babylonjs/Materials/material";
  16971. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16972. /**
  16973. * Defines the options associated with the creation of a shader material.
  16974. */
  16975. export interface IShaderMaterialOptions {
  16976. /**
  16977. * Does the material work in alpha blend mode
  16978. */
  16979. needAlphaBlending: boolean;
  16980. /**
  16981. * Does the material work in alpha test mode
  16982. */
  16983. needAlphaTesting: boolean;
  16984. /**
  16985. * The list of attribute names used in the shader
  16986. */
  16987. attributes: string[];
  16988. /**
  16989. * The list of unifrom names used in the shader
  16990. */
  16991. uniforms: string[];
  16992. /**
  16993. * The list of UBO names used in the shader
  16994. */
  16995. uniformBuffers: string[];
  16996. /**
  16997. * The list of sampler names used in the shader
  16998. */
  16999. samplers: string[];
  17000. /**
  17001. * The list of defines used in the shader
  17002. */
  17003. defines: string[];
  17004. }
  17005. /**
  17006. * 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.
  17007. *
  17008. * This returned material effects how the mesh will look based on the code in the shaders.
  17009. *
  17010. * @see https://doc.babylonjs.com/how_to/shader_material
  17011. */
  17012. export class ShaderMaterial extends Material {
  17013. private _shaderPath;
  17014. private _options;
  17015. private _textures;
  17016. private _textureArrays;
  17017. private _floats;
  17018. private _ints;
  17019. private _floatsArrays;
  17020. private _colors3;
  17021. private _colors3Arrays;
  17022. private _colors4;
  17023. private _colors4Arrays;
  17024. private _vectors2;
  17025. private _vectors3;
  17026. private _vectors4;
  17027. private _matrices;
  17028. private _matrixArrays;
  17029. private _matrices3x3;
  17030. private _matrices2x2;
  17031. private _vectors2Arrays;
  17032. private _vectors3Arrays;
  17033. private _vectors4Arrays;
  17034. private _cachedWorldViewMatrix;
  17035. private _cachedWorldViewProjectionMatrix;
  17036. private _renderId;
  17037. private _multiview;
  17038. private _cachedDefines;
  17039. /** Define the Url to load snippets */
  17040. static SnippetUrl: string;
  17041. /** Snippet ID if the material was created from the snippet server */
  17042. snippetId: string;
  17043. /**
  17044. * Instantiate a new shader material.
  17045. * 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.
  17046. * This returned material effects how the mesh will look based on the code in the shaders.
  17047. * @see https://doc.babylonjs.com/how_to/shader_material
  17048. * @param name Define the name of the material in the scene
  17049. * @param scene Define the scene the material belongs to
  17050. * @param shaderPath Defines the route to the shader code in one of three ways:
  17051. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17052. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17053. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17054. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17055. * @param options Define the options used to create the shader
  17056. */
  17057. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17058. /**
  17059. * Gets the shader path used to define the shader code
  17060. * It can be modified to trigger a new compilation
  17061. */
  17062. get shaderPath(): any;
  17063. /**
  17064. * Sets the shader path used to define the shader code
  17065. * It can be modified to trigger a new compilation
  17066. */
  17067. set shaderPath(shaderPath: any);
  17068. /**
  17069. * Gets the options used to compile the shader.
  17070. * They can be modified to trigger a new compilation
  17071. */
  17072. get options(): IShaderMaterialOptions;
  17073. /**
  17074. * Gets the current class name of the material e.g. "ShaderMaterial"
  17075. * Mainly use in serialization.
  17076. * @returns the class name
  17077. */
  17078. getClassName(): string;
  17079. /**
  17080. * Specifies if the material will require alpha blending
  17081. * @returns a boolean specifying if alpha blending is needed
  17082. */
  17083. needAlphaBlending(): boolean;
  17084. /**
  17085. * Specifies if this material should be rendered in alpha test mode
  17086. * @returns a boolean specifying if an alpha test is needed.
  17087. */
  17088. needAlphaTesting(): boolean;
  17089. private _checkUniform;
  17090. /**
  17091. * Set a texture in the shader.
  17092. * @param name Define the name of the uniform samplers as defined in the shader
  17093. * @param texture Define the texture to bind to this sampler
  17094. * @return the material itself allowing "fluent" like uniform updates
  17095. */
  17096. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17097. /**
  17098. * Set a texture array in the shader.
  17099. * @param name Define the name of the uniform sampler array as defined in the shader
  17100. * @param textures Define the list of textures to bind to this sampler
  17101. * @return the material itself allowing "fluent" like uniform updates
  17102. */
  17103. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17104. /**
  17105. * Set a float in the shader.
  17106. * @param name Define the name of the uniform as defined in the shader
  17107. * @param value Define the value to give to the uniform
  17108. * @return the material itself allowing "fluent" like uniform updates
  17109. */
  17110. setFloat(name: string, value: number): ShaderMaterial;
  17111. /**
  17112. * Set a int in the shader.
  17113. * @param name Define the name of the uniform as defined in the shader
  17114. * @param value Define the value to give to the uniform
  17115. * @return the material itself allowing "fluent" like uniform updates
  17116. */
  17117. setInt(name: string, value: number): ShaderMaterial;
  17118. /**
  17119. * Set an array of floats in the shader.
  17120. * @param name Define the name of the uniform as defined in the shader
  17121. * @param value Define the value to give to the uniform
  17122. * @return the material itself allowing "fluent" like uniform updates
  17123. */
  17124. setFloats(name: string, value: number[]): ShaderMaterial;
  17125. /**
  17126. * Set a vec3 in the shader from a Color3.
  17127. * @param name Define the name of the uniform as defined in the shader
  17128. * @param value Define the value to give to the uniform
  17129. * @return the material itself allowing "fluent" like uniform updates
  17130. */
  17131. setColor3(name: string, value: Color3): ShaderMaterial;
  17132. /**
  17133. * Set a vec3 array in the shader from a Color3 array.
  17134. * @param name Define the name of the uniform as defined in the shader
  17135. * @param value Define the value to give to the uniform
  17136. * @return the material itself allowing "fluent" like uniform updates
  17137. */
  17138. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17139. /**
  17140. * Set a vec4 in the shader from a Color4.
  17141. * @param name Define the name of the uniform as defined in the shader
  17142. * @param value Define the value to give to the uniform
  17143. * @return the material itself allowing "fluent" like uniform updates
  17144. */
  17145. setColor4(name: string, value: Color4): ShaderMaterial;
  17146. /**
  17147. * Set a vec4 array in the shader from a Color4 array.
  17148. * @param name Define the name of the uniform as defined in the shader
  17149. * @param value Define the value to give to the uniform
  17150. * @return the material itself allowing "fluent" like uniform updates
  17151. */
  17152. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17153. /**
  17154. * Set a vec2 in the shader from a Vector2.
  17155. * @param name Define the name of the uniform as defined in the shader
  17156. * @param value Define the value to give to the uniform
  17157. * @return the material itself allowing "fluent" like uniform updates
  17158. */
  17159. setVector2(name: string, value: Vector2): ShaderMaterial;
  17160. /**
  17161. * Set a vec3 in the shader from a Vector3.
  17162. * @param name Define the name of the uniform as defined in the shader
  17163. * @param value Define the value to give to the uniform
  17164. * @return the material itself allowing "fluent" like uniform updates
  17165. */
  17166. setVector3(name: string, value: Vector3): ShaderMaterial;
  17167. /**
  17168. * Set a vec4 in the shader from a Vector4.
  17169. * @param name Define the name of the uniform as defined in the shader
  17170. * @param value Define the value to give to the uniform
  17171. * @return the material itself allowing "fluent" like uniform updates
  17172. */
  17173. setVector4(name: string, value: Vector4): ShaderMaterial;
  17174. /**
  17175. * Set a mat4 in the shader from a Matrix.
  17176. * @param name Define the name of the uniform as defined in the shader
  17177. * @param value Define the value to give to the uniform
  17178. * @return the material itself allowing "fluent" like uniform updates
  17179. */
  17180. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17181. /**
  17182. * Set a float32Array in the shader from a matrix array.
  17183. * @param name Define the name of the uniform as defined in the shader
  17184. * @param value Define the value to give to the uniform
  17185. * @return the material itself allowing "fluent" like uniform updates
  17186. */
  17187. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17188. /**
  17189. * Set a mat3 in the shader from a Float32Array.
  17190. * @param name Define the name of the uniform as defined in the shader
  17191. * @param value Define the value to give to the uniform
  17192. * @return the material itself allowing "fluent" like uniform updates
  17193. */
  17194. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17195. /**
  17196. * Set a mat2 in the shader from a Float32Array.
  17197. * @param name Define the name of the uniform as defined in the shader
  17198. * @param value Define the value to give to the uniform
  17199. * @return the material itself allowing "fluent" like uniform updates
  17200. */
  17201. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17202. /**
  17203. * Set a vec2 array in the shader from a number array.
  17204. * @param name Define the name of the uniform as defined in the shader
  17205. * @param value Define the value to give to the uniform
  17206. * @return the material itself allowing "fluent" like uniform updates
  17207. */
  17208. setArray2(name: string, value: number[]): ShaderMaterial;
  17209. /**
  17210. * Set a vec3 array in the shader from a number array.
  17211. * @param name Define the name of the uniform as defined in the shader
  17212. * @param value Define the value to give to the uniform
  17213. * @return the material itself allowing "fluent" like uniform updates
  17214. */
  17215. setArray3(name: string, value: number[]): ShaderMaterial;
  17216. /**
  17217. * Set a vec4 array in the shader from a number array.
  17218. * @param name Define the name of the uniform as defined in the shader
  17219. * @param value Define the value to give to the uniform
  17220. * @return the material itself allowing "fluent" like uniform updates
  17221. */
  17222. setArray4(name: string, value: number[]): ShaderMaterial;
  17223. private _checkCache;
  17224. /**
  17225. * Specifies that the submesh is ready to be used
  17226. * @param mesh defines the mesh to check
  17227. * @param subMesh defines which submesh to check
  17228. * @param useInstances specifies that instances should be used
  17229. * @returns a boolean indicating that the submesh is ready or not
  17230. */
  17231. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17232. /**
  17233. * Checks if the material is ready to render the requested mesh
  17234. * @param mesh Define the mesh to render
  17235. * @param useInstances Define whether or not the material is used with instances
  17236. * @returns true if ready, otherwise false
  17237. */
  17238. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17239. /**
  17240. * Binds the world matrix to the material
  17241. * @param world defines the world transformation matrix
  17242. * @param effectOverride - If provided, use this effect instead of internal effect
  17243. */
  17244. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17245. /**
  17246. * Binds the submesh to this material by preparing the effect and shader to draw
  17247. * @param world defines the world transformation matrix
  17248. * @param mesh defines the mesh containing the submesh
  17249. * @param subMesh defines the submesh to bind the material to
  17250. */
  17251. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17252. /**
  17253. * Binds the material to the mesh
  17254. * @param world defines the world transformation matrix
  17255. * @param mesh defines the mesh to bind the material to
  17256. * @param effectOverride - If provided, use this effect instead of internal effect
  17257. */
  17258. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17259. protected _afterBind(mesh?: Mesh): void;
  17260. /**
  17261. * Gets the active textures from the material
  17262. * @returns an array of textures
  17263. */
  17264. getActiveTextures(): BaseTexture[];
  17265. /**
  17266. * Specifies if the material uses a texture
  17267. * @param texture defines the texture to check against the material
  17268. * @returns a boolean specifying if the material uses the texture
  17269. */
  17270. hasTexture(texture: BaseTexture): boolean;
  17271. /**
  17272. * Makes a duplicate of the material, and gives it a new name
  17273. * @param name defines the new name for the duplicated material
  17274. * @returns the cloned material
  17275. */
  17276. clone(name: string): ShaderMaterial;
  17277. /**
  17278. * Disposes the material
  17279. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17280. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17281. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17282. */
  17283. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17284. /**
  17285. * Serializes this material in a JSON representation
  17286. * @returns the serialized material object
  17287. */
  17288. serialize(): any;
  17289. /**
  17290. * Creates a shader material from parsed shader material data
  17291. * @param source defines the JSON represnetation of the material
  17292. * @param scene defines the hosting scene
  17293. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17294. * @returns a new material
  17295. */
  17296. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17297. /**
  17298. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17299. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17300. * @param url defines the url to load from
  17301. * @param scene defines the hosting scene
  17302. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17303. * @returns a promise that will resolve to the new ShaderMaterial
  17304. */
  17305. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17306. /**
  17307. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17308. * @param snippetId defines the snippet to load
  17309. * @param scene defines the hosting scene
  17310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17311. * @returns a promise that will resolve to the new ShaderMaterial
  17312. */
  17313. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17314. }
  17315. }
  17316. declare module "babylonjs/Shaders/color.fragment" {
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17319. /** @hidden */
  17320. export var colorPixelShader: {
  17321. name: string;
  17322. shader: string;
  17323. };
  17324. }
  17325. declare module "babylonjs/Shaders/color.vertex" {
  17326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17332. /** @hidden */
  17333. export var colorVertexShader: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Meshes/linesMesh" {
  17339. import { Nullable } from "babylonjs/types";
  17340. import { Scene } from "babylonjs/scene";
  17341. import { Color3 } from "babylonjs/Maths/math.color";
  17342. import { Node } from "babylonjs/node";
  17343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17344. import { Mesh } from "babylonjs/Meshes/mesh";
  17345. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17346. import { Effect } from "babylonjs/Materials/effect";
  17347. import { Material } from "babylonjs/Materials/material";
  17348. import "babylonjs/Shaders/color.fragment";
  17349. import "babylonjs/Shaders/color.vertex";
  17350. /**
  17351. * Line mesh
  17352. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17353. */
  17354. export class LinesMesh extends Mesh {
  17355. /**
  17356. * If vertex color should be applied to the mesh
  17357. */
  17358. readonly useVertexColor?: boolean | undefined;
  17359. /**
  17360. * If vertex alpha should be applied to the mesh
  17361. */
  17362. readonly useVertexAlpha?: boolean | undefined;
  17363. /**
  17364. * Color of the line (Default: White)
  17365. */
  17366. color: Color3;
  17367. /**
  17368. * Alpha of the line (Default: 1)
  17369. */
  17370. alpha: number;
  17371. /**
  17372. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17373. * This margin is expressed in world space coordinates, so its value may vary.
  17374. * Default value is 0.1
  17375. */
  17376. intersectionThreshold: number;
  17377. private _colorShader;
  17378. private color4;
  17379. /**
  17380. * Creates a new LinesMesh
  17381. * @param name defines the name
  17382. * @param scene defines the hosting scene
  17383. * @param parent defines the parent mesh if any
  17384. * @param source defines the optional source LinesMesh used to clone data from
  17385. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17386. * When false, achieved by calling a clone(), also passing False.
  17387. * This will make creation of children, recursive.
  17388. * @param useVertexColor defines if this LinesMesh supports vertex color
  17389. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17390. */
  17391. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17392. /**
  17393. * If vertex color should be applied to the mesh
  17394. */
  17395. useVertexColor?: boolean | undefined,
  17396. /**
  17397. * If vertex alpha should be applied to the mesh
  17398. */
  17399. useVertexAlpha?: boolean | undefined);
  17400. private _addClipPlaneDefine;
  17401. private _removeClipPlaneDefine;
  17402. isReady(): boolean;
  17403. /**
  17404. * Returns the string "LineMesh"
  17405. */
  17406. getClassName(): string;
  17407. /**
  17408. * @hidden
  17409. */
  17410. get material(): Material;
  17411. /**
  17412. * @hidden
  17413. */
  17414. set material(value: Material);
  17415. /**
  17416. * @hidden
  17417. */
  17418. get checkCollisions(): boolean;
  17419. /** @hidden */
  17420. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17421. /** @hidden */
  17422. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17423. /**
  17424. * Disposes of the line mesh
  17425. * @param doNotRecurse If children should be disposed
  17426. */
  17427. dispose(doNotRecurse?: boolean): void;
  17428. /**
  17429. * Returns a new LineMesh object cloned from the current one.
  17430. */
  17431. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17432. /**
  17433. * Creates a new InstancedLinesMesh object from the mesh model.
  17434. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17435. * @param name defines the name of the new instance
  17436. * @returns a new InstancedLinesMesh
  17437. */
  17438. createInstance(name: string): InstancedLinesMesh;
  17439. }
  17440. /**
  17441. * Creates an instance based on a source LinesMesh
  17442. */
  17443. export class InstancedLinesMesh extends InstancedMesh {
  17444. /**
  17445. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17446. * This margin is expressed in world space coordinates, so its value may vary.
  17447. * Initilized with the intersectionThreshold value of the source LinesMesh
  17448. */
  17449. intersectionThreshold: number;
  17450. constructor(name: string, source: LinesMesh);
  17451. /**
  17452. * Returns the string "InstancedLinesMesh".
  17453. */
  17454. getClassName(): string;
  17455. }
  17456. }
  17457. declare module "babylonjs/Shaders/line.fragment" {
  17458. /** @hidden */
  17459. export var linePixelShader: {
  17460. name: string;
  17461. shader: string;
  17462. };
  17463. }
  17464. declare module "babylonjs/Shaders/line.vertex" {
  17465. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17467. /** @hidden */
  17468. export var lineVertexShader: {
  17469. name: string;
  17470. shader: string;
  17471. };
  17472. }
  17473. declare module "babylonjs/Rendering/edgesRenderer" {
  17474. import { Nullable } from "babylonjs/types";
  17475. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17477. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17478. import { IDisposable } from "babylonjs/scene";
  17479. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17480. import "babylonjs/Shaders/line.fragment";
  17481. import "babylonjs/Shaders/line.vertex";
  17482. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17483. import { SmartArray } from "babylonjs/Misc/smartArray";
  17484. module "babylonjs/scene" {
  17485. interface Scene {
  17486. /** @hidden */
  17487. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17488. }
  17489. }
  17490. module "babylonjs/Meshes/abstractMesh" {
  17491. interface AbstractMesh {
  17492. /**
  17493. * Gets the edgesRenderer associated with the mesh
  17494. */
  17495. edgesRenderer: Nullable<EdgesRenderer>;
  17496. }
  17497. }
  17498. module "babylonjs/Meshes/linesMesh" {
  17499. interface LinesMesh {
  17500. /**
  17501. * Enables the edge rendering mode on the mesh.
  17502. * This mode makes the mesh edges visible
  17503. * @param epsilon defines the maximal distance between two angles to detect a face
  17504. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17505. * @returns the currentAbstractMesh
  17506. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17507. */
  17508. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17509. }
  17510. }
  17511. module "babylonjs/Meshes/linesMesh" {
  17512. interface InstancedLinesMesh {
  17513. /**
  17514. * Enables the edge rendering mode on the mesh.
  17515. * This mode makes the mesh edges visible
  17516. * @param epsilon defines the maximal distance between two angles to detect a face
  17517. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17518. * @returns the current InstancedLinesMesh
  17519. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17520. */
  17521. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17522. }
  17523. }
  17524. /**
  17525. * Defines the minimum contract an Edges renderer should follow.
  17526. */
  17527. export interface IEdgesRenderer extends IDisposable {
  17528. /**
  17529. * Gets or sets a boolean indicating if the edgesRenderer is active
  17530. */
  17531. isEnabled: boolean;
  17532. /**
  17533. * Renders the edges of the attached mesh,
  17534. */
  17535. render(): void;
  17536. /**
  17537. * Checks wether or not the edges renderer is ready to render.
  17538. * @return true if ready, otherwise false.
  17539. */
  17540. isReady(): boolean;
  17541. /**
  17542. * List of instances to render in case the source mesh has instances
  17543. */
  17544. customInstances: SmartArray<Matrix>;
  17545. }
  17546. /**
  17547. * Defines the additional options of the edges renderer
  17548. */
  17549. export interface IEdgesRendererOptions {
  17550. /**
  17551. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17552. * If not defined, the default value is true
  17553. */
  17554. useAlternateEdgeFinder?: boolean;
  17555. /**
  17556. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17557. * If not defined, the default value is true.
  17558. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  17559. * This option is used only if useAlternateEdgeFinder = true
  17560. */
  17561. useFastVertexMerger?: boolean;
  17562. /**
  17563. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17564. * The default value is 1e-6
  17565. * This option is used only if useAlternateEdgeFinder = true
  17566. */
  17567. epsilonVertexMerge?: number;
  17568. /**
  17569. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  17570. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  17571. * This option is used only if useAlternateEdgeFinder = true
  17572. */
  17573. applyTessellation?: boolean;
  17574. /**
  17575. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  17576. * The default value is 1e-6
  17577. * This option is used only if useAlternateEdgeFinder = true
  17578. */
  17579. epsilonVertexAligned?: number;
  17580. }
  17581. /**
  17582. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17583. */
  17584. export class EdgesRenderer implements IEdgesRenderer {
  17585. /**
  17586. * Define the size of the edges with an orthographic camera
  17587. */
  17588. edgesWidthScalerForOrthographic: number;
  17589. /**
  17590. * Define the size of the edges with a perspective camera
  17591. */
  17592. edgesWidthScalerForPerspective: number;
  17593. protected _source: AbstractMesh;
  17594. protected _linesPositions: number[];
  17595. protected _linesNormals: number[];
  17596. protected _linesIndices: number[];
  17597. protected _epsilon: number;
  17598. protected _indicesCount: number;
  17599. protected _lineShader: ShaderMaterial;
  17600. protected _ib: DataBuffer;
  17601. protected _buffers: {
  17602. [key: string]: Nullable<VertexBuffer>;
  17603. };
  17604. protected _buffersForInstances: {
  17605. [key: string]: Nullable<VertexBuffer>;
  17606. };
  17607. protected _checkVerticesInsteadOfIndices: boolean;
  17608. protected _options: Nullable<IEdgesRendererOptions>;
  17609. private _meshRebuildObserver;
  17610. private _meshDisposeObserver;
  17611. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17612. isEnabled: boolean;
  17613. /**
  17614. * List of instances to render in case the source mesh has instances
  17615. */
  17616. customInstances: SmartArray<Matrix>;
  17617. private static GetShader;
  17618. /**
  17619. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17620. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17621. * @param source Mesh used to create edges
  17622. * @param epsilon sum of angles in adjacency to check for edge
  17623. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17624. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17625. * @param options The options to apply when generating the edges
  17626. */
  17627. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17628. protected _prepareRessources(): void;
  17629. /** @hidden */
  17630. _rebuild(): void;
  17631. /**
  17632. * Releases the required resources for the edges renderer
  17633. */
  17634. dispose(): void;
  17635. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17636. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17637. /**
  17638. * Checks if the pair of p0 and p1 is en edge
  17639. * @param faceIndex
  17640. * @param edge
  17641. * @param faceNormals
  17642. * @param p0
  17643. * @param p1
  17644. * @private
  17645. */
  17646. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17647. /**
  17648. * push line into the position, normal and index buffer
  17649. * @protected
  17650. */
  17651. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17652. /**
  17653. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17654. */
  17655. private _tessellateTriangle;
  17656. private _generateEdgesLinesAlternate;
  17657. /**
  17658. * Generates lines edges from adjacencjes
  17659. * @private
  17660. */
  17661. _generateEdgesLines(): void;
  17662. /**
  17663. * Checks wether or not the edges renderer is ready to render.
  17664. * @return true if ready, otherwise false.
  17665. */
  17666. isReady(): boolean;
  17667. /**
  17668. * Renders the edges of the attached mesh,
  17669. */
  17670. render(): void;
  17671. }
  17672. /**
  17673. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17674. */
  17675. export class LineEdgesRenderer extends EdgesRenderer {
  17676. /**
  17677. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17678. * @param source LineMesh used to generate edges
  17679. * @param epsilon not important (specified angle for edge detection)
  17680. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17681. */
  17682. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17683. /**
  17684. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17685. */
  17686. _generateEdgesLines(): void;
  17687. }
  17688. }
  17689. declare module "babylonjs/Rendering/renderingGroup" {
  17690. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17691. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17692. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17693. import { Nullable } from "babylonjs/types";
  17694. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17695. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17696. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17697. import { Material } from "babylonjs/Materials/material";
  17698. import { Scene } from "babylonjs/scene";
  17699. /**
  17700. * This represents the object necessary to create a rendering group.
  17701. * This is exclusively used and created by the rendering manager.
  17702. * To modify the behavior, you use the available helpers in your scene or meshes.
  17703. * @hidden
  17704. */
  17705. export class RenderingGroup {
  17706. index: number;
  17707. private static _zeroVector;
  17708. private _scene;
  17709. private _opaqueSubMeshes;
  17710. private _transparentSubMeshes;
  17711. private _alphaTestSubMeshes;
  17712. private _depthOnlySubMeshes;
  17713. private _particleSystems;
  17714. private _spriteManagers;
  17715. private _opaqueSortCompareFn;
  17716. private _alphaTestSortCompareFn;
  17717. private _transparentSortCompareFn;
  17718. private _renderOpaque;
  17719. private _renderAlphaTest;
  17720. private _renderTransparent;
  17721. /** @hidden */
  17722. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17723. onBeforeTransparentRendering: () => void;
  17724. /**
  17725. * Set the opaque sort comparison function.
  17726. * If null the sub meshes will be render in the order they were created
  17727. */
  17728. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17729. /**
  17730. * Set the alpha test sort comparison function.
  17731. * If null the sub meshes will be render in the order they were created
  17732. */
  17733. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17734. /**
  17735. * Set the transparent sort comparison function.
  17736. * If null the sub meshes will be render in the order they were created
  17737. */
  17738. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17739. /**
  17740. * Creates a new rendering group.
  17741. * @param index The rendering group index
  17742. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17743. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17744. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17745. */
  17746. 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>);
  17747. /**
  17748. * Render all the sub meshes contained in the group.
  17749. * @param customRenderFunction Used to override the default render behaviour of the group.
  17750. * @returns true if rendered some submeshes.
  17751. */
  17752. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17753. /**
  17754. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17755. * @param subMeshes The submeshes to render
  17756. */
  17757. private renderOpaqueSorted;
  17758. /**
  17759. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17760. * @param subMeshes The submeshes to render
  17761. */
  17762. private renderAlphaTestSorted;
  17763. /**
  17764. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17765. * @param subMeshes The submeshes to render
  17766. */
  17767. private renderTransparentSorted;
  17768. /**
  17769. * Renders the submeshes in a specified order.
  17770. * @param subMeshes The submeshes to sort before render
  17771. * @param sortCompareFn The comparison function use to sort
  17772. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17773. * @param transparent Specifies to activate blending if true
  17774. */
  17775. private static renderSorted;
  17776. /**
  17777. * Renders the submeshes in the order they were dispatched (no sort applied).
  17778. * @param subMeshes The submeshes to render
  17779. */
  17780. private static renderUnsorted;
  17781. /**
  17782. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17783. * are rendered back to front if in the same alpha index.
  17784. *
  17785. * @param a The first submesh
  17786. * @param b The second submesh
  17787. * @returns The result of the comparison
  17788. */
  17789. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17790. /**
  17791. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17792. * are rendered back to front.
  17793. *
  17794. * @param a The first submesh
  17795. * @param b The second submesh
  17796. * @returns The result of the comparison
  17797. */
  17798. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17799. /**
  17800. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17801. * are rendered front to back (prevent overdraw).
  17802. *
  17803. * @param a The first submesh
  17804. * @param b The second submesh
  17805. * @returns The result of the comparison
  17806. */
  17807. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17808. /**
  17809. * Resets the different lists of submeshes to prepare a new frame.
  17810. */
  17811. prepare(): void;
  17812. dispose(): void;
  17813. /**
  17814. * Inserts the submesh in its correct queue depending on its material.
  17815. * @param subMesh The submesh to dispatch
  17816. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17817. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17818. */
  17819. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17820. dispatchSprites(spriteManager: ISpriteManager): void;
  17821. dispatchParticles(particleSystem: IParticleSystem): void;
  17822. private _renderParticles;
  17823. private _renderSprites;
  17824. }
  17825. }
  17826. declare module "babylonjs/Rendering/renderingManager" {
  17827. import { Nullable } from "babylonjs/types";
  17828. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17829. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17830. import { SmartArray } from "babylonjs/Misc/smartArray";
  17831. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17832. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17833. import { Material } from "babylonjs/Materials/material";
  17834. import { Scene } from "babylonjs/scene";
  17835. import { Camera } from "babylonjs/Cameras/camera";
  17836. /**
  17837. * Interface describing the different options available in the rendering manager
  17838. * regarding Auto Clear between groups.
  17839. */
  17840. export interface IRenderingManagerAutoClearSetup {
  17841. /**
  17842. * Defines whether or not autoclear is enable.
  17843. */
  17844. autoClear: boolean;
  17845. /**
  17846. * Defines whether or not to autoclear the depth buffer.
  17847. */
  17848. depth: boolean;
  17849. /**
  17850. * Defines whether or not to autoclear the stencil buffer.
  17851. */
  17852. stencil: boolean;
  17853. }
  17854. /**
  17855. * This class is used by the onRenderingGroupObservable
  17856. */
  17857. export class RenderingGroupInfo {
  17858. /**
  17859. * The Scene that being rendered
  17860. */
  17861. scene: Scene;
  17862. /**
  17863. * The camera currently used for the rendering pass
  17864. */
  17865. camera: Nullable<Camera>;
  17866. /**
  17867. * The ID of the renderingGroup being processed
  17868. */
  17869. renderingGroupId: number;
  17870. }
  17871. /**
  17872. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17873. * It is enable to manage the different groups as well as the different necessary sort functions.
  17874. * This should not be used directly aside of the few static configurations
  17875. */
  17876. export class RenderingManager {
  17877. /**
  17878. * The max id used for rendering groups (not included)
  17879. */
  17880. static MAX_RENDERINGGROUPS: number;
  17881. /**
  17882. * The min id used for rendering groups (included)
  17883. */
  17884. static MIN_RENDERINGGROUPS: number;
  17885. /**
  17886. * Used to globally prevent autoclearing scenes.
  17887. */
  17888. static AUTOCLEAR: boolean;
  17889. /**
  17890. * @hidden
  17891. */
  17892. _useSceneAutoClearSetup: boolean;
  17893. private _scene;
  17894. private _renderingGroups;
  17895. private _depthStencilBufferAlreadyCleaned;
  17896. private _autoClearDepthStencil;
  17897. private _customOpaqueSortCompareFn;
  17898. private _customAlphaTestSortCompareFn;
  17899. private _customTransparentSortCompareFn;
  17900. private _renderingGroupInfo;
  17901. /**
  17902. * Instantiates a new rendering group for a particular scene
  17903. * @param scene Defines the scene the groups belongs to
  17904. */
  17905. constructor(scene: Scene);
  17906. private _clearDepthStencilBuffer;
  17907. /**
  17908. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17909. * @hidden
  17910. */
  17911. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17912. /**
  17913. * Resets the different information of the group to prepare a new frame
  17914. * @hidden
  17915. */
  17916. reset(): void;
  17917. /**
  17918. * Dispose and release the group and its associated resources.
  17919. * @hidden
  17920. */
  17921. dispose(): void;
  17922. /**
  17923. * Clear the info related to rendering groups preventing retention points during dispose.
  17924. */
  17925. freeRenderingGroups(): void;
  17926. private _prepareRenderingGroup;
  17927. /**
  17928. * Add a sprite manager to the rendering manager in order to render it this frame.
  17929. * @param spriteManager Define the sprite manager to render
  17930. */
  17931. dispatchSprites(spriteManager: ISpriteManager): void;
  17932. /**
  17933. * Add a particle system to the rendering manager in order to render it this frame.
  17934. * @param particleSystem Define the particle system to render
  17935. */
  17936. dispatchParticles(particleSystem: IParticleSystem): void;
  17937. /**
  17938. * Add a submesh to the manager in order to render it this frame
  17939. * @param subMesh The submesh to dispatch
  17940. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17941. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17942. */
  17943. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17944. /**
  17945. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17946. * This allowed control for front to back rendering or reversly depending of the special needs.
  17947. *
  17948. * @param renderingGroupId The rendering group id corresponding to its index
  17949. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17950. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17951. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17952. */
  17953. 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;
  17954. /**
  17955. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17956. *
  17957. * @param renderingGroupId The rendering group id corresponding to its index
  17958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17959. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17960. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17961. */
  17962. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17963. /**
  17964. * Gets the current auto clear configuration for one rendering group of the rendering
  17965. * manager.
  17966. * @param index the rendering group index to get the information for
  17967. * @returns The auto clear setup for the requested rendering group
  17968. */
  17969. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17970. }
  17971. }
  17972. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17973. import { SmartArray } from "babylonjs/Misc/smartArray";
  17974. import { Nullable } from "babylonjs/types";
  17975. import { Scene } from "babylonjs/scene";
  17976. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17978. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17979. import { Mesh } from "babylonjs/Meshes/mesh";
  17980. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17981. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17982. import { Effect } from "babylonjs/Materials/effect";
  17983. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17984. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17985. import "babylonjs/Shaders/shadowMap.fragment";
  17986. import "babylonjs/Shaders/shadowMap.vertex";
  17987. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17988. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17989. import { Observable } from "babylonjs/Misc/observable";
  17990. /**
  17991. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17992. */
  17993. export interface ICustomShaderOptions {
  17994. /**
  17995. * Gets or sets the custom shader name to use
  17996. */
  17997. shaderName: string;
  17998. /**
  17999. * The list of attribute names used in the shader
  18000. */
  18001. attributes?: string[];
  18002. /**
  18003. * The list of unifrom names used in the shader
  18004. */
  18005. uniforms?: string[];
  18006. /**
  18007. * The list of sampler names used in the shader
  18008. */
  18009. samplers?: string[];
  18010. /**
  18011. * The list of defines used in the shader
  18012. */
  18013. defines?: string[];
  18014. }
  18015. /**
  18016. * Interface to implement to create a shadow generator compatible with BJS.
  18017. */
  18018. export interface IShadowGenerator {
  18019. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18020. id: string;
  18021. /**
  18022. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18023. * @returns The render target texture if present otherwise, null
  18024. */
  18025. getShadowMap(): Nullable<RenderTargetTexture>;
  18026. /**
  18027. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18028. * @param subMesh The submesh we want to render in the shadow map
  18029. * @param useInstances Defines wether will draw in the map using instances
  18030. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18031. * @returns true if ready otherwise, false
  18032. */
  18033. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18034. /**
  18035. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18036. * @param defines Defines of the material we want to update
  18037. * @param lightIndex Index of the light in the enabled light list of the material
  18038. */
  18039. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18040. /**
  18041. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18042. * defined in the generator but impacting the effect).
  18043. * It implies the unifroms available on the materials are the standard BJS ones.
  18044. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18045. * @param effect The effect we are binfing the information for
  18046. */
  18047. bindShadowLight(lightIndex: string, effect: Effect): void;
  18048. /**
  18049. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18050. * (eq to shadow prjection matrix * light transform matrix)
  18051. * @returns The transform matrix used to create the shadow map
  18052. */
  18053. getTransformMatrix(): Matrix;
  18054. /**
  18055. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18056. * Cube and 2D textures for instance.
  18057. */
  18058. recreateShadowMap(): void;
  18059. /**
  18060. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18061. * @param onCompiled Callback triggered at the and of the effects compilation
  18062. * @param options Sets of optional options forcing the compilation with different modes
  18063. */
  18064. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18065. useInstances: boolean;
  18066. }>): void;
  18067. /**
  18068. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18069. * @param options Sets of optional options forcing the compilation with different modes
  18070. * @returns A promise that resolves when the compilation completes
  18071. */
  18072. forceCompilationAsync(options?: Partial<{
  18073. useInstances: boolean;
  18074. }>): Promise<void>;
  18075. /**
  18076. * Serializes the shadow generator setup to a json object.
  18077. * @returns The serialized JSON object
  18078. */
  18079. serialize(): any;
  18080. /**
  18081. * Disposes the Shadow map and related Textures and effects.
  18082. */
  18083. dispose(): void;
  18084. }
  18085. /**
  18086. * Default implementation IShadowGenerator.
  18087. * This is the main object responsible of generating shadows in the framework.
  18088. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18089. */
  18090. export class ShadowGenerator implements IShadowGenerator {
  18091. /**
  18092. * Name of the shadow generator class
  18093. */
  18094. static CLASSNAME: string;
  18095. /**
  18096. * Shadow generator mode None: no filtering applied.
  18097. */
  18098. static readonly FILTER_NONE: number;
  18099. /**
  18100. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18101. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18102. */
  18103. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18104. /**
  18105. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18106. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18107. */
  18108. static readonly FILTER_POISSONSAMPLING: number;
  18109. /**
  18110. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18112. */
  18113. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18114. /**
  18115. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18116. * edge artifacts on steep falloff.
  18117. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18118. */
  18119. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18120. /**
  18121. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18122. * edge artifacts on steep falloff.
  18123. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18124. */
  18125. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18126. /**
  18127. * Shadow generator mode PCF: Percentage Closer Filtering
  18128. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18129. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18130. */
  18131. static readonly FILTER_PCF: number;
  18132. /**
  18133. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18134. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18135. * Contact Hardening
  18136. */
  18137. static readonly FILTER_PCSS: number;
  18138. /**
  18139. * Reserved for PCF and PCSS
  18140. * Highest Quality.
  18141. *
  18142. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18143. *
  18144. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18145. */
  18146. static readonly QUALITY_HIGH: number;
  18147. /**
  18148. * Reserved for PCF and PCSS
  18149. * Good tradeoff for quality/perf cross devices
  18150. *
  18151. * Execute PCF on a 3*3 kernel.
  18152. *
  18153. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18154. */
  18155. static readonly QUALITY_MEDIUM: number;
  18156. /**
  18157. * Reserved for PCF and PCSS
  18158. * The lowest quality but the fastest.
  18159. *
  18160. * Execute PCF on a 1*1 kernel.
  18161. *
  18162. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18163. */
  18164. static readonly QUALITY_LOW: number;
  18165. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18166. id: string;
  18167. /** Gets or sets the custom shader name to use */
  18168. customShaderOptions: ICustomShaderOptions;
  18169. /**
  18170. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18171. */
  18172. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18173. /**
  18174. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18175. */
  18176. onAfterShadowMapRenderObservable: Observable<Effect>;
  18177. /**
  18178. * Observable triggered before a mesh is rendered in the shadow map.
  18179. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18180. */
  18181. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18182. /**
  18183. * Observable triggered after a mesh is rendered in the shadow map.
  18184. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18185. */
  18186. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18187. protected _bias: number;
  18188. /**
  18189. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18190. */
  18191. get bias(): number;
  18192. /**
  18193. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18194. */
  18195. set bias(bias: number);
  18196. protected _normalBias: number;
  18197. /**
  18198. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18199. */
  18200. get normalBias(): number;
  18201. /**
  18202. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18203. */
  18204. set normalBias(normalBias: number);
  18205. protected _blurBoxOffset: number;
  18206. /**
  18207. * Gets the blur box offset: offset applied during the blur pass.
  18208. * Only useful if useKernelBlur = false
  18209. */
  18210. get blurBoxOffset(): number;
  18211. /**
  18212. * Sets the blur box offset: offset applied during the blur pass.
  18213. * Only useful if useKernelBlur = false
  18214. */
  18215. set blurBoxOffset(value: number);
  18216. protected _blurScale: number;
  18217. /**
  18218. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18219. * 2 means half of the size.
  18220. */
  18221. get blurScale(): number;
  18222. /**
  18223. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18224. * 2 means half of the size.
  18225. */
  18226. set blurScale(value: number);
  18227. protected _blurKernel: number;
  18228. /**
  18229. * Gets the blur kernel: kernel size of the blur pass.
  18230. * Only useful if useKernelBlur = true
  18231. */
  18232. get blurKernel(): number;
  18233. /**
  18234. * Sets the blur kernel: kernel size of the blur pass.
  18235. * Only useful if useKernelBlur = true
  18236. */
  18237. set blurKernel(value: number);
  18238. protected _useKernelBlur: boolean;
  18239. /**
  18240. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18241. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18242. */
  18243. get useKernelBlur(): boolean;
  18244. /**
  18245. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18246. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18247. */
  18248. set useKernelBlur(value: boolean);
  18249. protected _depthScale: number;
  18250. /**
  18251. * Gets the depth scale used in ESM mode.
  18252. */
  18253. get depthScale(): number;
  18254. /**
  18255. * Sets the depth scale used in ESM mode.
  18256. * This can override the scale stored on the light.
  18257. */
  18258. set depthScale(value: number);
  18259. protected _validateFilter(filter: number): number;
  18260. protected _filter: number;
  18261. /**
  18262. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18263. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18264. */
  18265. get filter(): number;
  18266. /**
  18267. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18268. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18269. */
  18270. set filter(value: number);
  18271. /**
  18272. * Gets if the current filter is set to Poisson Sampling.
  18273. */
  18274. get usePoissonSampling(): boolean;
  18275. /**
  18276. * Sets the current filter to Poisson Sampling.
  18277. */
  18278. set usePoissonSampling(value: boolean);
  18279. /**
  18280. * Gets if the current filter is set to ESM.
  18281. */
  18282. get useExponentialShadowMap(): boolean;
  18283. /**
  18284. * Sets the current filter is to ESM.
  18285. */
  18286. set useExponentialShadowMap(value: boolean);
  18287. /**
  18288. * Gets if the current filter is set to filtered ESM.
  18289. */
  18290. get useBlurExponentialShadowMap(): boolean;
  18291. /**
  18292. * Gets if the current filter is set to filtered ESM.
  18293. */
  18294. set useBlurExponentialShadowMap(value: boolean);
  18295. /**
  18296. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18297. * exponential to prevent steep falloff artifacts).
  18298. */
  18299. get useCloseExponentialShadowMap(): boolean;
  18300. /**
  18301. * Sets the current filter to "close ESM" (using the inverse of the
  18302. * exponential to prevent steep falloff artifacts).
  18303. */
  18304. set useCloseExponentialShadowMap(value: boolean);
  18305. /**
  18306. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18307. * exponential to prevent steep falloff artifacts).
  18308. */
  18309. get useBlurCloseExponentialShadowMap(): boolean;
  18310. /**
  18311. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18312. * exponential to prevent steep falloff artifacts).
  18313. */
  18314. set useBlurCloseExponentialShadowMap(value: boolean);
  18315. /**
  18316. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18317. */
  18318. get usePercentageCloserFiltering(): boolean;
  18319. /**
  18320. * Sets the current filter to "PCF" (percentage closer filtering).
  18321. */
  18322. set usePercentageCloserFiltering(value: boolean);
  18323. protected _filteringQuality: number;
  18324. /**
  18325. * Gets the PCF or PCSS Quality.
  18326. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18327. */
  18328. get filteringQuality(): number;
  18329. /**
  18330. * Sets the PCF or PCSS Quality.
  18331. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18332. */
  18333. set filteringQuality(filteringQuality: number);
  18334. /**
  18335. * Gets if the current filter is set to "PCSS" (contact hardening).
  18336. */
  18337. get useContactHardeningShadow(): boolean;
  18338. /**
  18339. * Sets the current filter to "PCSS" (contact hardening).
  18340. */
  18341. set useContactHardeningShadow(value: boolean);
  18342. protected _contactHardeningLightSizeUVRatio: number;
  18343. /**
  18344. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18345. * Using a ratio helps keeping shape stability independently of the map size.
  18346. *
  18347. * It does not account for the light projection as it was having too much
  18348. * instability during the light setup or during light position changes.
  18349. *
  18350. * Only valid if useContactHardeningShadow is true.
  18351. */
  18352. get contactHardeningLightSizeUVRatio(): number;
  18353. /**
  18354. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18355. * Using a ratio helps keeping shape stability independently of the map size.
  18356. *
  18357. * It does not account for the light projection as it was having too much
  18358. * instability during the light setup or during light position changes.
  18359. *
  18360. * Only valid if useContactHardeningShadow is true.
  18361. */
  18362. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18363. protected _darkness: number;
  18364. /** Gets or sets the actual darkness of a shadow */
  18365. get darkness(): number;
  18366. set darkness(value: number);
  18367. /**
  18368. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18369. * 0 means strongest and 1 would means no shadow.
  18370. * @returns the darkness.
  18371. */
  18372. getDarkness(): number;
  18373. /**
  18374. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18375. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18376. * @returns the shadow generator allowing fluent coding.
  18377. */
  18378. setDarkness(darkness: number): ShadowGenerator;
  18379. protected _transparencyShadow: boolean;
  18380. /** Gets or sets the ability to have transparent shadow */
  18381. get transparencyShadow(): boolean;
  18382. set transparencyShadow(value: boolean);
  18383. /**
  18384. * Sets the ability to have transparent shadow (boolean).
  18385. * @param transparent True if transparent else False
  18386. * @returns the shadow generator allowing fluent coding
  18387. */
  18388. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18389. /**
  18390. * Enables or disables shadows with varying strength based on the transparency
  18391. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18392. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18393. * mesh.visibility * alphaTexture.a
  18394. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18395. */
  18396. enableSoftTransparentShadow: boolean;
  18397. protected _shadowMap: Nullable<RenderTargetTexture>;
  18398. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18399. /**
  18400. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18401. * @returns The render target texture if present otherwise, null
  18402. */
  18403. getShadowMap(): Nullable<RenderTargetTexture>;
  18404. /**
  18405. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18406. * @returns The render target texture if the shadow map is present otherwise, null
  18407. */
  18408. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18409. /**
  18410. * Gets the class name of that object
  18411. * @returns "ShadowGenerator"
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18416. * @param mesh Mesh to add
  18417. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18418. * @returns the Shadow Generator itself
  18419. */
  18420. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18421. /**
  18422. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18423. * @param mesh Mesh to remove
  18424. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18425. * @returns the Shadow Generator itself
  18426. */
  18427. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18428. /**
  18429. * Controls the extent to which the shadows fade out at the edge of the frustum
  18430. */
  18431. frustumEdgeFalloff: number;
  18432. protected _light: IShadowLight;
  18433. /**
  18434. * Returns the associated light object.
  18435. * @returns the light generating the shadow
  18436. */
  18437. getLight(): IShadowLight;
  18438. /**
  18439. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18440. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18441. * It might on the other hand introduce peter panning.
  18442. */
  18443. forceBackFacesOnly: boolean;
  18444. protected _scene: Scene;
  18445. protected _lightDirection: Vector3;
  18446. protected _effect: Effect;
  18447. protected _viewMatrix: Matrix;
  18448. protected _projectionMatrix: Matrix;
  18449. protected _transformMatrix: Matrix;
  18450. protected _cachedPosition: Vector3;
  18451. protected _cachedDirection: Vector3;
  18452. protected _cachedDefines: string;
  18453. protected _currentRenderID: number;
  18454. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18455. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18456. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18457. protected _blurPostProcesses: PostProcess[];
  18458. protected _mapSize: number;
  18459. protected _currentFaceIndex: number;
  18460. protected _currentFaceIndexCache: number;
  18461. protected _textureType: number;
  18462. protected _defaultTextureMatrix: Matrix;
  18463. protected _storedUniqueId: Nullable<number>;
  18464. /** @hidden */
  18465. static _SceneComponentInitialization: (scene: Scene) => void;
  18466. /**
  18467. * Creates a ShadowGenerator object.
  18468. * A ShadowGenerator is the required tool to use the shadows.
  18469. * Each light casting shadows needs to use its own ShadowGenerator.
  18470. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18471. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18472. * @param light The light object generating the shadows.
  18473. * @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.
  18474. */
  18475. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18476. protected _initializeGenerator(): void;
  18477. protected _createTargetRenderTexture(): void;
  18478. protected _initializeShadowMap(): void;
  18479. protected _initializeBlurRTTAndPostProcesses(): void;
  18480. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18481. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18482. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18483. protected _applyFilterValues(): void;
  18484. /**
  18485. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18486. * @param onCompiled Callback triggered at the and of the effects compilation
  18487. * @param options Sets of optional options forcing the compilation with different modes
  18488. */
  18489. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18490. useInstances: boolean;
  18491. }>): void;
  18492. /**
  18493. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18494. * @param options Sets of optional options forcing the compilation with different modes
  18495. * @returns A promise that resolves when the compilation completes
  18496. */
  18497. forceCompilationAsync(options?: Partial<{
  18498. useInstances: boolean;
  18499. }>): Promise<void>;
  18500. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18501. private _prepareShadowDefines;
  18502. /**
  18503. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18504. * @param subMesh The submesh we want to render in the shadow map
  18505. * @param useInstances Defines wether will draw in the map using instances
  18506. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18507. * @returns true if ready otherwise, false
  18508. */
  18509. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18510. /**
  18511. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18512. * @param defines Defines of the material we want to update
  18513. * @param lightIndex Index of the light in the enabled light list of the material
  18514. */
  18515. prepareDefines(defines: any, lightIndex: number): void;
  18516. /**
  18517. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18518. * defined in the generator but impacting the effect).
  18519. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18520. * @param effect The effect we are binfing the information for
  18521. */
  18522. bindShadowLight(lightIndex: string, effect: Effect): void;
  18523. /**
  18524. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18525. * (eq to shadow prjection matrix * light transform matrix)
  18526. * @returns The transform matrix used to create the shadow map
  18527. */
  18528. getTransformMatrix(): Matrix;
  18529. /**
  18530. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18531. * Cube and 2D textures for instance.
  18532. */
  18533. recreateShadowMap(): void;
  18534. protected _disposeBlurPostProcesses(): void;
  18535. protected _disposeRTTandPostProcesses(): void;
  18536. /**
  18537. * Disposes the ShadowGenerator.
  18538. * Returns nothing.
  18539. */
  18540. dispose(): void;
  18541. /**
  18542. * Serializes the shadow generator setup to a json object.
  18543. * @returns The serialized JSON object
  18544. */
  18545. serialize(): any;
  18546. /**
  18547. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18548. * @param parsedShadowGenerator The JSON object to parse
  18549. * @param scene The scene to create the shadow map for
  18550. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18551. * @returns The parsed shadow generator
  18552. */
  18553. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18554. }
  18555. }
  18556. declare module "babylonjs/Lights/light" {
  18557. import { Nullable } from "babylonjs/types";
  18558. import { Scene } from "babylonjs/scene";
  18559. import { Vector3 } from "babylonjs/Maths/math.vector";
  18560. import { Color3 } from "babylonjs/Maths/math.color";
  18561. import { Node } from "babylonjs/node";
  18562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18563. import { Effect } from "babylonjs/Materials/effect";
  18564. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18565. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18566. /**
  18567. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18568. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18569. * 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.
  18570. */
  18571. export abstract class Light extends Node {
  18572. /**
  18573. * Falloff Default: light is falling off following the material specification:
  18574. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18575. */
  18576. static readonly FALLOFF_DEFAULT: number;
  18577. /**
  18578. * Falloff Physical: light is falling off following the inverse squared distance law.
  18579. */
  18580. static readonly FALLOFF_PHYSICAL: number;
  18581. /**
  18582. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18583. * to enhance interoperability with other engines.
  18584. */
  18585. static readonly FALLOFF_GLTF: number;
  18586. /**
  18587. * Falloff Standard: light is falling off like in the standard material
  18588. * to enhance interoperability with other materials.
  18589. */
  18590. static readonly FALLOFF_STANDARD: number;
  18591. /**
  18592. * If every light affecting the material is in this lightmapMode,
  18593. * material.lightmapTexture adds or multiplies
  18594. * (depends on material.useLightmapAsShadowmap)
  18595. * after every other light calculations.
  18596. */
  18597. static readonly LIGHTMAP_DEFAULT: number;
  18598. /**
  18599. * material.lightmapTexture as only diffuse lighting from this light
  18600. * adds only specular lighting from this light
  18601. * adds dynamic shadows
  18602. */
  18603. static readonly LIGHTMAP_SPECULAR: number;
  18604. /**
  18605. * material.lightmapTexture as only lighting
  18606. * no light calculation from this light
  18607. * only adds dynamic shadows from this light
  18608. */
  18609. static readonly LIGHTMAP_SHADOWSONLY: number;
  18610. /**
  18611. * Each light type uses the default quantity according to its type:
  18612. * point/spot lights use luminous intensity
  18613. * directional lights use illuminance
  18614. */
  18615. static readonly INTENSITYMODE_AUTOMATIC: number;
  18616. /**
  18617. * lumen (lm)
  18618. */
  18619. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18620. /**
  18621. * candela (lm/sr)
  18622. */
  18623. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18624. /**
  18625. * lux (lm/m^2)
  18626. */
  18627. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18628. /**
  18629. * nit (cd/m^2)
  18630. */
  18631. static readonly INTENSITYMODE_LUMINANCE: number;
  18632. /**
  18633. * Light type const id of the point light.
  18634. */
  18635. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18636. /**
  18637. * Light type const id of the directional light.
  18638. */
  18639. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18640. /**
  18641. * Light type const id of the spot light.
  18642. */
  18643. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18644. /**
  18645. * Light type const id of the hemispheric light.
  18646. */
  18647. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18648. /**
  18649. * Diffuse gives the basic color to an object.
  18650. */
  18651. diffuse: Color3;
  18652. /**
  18653. * Specular produces a highlight color on an object.
  18654. * Note: This is note affecting PBR materials.
  18655. */
  18656. specular: Color3;
  18657. /**
  18658. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18659. * falling off base on range or angle.
  18660. * This can be set to any values in Light.FALLOFF_x.
  18661. *
  18662. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18663. * other types of materials.
  18664. */
  18665. falloffType: number;
  18666. /**
  18667. * Strength of the light.
  18668. * Note: By default it is define in the framework own unit.
  18669. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18670. */
  18671. intensity: number;
  18672. private _range;
  18673. protected _inverseSquaredRange: number;
  18674. /**
  18675. * Defines how far from the source the light is impacting in scene units.
  18676. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18677. */
  18678. get range(): number;
  18679. /**
  18680. * Defines how far from the source the light is impacting in scene units.
  18681. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18682. */
  18683. set range(value: number);
  18684. /**
  18685. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18686. * of light.
  18687. */
  18688. private _photometricScale;
  18689. private _intensityMode;
  18690. /**
  18691. * Gets the photometric scale used to interpret the intensity.
  18692. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18693. */
  18694. get intensityMode(): number;
  18695. /**
  18696. * Sets the photometric scale used to interpret the intensity.
  18697. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18698. */
  18699. set intensityMode(value: number);
  18700. private _radius;
  18701. /**
  18702. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18703. */
  18704. get radius(): number;
  18705. /**
  18706. * sets the light radius used by PBR Materials to simulate soft area lights.
  18707. */
  18708. set radius(value: number);
  18709. private _renderPriority;
  18710. /**
  18711. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18712. * exceeding the number allowed of the materials.
  18713. */
  18714. renderPriority: number;
  18715. private _shadowEnabled;
  18716. /**
  18717. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18718. * the current shadow generator.
  18719. */
  18720. get shadowEnabled(): boolean;
  18721. /**
  18722. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18723. * the current shadow generator.
  18724. */
  18725. set shadowEnabled(value: boolean);
  18726. private _includedOnlyMeshes;
  18727. /**
  18728. * Gets the only meshes impacted by this light.
  18729. */
  18730. get includedOnlyMeshes(): AbstractMesh[];
  18731. /**
  18732. * Sets the only meshes impacted by this light.
  18733. */
  18734. set includedOnlyMeshes(value: AbstractMesh[]);
  18735. private _excludedMeshes;
  18736. /**
  18737. * Gets the meshes not impacted by this light.
  18738. */
  18739. get excludedMeshes(): AbstractMesh[];
  18740. /**
  18741. * Sets the meshes not impacted by this light.
  18742. */
  18743. set excludedMeshes(value: AbstractMesh[]);
  18744. private _excludeWithLayerMask;
  18745. /**
  18746. * Gets the layer id use to find what meshes are not impacted by the light.
  18747. * Inactive if 0
  18748. */
  18749. get excludeWithLayerMask(): number;
  18750. /**
  18751. * Sets the layer id use to find what meshes are not impacted by the light.
  18752. * Inactive if 0
  18753. */
  18754. set excludeWithLayerMask(value: number);
  18755. private _includeOnlyWithLayerMask;
  18756. /**
  18757. * Gets the layer id use to find what meshes are impacted by the light.
  18758. * Inactive if 0
  18759. */
  18760. get includeOnlyWithLayerMask(): number;
  18761. /**
  18762. * Sets the layer id use to find what meshes are impacted by the light.
  18763. * Inactive if 0
  18764. */
  18765. set includeOnlyWithLayerMask(value: number);
  18766. private _lightmapMode;
  18767. /**
  18768. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18769. */
  18770. get lightmapMode(): number;
  18771. /**
  18772. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18773. */
  18774. set lightmapMode(value: number);
  18775. /**
  18776. * Shadow generator associted to the light.
  18777. * @hidden Internal use only.
  18778. */
  18779. _shadowGenerator: Nullable<IShadowGenerator>;
  18780. /**
  18781. * @hidden Internal use only.
  18782. */
  18783. _excludedMeshesIds: string[];
  18784. /**
  18785. * @hidden Internal use only.
  18786. */
  18787. _includedOnlyMeshesIds: string[];
  18788. /**
  18789. * The current light unifom buffer.
  18790. * @hidden Internal use only.
  18791. */
  18792. _uniformBuffer: UniformBuffer;
  18793. /** @hidden */
  18794. _renderId: number;
  18795. /**
  18796. * Creates a Light object in the scene.
  18797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18798. * @param name The firendly name of the light
  18799. * @param scene The scene the light belongs too
  18800. */
  18801. constructor(name: string, scene: Scene);
  18802. protected abstract _buildUniformLayout(): void;
  18803. /**
  18804. * Sets the passed Effect "effect" with the Light information.
  18805. * @param effect The effect to update
  18806. * @param lightIndex The index of the light in the effect to update
  18807. * @returns The light
  18808. */
  18809. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18810. /**
  18811. * Sets the passed Effect "effect" with the Light textures.
  18812. * @param effect The effect to update
  18813. * @param lightIndex The index of the light in the effect to update
  18814. * @returns The light
  18815. */
  18816. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18817. /**
  18818. * Binds the lights information from the scene to the effect for the given mesh.
  18819. * @param lightIndex Light index
  18820. * @param scene The scene where the light belongs to
  18821. * @param effect The effect we are binding the data to
  18822. * @param useSpecular Defines if specular is supported
  18823. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18824. */
  18825. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18826. /**
  18827. * Sets the passed Effect "effect" with the Light information.
  18828. * @param effect The effect to update
  18829. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18830. * @returns The light
  18831. */
  18832. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18833. /**
  18834. * Returns the string "Light".
  18835. * @returns the class name
  18836. */
  18837. getClassName(): string;
  18838. /** @hidden */
  18839. readonly _isLight: boolean;
  18840. /**
  18841. * Converts the light information to a readable string for debug purpose.
  18842. * @param fullDetails Supports for multiple levels of logging within scene loading
  18843. * @returns the human readable light info
  18844. */
  18845. toString(fullDetails?: boolean): string;
  18846. /** @hidden */
  18847. protected _syncParentEnabledState(): void;
  18848. /**
  18849. * Set the enabled state of this node.
  18850. * @param value - the new enabled state
  18851. */
  18852. setEnabled(value: boolean): void;
  18853. /**
  18854. * Returns the Light associated shadow generator if any.
  18855. * @return the associated shadow generator.
  18856. */
  18857. getShadowGenerator(): Nullable<IShadowGenerator>;
  18858. /**
  18859. * Returns a Vector3, the absolute light position in the World.
  18860. * @returns the world space position of the light
  18861. */
  18862. getAbsolutePosition(): Vector3;
  18863. /**
  18864. * Specifies if the light will affect the passed mesh.
  18865. * @param mesh The mesh to test against the light
  18866. * @return true the mesh is affected otherwise, false.
  18867. */
  18868. canAffectMesh(mesh: AbstractMesh): boolean;
  18869. /**
  18870. * Sort function to order lights for rendering.
  18871. * @param a First Light object to compare to second.
  18872. * @param b Second Light object to compare first.
  18873. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18874. */
  18875. static CompareLightsPriority(a: Light, b: Light): number;
  18876. /**
  18877. * Releases resources associated with this node.
  18878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18880. */
  18881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18882. /**
  18883. * Returns the light type ID (integer).
  18884. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18885. */
  18886. getTypeID(): number;
  18887. /**
  18888. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18889. * @returns the scaled intensity in intensity mode unit
  18890. */
  18891. getScaledIntensity(): number;
  18892. /**
  18893. * Returns a new Light object, named "name", from the current one.
  18894. * @param name The name of the cloned light
  18895. * @param newParent The parent of this light, if it has one
  18896. * @returns the new created light
  18897. */
  18898. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18899. /**
  18900. * Serializes the current light into a Serialization object.
  18901. * @returns the serialized object.
  18902. */
  18903. serialize(): any;
  18904. /**
  18905. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18906. * This new light is named "name" and added to the passed scene.
  18907. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18908. * @param name The friendly name of the light
  18909. * @param scene The scene the new light will belong to
  18910. * @returns the constructor function
  18911. */
  18912. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18913. /**
  18914. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18915. * @param parsedLight The JSON representation of the light
  18916. * @param scene The scene to create the parsed light in
  18917. * @returns the created light after parsing
  18918. */
  18919. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18920. private _hookArrayForExcluded;
  18921. private _hookArrayForIncludedOnly;
  18922. private _resyncMeshes;
  18923. /**
  18924. * Forces the meshes to update their light related information in their rendering used effects
  18925. * @hidden Internal Use Only
  18926. */
  18927. _markMeshesAsLightDirty(): void;
  18928. /**
  18929. * Recomputes the cached photometric scale if needed.
  18930. */
  18931. private _computePhotometricScale;
  18932. /**
  18933. * Returns the Photometric Scale according to the light type and intensity mode.
  18934. */
  18935. private _getPhotometricScale;
  18936. /**
  18937. * Reorder the light in the scene according to their defined priority.
  18938. * @hidden Internal Use Only
  18939. */
  18940. _reorderLightsInScene(): void;
  18941. /**
  18942. * Prepares the list of defines specific to the light type.
  18943. * @param defines the list of defines
  18944. * @param lightIndex defines the index of the light for the effect
  18945. */
  18946. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18947. }
  18948. }
  18949. declare module "babylonjs/Cameras/targetCamera" {
  18950. import { Nullable } from "babylonjs/types";
  18951. import { Camera } from "babylonjs/Cameras/camera";
  18952. import { Scene } from "babylonjs/scene";
  18953. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18954. /**
  18955. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18956. * This is the base of the follow, arc rotate cameras and Free camera
  18957. * @see https://doc.babylonjs.com/features/cameras
  18958. */
  18959. export class TargetCamera extends Camera {
  18960. private static _RigCamTransformMatrix;
  18961. private static _TargetTransformMatrix;
  18962. private static _TargetFocalPoint;
  18963. private _tmpUpVector;
  18964. private _tmpTargetVector;
  18965. /**
  18966. * Define the current direction the camera is moving to
  18967. */
  18968. cameraDirection: Vector3;
  18969. /**
  18970. * Define the current rotation the camera is rotating to
  18971. */
  18972. cameraRotation: Vector2;
  18973. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18974. ignoreParentScaling: boolean;
  18975. /**
  18976. * When set, the up vector of the camera will be updated by the rotation of the camera
  18977. */
  18978. updateUpVectorFromRotation: boolean;
  18979. private _tmpQuaternion;
  18980. /**
  18981. * Define the current rotation of the camera
  18982. */
  18983. rotation: Vector3;
  18984. /**
  18985. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18986. */
  18987. rotationQuaternion: Quaternion;
  18988. /**
  18989. * Define the current speed of the camera
  18990. */
  18991. speed: number;
  18992. /**
  18993. * Add constraint to the camera to prevent it to move freely in all directions and
  18994. * around all axis.
  18995. */
  18996. noRotationConstraint: boolean;
  18997. /**
  18998. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18999. * panning
  19000. */
  19001. invertRotation: boolean;
  19002. /**
  19003. * Speed multiplier for inverse camera panning
  19004. */
  19005. inverseRotationSpeed: number;
  19006. /**
  19007. * Define the current target of the camera as an object or a position.
  19008. */
  19009. lockedTarget: any;
  19010. /** @hidden */
  19011. _currentTarget: Vector3;
  19012. /** @hidden */
  19013. _initialFocalDistance: number;
  19014. /** @hidden */
  19015. _viewMatrix: Matrix;
  19016. /** @hidden */
  19017. _camMatrix: Matrix;
  19018. /** @hidden */
  19019. _cameraTransformMatrix: Matrix;
  19020. /** @hidden */
  19021. _cameraRotationMatrix: Matrix;
  19022. /** @hidden */
  19023. _referencePoint: Vector3;
  19024. /** @hidden */
  19025. _transformedReferencePoint: Vector3;
  19026. /** @hidden */
  19027. _reset: () => void;
  19028. private _defaultUp;
  19029. /**
  19030. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19031. * This is the base of the follow, arc rotate cameras and Free camera
  19032. * @see https://doc.babylonjs.com/features/cameras
  19033. * @param name Defines the name of the camera in the scene
  19034. * @param position Defines the start position of the camera in the scene
  19035. * @param scene Defines the scene the camera belongs to
  19036. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19037. */
  19038. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19039. /**
  19040. * Gets the position in front of the camera at a given distance.
  19041. * @param distance The distance from the camera we want the position to be
  19042. * @returns the position
  19043. */
  19044. getFrontPosition(distance: number): Vector3;
  19045. /** @hidden */
  19046. _getLockedTargetPosition(): Nullable<Vector3>;
  19047. private _storedPosition;
  19048. private _storedRotation;
  19049. private _storedRotationQuaternion;
  19050. /**
  19051. * Store current camera state of the camera (fov, position, rotation, etc..)
  19052. * @returns the camera
  19053. */
  19054. storeState(): Camera;
  19055. /**
  19056. * Restored camera state. You must call storeState() first
  19057. * @returns whether it was successful or not
  19058. * @hidden
  19059. */
  19060. _restoreStateValues(): boolean;
  19061. /** @hidden */
  19062. _initCache(): void;
  19063. /** @hidden */
  19064. _updateCache(ignoreParentClass?: boolean): void;
  19065. /** @hidden */
  19066. _isSynchronizedViewMatrix(): boolean;
  19067. /** @hidden */
  19068. _computeLocalCameraSpeed(): number;
  19069. /**
  19070. * Defines the target the camera should look at.
  19071. * @param target Defines the new target as a Vector or a mesh
  19072. */
  19073. setTarget(target: Vector3): void;
  19074. /**
  19075. * Defines the target point of the camera.
  19076. * The camera looks towards it form the radius distance.
  19077. */
  19078. get target(): Vector3;
  19079. set target(value: Vector3);
  19080. /**
  19081. * Return the current target position of the camera. This value is expressed in local space.
  19082. * @returns the target position
  19083. */
  19084. getTarget(): Vector3;
  19085. /** @hidden */
  19086. _decideIfNeedsToMove(): boolean;
  19087. /** @hidden */
  19088. _updatePosition(): void;
  19089. /** @hidden */
  19090. _checkInputs(): void;
  19091. protected _updateCameraRotationMatrix(): void;
  19092. /**
  19093. * 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)
  19094. * @returns the current camera
  19095. */
  19096. private _rotateUpVectorWithCameraRotationMatrix;
  19097. private _cachedRotationZ;
  19098. private _cachedQuaternionRotationZ;
  19099. /** @hidden */
  19100. _getViewMatrix(): Matrix;
  19101. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19102. /**
  19103. * @hidden
  19104. */
  19105. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19106. /**
  19107. * @hidden
  19108. */
  19109. _updateRigCameras(): void;
  19110. private _getRigCamPositionAndTarget;
  19111. /**
  19112. * Gets the current object class name.
  19113. * @return the class name
  19114. */
  19115. getClassName(): string;
  19116. }
  19117. }
  19118. declare module "babylonjs/Events/keyboardEvents" {
  19119. /**
  19120. * Gather the list of keyboard event types as constants.
  19121. */
  19122. export class KeyboardEventTypes {
  19123. /**
  19124. * The keydown event is fired when a key becomes active (pressed).
  19125. */
  19126. static readonly KEYDOWN: number;
  19127. /**
  19128. * The keyup event is fired when a key has been released.
  19129. */
  19130. static readonly KEYUP: number;
  19131. }
  19132. /**
  19133. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19134. */
  19135. export class KeyboardInfo {
  19136. /**
  19137. * Defines the type of event (KeyboardEventTypes)
  19138. */
  19139. type: number;
  19140. /**
  19141. * Defines the related dom event
  19142. */
  19143. event: KeyboardEvent;
  19144. /**
  19145. * Instantiates a new keyboard info.
  19146. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19147. * @param type Defines the type of event (KeyboardEventTypes)
  19148. * @param event Defines the related dom event
  19149. */
  19150. constructor(
  19151. /**
  19152. * Defines the type of event (KeyboardEventTypes)
  19153. */
  19154. type: number,
  19155. /**
  19156. * Defines the related dom event
  19157. */
  19158. event: KeyboardEvent);
  19159. }
  19160. /**
  19161. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19162. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19163. */
  19164. export class KeyboardInfoPre extends KeyboardInfo {
  19165. /**
  19166. * Defines the type of event (KeyboardEventTypes)
  19167. */
  19168. type: number;
  19169. /**
  19170. * Defines the related dom event
  19171. */
  19172. event: KeyboardEvent;
  19173. /**
  19174. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19175. */
  19176. skipOnPointerObservable: boolean;
  19177. /**
  19178. * Instantiates a new keyboard pre info.
  19179. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19180. * @param type Defines the type of event (KeyboardEventTypes)
  19181. * @param event Defines the related dom event
  19182. */
  19183. constructor(
  19184. /**
  19185. * Defines the type of event (KeyboardEventTypes)
  19186. */
  19187. type: number,
  19188. /**
  19189. * Defines the related dom event
  19190. */
  19191. event: KeyboardEvent);
  19192. }
  19193. }
  19194. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19195. import { Nullable } from "babylonjs/types";
  19196. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19197. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19198. /**
  19199. * Manage the keyboard inputs to control the movement of a free camera.
  19200. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19201. */
  19202. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19203. /**
  19204. * Defines the camera the input is attached to.
  19205. */
  19206. camera: FreeCamera;
  19207. /**
  19208. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19209. */
  19210. keysUp: number[];
  19211. /**
  19212. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19213. */
  19214. keysUpward: number[];
  19215. /**
  19216. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19217. */
  19218. keysDown: number[];
  19219. /**
  19220. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19221. */
  19222. keysDownward: number[];
  19223. /**
  19224. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19225. */
  19226. keysLeft: number[];
  19227. /**
  19228. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19229. */
  19230. keysRight: number[];
  19231. private _keys;
  19232. private _onCanvasBlurObserver;
  19233. private _onKeyboardObserver;
  19234. private _engine;
  19235. private _scene;
  19236. /**
  19237. * Attach the input controls to a specific dom element to get the input from.
  19238. * @param element Defines the element the controls should be listened from
  19239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19240. */
  19241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19242. /**
  19243. * Detach the current controls from the specified dom element.
  19244. * @param element Defines the element to stop listening the inputs from
  19245. */
  19246. detachControl(element: Nullable<HTMLElement>): void;
  19247. /**
  19248. * Update the current camera state depending on the inputs that have been used this frame.
  19249. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19250. */
  19251. checkInputs(): void;
  19252. /**
  19253. * Gets the class name of the current intput.
  19254. * @returns the class name
  19255. */
  19256. getClassName(): string;
  19257. /** @hidden */
  19258. _onLostFocus(): void;
  19259. /**
  19260. * Get the friendly name associated with the input class.
  19261. * @returns the input friendly name
  19262. */
  19263. getSimpleName(): string;
  19264. }
  19265. }
  19266. declare module "babylonjs/Events/pointerEvents" {
  19267. import { Nullable } from "babylonjs/types";
  19268. import { Vector2 } from "babylonjs/Maths/math.vector";
  19269. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19270. import { Ray } from "babylonjs/Culling/ray";
  19271. /**
  19272. * Gather the list of pointer event types as constants.
  19273. */
  19274. export class PointerEventTypes {
  19275. /**
  19276. * 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.
  19277. */
  19278. static readonly POINTERDOWN: number;
  19279. /**
  19280. * The pointerup event is fired when a pointer is no longer active.
  19281. */
  19282. static readonly POINTERUP: number;
  19283. /**
  19284. * The pointermove event is fired when a pointer changes coordinates.
  19285. */
  19286. static readonly POINTERMOVE: number;
  19287. /**
  19288. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19289. */
  19290. static readonly POINTERWHEEL: number;
  19291. /**
  19292. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19293. */
  19294. static readonly POINTERPICK: number;
  19295. /**
  19296. * The pointertap event is fired when a the object has been touched and released without drag.
  19297. */
  19298. static readonly POINTERTAP: number;
  19299. /**
  19300. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19301. */
  19302. static readonly POINTERDOUBLETAP: number;
  19303. }
  19304. /**
  19305. * Base class of pointer info types.
  19306. */
  19307. export class PointerInfoBase {
  19308. /**
  19309. * Defines the type of event (PointerEventTypes)
  19310. */
  19311. type: number;
  19312. /**
  19313. * Defines the related dom event
  19314. */
  19315. event: PointerEvent | MouseWheelEvent;
  19316. /**
  19317. * Instantiates the base class of pointers info.
  19318. * @param type Defines the type of event (PointerEventTypes)
  19319. * @param event Defines the related dom event
  19320. */
  19321. constructor(
  19322. /**
  19323. * Defines the type of event (PointerEventTypes)
  19324. */
  19325. type: number,
  19326. /**
  19327. * Defines the related dom event
  19328. */
  19329. event: PointerEvent | MouseWheelEvent);
  19330. }
  19331. /**
  19332. * This class is used to store pointer related info for the onPrePointerObservable event.
  19333. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19334. */
  19335. export class PointerInfoPre extends PointerInfoBase {
  19336. /**
  19337. * Ray from a pointer if availible (eg. 6dof controller)
  19338. */
  19339. ray: Nullable<Ray>;
  19340. /**
  19341. * Defines the local position of the pointer on the canvas.
  19342. */
  19343. localPosition: Vector2;
  19344. /**
  19345. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19346. */
  19347. skipOnPointerObservable: boolean;
  19348. /**
  19349. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19350. * @param type Defines the type of event (PointerEventTypes)
  19351. * @param event Defines the related dom event
  19352. * @param localX Defines the local x coordinates of the pointer when the event occured
  19353. * @param localY Defines the local y coordinates of the pointer when the event occured
  19354. */
  19355. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19356. }
  19357. /**
  19358. * This type contains all the data related to a pointer event in Babylon.js.
  19359. * 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.
  19360. */
  19361. export class PointerInfo extends PointerInfoBase {
  19362. /**
  19363. * Defines the picking info associated to the info (if any)\
  19364. */
  19365. pickInfo: Nullable<PickingInfo>;
  19366. /**
  19367. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19368. * @param type Defines the type of event (PointerEventTypes)
  19369. * @param event Defines the related dom event
  19370. * @param pickInfo Defines the picking info associated to the info (if any)\
  19371. */
  19372. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19373. /**
  19374. * Defines the picking info associated to the info (if any)\
  19375. */
  19376. pickInfo: Nullable<PickingInfo>);
  19377. }
  19378. /**
  19379. * Data relating to a touch event on the screen.
  19380. */
  19381. export interface PointerTouch {
  19382. /**
  19383. * X coordinate of touch.
  19384. */
  19385. x: number;
  19386. /**
  19387. * Y coordinate of touch.
  19388. */
  19389. y: number;
  19390. /**
  19391. * Id of touch. Unique for each finger.
  19392. */
  19393. pointerId: number;
  19394. /**
  19395. * Event type passed from DOM.
  19396. */
  19397. type: any;
  19398. }
  19399. }
  19400. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19401. import { Observable } from "babylonjs/Misc/observable";
  19402. import { Nullable } from "babylonjs/types";
  19403. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19404. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19405. /**
  19406. * Manage the mouse inputs to control the movement of a free camera.
  19407. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19408. */
  19409. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19410. /**
  19411. * Define if touch is enabled in the mouse input
  19412. */
  19413. touchEnabled: boolean;
  19414. /**
  19415. * Defines the camera the input is attached to.
  19416. */
  19417. camera: FreeCamera;
  19418. /**
  19419. * Defines the buttons associated with the input to handle camera move.
  19420. */
  19421. buttons: number[];
  19422. /**
  19423. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19424. */
  19425. angularSensibility: number;
  19426. private _pointerInput;
  19427. private _onMouseMove;
  19428. private _observer;
  19429. private previousPosition;
  19430. /**
  19431. * Observable for when a pointer move event occurs containing the move offset
  19432. */
  19433. onPointerMovedObservable: Observable<{
  19434. offsetX: number;
  19435. offsetY: number;
  19436. }>;
  19437. /**
  19438. * @hidden
  19439. * If the camera should be rotated automatically based on pointer movement
  19440. */
  19441. _allowCameraRotation: boolean;
  19442. /**
  19443. * Manage the mouse inputs to control the movement of a free camera.
  19444. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19445. * @param touchEnabled Defines if touch is enabled or not
  19446. */
  19447. constructor(
  19448. /**
  19449. * Define if touch is enabled in the mouse input
  19450. */
  19451. touchEnabled?: boolean);
  19452. /**
  19453. * Attach the input controls to a specific dom element to get the input from.
  19454. * @param element Defines the element the controls should be listened from
  19455. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19456. */
  19457. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19458. /**
  19459. * Called on JS contextmenu event.
  19460. * Override this method to provide functionality.
  19461. */
  19462. protected onContextMenu(evt: PointerEvent): void;
  19463. /**
  19464. * Detach the current controls from the specified dom element.
  19465. * @param element Defines the element to stop listening the inputs from
  19466. */
  19467. detachControl(element: Nullable<HTMLElement>): void;
  19468. /**
  19469. * Gets the class name of the current intput.
  19470. * @returns the class name
  19471. */
  19472. getClassName(): string;
  19473. /**
  19474. * Get the friendly name associated with the input class.
  19475. * @returns the input friendly name
  19476. */
  19477. getSimpleName(): string;
  19478. }
  19479. }
  19480. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19481. import { Nullable } from "babylonjs/types";
  19482. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19483. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19484. /**
  19485. * Manage the touch inputs to control the movement of a free camera.
  19486. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19487. */
  19488. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19489. /**
  19490. * Define if mouse events can be treated as touch events
  19491. */
  19492. allowMouse: boolean;
  19493. /**
  19494. * Defines the camera the input is attached to.
  19495. */
  19496. camera: FreeCamera;
  19497. /**
  19498. * Defines the touch sensibility for rotation.
  19499. * The higher the faster.
  19500. */
  19501. touchAngularSensibility: number;
  19502. /**
  19503. * Defines the touch sensibility for move.
  19504. * The higher the faster.
  19505. */
  19506. touchMoveSensibility: number;
  19507. private _offsetX;
  19508. private _offsetY;
  19509. private _pointerPressed;
  19510. private _pointerInput;
  19511. private _observer;
  19512. private _onLostFocus;
  19513. /**
  19514. * Manage the touch inputs to control the movement of a free camera.
  19515. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19516. * @param allowMouse Defines if mouse events can be treated as touch events
  19517. */
  19518. constructor(
  19519. /**
  19520. * Define if mouse events can be treated as touch events
  19521. */
  19522. allowMouse?: boolean);
  19523. /**
  19524. * Attach the input controls to a specific dom element to get the input from.
  19525. * @param element Defines the element the controls should be listened from
  19526. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19527. */
  19528. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19529. /**
  19530. * Detach the current controls from the specified dom element.
  19531. * @param element Defines the element to stop listening the inputs from
  19532. */
  19533. detachControl(element: Nullable<HTMLElement>): void;
  19534. /**
  19535. * Update the current camera state depending on the inputs that have been used this frame.
  19536. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19537. */
  19538. checkInputs(): void;
  19539. /**
  19540. * Gets the class name of the current intput.
  19541. * @returns the class name
  19542. */
  19543. getClassName(): string;
  19544. /**
  19545. * Get the friendly name associated with the input class.
  19546. * @returns the input friendly name
  19547. */
  19548. getSimpleName(): string;
  19549. }
  19550. }
  19551. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19552. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19553. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19554. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19555. import { Nullable } from "babylonjs/types";
  19556. /**
  19557. * Default Inputs manager for the FreeCamera.
  19558. * It groups all the default supported inputs for ease of use.
  19559. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19560. */
  19561. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19562. /**
  19563. * @hidden
  19564. */
  19565. _mouseInput: Nullable<FreeCameraMouseInput>;
  19566. /**
  19567. * Instantiates a new FreeCameraInputsManager.
  19568. * @param camera Defines the camera the inputs belong to
  19569. */
  19570. constructor(camera: FreeCamera);
  19571. /**
  19572. * Add keyboard input support to the input manager.
  19573. * @returns the current input manager
  19574. */
  19575. addKeyboard(): FreeCameraInputsManager;
  19576. /**
  19577. * Add mouse input support to the input manager.
  19578. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19579. * @returns the current input manager
  19580. */
  19581. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19582. /**
  19583. * Removes the mouse input support from the manager
  19584. * @returns the current input manager
  19585. */
  19586. removeMouse(): FreeCameraInputsManager;
  19587. /**
  19588. * Add touch input support to the input manager.
  19589. * @returns the current input manager
  19590. */
  19591. addTouch(): FreeCameraInputsManager;
  19592. /**
  19593. * Remove all attached input methods from a camera
  19594. */
  19595. clear(): void;
  19596. }
  19597. }
  19598. declare module "babylonjs/Cameras/freeCamera" {
  19599. import { Vector3 } from "babylonjs/Maths/math.vector";
  19600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19601. import { Scene } from "babylonjs/scene";
  19602. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19603. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19604. /**
  19605. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19606. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19607. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19608. */
  19609. export class FreeCamera extends TargetCamera {
  19610. /**
  19611. * Define the collision ellipsoid of the camera.
  19612. * This is helpful to simulate a camera body like the player body around the camera
  19613. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19614. */
  19615. ellipsoid: Vector3;
  19616. /**
  19617. * Define an offset for the position of the ellipsoid around the camera.
  19618. * This can be helpful to determine the center of the body near the gravity center of the body
  19619. * instead of its head.
  19620. */
  19621. ellipsoidOffset: Vector3;
  19622. /**
  19623. * Enable or disable collisions of the camera with the rest of the scene objects.
  19624. */
  19625. checkCollisions: boolean;
  19626. /**
  19627. * Enable or disable gravity on the camera.
  19628. */
  19629. applyGravity: boolean;
  19630. /**
  19631. * Define the input manager associated to the camera.
  19632. */
  19633. inputs: FreeCameraInputsManager;
  19634. /**
  19635. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19636. * Higher values reduce sensitivity.
  19637. */
  19638. get angularSensibility(): number;
  19639. /**
  19640. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19641. * Higher values reduce sensitivity.
  19642. */
  19643. set angularSensibility(value: number);
  19644. /**
  19645. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19646. */
  19647. get keysUp(): number[];
  19648. set keysUp(value: number[]);
  19649. /**
  19650. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19651. */
  19652. get keysUpward(): number[];
  19653. set keysUpward(value: number[]);
  19654. /**
  19655. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19656. */
  19657. get keysDown(): number[];
  19658. set keysDown(value: number[]);
  19659. /**
  19660. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19661. */
  19662. get keysDownward(): number[];
  19663. set keysDownward(value: number[]);
  19664. /**
  19665. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19666. */
  19667. get keysLeft(): number[];
  19668. set keysLeft(value: number[]);
  19669. /**
  19670. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19671. */
  19672. get keysRight(): number[];
  19673. set keysRight(value: number[]);
  19674. /**
  19675. * Event raised when the camera collide with a mesh in the scene.
  19676. */
  19677. onCollide: (collidedMesh: AbstractMesh) => void;
  19678. private _collider;
  19679. private _needMoveForGravity;
  19680. private _oldPosition;
  19681. private _diffPosition;
  19682. private _newPosition;
  19683. /** @hidden */
  19684. _localDirection: Vector3;
  19685. /** @hidden */
  19686. _transformedDirection: Vector3;
  19687. /**
  19688. * Instantiates a Free Camera.
  19689. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19690. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19691. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19692. * @param name Define the name of the camera in the scene
  19693. * @param position Define the start position of the camera in the scene
  19694. * @param scene Define the scene the camera belongs to
  19695. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19696. */
  19697. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19698. /**
  19699. * Attached controls to the current camera.
  19700. * @param element Defines the element the controls should be listened from
  19701. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19702. */
  19703. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19704. /**
  19705. * Detach the current controls from the camera.
  19706. * The camera will stop reacting to inputs.
  19707. * @param element Defines the element to stop listening the inputs from
  19708. */
  19709. detachControl(element: HTMLElement): void;
  19710. private _collisionMask;
  19711. /**
  19712. * Define a collision mask to limit the list of object the camera can collide with
  19713. */
  19714. get collisionMask(): number;
  19715. set collisionMask(mask: number);
  19716. /** @hidden */
  19717. _collideWithWorld(displacement: Vector3): void;
  19718. private _onCollisionPositionChange;
  19719. /** @hidden */
  19720. _checkInputs(): void;
  19721. /** @hidden */
  19722. _decideIfNeedsToMove(): boolean;
  19723. /** @hidden */
  19724. _updatePosition(): void;
  19725. /**
  19726. * Destroy the camera and release the current resources hold by it.
  19727. */
  19728. dispose(): void;
  19729. /**
  19730. * Gets the current object class name.
  19731. * @return the class name
  19732. */
  19733. getClassName(): string;
  19734. }
  19735. }
  19736. declare module "babylonjs/Gamepads/gamepad" {
  19737. import { Observable } from "babylonjs/Misc/observable";
  19738. /**
  19739. * Represents a gamepad control stick position
  19740. */
  19741. export class StickValues {
  19742. /**
  19743. * The x component of the control stick
  19744. */
  19745. x: number;
  19746. /**
  19747. * The y component of the control stick
  19748. */
  19749. y: number;
  19750. /**
  19751. * Initializes the gamepad x and y control stick values
  19752. * @param x The x component of the gamepad control stick value
  19753. * @param y The y component of the gamepad control stick value
  19754. */
  19755. constructor(
  19756. /**
  19757. * The x component of the control stick
  19758. */
  19759. x: number,
  19760. /**
  19761. * The y component of the control stick
  19762. */
  19763. y: number);
  19764. }
  19765. /**
  19766. * An interface which manages callbacks for gamepad button changes
  19767. */
  19768. export interface GamepadButtonChanges {
  19769. /**
  19770. * Called when a gamepad has been changed
  19771. */
  19772. changed: boolean;
  19773. /**
  19774. * Called when a gamepad press event has been triggered
  19775. */
  19776. pressChanged: boolean;
  19777. /**
  19778. * Called when a touch event has been triggered
  19779. */
  19780. touchChanged: boolean;
  19781. /**
  19782. * Called when a value has changed
  19783. */
  19784. valueChanged: boolean;
  19785. }
  19786. /**
  19787. * Represents a gamepad
  19788. */
  19789. export class Gamepad {
  19790. /**
  19791. * The id of the gamepad
  19792. */
  19793. id: string;
  19794. /**
  19795. * The index of the gamepad
  19796. */
  19797. index: number;
  19798. /**
  19799. * The browser gamepad
  19800. */
  19801. browserGamepad: any;
  19802. /**
  19803. * Specifies what type of gamepad this represents
  19804. */
  19805. type: number;
  19806. private _leftStick;
  19807. private _rightStick;
  19808. /** @hidden */
  19809. _isConnected: boolean;
  19810. private _leftStickAxisX;
  19811. private _leftStickAxisY;
  19812. private _rightStickAxisX;
  19813. private _rightStickAxisY;
  19814. /**
  19815. * Triggered when the left control stick has been changed
  19816. */
  19817. private _onleftstickchanged;
  19818. /**
  19819. * Triggered when the right control stick has been changed
  19820. */
  19821. private _onrightstickchanged;
  19822. /**
  19823. * Represents a gamepad controller
  19824. */
  19825. static GAMEPAD: number;
  19826. /**
  19827. * Represents a generic controller
  19828. */
  19829. static GENERIC: number;
  19830. /**
  19831. * Represents an XBox controller
  19832. */
  19833. static XBOX: number;
  19834. /**
  19835. * Represents a pose-enabled controller
  19836. */
  19837. static POSE_ENABLED: number;
  19838. /**
  19839. * Represents an Dual Shock controller
  19840. */
  19841. static DUALSHOCK: number;
  19842. /**
  19843. * Specifies whether the left control stick should be Y-inverted
  19844. */
  19845. protected _invertLeftStickY: boolean;
  19846. /**
  19847. * Specifies if the gamepad has been connected
  19848. */
  19849. get isConnected(): boolean;
  19850. /**
  19851. * Initializes the gamepad
  19852. * @param id The id of the gamepad
  19853. * @param index The index of the gamepad
  19854. * @param browserGamepad The browser gamepad
  19855. * @param leftStickX The x component of the left joystick
  19856. * @param leftStickY The y component of the left joystick
  19857. * @param rightStickX The x component of the right joystick
  19858. * @param rightStickY The y component of the right joystick
  19859. */
  19860. constructor(
  19861. /**
  19862. * The id of the gamepad
  19863. */
  19864. id: string,
  19865. /**
  19866. * The index of the gamepad
  19867. */
  19868. index: number,
  19869. /**
  19870. * The browser gamepad
  19871. */
  19872. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19873. /**
  19874. * Callback triggered when the left joystick has changed
  19875. * @param callback
  19876. */
  19877. onleftstickchanged(callback: (values: StickValues) => void): void;
  19878. /**
  19879. * Callback triggered when the right joystick has changed
  19880. * @param callback
  19881. */
  19882. onrightstickchanged(callback: (values: StickValues) => void): void;
  19883. /**
  19884. * Gets the left joystick
  19885. */
  19886. get leftStick(): StickValues;
  19887. /**
  19888. * Sets the left joystick values
  19889. */
  19890. set leftStick(newValues: StickValues);
  19891. /**
  19892. * Gets the right joystick
  19893. */
  19894. get rightStick(): StickValues;
  19895. /**
  19896. * Sets the right joystick value
  19897. */
  19898. set rightStick(newValues: StickValues);
  19899. /**
  19900. * Updates the gamepad joystick positions
  19901. */
  19902. update(): void;
  19903. /**
  19904. * Disposes the gamepad
  19905. */
  19906. dispose(): void;
  19907. }
  19908. /**
  19909. * Represents a generic gamepad
  19910. */
  19911. export class GenericPad extends Gamepad {
  19912. private _buttons;
  19913. private _onbuttondown;
  19914. private _onbuttonup;
  19915. /**
  19916. * Observable triggered when a button has been pressed
  19917. */
  19918. onButtonDownObservable: Observable<number>;
  19919. /**
  19920. * Observable triggered when a button has been released
  19921. */
  19922. onButtonUpObservable: Observable<number>;
  19923. /**
  19924. * Callback triggered when a button has been pressed
  19925. * @param callback Called when a button has been pressed
  19926. */
  19927. onbuttondown(callback: (buttonPressed: number) => void): void;
  19928. /**
  19929. * Callback triggered when a button has been released
  19930. * @param callback Called when a button has been released
  19931. */
  19932. onbuttonup(callback: (buttonReleased: number) => void): void;
  19933. /**
  19934. * Initializes the generic gamepad
  19935. * @param id The id of the generic gamepad
  19936. * @param index The index of the generic gamepad
  19937. * @param browserGamepad The browser gamepad
  19938. */
  19939. constructor(id: string, index: number, browserGamepad: any);
  19940. private _setButtonValue;
  19941. /**
  19942. * Updates the generic gamepad
  19943. */
  19944. update(): void;
  19945. /**
  19946. * Disposes the generic gamepad
  19947. */
  19948. dispose(): void;
  19949. }
  19950. }
  19951. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19952. import { Observable } from "babylonjs/Misc/observable";
  19953. import { Nullable } from "babylonjs/types";
  19954. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19955. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19957. import { Ray } from "babylonjs/Culling/ray";
  19958. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19959. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19960. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19961. /**
  19962. * Defines the types of pose enabled controllers that are supported
  19963. */
  19964. export enum PoseEnabledControllerType {
  19965. /**
  19966. * HTC Vive
  19967. */
  19968. VIVE = 0,
  19969. /**
  19970. * Oculus Rift
  19971. */
  19972. OCULUS = 1,
  19973. /**
  19974. * Windows mixed reality
  19975. */
  19976. WINDOWS = 2,
  19977. /**
  19978. * Samsung gear VR
  19979. */
  19980. GEAR_VR = 3,
  19981. /**
  19982. * Google Daydream
  19983. */
  19984. DAYDREAM = 4,
  19985. /**
  19986. * Generic
  19987. */
  19988. GENERIC = 5
  19989. }
  19990. /**
  19991. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19992. */
  19993. export interface MutableGamepadButton {
  19994. /**
  19995. * Value of the button/trigger
  19996. */
  19997. value: number;
  19998. /**
  19999. * If the button/trigger is currently touched
  20000. */
  20001. touched: boolean;
  20002. /**
  20003. * If the button/trigger is currently pressed
  20004. */
  20005. pressed: boolean;
  20006. }
  20007. /**
  20008. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20009. * @hidden
  20010. */
  20011. export interface ExtendedGamepadButton extends GamepadButton {
  20012. /**
  20013. * If the button/trigger is currently pressed
  20014. */
  20015. readonly pressed: boolean;
  20016. /**
  20017. * If the button/trigger is currently touched
  20018. */
  20019. readonly touched: boolean;
  20020. /**
  20021. * Value of the button/trigger
  20022. */
  20023. readonly value: number;
  20024. }
  20025. /** @hidden */
  20026. export interface _GamePadFactory {
  20027. /**
  20028. * Returns whether or not the current gamepad can be created for this type of controller.
  20029. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20030. * @returns true if it can be created, otherwise false
  20031. */
  20032. canCreate(gamepadInfo: any): boolean;
  20033. /**
  20034. * Creates a new instance of the Gamepad.
  20035. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20036. * @returns the new gamepad instance
  20037. */
  20038. create(gamepadInfo: any): Gamepad;
  20039. }
  20040. /**
  20041. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20042. */
  20043. export class PoseEnabledControllerHelper {
  20044. /** @hidden */
  20045. static _ControllerFactories: _GamePadFactory[];
  20046. /** @hidden */
  20047. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20048. /**
  20049. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20050. * @param vrGamepad the gamepad to initialized
  20051. * @returns a vr controller of the type the gamepad identified as
  20052. */
  20053. static InitiateController(vrGamepad: any): Gamepad;
  20054. }
  20055. /**
  20056. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20057. */
  20058. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20059. /**
  20060. * If the controller is used in a webXR session
  20061. */
  20062. isXR: boolean;
  20063. private _deviceRoomPosition;
  20064. private _deviceRoomRotationQuaternion;
  20065. /**
  20066. * The device position in babylon space
  20067. */
  20068. devicePosition: Vector3;
  20069. /**
  20070. * The device rotation in babylon space
  20071. */
  20072. deviceRotationQuaternion: Quaternion;
  20073. /**
  20074. * The scale factor of the device in babylon space
  20075. */
  20076. deviceScaleFactor: number;
  20077. /**
  20078. * (Likely devicePosition should be used instead) The device position in its room space
  20079. */
  20080. position: Vector3;
  20081. /**
  20082. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20083. */
  20084. rotationQuaternion: Quaternion;
  20085. /**
  20086. * The type of controller (Eg. Windows mixed reality)
  20087. */
  20088. controllerType: PoseEnabledControllerType;
  20089. protected _calculatedPosition: Vector3;
  20090. private _calculatedRotation;
  20091. /**
  20092. * The raw pose from the device
  20093. */
  20094. rawPose: DevicePose;
  20095. private _trackPosition;
  20096. private _maxRotationDistFromHeadset;
  20097. private _draggedRoomRotation;
  20098. /**
  20099. * @hidden
  20100. */
  20101. _disableTrackPosition(fixedPosition: Vector3): void;
  20102. /**
  20103. * Internal, the mesh attached to the controller
  20104. * @hidden
  20105. */
  20106. _mesh: Nullable<AbstractMesh>;
  20107. private _poseControlledCamera;
  20108. private _leftHandSystemQuaternion;
  20109. /**
  20110. * Internal, matrix used to convert room space to babylon space
  20111. * @hidden
  20112. */
  20113. _deviceToWorld: Matrix;
  20114. /**
  20115. * Node to be used when casting a ray from the controller
  20116. * @hidden
  20117. */
  20118. _pointingPoseNode: Nullable<TransformNode>;
  20119. /**
  20120. * Name of the child mesh that can be used to cast a ray from the controller
  20121. */
  20122. static readonly POINTING_POSE: string;
  20123. /**
  20124. * Creates a new PoseEnabledController from a gamepad
  20125. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20126. */
  20127. constructor(browserGamepad: any);
  20128. private _workingMatrix;
  20129. /**
  20130. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20131. */
  20132. update(): void;
  20133. /**
  20134. * Updates only the pose device and mesh without doing any button event checking
  20135. */
  20136. protected _updatePoseAndMesh(): void;
  20137. /**
  20138. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20139. * @param poseData raw pose fromthe device
  20140. */
  20141. updateFromDevice(poseData: DevicePose): void;
  20142. /**
  20143. * @hidden
  20144. */
  20145. _meshAttachedObservable: Observable<AbstractMesh>;
  20146. /**
  20147. * Attaches a mesh to the controller
  20148. * @param mesh the mesh to be attached
  20149. */
  20150. attachToMesh(mesh: AbstractMesh): void;
  20151. /**
  20152. * Attaches the controllers mesh to a camera
  20153. * @param camera the camera the mesh should be attached to
  20154. */
  20155. attachToPoseControlledCamera(camera: TargetCamera): void;
  20156. /**
  20157. * Disposes of the controller
  20158. */
  20159. dispose(): void;
  20160. /**
  20161. * The mesh that is attached to the controller
  20162. */
  20163. get mesh(): Nullable<AbstractMesh>;
  20164. /**
  20165. * Gets the ray of the controller in the direction the controller is pointing
  20166. * @param length the length the resulting ray should be
  20167. * @returns a ray in the direction the controller is pointing
  20168. */
  20169. getForwardRay(length?: number): Ray;
  20170. }
  20171. }
  20172. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20173. import { Observable } from "babylonjs/Misc/observable";
  20174. import { Scene } from "babylonjs/scene";
  20175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20176. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20177. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20178. import { Nullable } from "babylonjs/types";
  20179. /**
  20180. * Defines the WebVRController object that represents controllers tracked in 3D space
  20181. */
  20182. export abstract class WebVRController extends PoseEnabledController {
  20183. /**
  20184. * Internal, the default controller model for the controller
  20185. */
  20186. protected _defaultModel: Nullable<AbstractMesh>;
  20187. /**
  20188. * Fired when the trigger state has changed
  20189. */
  20190. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20191. /**
  20192. * Fired when the main button state has changed
  20193. */
  20194. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20195. /**
  20196. * Fired when the secondary button state has changed
  20197. */
  20198. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20199. /**
  20200. * Fired when the pad state has changed
  20201. */
  20202. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20203. /**
  20204. * Fired when controllers stick values have changed
  20205. */
  20206. onPadValuesChangedObservable: Observable<StickValues>;
  20207. /**
  20208. * Array of button availible on the controller
  20209. */
  20210. protected _buttons: Array<MutableGamepadButton>;
  20211. private _onButtonStateChange;
  20212. /**
  20213. * Fired when a controller button's state has changed
  20214. * @param callback the callback containing the button that was modified
  20215. */
  20216. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20217. /**
  20218. * X and Y axis corresponding to the controllers joystick
  20219. */
  20220. pad: StickValues;
  20221. /**
  20222. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20223. */
  20224. hand: string;
  20225. /**
  20226. * The default controller model for the controller
  20227. */
  20228. get defaultModel(): Nullable<AbstractMesh>;
  20229. /**
  20230. * Creates a new WebVRController from a gamepad
  20231. * @param vrGamepad the gamepad that the WebVRController should be created from
  20232. */
  20233. constructor(vrGamepad: any);
  20234. /**
  20235. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20236. */
  20237. update(): void;
  20238. /**
  20239. * Function to be called when a button is modified
  20240. */
  20241. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20242. /**
  20243. * Loads a mesh and attaches it to the controller
  20244. * @param scene the scene the mesh should be added to
  20245. * @param meshLoaded callback for when the mesh has been loaded
  20246. */
  20247. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20248. private _setButtonValue;
  20249. private _changes;
  20250. private _checkChanges;
  20251. /**
  20252. * Disposes of th webVRCOntroller
  20253. */
  20254. dispose(): void;
  20255. }
  20256. }
  20257. declare module "babylonjs/Lights/hemisphericLight" {
  20258. import { Nullable } from "babylonjs/types";
  20259. import { Scene } from "babylonjs/scene";
  20260. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20261. import { Color3 } from "babylonjs/Maths/math.color";
  20262. import { Effect } from "babylonjs/Materials/effect";
  20263. import { Light } from "babylonjs/Lights/light";
  20264. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20265. /**
  20266. * The HemisphericLight simulates the ambient environment light,
  20267. * so the passed direction is the light reflection direction, not the incoming direction.
  20268. */
  20269. export class HemisphericLight extends Light {
  20270. /**
  20271. * The groundColor is the light in the opposite direction to the one specified during creation.
  20272. * 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.
  20273. */
  20274. groundColor: Color3;
  20275. /**
  20276. * The light reflection direction, not the incoming direction.
  20277. */
  20278. direction: Vector3;
  20279. /**
  20280. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20281. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20282. * The HemisphericLight can't cast shadows.
  20283. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20284. * @param name The friendly name of the light
  20285. * @param direction The direction of the light reflection
  20286. * @param scene The scene the light belongs to
  20287. */
  20288. constructor(name: string, direction: Vector3, scene: Scene);
  20289. protected _buildUniformLayout(): void;
  20290. /**
  20291. * Returns the string "HemisphericLight".
  20292. * @return The class name
  20293. */
  20294. getClassName(): string;
  20295. /**
  20296. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20297. * Returns the updated direction.
  20298. * @param target The target the direction should point to
  20299. * @return The computed direction
  20300. */
  20301. setDirectionToTarget(target: Vector3): Vector3;
  20302. /**
  20303. * Returns the shadow generator associated to the light.
  20304. * @returns Always null for hemispheric lights because it does not support shadows.
  20305. */
  20306. getShadowGenerator(): Nullable<IShadowGenerator>;
  20307. /**
  20308. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20309. * @param effect The effect to update
  20310. * @param lightIndex The index of the light in the effect to update
  20311. * @returns The hemispheric light
  20312. */
  20313. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20314. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20315. /**
  20316. * Computes the world matrix of the node
  20317. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20318. * @param useWasUpdatedFlag defines a reserved property
  20319. * @returns the world matrix
  20320. */
  20321. computeWorldMatrix(): Matrix;
  20322. /**
  20323. * Returns the integer 3.
  20324. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20325. */
  20326. getTypeID(): number;
  20327. /**
  20328. * Prepares the list of defines specific to the light type.
  20329. * @param defines the list of defines
  20330. * @param lightIndex defines the index of the light for the effect
  20331. */
  20332. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20333. }
  20334. }
  20335. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20336. /** @hidden */
  20337. export var vrMultiviewToSingleviewPixelShader: {
  20338. name: string;
  20339. shader: string;
  20340. };
  20341. }
  20342. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20343. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20344. import { Scene } from "babylonjs/scene";
  20345. /**
  20346. * Renders to multiple views with a single draw call
  20347. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20348. */
  20349. export class MultiviewRenderTarget extends RenderTargetTexture {
  20350. /**
  20351. * Creates a multiview render target
  20352. * @param scene scene used with the render target
  20353. * @param size the size of the render target (used for each view)
  20354. */
  20355. constructor(scene: Scene, size?: number | {
  20356. width: number;
  20357. height: number;
  20358. } | {
  20359. ratio: number;
  20360. });
  20361. /**
  20362. * @hidden
  20363. * @param faceIndex the face index, if its a cube texture
  20364. */
  20365. _bindFrameBuffer(faceIndex?: number): void;
  20366. /**
  20367. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20368. * @returns the view count
  20369. */
  20370. getViewCount(): number;
  20371. }
  20372. }
  20373. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20374. import { Camera } from "babylonjs/Cameras/camera";
  20375. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20376. import { Nullable } from "babylonjs/types";
  20377. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20378. import { Matrix } from "babylonjs/Maths/math.vector";
  20379. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20380. module "babylonjs/Engines/engine" {
  20381. interface Engine {
  20382. /**
  20383. * Creates a new multiview render target
  20384. * @param width defines the width of the texture
  20385. * @param height defines the height of the texture
  20386. * @returns the created multiview texture
  20387. */
  20388. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20389. /**
  20390. * Binds a multiview framebuffer to be drawn to
  20391. * @param multiviewTexture texture to bind
  20392. */
  20393. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20394. }
  20395. }
  20396. module "babylonjs/Cameras/camera" {
  20397. interface Camera {
  20398. /**
  20399. * @hidden
  20400. * 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)
  20401. */
  20402. _useMultiviewToSingleView: boolean;
  20403. /**
  20404. * @hidden
  20405. * 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)
  20406. */
  20407. _multiviewTexture: Nullable<RenderTargetTexture>;
  20408. /**
  20409. * @hidden
  20410. * ensures the multiview texture of the camera exists and has the specified width/height
  20411. * @param width height to set on the multiview texture
  20412. * @param height width to set on the multiview texture
  20413. */
  20414. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20415. }
  20416. }
  20417. module "babylonjs/scene" {
  20418. interface Scene {
  20419. /** @hidden */
  20420. _transformMatrixR: Matrix;
  20421. /** @hidden */
  20422. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20423. /** @hidden */
  20424. _createMultiviewUbo(): void;
  20425. /** @hidden */
  20426. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20427. /** @hidden */
  20428. _renderMultiviewToSingleView(camera: Camera): void;
  20429. }
  20430. }
  20431. }
  20432. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20433. import { Camera } from "babylonjs/Cameras/camera";
  20434. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20435. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20436. import "babylonjs/Engines/Extensions/engine.multiview";
  20437. /**
  20438. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20439. * This will not be used for webXR as it supports displaying texture arrays directly
  20440. */
  20441. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20442. /**
  20443. * Gets a string identifying the name of the class
  20444. * @returns "VRMultiviewToSingleviewPostProcess" string
  20445. */
  20446. getClassName(): string;
  20447. /**
  20448. * Initializes a VRMultiviewToSingleview
  20449. * @param name name of the post process
  20450. * @param camera camera to be applied to
  20451. * @param scaleFactor scaling factor to the size of the output texture
  20452. */
  20453. constructor(name: string, camera: Camera, scaleFactor: number);
  20454. }
  20455. }
  20456. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20457. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20458. import { Nullable } from "babylonjs/types";
  20459. import { Size } from "babylonjs/Maths/math.size";
  20460. import { Observable } from "babylonjs/Misc/observable";
  20461. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20462. /**
  20463. * Interface used to define additional presentation attributes
  20464. */
  20465. export interface IVRPresentationAttributes {
  20466. /**
  20467. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20468. */
  20469. highRefreshRate: boolean;
  20470. /**
  20471. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20472. */
  20473. foveationLevel: number;
  20474. }
  20475. module "babylonjs/Engines/engine" {
  20476. interface Engine {
  20477. /** @hidden */
  20478. _vrDisplay: any;
  20479. /** @hidden */
  20480. _vrSupported: boolean;
  20481. /** @hidden */
  20482. _oldSize: Size;
  20483. /** @hidden */
  20484. _oldHardwareScaleFactor: number;
  20485. /** @hidden */
  20486. _vrExclusivePointerMode: boolean;
  20487. /** @hidden */
  20488. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20489. /** @hidden */
  20490. _onVRDisplayPointerRestricted: () => void;
  20491. /** @hidden */
  20492. _onVRDisplayPointerUnrestricted: () => void;
  20493. /** @hidden */
  20494. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20495. /** @hidden */
  20496. _onVrDisplayDisconnect: Nullable<() => void>;
  20497. /** @hidden */
  20498. _onVrDisplayPresentChange: Nullable<() => void>;
  20499. /**
  20500. * Observable signaled when VR display mode changes
  20501. */
  20502. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20503. /**
  20504. * Observable signaled when VR request present is complete
  20505. */
  20506. onVRRequestPresentComplete: Observable<boolean>;
  20507. /**
  20508. * Observable signaled when VR request present starts
  20509. */
  20510. onVRRequestPresentStart: Observable<Engine>;
  20511. /**
  20512. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20513. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20514. */
  20515. isInVRExclusivePointerMode: boolean;
  20516. /**
  20517. * Gets a boolean indicating if a webVR device was detected
  20518. * @returns true if a webVR device was detected
  20519. */
  20520. isVRDevicePresent(): boolean;
  20521. /**
  20522. * Gets the current webVR device
  20523. * @returns the current webVR device (or null)
  20524. */
  20525. getVRDevice(): any;
  20526. /**
  20527. * Initializes a webVR display and starts listening to display change events
  20528. * The onVRDisplayChangedObservable will be notified upon these changes
  20529. * @returns A promise containing a VRDisplay and if vr is supported
  20530. */
  20531. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20532. /** @hidden */
  20533. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20534. /**
  20535. * Gets or sets the presentation attributes used to configure VR rendering
  20536. */
  20537. vrPresentationAttributes?: IVRPresentationAttributes;
  20538. /**
  20539. * Call this function to switch to webVR mode
  20540. * Will do nothing if webVR is not supported or if there is no webVR device
  20541. * @param options the webvr options provided to the camera. mainly used for multiview
  20542. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20543. */
  20544. enableVR(options: WebVROptions): void;
  20545. /** @hidden */
  20546. _onVRFullScreenTriggered(): void;
  20547. }
  20548. }
  20549. }
  20550. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20551. import { Nullable } from "babylonjs/types";
  20552. import { Observable } from "babylonjs/Misc/observable";
  20553. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20554. import { Scene } from "babylonjs/scene";
  20555. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20556. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20557. import { Node } from "babylonjs/node";
  20558. import { Ray } from "babylonjs/Culling/ray";
  20559. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20560. import "babylonjs/Engines/Extensions/engine.webVR";
  20561. /**
  20562. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20563. * IMPORTANT!! The data is right-hand data.
  20564. * @export
  20565. * @interface DevicePose
  20566. */
  20567. export interface DevicePose {
  20568. /**
  20569. * The position of the device, values in array are [x,y,z].
  20570. */
  20571. readonly position: Nullable<Float32Array>;
  20572. /**
  20573. * The linearVelocity of the device, values in array are [x,y,z].
  20574. */
  20575. readonly linearVelocity: Nullable<Float32Array>;
  20576. /**
  20577. * The linearAcceleration of the device, values in array are [x,y,z].
  20578. */
  20579. readonly linearAcceleration: Nullable<Float32Array>;
  20580. /**
  20581. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20582. */
  20583. readonly orientation: Nullable<Float32Array>;
  20584. /**
  20585. * The angularVelocity of the device, values in array are [x,y,z].
  20586. */
  20587. readonly angularVelocity: Nullable<Float32Array>;
  20588. /**
  20589. * The angularAcceleration of the device, values in array are [x,y,z].
  20590. */
  20591. readonly angularAcceleration: Nullable<Float32Array>;
  20592. }
  20593. /**
  20594. * Interface representing a pose controlled object in Babylon.
  20595. * A pose controlled object has both regular pose values as well as pose values
  20596. * from an external device such as a VR head mounted display
  20597. */
  20598. export interface PoseControlled {
  20599. /**
  20600. * The position of the object in babylon space.
  20601. */
  20602. position: Vector3;
  20603. /**
  20604. * The rotation quaternion of the object in babylon space.
  20605. */
  20606. rotationQuaternion: Quaternion;
  20607. /**
  20608. * The position of the device in babylon space.
  20609. */
  20610. devicePosition?: Vector3;
  20611. /**
  20612. * The rotation quaternion of the device in babylon space.
  20613. */
  20614. deviceRotationQuaternion: Quaternion;
  20615. /**
  20616. * The raw pose coming from the device.
  20617. */
  20618. rawPose: Nullable<DevicePose>;
  20619. /**
  20620. * The scale of the device to be used when translating from device space to babylon space.
  20621. */
  20622. deviceScaleFactor: number;
  20623. /**
  20624. * Updates the poseControlled values based on the input device pose.
  20625. * @param poseData the pose data to update the object with
  20626. */
  20627. updateFromDevice(poseData: DevicePose): void;
  20628. }
  20629. /**
  20630. * Set of options to customize the webVRCamera
  20631. */
  20632. export interface WebVROptions {
  20633. /**
  20634. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20635. */
  20636. trackPosition?: boolean;
  20637. /**
  20638. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20639. */
  20640. positionScale?: number;
  20641. /**
  20642. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20643. */
  20644. displayName?: string;
  20645. /**
  20646. * Should the native controller meshes be initialized. (default: true)
  20647. */
  20648. controllerMeshes?: boolean;
  20649. /**
  20650. * Creating a default HemiLight only on controllers. (default: true)
  20651. */
  20652. defaultLightingOnControllers?: boolean;
  20653. /**
  20654. * If you don't want to use the default VR button of the helper. (default: false)
  20655. */
  20656. useCustomVRButton?: boolean;
  20657. /**
  20658. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20659. */
  20660. customVRButton?: HTMLButtonElement;
  20661. /**
  20662. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20663. */
  20664. rayLength?: number;
  20665. /**
  20666. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20667. */
  20668. defaultHeight?: number;
  20669. /**
  20670. * If multiview should be used if availible (default: false)
  20671. */
  20672. useMultiview?: boolean;
  20673. }
  20674. /**
  20675. * This represents a WebVR camera.
  20676. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20677. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20678. */
  20679. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20680. private webVROptions;
  20681. /**
  20682. * @hidden
  20683. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20684. */
  20685. _vrDevice: any;
  20686. /**
  20687. * The rawPose of the vrDevice.
  20688. */
  20689. rawPose: Nullable<DevicePose>;
  20690. private _onVREnabled;
  20691. private _specsVersion;
  20692. private _attached;
  20693. private _frameData;
  20694. protected _descendants: Array<Node>;
  20695. private _deviceRoomPosition;
  20696. /** @hidden */
  20697. _deviceRoomRotationQuaternion: Quaternion;
  20698. private _standingMatrix;
  20699. /**
  20700. * Represents device position in babylon space.
  20701. */
  20702. devicePosition: Vector3;
  20703. /**
  20704. * Represents device rotation in babylon space.
  20705. */
  20706. deviceRotationQuaternion: Quaternion;
  20707. /**
  20708. * The scale of the device to be used when translating from device space to babylon space.
  20709. */
  20710. deviceScaleFactor: number;
  20711. private _deviceToWorld;
  20712. private _worldToDevice;
  20713. /**
  20714. * References to the webVR controllers for the vrDevice.
  20715. */
  20716. controllers: Array<WebVRController>;
  20717. /**
  20718. * Emits an event when a controller is attached.
  20719. */
  20720. onControllersAttachedObservable: Observable<WebVRController[]>;
  20721. /**
  20722. * Emits an event when a controller's mesh has been loaded;
  20723. */
  20724. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20725. /**
  20726. * Emits an event when the HMD's pose has been updated.
  20727. */
  20728. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20729. private _poseSet;
  20730. /**
  20731. * If the rig cameras be used as parent instead of this camera.
  20732. */
  20733. rigParenting: boolean;
  20734. private _lightOnControllers;
  20735. private _defaultHeight?;
  20736. /**
  20737. * Instantiates a WebVRFreeCamera.
  20738. * @param name The name of the WebVRFreeCamera
  20739. * @param position The starting anchor position for the camera
  20740. * @param scene The scene the camera belongs to
  20741. * @param webVROptions a set of customizable options for the webVRCamera
  20742. */
  20743. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20744. /**
  20745. * Gets the device distance from the ground in meters.
  20746. * @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.
  20747. */
  20748. deviceDistanceToRoomGround(): number;
  20749. /**
  20750. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20751. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20752. */
  20753. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20754. /**
  20755. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20756. * @returns A promise with a boolean set to if the standing matrix is supported.
  20757. */
  20758. useStandingMatrixAsync(): Promise<boolean>;
  20759. /**
  20760. * Disposes the camera
  20761. */
  20762. dispose(): void;
  20763. /**
  20764. * Gets a vrController by name.
  20765. * @param name The name of the controller to retreive
  20766. * @returns the controller matching the name specified or null if not found
  20767. */
  20768. getControllerByName(name: string): Nullable<WebVRController>;
  20769. private _leftController;
  20770. /**
  20771. * The controller corresponding to the users left hand.
  20772. */
  20773. get leftController(): Nullable<WebVRController>;
  20774. private _rightController;
  20775. /**
  20776. * The controller corresponding to the users right hand.
  20777. */
  20778. get rightController(): Nullable<WebVRController>;
  20779. /**
  20780. * Casts a ray forward from the vrCamera's gaze.
  20781. * @param length Length of the ray (default: 100)
  20782. * @returns the ray corresponding to the gaze
  20783. */
  20784. getForwardRay(length?: number): Ray;
  20785. /**
  20786. * @hidden
  20787. * Updates the camera based on device's frame data
  20788. */
  20789. _checkInputs(): void;
  20790. /**
  20791. * Updates the poseControlled values based on the input device pose.
  20792. * @param poseData Pose coming from the device
  20793. */
  20794. updateFromDevice(poseData: DevicePose): void;
  20795. private _htmlElementAttached;
  20796. private _detachIfAttached;
  20797. /**
  20798. * WebVR's attach control will start broadcasting frames to the device.
  20799. * Note that in certain browsers (chrome for example) this function must be called
  20800. * within a user-interaction callback. Example:
  20801. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20802. *
  20803. * @param element html element to attach the vrDevice to
  20804. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20805. */
  20806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20807. /**
  20808. * Detaches the camera from the html element and disables VR
  20809. *
  20810. * @param element html element to detach from
  20811. */
  20812. detachControl(element: HTMLElement): void;
  20813. /**
  20814. * @returns the name of this class
  20815. */
  20816. getClassName(): string;
  20817. /**
  20818. * Calls resetPose on the vrDisplay
  20819. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20820. */
  20821. resetToCurrentRotation(): void;
  20822. /**
  20823. * @hidden
  20824. * Updates the rig cameras (left and right eye)
  20825. */
  20826. _updateRigCameras(): void;
  20827. private _workingVector;
  20828. private _oneVector;
  20829. private _workingMatrix;
  20830. private updateCacheCalled;
  20831. private _correctPositionIfNotTrackPosition;
  20832. /**
  20833. * @hidden
  20834. * Updates the cached values of the camera
  20835. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20836. */
  20837. _updateCache(ignoreParentClass?: boolean): void;
  20838. /**
  20839. * @hidden
  20840. * Get current device position in babylon world
  20841. */
  20842. _computeDevicePosition(): void;
  20843. /**
  20844. * Updates the current device position and rotation in the babylon world
  20845. */
  20846. update(): void;
  20847. /**
  20848. * @hidden
  20849. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20850. * @returns an identity matrix
  20851. */
  20852. _getViewMatrix(): Matrix;
  20853. private _tmpMatrix;
  20854. /**
  20855. * This function is called by the two RIG cameras.
  20856. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20857. * @hidden
  20858. */
  20859. _getWebVRViewMatrix(): Matrix;
  20860. /** @hidden */
  20861. _getWebVRProjectionMatrix(): Matrix;
  20862. private _onGamepadConnectedObserver;
  20863. private _onGamepadDisconnectedObserver;
  20864. private _updateCacheWhenTrackingDisabledObserver;
  20865. /**
  20866. * Initializes the controllers and their meshes
  20867. */
  20868. initControllers(): void;
  20869. }
  20870. }
  20871. declare module "babylonjs/Materials/materialHelper" {
  20872. import { Nullable } from "babylonjs/types";
  20873. import { Scene } from "babylonjs/scene";
  20874. import { Engine } from "babylonjs/Engines/engine";
  20875. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20876. import { Light } from "babylonjs/Lights/light";
  20877. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20878. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20879. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20880. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20881. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20882. /**
  20883. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20884. *
  20885. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20886. *
  20887. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20888. */
  20889. export class MaterialHelper {
  20890. /**
  20891. * Bind the current view position to an effect.
  20892. * @param effect The effect to be bound
  20893. * @param scene The scene the eyes position is used from
  20894. * @param variableName name of the shader variable that will hold the eye position
  20895. */
  20896. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20897. /**
  20898. * Helps preparing the defines values about the UVs in used in the effect.
  20899. * UVs are shared as much as we can accross channels in the shaders.
  20900. * @param texture The texture we are preparing the UVs for
  20901. * @param defines The defines to update
  20902. * @param key The channel key "diffuse", "specular"... used in the shader
  20903. */
  20904. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20905. /**
  20906. * Binds a texture matrix value to its corrsponding uniform
  20907. * @param texture The texture to bind the matrix for
  20908. * @param uniformBuffer The uniform buffer receivin the data
  20909. * @param key The channel key "diffuse", "specular"... used in the shader
  20910. */
  20911. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20912. /**
  20913. * Gets the current status of the fog (should it be enabled?)
  20914. * @param mesh defines the mesh to evaluate for fog support
  20915. * @param scene defines the hosting scene
  20916. * @returns true if fog must be enabled
  20917. */
  20918. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20919. /**
  20920. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20921. * @param mesh defines the current mesh
  20922. * @param scene defines the current scene
  20923. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20924. * @param pointsCloud defines if point cloud rendering has to be turned on
  20925. * @param fogEnabled defines if fog has to be turned on
  20926. * @param alphaTest defines if alpha testing has to be turned on
  20927. * @param defines defines the current list of defines
  20928. */
  20929. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20930. /**
  20931. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20932. * @param scene defines the current scene
  20933. * @param engine defines the current engine
  20934. * @param defines specifies the list of active defines
  20935. * @param useInstances defines if instances have to be turned on
  20936. * @param useClipPlane defines if clip plane have to be turned on
  20937. * @param useInstances defines if instances have to be turned on
  20938. * @param useThinInstances defines if thin instances have to be turned on
  20939. */
  20940. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20941. /**
  20942. * Prepares the defines for bones
  20943. * @param mesh The mesh containing the geometry data we will draw
  20944. * @param defines The defines to update
  20945. */
  20946. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20947. /**
  20948. * Prepares the defines for morph targets
  20949. * @param mesh The mesh containing the geometry data we will draw
  20950. * @param defines The defines to update
  20951. */
  20952. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20953. /**
  20954. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20955. * @param mesh The mesh containing the geometry data we will draw
  20956. * @param defines The defines to update
  20957. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20958. * @param useBones Precise whether bones should be used or not (override mesh info)
  20959. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20960. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20961. * @returns false if defines are considered not dirty and have not been checked
  20962. */
  20963. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20964. /**
  20965. * Prepares the defines related to multiview
  20966. * @param scene The scene we are intending to draw
  20967. * @param defines The defines to update
  20968. */
  20969. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20970. /**
  20971. * Prepares the defines related to the prepass
  20972. * @param scene The scene we are intending to draw
  20973. * @param defines The defines to update
  20974. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20975. */
  20976. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20977. /**
  20978. * Prepares the defines related to the light information passed in parameter
  20979. * @param scene The scene we are intending to draw
  20980. * @param mesh The mesh the effect is compiling for
  20981. * @param light The light the effect is compiling for
  20982. * @param lightIndex The index of the light
  20983. * @param defines The defines to update
  20984. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20985. * @param state Defines the current state regarding what is needed (normals, etc...)
  20986. */
  20987. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20988. needNormals: boolean;
  20989. needRebuild: boolean;
  20990. shadowEnabled: boolean;
  20991. specularEnabled: boolean;
  20992. lightmapMode: boolean;
  20993. }): void;
  20994. /**
  20995. * Prepares the defines related to the light information passed in parameter
  20996. * @param scene The scene we are intending to draw
  20997. * @param mesh The mesh the effect is compiling for
  20998. * @param defines The defines to update
  20999. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21000. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21001. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21002. * @returns true if normals will be required for the rest of the effect
  21003. */
  21004. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21005. /**
  21006. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21007. * @param lightIndex defines the light index
  21008. * @param uniformsList The uniform list
  21009. * @param samplersList The sampler list
  21010. * @param projectedLightTexture defines if projected texture must be used
  21011. * @param uniformBuffersList defines an optional list of uniform buffers
  21012. */
  21013. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21014. /**
  21015. * Prepares the uniforms and samplers list to be used in the effect
  21016. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21017. * @param samplersList The sampler list
  21018. * @param defines The defines helping in the list generation
  21019. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21020. */
  21021. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21022. /**
  21023. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21024. * @param defines The defines to update while falling back
  21025. * @param fallbacks The authorized effect fallbacks
  21026. * @param maxSimultaneousLights The maximum number of lights allowed
  21027. * @param rank the current rank of the Effect
  21028. * @returns The newly affected rank
  21029. */
  21030. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21031. private static _TmpMorphInfluencers;
  21032. /**
  21033. * Prepares the list of attributes required for morph targets according to the effect defines.
  21034. * @param attribs The current list of supported attribs
  21035. * @param mesh The mesh to prepare the morph targets attributes for
  21036. * @param influencers The number of influencers
  21037. */
  21038. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21039. /**
  21040. * Prepares the list of attributes required for morph targets according to the effect defines.
  21041. * @param attribs The current list of supported attribs
  21042. * @param mesh The mesh to prepare the morph targets attributes for
  21043. * @param defines The current Defines of the effect
  21044. */
  21045. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21046. /**
  21047. * Prepares the list of attributes required for bones according to the effect defines.
  21048. * @param attribs The current list of supported attribs
  21049. * @param mesh The mesh to prepare the bones attributes for
  21050. * @param defines The current Defines of the effect
  21051. * @param fallbacks The current efffect fallback strategy
  21052. */
  21053. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21054. /**
  21055. * Check and prepare the list of attributes required for instances according to the effect defines.
  21056. * @param attribs The current list of supported attribs
  21057. * @param defines The current MaterialDefines of the effect
  21058. */
  21059. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21060. /**
  21061. * Add the list of attributes required for instances to the attribs array.
  21062. * @param attribs The current list of supported attribs
  21063. */
  21064. static PushAttributesForInstances(attribs: string[]): void;
  21065. /**
  21066. * Binds the light information to the effect.
  21067. * @param light The light containing the generator
  21068. * @param effect The effect we are binding the data to
  21069. * @param lightIndex The light index in the effect used to render
  21070. */
  21071. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21072. /**
  21073. * Binds the lights information from the scene to the effect for the given mesh.
  21074. * @param light Light to bind
  21075. * @param lightIndex Light index
  21076. * @param scene The scene where the light belongs to
  21077. * @param effect The effect we are binding the data to
  21078. * @param useSpecular Defines if specular is supported
  21079. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21080. */
  21081. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21082. /**
  21083. * Binds the lights information from the scene to the effect for the given mesh.
  21084. * @param scene The scene the lights belongs to
  21085. * @param mesh The mesh we are binding the information to render
  21086. * @param effect The effect we are binding the data to
  21087. * @param defines The generated defines for the effect
  21088. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21089. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21090. */
  21091. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21092. private static _tempFogColor;
  21093. /**
  21094. * Binds the fog information from the scene to the effect for the given mesh.
  21095. * @param scene The scene the lights belongs to
  21096. * @param mesh The mesh we are binding the information to render
  21097. * @param effect The effect we are binding the data to
  21098. * @param linearSpace Defines if the fog effect is applied in linear space
  21099. */
  21100. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21101. /**
  21102. * Binds the bones information from the mesh to the effect.
  21103. * @param mesh The mesh we are binding the information to render
  21104. * @param effect The effect we are binding the data to
  21105. */
  21106. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  21107. /**
  21108. * Binds the morph targets information from the mesh to the effect.
  21109. * @param abstractMesh The mesh we are binding the information to render
  21110. * @param effect The effect we are binding the data to
  21111. */
  21112. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21113. /**
  21114. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21115. * @param defines The generated defines used in the effect
  21116. * @param effect The effect we are binding the data to
  21117. * @param scene The scene we are willing to render with logarithmic scale for
  21118. */
  21119. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21120. /**
  21121. * Binds the clip plane information from the scene to the effect.
  21122. * @param scene The scene the clip plane information are extracted from
  21123. * @param effect The effect we are binding the data to
  21124. */
  21125. static BindClipPlane(effect: Effect, scene: Scene): void;
  21126. }
  21127. }
  21128. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21129. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21130. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21131. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21132. import { Nullable } from "babylonjs/types";
  21133. import { Effect } from "babylonjs/Materials/effect";
  21134. import { Matrix } from "babylonjs/Maths/math.vector";
  21135. import { Scene } from "babylonjs/scene";
  21136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21137. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21138. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21139. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21140. import { Observable } from "babylonjs/Misc/observable";
  21141. /**
  21142. * Block used to expose an input value
  21143. */
  21144. export class InputBlock extends NodeMaterialBlock {
  21145. private _mode;
  21146. private _associatedVariableName;
  21147. private _storedValue;
  21148. private _valueCallback;
  21149. private _type;
  21150. private _animationType;
  21151. /** Gets or set a value used to limit the range of float values */
  21152. min: number;
  21153. /** Gets or set a value used to limit the range of float values */
  21154. max: number;
  21155. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21156. isBoolean: boolean;
  21157. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21158. matrixMode: number;
  21159. /** @hidden */
  21160. _systemValue: Nullable<NodeMaterialSystemValues>;
  21161. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21162. isConstant: boolean;
  21163. /** Gets or sets the group to use to display this block in the Inspector */
  21164. groupInInspector: string;
  21165. /** Gets an observable raised when the value is changed */
  21166. onValueChangedObservable: Observable<InputBlock>;
  21167. /**
  21168. * Gets or sets the connection point type (default is float)
  21169. */
  21170. get type(): NodeMaterialBlockConnectionPointTypes;
  21171. /**
  21172. * Creates a new InputBlock
  21173. * @param name defines the block name
  21174. * @param target defines the target of that block (Vertex by default)
  21175. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21176. */
  21177. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21178. /**
  21179. * Validates if a name is a reserve word.
  21180. * @param newName the new name to be given to the node.
  21181. * @returns false if the name is a reserve word, else true.
  21182. */
  21183. validateBlockName(newName: string): boolean;
  21184. /**
  21185. * Gets the output component
  21186. */
  21187. get output(): NodeMaterialConnectionPoint;
  21188. /**
  21189. * Set the source of this connection point to a vertex attribute
  21190. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21191. * @returns the current connection point
  21192. */
  21193. setAsAttribute(attributeName?: string): InputBlock;
  21194. /**
  21195. * Set the source of this connection point to a system value
  21196. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21197. * @returns the current connection point
  21198. */
  21199. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21200. /**
  21201. * Gets or sets the value of that point.
  21202. * Please note that this value will be ignored if valueCallback is defined
  21203. */
  21204. get value(): any;
  21205. set value(value: any);
  21206. /**
  21207. * Gets or sets a callback used to get the value of that point.
  21208. * Please note that setting this value will force the connection point to ignore the value property
  21209. */
  21210. get valueCallback(): () => any;
  21211. set valueCallback(value: () => any);
  21212. /**
  21213. * Gets or sets the associated variable name in the shader
  21214. */
  21215. get associatedVariableName(): string;
  21216. set associatedVariableName(value: string);
  21217. /** Gets or sets the type of animation applied to the input */
  21218. get animationType(): AnimatedInputBlockTypes;
  21219. set animationType(value: AnimatedInputBlockTypes);
  21220. /**
  21221. * Gets a boolean indicating that this connection point not defined yet
  21222. */
  21223. get isUndefined(): boolean;
  21224. /**
  21225. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21226. * In this case the connection point name must be the name of the uniform to use.
  21227. * Can only be set on inputs
  21228. */
  21229. get isUniform(): boolean;
  21230. set isUniform(value: boolean);
  21231. /**
  21232. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21233. * In this case the connection point name must be the name of the attribute to use
  21234. * Can only be set on inputs
  21235. */
  21236. get isAttribute(): boolean;
  21237. set isAttribute(value: boolean);
  21238. /**
  21239. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21240. * Can only be set on exit points
  21241. */
  21242. get isVarying(): boolean;
  21243. set isVarying(value: boolean);
  21244. /**
  21245. * Gets a boolean indicating that the current connection point is a system value
  21246. */
  21247. get isSystemValue(): boolean;
  21248. /**
  21249. * Gets or sets the current well known value or null if not defined as a system value
  21250. */
  21251. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21252. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21253. /**
  21254. * Gets the current class name
  21255. * @returns the class name
  21256. */
  21257. getClassName(): string;
  21258. /**
  21259. * Animate the input if animationType !== None
  21260. * @param scene defines the rendering scene
  21261. */
  21262. animate(scene: Scene): void;
  21263. private _emitDefine;
  21264. initialize(state: NodeMaterialBuildState): void;
  21265. /**
  21266. * Set the input block to its default value (based on its type)
  21267. */
  21268. setDefaultValue(): void;
  21269. private _emitConstant;
  21270. /** @hidden */
  21271. get _noContextSwitch(): boolean;
  21272. private _emit;
  21273. /** @hidden */
  21274. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21275. /** @hidden */
  21276. _transmit(effect: Effect, scene: Scene): void;
  21277. protected _buildBlock(state: NodeMaterialBuildState): void;
  21278. protected _dumpPropertiesCode(): string;
  21279. dispose(): void;
  21280. serialize(): any;
  21281. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21282. }
  21283. }
  21284. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21285. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21286. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21287. import { Nullable } from "babylonjs/types";
  21288. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21289. import { Observable } from "babylonjs/Misc/observable";
  21290. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21291. /**
  21292. * Enum used to define the compatibility state between two connection points
  21293. */
  21294. export enum NodeMaterialConnectionPointCompatibilityStates {
  21295. /** Points are compatibles */
  21296. Compatible = 0,
  21297. /** Points are incompatible because of their types */
  21298. TypeIncompatible = 1,
  21299. /** Points are incompatible because of their targets (vertex vs fragment) */
  21300. TargetIncompatible = 2
  21301. }
  21302. /**
  21303. * Defines the direction of a connection point
  21304. */
  21305. export enum NodeMaterialConnectionPointDirection {
  21306. /** Input */
  21307. Input = 0,
  21308. /** Output */
  21309. Output = 1
  21310. }
  21311. /**
  21312. * Defines a connection point for a block
  21313. */
  21314. export class NodeMaterialConnectionPoint {
  21315. /** @hidden */
  21316. _ownerBlock: NodeMaterialBlock;
  21317. /** @hidden */
  21318. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21319. private _endpoints;
  21320. private _associatedVariableName;
  21321. private _direction;
  21322. /** @hidden */
  21323. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21324. /** @hidden */
  21325. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21326. private _type;
  21327. /** @hidden */
  21328. _enforceAssociatedVariableName: boolean;
  21329. /** Gets the direction of the point */
  21330. get direction(): NodeMaterialConnectionPointDirection;
  21331. /** Indicates that this connection point needs dual validation before being connected to another point */
  21332. needDualDirectionValidation: boolean;
  21333. /**
  21334. * Gets or sets the additional types supported by this connection point
  21335. */
  21336. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21337. /**
  21338. * Gets or sets the additional types excluded by this connection point
  21339. */
  21340. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21341. /**
  21342. * Observable triggered when this point is connected
  21343. */
  21344. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21345. /**
  21346. * Gets or sets the associated variable name in the shader
  21347. */
  21348. get associatedVariableName(): string;
  21349. set associatedVariableName(value: string);
  21350. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21351. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21352. /**
  21353. * Gets or sets the connection point type (default is float)
  21354. */
  21355. get type(): NodeMaterialBlockConnectionPointTypes;
  21356. set type(value: NodeMaterialBlockConnectionPointTypes);
  21357. /**
  21358. * Gets or sets the connection point name
  21359. */
  21360. name: string;
  21361. /**
  21362. * Gets or sets the connection point name
  21363. */
  21364. displayName: string;
  21365. /**
  21366. * Gets or sets a boolean indicating that this connection point can be omitted
  21367. */
  21368. isOptional: boolean;
  21369. /**
  21370. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21371. */
  21372. isExposedOnFrame: boolean;
  21373. /**
  21374. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21375. */
  21376. define: string;
  21377. /** @hidden */
  21378. _prioritizeVertex: boolean;
  21379. private _target;
  21380. /** Gets or sets the target of that connection point */
  21381. get target(): NodeMaterialBlockTargets;
  21382. set target(value: NodeMaterialBlockTargets);
  21383. /**
  21384. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21385. */
  21386. get isConnected(): boolean;
  21387. /**
  21388. * Gets a boolean indicating that the current point is connected to an input block
  21389. */
  21390. get isConnectedToInputBlock(): boolean;
  21391. /**
  21392. * Gets a the connected input block (if any)
  21393. */
  21394. get connectInputBlock(): Nullable<InputBlock>;
  21395. /** Get the other side of the connection (if any) */
  21396. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21397. /** Get the block that owns this connection point */
  21398. get ownerBlock(): NodeMaterialBlock;
  21399. /** Get the block connected on the other side of this connection (if any) */
  21400. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21401. /** Get the block connected on the endpoints of this connection (if any) */
  21402. get connectedBlocks(): Array<NodeMaterialBlock>;
  21403. /** Gets the list of connected endpoints */
  21404. get endpoints(): NodeMaterialConnectionPoint[];
  21405. /** Gets a boolean indicating if that output point is connected to at least one input */
  21406. get hasEndpoints(): boolean;
  21407. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21408. get isConnectedInVertexShader(): boolean;
  21409. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21410. get isConnectedInFragmentShader(): boolean;
  21411. /**
  21412. * Creates a block suitable to be used as an input for this input point.
  21413. * If null is returned, a block based on the point type will be created.
  21414. * @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
  21415. */
  21416. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21417. /**
  21418. * Creates a new connection point
  21419. * @param name defines the connection point name
  21420. * @param ownerBlock defines the block hosting this connection point
  21421. * @param direction defines the direction of the connection point
  21422. */
  21423. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21424. /**
  21425. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21426. * @returns the class name
  21427. */
  21428. getClassName(): string;
  21429. /**
  21430. * Gets a boolean indicating if the current point can be connected to another point
  21431. * @param connectionPoint defines the other connection point
  21432. * @returns a boolean
  21433. */
  21434. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21435. /**
  21436. * Gets a number indicating if the current point can be connected to another point
  21437. * @param connectionPoint defines the other connection point
  21438. * @returns a number defining the compatibility state
  21439. */
  21440. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21441. /**
  21442. * Connect this point to another connection point
  21443. * @param connectionPoint defines the other connection point
  21444. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21445. * @returns the current connection point
  21446. */
  21447. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21448. /**
  21449. * Disconnect this point from one of his endpoint
  21450. * @param endpoint defines the other connection point
  21451. * @returns the current connection point
  21452. */
  21453. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21454. /**
  21455. * Serializes this point in a JSON representation
  21456. * @param isInput defines if the connection point is an input (default is true)
  21457. * @returns the serialized point object
  21458. */
  21459. serialize(isInput?: boolean): any;
  21460. /**
  21461. * Release resources
  21462. */
  21463. dispose(): void;
  21464. }
  21465. }
  21466. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21467. /**
  21468. * Enum used to define the material modes
  21469. */
  21470. export enum NodeMaterialModes {
  21471. /** Regular material */
  21472. Material = 0,
  21473. /** For post process */
  21474. PostProcess = 1,
  21475. /** For particle system */
  21476. Particle = 2,
  21477. /** For procedural texture */
  21478. ProceduralTexture = 3
  21479. }
  21480. }
  21481. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21484. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21488. import { Effect } from "babylonjs/Materials/effect";
  21489. import { Mesh } from "babylonjs/Meshes/mesh";
  21490. import { Nullable } from "babylonjs/types";
  21491. import { Texture } from "babylonjs/Materials/Textures/texture";
  21492. import { Scene } from "babylonjs/scene";
  21493. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21494. /**
  21495. * Block used to read a texture from a sampler
  21496. */
  21497. export class TextureBlock extends NodeMaterialBlock {
  21498. private _defineName;
  21499. private _linearDefineName;
  21500. private _gammaDefineName;
  21501. private _tempTextureRead;
  21502. private _samplerName;
  21503. private _transformedUVName;
  21504. private _textureTransformName;
  21505. private _textureInfoName;
  21506. private _mainUVName;
  21507. private _mainUVDefineName;
  21508. private _fragmentOnly;
  21509. /**
  21510. * Gets or sets the texture associated with the node
  21511. */
  21512. texture: Nullable<Texture>;
  21513. /**
  21514. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21515. */
  21516. convertToGammaSpace: boolean;
  21517. /**
  21518. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21519. */
  21520. convertToLinearSpace: boolean;
  21521. /**
  21522. * Create a new TextureBlock
  21523. * @param name defines the block name
  21524. */
  21525. constructor(name: string, fragmentOnly?: boolean);
  21526. /**
  21527. * Gets the current class name
  21528. * @returns the class name
  21529. */
  21530. getClassName(): string;
  21531. /**
  21532. * Gets the uv input component
  21533. */
  21534. get uv(): NodeMaterialConnectionPoint;
  21535. /**
  21536. * Gets the rgba output component
  21537. */
  21538. get rgba(): NodeMaterialConnectionPoint;
  21539. /**
  21540. * Gets the rgb output component
  21541. */
  21542. get rgb(): NodeMaterialConnectionPoint;
  21543. /**
  21544. * Gets the r output component
  21545. */
  21546. get r(): NodeMaterialConnectionPoint;
  21547. /**
  21548. * Gets the g output component
  21549. */
  21550. get g(): NodeMaterialConnectionPoint;
  21551. /**
  21552. * Gets the b output component
  21553. */
  21554. get b(): NodeMaterialConnectionPoint;
  21555. /**
  21556. * Gets the a output component
  21557. */
  21558. get a(): NodeMaterialConnectionPoint;
  21559. get target(): NodeMaterialBlockTargets;
  21560. autoConfigure(material: NodeMaterial): void;
  21561. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21562. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21563. isReady(): boolean;
  21564. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21565. private get _isMixed();
  21566. private _injectVertexCode;
  21567. private _writeTextureRead;
  21568. private _writeOutput;
  21569. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21570. protected _dumpPropertiesCode(): string;
  21571. serialize(): any;
  21572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21573. }
  21574. }
  21575. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21576. /** @hidden */
  21577. export var reflectionFunction: {
  21578. name: string;
  21579. shader: string;
  21580. };
  21581. }
  21582. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21587. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21588. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21589. import { Effect } from "babylonjs/Materials/effect";
  21590. import { Mesh } from "babylonjs/Meshes/mesh";
  21591. import { Nullable } from "babylonjs/types";
  21592. import { Scene } from "babylonjs/scene";
  21593. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21594. /**
  21595. * Base block used to read a reflection texture from a sampler
  21596. */
  21597. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21598. /** @hidden */
  21599. _define3DName: string;
  21600. /** @hidden */
  21601. _defineCubicName: string;
  21602. /** @hidden */
  21603. _defineExplicitName: string;
  21604. /** @hidden */
  21605. _defineProjectionName: string;
  21606. /** @hidden */
  21607. _defineLocalCubicName: string;
  21608. /** @hidden */
  21609. _defineSphericalName: string;
  21610. /** @hidden */
  21611. _definePlanarName: string;
  21612. /** @hidden */
  21613. _defineEquirectangularName: string;
  21614. /** @hidden */
  21615. _defineMirroredEquirectangularFixedName: string;
  21616. /** @hidden */
  21617. _defineEquirectangularFixedName: string;
  21618. /** @hidden */
  21619. _defineSkyboxName: string;
  21620. /** @hidden */
  21621. _defineOppositeZ: string;
  21622. /** @hidden */
  21623. _cubeSamplerName: string;
  21624. /** @hidden */
  21625. _2DSamplerName: string;
  21626. protected _positionUVWName: string;
  21627. protected _directionWName: string;
  21628. protected _reflectionVectorName: string;
  21629. /** @hidden */
  21630. _reflectionCoordsName: string;
  21631. /** @hidden */
  21632. _reflectionMatrixName: string;
  21633. protected _reflectionColorName: string;
  21634. /**
  21635. * Gets or sets the texture associated with the node
  21636. */
  21637. texture: Nullable<BaseTexture>;
  21638. /**
  21639. * Create a new ReflectionTextureBaseBlock
  21640. * @param name defines the block name
  21641. */
  21642. constructor(name: string);
  21643. /**
  21644. * Gets the current class name
  21645. * @returns the class name
  21646. */
  21647. getClassName(): string;
  21648. /**
  21649. * Gets the world position input component
  21650. */
  21651. abstract get position(): NodeMaterialConnectionPoint;
  21652. /**
  21653. * Gets the world position input component
  21654. */
  21655. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21656. /**
  21657. * Gets the world normal input component
  21658. */
  21659. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21660. /**
  21661. * Gets the world input component
  21662. */
  21663. abstract get world(): NodeMaterialConnectionPoint;
  21664. /**
  21665. * Gets the camera (or eye) position component
  21666. */
  21667. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21668. /**
  21669. * Gets the view input component
  21670. */
  21671. abstract get view(): NodeMaterialConnectionPoint;
  21672. protected _getTexture(): Nullable<BaseTexture>;
  21673. autoConfigure(material: NodeMaterial): void;
  21674. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21675. isReady(): boolean;
  21676. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21677. /**
  21678. * Gets the code to inject in the vertex shader
  21679. * @param state current state of the node material building
  21680. * @returns the shader code
  21681. */
  21682. handleVertexSide(state: NodeMaterialBuildState): string;
  21683. /**
  21684. * Handles the inits for the fragment code path
  21685. * @param state node material build state
  21686. */
  21687. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21688. /**
  21689. * Generates the reflection coords code for the fragment code path
  21690. * @param worldNormalVarName name of the world normal variable
  21691. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21692. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21693. * @returns the shader code
  21694. */
  21695. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21696. /**
  21697. * Generates the reflection color code for the fragment code path
  21698. * @param lodVarName name of the lod variable
  21699. * @param swizzleLookupTexture swizzle to use for the final color variable
  21700. * @returns the shader code
  21701. */
  21702. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21703. /**
  21704. * Generates the code corresponding to the connected output points
  21705. * @param state node material build state
  21706. * @param varName name of the variable to output
  21707. * @returns the shader code
  21708. */
  21709. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21710. protected _buildBlock(state: NodeMaterialBuildState): this;
  21711. protected _dumpPropertiesCode(): string;
  21712. serialize(): any;
  21713. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21714. }
  21715. }
  21716. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21717. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21718. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21719. import { Nullable } from "babylonjs/types";
  21720. /**
  21721. * Defines a connection point to be used for points with a custom object type
  21722. */
  21723. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21724. private _blockType;
  21725. private _blockName;
  21726. private _nameForCheking?;
  21727. /**
  21728. * Creates a new connection point
  21729. * @param name defines the connection point name
  21730. * @param ownerBlock defines the block hosting this connection point
  21731. * @param direction defines the direction of the connection point
  21732. */
  21733. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21734. /**
  21735. * Gets a number indicating if the current point can be connected to another point
  21736. * @param connectionPoint defines the other connection point
  21737. * @returns a number defining the compatibility state
  21738. */
  21739. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21740. /**
  21741. * Creates a block suitable to be used as an input for this input point.
  21742. * If null is returned, a block based on the point type will be created.
  21743. * @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
  21744. */
  21745. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21746. }
  21747. }
  21748. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21749. /**
  21750. * Enum defining the type of properties that can be edited in the property pages in the NME
  21751. */
  21752. export enum PropertyTypeForEdition {
  21753. /** property is a boolean */
  21754. Boolean = 0,
  21755. /** property is a float */
  21756. Float = 1,
  21757. /** property is a Vector2 */
  21758. Vector2 = 2,
  21759. /** property is a list of values */
  21760. List = 3
  21761. }
  21762. /**
  21763. * Interface that defines an option in a variable of type list
  21764. */
  21765. export interface IEditablePropertyListOption {
  21766. /** label of the option */
  21767. "label": string;
  21768. /** value of the option */
  21769. "value": number;
  21770. }
  21771. /**
  21772. * Interface that defines the options available for an editable property
  21773. */
  21774. export interface IEditablePropertyOption {
  21775. /** min value */
  21776. "min"?: number;
  21777. /** max value */
  21778. "max"?: number;
  21779. /** notifiers: indicates which actions to take when the property is changed */
  21780. "notifiers"?: {
  21781. /** the material should be rebuilt */
  21782. "rebuild"?: boolean;
  21783. /** the preview should be updated */
  21784. "update"?: boolean;
  21785. };
  21786. /** list of the options for a variable of type list */
  21787. "options"?: IEditablePropertyListOption[];
  21788. }
  21789. /**
  21790. * Interface that describes an editable property
  21791. */
  21792. export interface IPropertyDescriptionForEdition {
  21793. /** name of the property */
  21794. "propertyName": string;
  21795. /** display name of the property */
  21796. "displayName": string;
  21797. /** type of the property */
  21798. "type": PropertyTypeForEdition;
  21799. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21800. "groupName": string;
  21801. /** options for the property */
  21802. "options": IEditablePropertyOption;
  21803. }
  21804. /**
  21805. * Decorator that flags a property in a node material block as being editable
  21806. */
  21807. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21808. }
  21809. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21812. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21813. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21814. import { Nullable } from "babylonjs/types";
  21815. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21816. import { Mesh } from "babylonjs/Meshes/mesh";
  21817. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21818. import { Effect } from "babylonjs/Materials/effect";
  21819. import { Scene } from "babylonjs/scene";
  21820. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21821. /**
  21822. * Block used to implement the refraction part of the sub surface module of the PBR material
  21823. */
  21824. export class RefractionBlock extends NodeMaterialBlock {
  21825. /** @hidden */
  21826. _define3DName: string;
  21827. /** @hidden */
  21828. _refractionMatrixName: string;
  21829. /** @hidden */
  21830. _defineLODRefractionAlpha: string;
  21831. /** @hidden */
  21832. _defineLinearSpecularRefraction: string;
  21833. /** @hidden */
  21834. _defineOppositeZ: string;
  21835. /** @hidden */
  21836. _cubeSamplerName: string;
  21837. /** @hidden */
  21838. _2DSamplerName: string;
  21839. /** @hidden */
  21840. _vRefractionMicrosurfaceInfosName: string;
  21841. /** @hidden */
  21842. _vRefractionInfosName: string;
  21843. private _scene;
  21844. /**
  21845. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21846. * Materials half opaque for instance using refraction could benefit from this control.
  21847. */
  21848. linkRefractionWithTransparency: boolean;
  21849. /**
  21850. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21851. */
  21852. invertRefractionY: boolean;
  21853. /**
  21854. * Gets or sets the texture associated with the node
  21855. */
  21856. texture: Nullable<BaseTexture>;
  21857. /**
  21858. * Create a new RefractionBlock
  21859. * @param name defines the block name
  21860. */
  21861. constructor(name: string);
  21862. /**
  21863. * Gets the current class name
  21864. * @returns the class name
  21865. */
  21866. getClassName(): string;
  21867. /**
  21868. * Gets the intensity input component
  21869. */
  21870. get intensity(): NodeMaterialConnectionPoint;
  21871. /**
  21872. * Gets the index of refraction input component
  21873. */
  21874. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21875. /**
  21876. * Gets the tint at distance input component
  21877. */
  21878. get tintAtDistance(): NodeMaterialConnectionPoint;
  21879. /**
  21880. * Gets the view input component
  21881. */
  21882. get view(): NodeMaterialConnectionPoint;
  21883. /**
  21884. * Gets the refraction object output component
  21885. */
  21886. get refraction(): NodeMaterialConnectionPoint;
  21887. /**
  21888. * Returns true if the block has a texture
  21889. */
  21890. get hasTexture(): boolean;
  21891. protected _getTexture(): Nullable<BaseTexture>;
  21892. autoConfigure(material: NodeMaterial): void;
  21893. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21894. isReady(): boolean;
  21895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21896. /**
  21897. * Gets the main code of the block (fragment side)
  21898. * @param state current state of the node material building
  21899. * @returns the shader code
  21900. */
  21901. getCode(state: NodeMaterialBuildState): string;
  21902. protected _buildBlock(state: NodeMaterialBuildState): this;
  21903. protected _dumpPropertiesCode(): string;
  21904. serialize(): any;
  21905. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21906. }
  21907. }
  21908. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21909. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21910. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21911. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21912. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21914. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21915. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21916. import { Nullable } from "babylonjs/types";
  21917. import { Scene } from "babylonjs/scene";
  21918. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21919. /**
  21920. * Base block used as input for post process
  21921. */
  21922. export class CurrentScreenBlock extends NodeMaterialBlock {
  21923. private _samplerName;
  21924. private _linearDefineName;
  21925. private _gammaDefineName;
  21926. private _mainUVName;
  21927. private _tempTextureRead;
  21928. /**
  21929. * Gets or sets the texture associated with the node
  21930. */
  21931. texture: Nullable<BaseTexture>;
  21932. /**
  21933. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21934. */
  21935. convertToGammaSpace: boolean;
  21936. /**
  21937. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21938. */
  21939. convertToLinearSpace: boolean;
  21940. /**
  21941. * Create a new CurrentScreenBlock
  21942. * @param name defines the block name
  21943. */
  21944. constructor(name: string);
  21945. /**
  21946. * Gets the current class name
  21947. * @returns the class name
  21948. */
  21949. getClassName(): string;
  21950. /**
  21951. * Gets the uv input component
  21952. */
  21953. get uv(): NodeMaterialConnectionPoint;
  21954. /**
  21955. * Gets the rgba output component
  21956. */
  21957. get rgba(): NodeMaterialConnectionPoint;
  21958. /**
  21959. * Gets the rgb output component
  21960. */
  21961. get rgb(): NodeMaterialConnectionPoint;
  21962. /**
  21963. * Gets the r output component
  21964. */
  21965. get r(): NodeMaterialConnectionPoint;
  21966. /**
  21967. * Gets the g output component
  21968. */
  21969. get g(): NodeMaterialConnectionPoint;
  21970. /**
  21971. * Gets the b output component
  21972. */
  21973. get b(): NodeMaterialConnectionPoint;
  21974. /**
  21975. * Gets the a output component
  21976. */
  21977. get a(): NodeMaterialConnectionPoint;
  21978. /**
  21979. * Initialize the block and prepare the context for build
  21980. * @param state defines the state that will be used for the build
  21981. */
  21982. initialize(state: NodeMaterialBuildState): void;
  21983. get target(): NodeMaterialBlockTargets;
  21984. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21985. isReady(): boolean;
  21986. private _injectVertexCode;
  21987. private _writeTextureRead;
  21988. private _writeOutput;
  21989. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21990. serialize(): any;
  21991. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21992. }
  21993. }
  21994. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  21995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21999. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22000. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22001. import { Nullable } from "babylonjs/types";
  22002. import { Scene } from "babylonjs/scene";
  22003. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22004. /**
  22005. * Base block used for the particle texture
  22006. */
  22007. export class ParticleTextureBlock extends NodeMaterialBlock {
  22008. private _samplerName;
  22009. private _linearDefineName;
  22010. private _gammaDefineName;
  22011. private _tempTextureRead;
  22012. /**
  22013. * Gets or sets the texture associated with the node
  22014. */
  22015. texture: Nullable<BaseTexture>;
  22016. /**
  22017. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22018. */
  22019. convertToGammaSpace: boolean;
  22020. /**
  22021. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22022. */
  22023. convertToLinearSpace: boolean;
  22024. /**
  22025. * Create a new ParticleTextureBlock
  22026. * @param name defines the block name
  22027. */
  22028. constructor(name: string);
  22029. /**
  22030. * Gets the current class name
  22031. * @returns the class name
  22032. */
  22033. getClassName(): string;
  22034. /**
  22035. * Gets the uv input component
  22036. */
  22037. get uv(): NodeMaterialConnectionPoint;
  22038. /**
  22039. * Gets the rgba output component
  22040. */
  22041. get rgba(): NodeMaterialConnectionPoint;
  22042. /**
  22043. * Gets the rgb output component
  22044. */
  22045. get rgb(): NodeMaterialConnectionPoint;
  22046. /**
  22047. * Gets the r output component
  22048. */
  22049. get r(): NodeMaterialConnectionPoint;
  22050. /**
  22051. * Gets the g output component
  22052. */
  22053. get g(): NodeMaterialConnectionPoint;
  22054. /**
  22055. * Gets the b output component
  22056. */
  22057. get b(): NodeMaterialConnectionPoint;
  22058. /**
  22059. * Gets the a output component
  22060. */
  22061. get a(): NodeMaterialConnectionPoint;
  22062. /**
  22063. * Initialize the block and prepare the context for build
  22064. * @param state defines the state that will be used for the build
  22065. */
  22066. initialize(state: NodeMaterialBuildState): void;
  22067. autoConfigure(material: NodeMaterial): void;
  22068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22069. isReady(): boolean;
  22070. private _writeOutput;
  22071. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22072. serialize(): any;
  22073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22074. }
  22075. }
  22076. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22079. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22080. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22081. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22082. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22083. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22084. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22085. import { Scene } from "babylonjs/scene";
  22086. /**
  22087. * Class used to store shared data between 2 NodeMaterialBuildState
  22088. */
  22089. export class NodeMaterialBuildStateSharedData {
  22090. /**
  22091. * Gets the list of emitted varyings
  22092. */
  22093. temps: string[];
  22094. /**
  22095. * Gets the list of emitted varyings
  22096. */
  22097. varyings: string[];
  22098. /**
  22099. * Gets the varying declaration string
  22100. */
  22101. varyingDeclaration: string;
  22102. /**
  22103. * Input blocks
  22104. */
  22105. inputBlocks: InputBlock[];
  22106. /**
  22107. * Input blocks
  22108. */
  22109. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22110. /**
  22111. * Bindable blocks (Blocks that need to set data to the effect)
  22112. */
  22113. bindableBlocks: NodeMaterialBlock[];
  22114. /**
  22115. * List of blocks that can provide a compilation fallback
  22116. */
  22117. blocksWithFallbacks: NodeMaterialBlock[];
  22118. /**
  22119. * List of blocks that can provide a define update
  22120. */
  22121. blocksWithDefines: NodeMaterialBlock[];
  22122. /**
  22123. * List of blocks that can provide a repeatable content
  22124. */
  22125. repeatableContentBlocks: NodeMaterialBlock[];
  22126. /**
  22127. * List of blocks that can provide a dynamic list of uniforms
  22128. */
  22129. dynamicUniformBlocks: NodeMaterialBlock[];
  22130. /**
  22131. * List of blocks that can block the isReady function for the material
  22132. */
  22133. blockingBlocks: NodeMaterialBlock[];
  22134. /**
  22135. * Gets the list of animated inputs
  22136. */
  22137. animatedInputs: InputBlock[];
  22138. /**
  22139. * Build Id used to avoid multiple recompilations
  22140. */
  22141. buildId: number;
  22142. /** List of emitted variables */
  22143. variableNames: {
  22144. [key: string]: number;
  22145. };
  22146. /** List of emitted defines */
  22147. defineNames: {
  22148. [key: string]: number;
  22149. };
  22150. /** Should emit comments? */
  22151. emitComments: boolean;
  22152. /** Emit build activity */
  22153. verbose: boolean;
  22154. /** Gets or sets the hosting scene */
  22155. scene: Scene;
  22156. /**
  22157. * Gets the compilation hints emitted at compilation time
  22158. */
  22159. hints: {
  22160. needWorldViewMatrix: boolean;
  22161. needWorldViewProjectionMatrix: boolean;
  22162. needAlphaBlending: boolean;
  22163. needAlphaTesting: boolean;
  22164. };
  22165. /**
  22166. * List of compilation checks
  22167. */
  22168. checks: {
  22169. emitVertex: boolean;
  22170. emitFragment: boolean;
  22171. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22172. };
  22173. /**
  22174. * Is vertex program allowed to be empty?
  22175. */
  22176. allowEmptyVertexProgram: boolean;
  22177. /** Creates a new shared data */
  22178. constructor();
  22179. /**
  22180. * Emits console errors and exceptions if there is a failing check
  22181. */
  22182. emitErrors(): void;
  22183. }
  22184. }
  22185. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22186. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22187. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22188. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22189. /**
  22190. * Class used to store node based material build state
  22191. */
  22192. export class NodeMaterialBuildState {
  22193. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22194. supportUniformBuffers: boolean;
  22195. /**
  22196. * Gets the list of emitted attributes
  22197. */
  22198. attributes: string[];
  22199. /**
  22200. * Gets the list of emitted uniforms
  22201. */
  22202. uniforms: string[];
  22203. /**
  22204. * Gets the list of emitted constants
  22205. */
  22206. constants: string[];
  22207. /**
  22208. * Gets the list of emitted samplers
  22209. */
  22210. samplers: string[];
  22211. /**
  22212. * Gets the list of emitted functions
  22213. */
  22214. functions: {
  22215. [key: string]: string;
  22216. };
  22217. /**
  22218. * Gets the list of emitted extensions
  22219. */
  22220. extensions: {
  22221. [key: string]: string;
  22222. };
  22223. /**
  22224. * Gets the target of the compilation state
  22225. */
  22226. target: NodeMaterialBlockTargets;
  22227. /**
  22228. * Gets the list of emitted counters
  22229. */
  22230. counters: {
  22231. [key: string]: number;
  22232. };
  22233. /**
  22234. * Shared data between multiple NodeMaterialBuildState instances
  22235. */
  22236. sharedData: NodeMaterialBuildStateSharedData;
  22237. /** @hidden */
  22238. _vertexState: NodeMaterialBuildState;
  22239. /** @hidden */
  22240. _attributeDeclaration: string;
  22241. /** @hidden */
  22242. _uniformDeclaration: string;
  22243. /** @hidden */
  22244. _constantDeclaration: string;
  22245. /** @hidden */
  22246. _samplerDeclaration: string;
  22247. /** @hidden */
  22248. _varyingTransfer: string;
  22249. /** @hidden */
  22250. _injectAtEnd: string;
  22251. private _repeatableContentAnchorIndex;
  22252. /** @hidden */
  22253. _builtCompilationString: string;
  22254. /**
  22255. * Gets the emitted compilation strings
  22256. */
  22257. compilationString: string;
  22258. /**
  22259. * Finalize the compilation strings
  22260. * @param state defines the current compilation state
  22261. */
  22262. finalize(state: NodeMaterialBuildState): void;
  22263. /** @hidden */
  22264. get _repeatableContentAnchor(): string;
  22265. /** @hidden */
  22266. _getFreeVariableName(prefix: string): string;
  22267. /** @hidden */
  22268. _getFreeDefineName(prefix: string): string;
  22269. /** @hidden */
  22270. _excludeVariableName(name: string): void;
  22271. /** @hidden */
  22272. _emit2DSampler(name: string): void;
  22273. /** @hidden */
  22274. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22275. /** @hidden */
  22276. _emitExtension(name: string, extension: string, define?: string): void;
  22277. /** @hidden */
  22278. _emitFunction(name: string, code: string, comments: string): void;
  22279. /** @hidden */
  22280. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22281. replaceStrings?: {
  22282. search: RegExp;
  22283. replace: string;
  22284. }[];
  22285. repeatKey?: string;
  22286. }): string;
  22287. /** @hidden */
  22288. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22289. repeatKey?: string;
  22290. removeAttributes?: boolean;
  22291. removeUniforms?: boolean;
  22292. removeVaryings?: boolean;
  22293. removeIfDef?: boolean;
  22294. replaceStrings?: {
  22295. search: RegExp;
  22296. replace: string;
  22297. }[];
  22298. }, storeKey?: string): void;
  22299. /** @hidden */
  22300. _registerTempVariable(name: string): boolean;
  22301. /** @hidden */
  22302. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22303. /** @hidden */
  22304. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22305. /** @hidden */
  22306. _emitFloat(value: number): string;
  22307. }
  22308. }
  22309. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22310. /**
  22311. * Helper class used to generate session unique ID
  22312. */
  22313. export class UniqueIdGenerator {
  22314. private static _UniqueIdCounter;
  22315. /**
  22316. * Gets an unique (relatively to the current scene) Id
  22317. */
  22318. static get UniqueId(): number;
  22319. }
  22320. }
  22321. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22322. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22323. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22324. import { Nullable } from "babylonjs/types";
  22325. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22326. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22327. import { Effect } from "babylonjs/Materials/effect";
  22328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22329. import { Mesh } from "babylonjs/Meshes/mesh";
  22330. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22331. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22334. /**
  22335. * Defines a block that can be used inside a node based material
  22336. */
  22337. export class NodeMaterialBlock {
  22338. private _buildId;
  22339. private _buildTarget;
  22340. private _target;
  22341. private _isFinalMerger;
  22342. private _isInput;
  22343. private _name;
  22344. protected _isUnique: boolean;
  22345. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22346. inputsAreExclusive: boolean;
  22347. /** @hidden */
  22348. _codeVariableName: string;
  22349. /** @hidden */
  22350. _inputs: NodeMaterialConnectionPoint[];
  22351. /** @hidden */
  22352. _outputs: NodeMaterialConnectionPoint[];
  22353. /** @hidden */
  22354. _preparationId: number;
  22355. /**
  22356. * Gets the name of the block
  22357. */
  22358. get name(): string;
  22359. /**
  22360. * Sets the name of the block. Will check if the name is valid.
  22361. */
  22362. set name(newName: string);
  22363. /**
  22364. * Gets or sets the unique id of the node
  22365. */
  22366. uniqueId: number;
  22367. /**
  22368. * Gets or sets the comments associated with this block
  22369. */
  22370. comments: string;
  22371. /**
  22372. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22373. */
  22374. get isUnique(): boolean;
  22375. /**
  22376. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22377. */
  22378. get isFinalMerger(): boolean;
  22379. /**
  22380. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22381. */
  22382. get isInput(): boolean;
  22383. /**
  22384. * Gets or sets the build Id
  22385. */
  22386. get buildId(): number;
  22387. set buildId(value: number);
  22388. /**
  22389. * Gets or sets the target of the block
  22390. */
  22391. get target(): NodeMaterialBlockTargets;
  22392. set target(value: NodeMaterialBlockTargets);
  22393. /**
  22394. * Gets the list of input points
  22395. */
  22396. get inputs(): NodeMaterialConnectionPoint[];
  22397. /** Gets the list of output points */
  22398. get outputs(): NodeMaterialConnectionPoint[];
  22399. /**
  22400. * Find an input by its name
  22401. * @param name defines the name of the input to look for
  22402. * @returns the input or null if not found
  22403. */
  22404. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22405. /**
  22406. * Find an output by its name
  22407. * @param name defines the name of the outputto look for
  22408. * @returns the output or null if not found
  22409. */
  22410. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22411. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22412. visibleInInspector: boolean;
  22413. /**
  22414. * Creates a new NodeMaterialBlock
  22415. * @param name defines the block name
  22416. * @param target defines the target of that block (Vertex by default)
  22417. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22418. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22419. */
  22420. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22421. /**
  22422. * Initialize the block and prepare the context for build
  22423. * @param state defines the state that will be used for the build
  22424. */
  22425. initialize(state: NodeMaterialBuildState): void;
  22426. /**
  22427. * Bind data to effect. Will only be called for blocks with isBindable === true
  22428. * @param effect defines the effect to bind data to
  22429. * @param nodeMaterial defines the hosting NodeMaterial
  22430. * @param mesh defines the mesh that will be rendered
  22431. * @param subMesh defines the submesh that will be rendered
  22432. */
  22433. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22434. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22435. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22436. protected _writeFloat(value: number): string;
  22437. /**
  22438. * Gets the current class name e.g. "NodeMaterialBlock"
  22439. * @returns the class name
  22440. */
  22441. getClassName(): string;
  22442. /**
  22443. * Register a new input. Must be called inside a block constructor
  22444. * @param name defines the connection point name
  22445. * @param type defines the connection point type
  22446. * @param isOptional defines a boolean indicating that this input can be omitted
  22447. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22448. * @param point an already created connection point. If not provided, create a new one
  22449. * @returns the current block
  22450. */
  22451. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22452. /**
  22453. * Register a new output. Must be called inside a block constructor
  22454. * @param name defines the connection point name
  22455. * @param type defines the connection point type
  22456. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22457. * @param point an already created connection point. If not provided, create a new one
  22458. * @returns the current block
  22459. */
  22460. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22461. /**
  22462. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22463. * @param forOutput defines an optional connection point to check compatibility with
  22464. * @returns the first available input or null
  22465. */
  22466. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22467. /**
  22468. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22469. * @param forBlock defines an optional block to check compatibility with
  22470. * @returns the first available input or null
  22471. */
  22472. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22473. /**
  22474. * Gets the sibling of the given output
  22475. * @param current defines the current output
  22476. * @returns the next output in the list or null
  22477. */
  22478. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22479. /**
  22480. * Connect current block with another block
  22481. * @param other defines the block to connect with
  22482. * @param options define the various options to help pick the right connections
  22483. * @returns the current block
  22484. */
  22485. connectTo(other: NodeMaterialBlock, options?: {
  22486. input?: string;
  22487. output?: string;
  22488. outputSwizzle?: string;
  22489. }): this | undefined;
  22490. protected _buildBlock(state: NodeMaterialBuildState): void;
  22491. /**
  22492. * Add uniforms, samplers and uniform buffers at compilation time
  22493. * @param state defines the state to update
  22494. * @param nodeMaterial defines the node material requesting the update
  22495. * @param defines defines the material defines to update
  22496. * @param uniformBuffers defines the list of uniform buffer names
  22497. */
  22498. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22499. /**
  22500. * Add potential fallbacks if shader compilation fails
  22501. * @param mesh defines the mesh to be rendered
  22502. * @param fallbacks defines the current prioritized list of fallbacks
  22503. */
  22504. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22505. /**
  22506. * Initialize defines for shader compilation
  22507. * @param mesh defines the mesh to be rendered
  22508. * @param nodeMaterial defines the node material requesting the update
  22509. * @param defines defines the material defines to update
  22510. * @param useInstances specifies that instances should be used
  22511. */
  22512. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22513. /**
  22514. * Update defines for shader compilation
  22515. * @param mesh defines the mesh to be rendered
  22516. * @param nodeMaterial defines the node material requesting the update
  22517. * @param defines defines the material defines to update
  22518. * @param useInstances specifies that instances should be used
  22519. * @param subMesh defines which submesh to render
  22520. */
  22521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22522. /**
  22523. * Lets the block try to connect some inputs automatically
  22524. * @param material defines the hosting NodeMaterial
  22525. */
  22526. autoConfigure(material: NodeMaterial): void;
  22527. /**
  22528. * Function called when a block is declared as repeatable content generator
  22529. * @param vertexShaderState defines the current compilation state for the vertex shader
  22530. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22531. * @param mesh defines the mesh to be rendered
  22532. * @param defines defines the material defines to update
  22533. */
  22534. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22535. /**
  22536. * Checks if the block is ready
  22537. * @param mesh defines the mesh to be rendered
  22538. * @param nodeMaterial defines the node material requesting the update
  22539. * @param defines defines the material defines to update
  22540. * @param useInstances specifies that instances should be used
  22541. * @returns true if the block is ready
  22542. */
  22543. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22544. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22545. private _processBuild;
  22546. /**
  22547. * Validates the new name for the block node.
  22548. * @param newName the new name to be given to the node.
  22549. * @returns false if the name is a reserve word, else true.
  22550. */
  22551. validateBlockName(newName: string): boolean;
  22552. /**
  22553. * Compile the current node and generate the shader code
  22554. * @param state defines the current compilation state (uniforms, samplers, current string)
  22555. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22556. * @returns true if already built
  22557. */
  22558. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22559. protected _inputRename(name: string): string;
  22560. protected _outputRename(name: string): string;
  22561. protected _dumpPropertiesCode(): string;
  22562. /** @hidden */
  22563. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22564. /** @hidden */
  22565. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22566. /**
  22567. * Clone the current block to a new identical block
  22568. * @param scene defines the hosting scene
  22569. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22570. * @returns a copy of the current block
  22571. */
  22572. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22573. /**
  22574. * Serializes this block in a JSON representation
  22575. * @returns the serialized block object
  22576. */
  22577. serialize(): any;
  22578. /** @hidden */
  22579. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22580. private _deserializePortDisplayNamesAndExposedOnFrame;
  22581. /**
  22582. * Release resources
  22583. */
  22584. dispose(): void;
  22585. }
  22586. }
  22587. declare module "babylonjs/Materials/pushMaterial" {
  22588. import { Nullable } from "babylonjs/types";
  22589. import { Scene } from "babylonjs/scene";
  22590. import { Matrix } from "babylonjs/Maths/math.vector";
  22591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22592. import { Mesh } from "babylonjs/Meshes/mesh";
  22593. import { Material } from "babylonjs/Materials/material";
  22594. import { Effect } from "babylonjs/Materials/effect";
  22595. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22596. /**
  22597. * Base class of materials working in push mode in babylon JS
  22598. * @hidden
  22599. */
  22600. export class PushMaterial extends Material {
  22601. protected _activeEffect: Effect;
  22602. protected _normalMatrix: Matrix;
  22603. constructor(name: string, scene: Scene);
  22604. getEffect(): Effect;
  22605. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22606. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22607. /**
  22608. * Binds the given world matrix to the active effect
  22609. *
  22610. * @param world the matrix to bind
  22611. */
  22612. bindOnlyWorldMatrix(world: Matrix): void;
  22613. /**
  22614. * Binds the given normal matrix to the active effect
  22615. *
  22616. * @param normalMatrix the matrix to bind
  22617. */
  22618. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22619. bind(world: Matrix, mesh?: Mesh): void;
  22620. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22621. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22622. }
  22623. }
  22624. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22625. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22626. /**
  22627. * Root class for all node material optimizers
  22628. */
  22629. export class NodeMaterialOptimizer {
  22630. /**
  22631. * Function used to optimize a NodeMaterial graph
  22632. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22633. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22634. */
  22635. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22636. }
  22637. }
  22638. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22639. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22640. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22641. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22642. import { Scene } from "babylonjs/scene";
  22643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22644. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22645. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22646. /**
  22647. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22648. */
  22649. export class TransformBlock extends NodeMaterialBlock {
  22650. /**
  22651. * Defines the value to use to complement W value to transform it to a Vector4
  22652. */
  22653. complementW: number;
  22654. /**
  22655. * Defines the value to use to complement z value to transform it to a Vector4
  22656. */
  22657. complementZ: number;
  22658. /**
  22659. * Creates a new TransformBlock
  22660. * @param name defines the block name
  22661. */
  22662. constructor(name: string);
  22663. /**
  22664. * Gets the current class name
  22665. * @returns the class name
  22666. */
  22667. getClassName(): string;
  22668. /**
  22669. * Gets the vector input
  22670. */
  22671. get vector(): NodeMaterialConnectionPoint;
  22672. /**
  22673. * Gets the output component
  22674. */
  22675. get output(): NodeMaterialConnectionPoint;
  22676. /**
  22677. * Gets the xyz output component
  22678. */
  22679. get xyz(): NodeMaterialConnectionPoint;
  22680. /**
  22681. * Gets the matrix transform input
  22682. */
  22683. get transform(): NodeMaterialConnectionPoint;
  22684. protected _buildBlock(state: NodeMaterialBuildState): this;
  22685. /**
  22686. * Update defines for shader compilation
  22687. * @param mesh defines the mesh to be rendered
  22688. * @param nodeMaterial defines the node material requesting the update
  22689. * @param defines defines the material defines to update
  22690. * @param useInstances specifies that instances should be used
  22691. * @param subMesh defines which submesh to render
  22692. */
  22693. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22694. serialize(): any;
  22695. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22696. protected _dumpPropertiesCode(): string;
  22697. }
  22698. }
  22699. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22700. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22701. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22702. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22703. /**
  22704. * Block used to output the vertex position
  22705. */
  22706. export class VertexOutputBlock extends NodeMaterialBlock {
  22707. /**
  22708. * Creates a new VertexOutputBlock
  22709. * @param name defines the block name
  22710. */
  22711. constructor(name: string);
  22712. /**
  22713. * Gets the current class name
  22714. * @returns the class name
  22715. */
  22716. getClassName(): string;
  22717. /**
  22718. * Gets the vector input component
  22719. */
  22720. get vector(): NodeMaterialConnectionPoint;
  22721. protected _buildBlock(state: NodeMaterialBuildState): this;
  22722. }
  22723. }
  22724. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22725. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22726. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22727. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22728. /**
  22729. * Block used to output the final color
  22730. */
  22731. export class FragmentOutputBlock extends NodeMaterialBlock {
  22732. /**
  22733. * Create a new FragmentOutputBlock
  22734. * @param name defines the block name
  22735. */
  22736. constructor(name: string);
  22737. /**
  22738. * Gets the current class name
  22739. * @returns the class name
  22740. */
  22741. getClassName(): string;
  22742. /**
  22743. * Gets the rgba input component
  22744. */
  22745. get rgba(): NodeMaterialConnectionPoint;
  22746. /**
  22747. * Gets the rgb input component
  22748. */
  22749. get rgb(): NodeMaterialConnectionPoint;
  22750. /**
  22751. * Gets the a input component
  22752. */
  22753. get a(): NodeMaterialConnectionPoint;
  22754. protected _buildBlock(state: NodeMaterialBuildState): this;
  22755. }
  22756. }
  22757. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22758. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22759. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22760. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22761. /**
  22762. * Block used for the particle ramp gradient section
  22763. */
  22764. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22765. /**
  22766. * Create a new ParticleRampGradientBlock
  22767. * @param name defines the block name
  22768. */
  22769. constructor(name: string);
  22770. /**
  22771. * Gets the current class name
  22772. * @returns the class name
  22773. */
  22774. getClassName(): string;
  22775. /**
  22776. * Gets the color input component
  22777. */
  22778. get color(): NodeMaterialConnectionPoint;
  22779. /**
  22780. * Gets the rampColor output component
  22781. */
  22782. get rampColor(): NodeMaterialConnectionPoint;
  22783. /**
  22784. * Initialize the block and prepare the context for build
  22785. * @param state defines the state that will be used for the build
  22786. */
  22787. initialize(state: NodeMaterialBuildState): void;
  22788. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22789. }
  22790. }
  22791. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22792. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22793. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22794. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22795. /**
  22796. * Block used for the particle blend multiply section
  22797. */
  22798. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22799. /**
  22800. * Create a new ParticleBlendMultiplyBlock
  22801. * @param name defines the block name
  22802. */
  22803. constructor(name: string);
  22804. /**
  22805. * Gets the current class name
  22806. * @returns the class name
  22807. */
  22808. getClassName(): string;
  22809. /**
  22810. * Gets the color input component
  22811. */
  22812. get color(): NodeMaterialConnectionPoint;
  22813. /**
  22814. * Gets the alphaTexture input component
  22815. */
  22816. get alphaTexture(): NodeMaterialConnectionPoint;
  22817. /**
  22818. * Gets the alphaColor input component
  22819. */
  22820. get alphaColor(): NodeMaterialConnectionPoint;
  22821. /**
  22822. * Gets the blendColor output component
  22823. */
  22824. get blendColor(): NodeMaterialConnectionPoint;
  22825. /**
  22826. * Initialize the block and prepare the context for build
  22827. * @param state defines the state that will be used for the build
  22828. */
  22829. initialize(state: NodeMaterialBuildState): void;
  22830. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22831. }
  22832. }
  22833. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22837. /**
  22838. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22839. */
  22840. export class VectorMergerBlock extends NodeMaterialBlock {
  22841. /**
  22842. * Create a new VectorMergerBlock
  22843. * @param name defines the block name
  22844. */
  22845. constructor(name: string);
  22846. /**
  22847. * Gets the current class name
  22848. * @returns the class name
  22849. */
  22850. getClassName(): string;
  22851. /**
  22852. * Gets the xyz component (input)
  22853. */
  22854. get xyzIn(): NodeMaterialConnectionPoint;
  22855. /**
  22856. * Gets the xy component (input)
  22857. */
  22858. get xyIn(): NodeMaterialConnectionPoint;
  22859. /**
  22860. * Gets the x component (input)
  22861. */
  22862. get x(): NodeMaterialConnectionPoint;
  22863. /**
  22864. * Gets the y component (input)
  22865. */
  22866. get y(): NodeMaterialConnectionPoint;
  22867. /**
  22868. * Gets the z component (input)
  22869. */
  22870. get z(): NodeMaterialConnectionPoint;
  22871. /**
  22872. * Gets the w component (input)
  22873. */
  22874. get w(): NodeMaterialConnectionPoint;
  22875. /**
  22876. * Gets the xyzw component (output)
  22877. */
  22878. get xyzw(): NodeMaterialConnectionPoint;
  22879. /**
  22880. * Gets the xyz component (output)
  22881. */
  22882. get xyzOut(): NodeMaterialConnectionPoint;
  22883. /**
  22884. * Gets the xy component (output)
  22885. */
  22886. get xyOut(): NodeMaterialConnectionPoint;
  22887. /**
  22888. * Gets the xy component (output)
  22889. * @deprecated Please use xyOut instead.
  22890. */
  22891. get xy(): NodeMaterialConnectionPoint;
  22892. /**
  22893. * Gets the xyz component (output)
  22894. * @deprecated Please use xyzOut instead.
  22895. */
  22896. get xyz(): NodeMaterialConnectionPoint;
  22897. protected _buildBlock(state: NodeMaterialBuildState): this;
  22898. }
  22899. }
  22900. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22904. import { Vector2 } from "babylonjs/Maths/math.vector";
  22905. import { Scene } from "babylonjs/scene";
  22906. /**
  22907. * Block used to remap a float from a range to a new one
  22908. */
  22909. export class RemapBlock extends NodeMaterialBlock {
  22910. /**
  22911. * Gets or sets the source range
  22912. */
  22913. sourceRange: Vector2;
  22914. /**
  22915. * Gets or sets the target range
  22916. */
  22917. targetRange: Vector2;
  22918. /**
  22919. * Creates a new RemapBlock
  22920. * @param name defines the block name
  22921. */
  22922. constructor(name: string);
  22923. /**
  22924. * Gets the current class name
  22925. * @returns the class name
  22926. */
  22927. getClassName(): string;
  22928. /**
  22929. * Gets the input component
  22930. */
  22931. get input(): NodeMaterialConnectionPoint;
  22932. /**
  22933. * Gets the source min input component
  22934. */
  22935. get sourceMin(): NodeMaterialConnectionPoint;
  22936. /**
  22937. * Gets the source max input component
  22938. */
  22939. get sourceMax(): NodeMaterialConnectionPoint;
  22940. /**
  22941. * Gets the target min input component
  22942. */
  22943. get targetMin(): NodeMaterialConnectionPoint;
  22944. /**
  22945. * Gets the target max input component
  22946. */
  22947. get targetMax(): NodeMaterialConnectionPoint;
  22948. /**
  22949. * Gets the output component
  22950. */
  22951. get output(): NodeMaterialConnectionPoint;
  22952. protected _buildBlock(state: NodeMaterialBuildState): this;
  22953. protected _dumpPropertiesCode(): string;
  22954. serialize(): any;
  22955. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22956. }
  22957. }
  22958. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  22959. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22960. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22961. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22962. /**
  22963. * Block used to multiply 2 values
  22964. */
  22965. export class MultiplyBlock extends NodeMaterialBlock {
  22966. /**
  22967. * Creates a new MultiplyBlock
  22968. * @param name defines the block name
  22969. */
  22970. constructor(name: string);
  22971. /**
  22972. * Gets the current class name
  22973. * @returns the class name
  22974. */
  22975. getClassName(): string;
  22976. /**
  22977. * Gets the left operand input component
  22978. */
  22979. get left(): NodeMaterialConnectionPoint;
  22980. /**
  22981. * Gets the right operand input component
  22982. */
  22983. get right(): NodeMaterialConnectionPoint;
  22984. /**
  22985. * Gets the output component
  22986. */
  22987. get output(): NodeMaterialConnectionPoint;
  22988. protected _buildBlock(state: NodeMaterialBuildState): this;
  22989. }
  22990. }
  22991. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  22992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22994. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22995. /**
  22996. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22997. */
  22998. export class ColorSplitterBlock extends NodeMaterialBlock {
  22999. /**
  23000. * Create a new ColorSplitterBlock
  23001. * @param name defines the block name
  23002. */
  23003. constructor(name: string);
  23004. /**
  23005. * Gets the current class name
  23006. * @returns the class name
  23007. */
  23008. getClassName(): string;
  23009. /**
  23010. * Gets the rgba component (input)
  23011. */
  23012. get rgba(): NodeMaterialConnectionPoint;
  23013. /**
  23014. * Gets the rgb component (input)
  23015. */
  23016. get rgbIn(): NodeMaterialConnectionPoint;
  23017. /**
  23018. * Gets the rgb component (output)
  23019. */
  23020. get rgbOut(): NodeMaterialConnectionPoint;
  23021. /**
  23022. * Gets the r component (output)
  23023. */
  23024. get r(): NodeMaterialConnectionPoint;
  23025. /**
  23026. * Gets the g component (output)
  23027. */
  23028. get g(): NodeMaterialConnectionPoint;
  23029. /**
  23030. * Gets the b component (output)
  23031. */
  23032. get b(): NodeMaterialConnectionPoint;
  23033. /**
  23034. * Gets the a component (output)
  23035. */
  23036. get a(): NodeMaterialConnectionPoint;
  23037. protected _inputRename(name: string): string;
  23038. protected _outputRename(name: string): string;
  23039. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23040. }
  23041. }
  23042. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23046. import { Scene } from "babylonjs/scene";
  23047. /**
  23048. * Operations supported by the Trigonometry block
  23049. */
  23050. export enum TrigonometryBlockOperations {
  23051. /** Cos */
  23052. Cos = 0,
  23053. /** Sin */
  23054. Sin = 1,
  23055. /** Abs */
  23056. Abs = 2,
  23057. /** Exp */
  23058. Exp = 3,
  23059. /** Exp2 */
  23060. Exp2 = 4,
  23061. /** Round */
  23062. Round = 5,
  23063. /** Floor */
  23064. Floor = 6,
  23065. /** Ceiling */
  23066. Ceiling = 7,
  23067. /** Square root */
  23068. Sqrt = 8,
  23069. /** Log */
  23070. Log = 9,
  23071. /** Tangent */
  23072. Tan = 10,
  23073. /** Arc tangent */
  23074. ArcTan = 11,
  23075. /** Arc cosinus */
  23076. ArcCos = 12,
  23077. /** Arc sinus */
  23078. ArcSin = 13,
  23079. /** Fraction */
  23080. Fract = 14,
  23081. /** Sign */
  23082. Sign = 15,
  23083. /** To radians (from degrees) */
  23084. Radians = 16,
  23085. /** To degrees (from radians) */
  23086. Degrees = 17
  23087. }
  23088. /**
  23089. * Block used to apply trigonometry operation to floats
  23090. */
  23091. export class TrigonometryBlock extends NodeMaterialBlock {
  23092. /**
  23093. * Gets or sets the operation applied by the block
  23094. */
  23095. operation: TrigonometryBlockOperations;
  23096. /**
  23097. * Creates a new TrigonometryBlock
  23098. * @param name defines the block name
  23099. */
  23100. constructor(name: string);
  23101. /**
  23102. * Gets the current class name
  23103. * @returns the class name
  23104. */
  23105. getClassName(): string;
  23106. /**
  23107. * Gets the input component
  23108. */
  23109. get input(): NodeMaterialConnectionPoint;
  23110. /**
  23111. * Gets the output component
  23112. */
  23113. get output(): NodeMaterialConnectionPoint;
  23114. protected _buildBlock(state: NodeMaterialBuildState): this;
  23115. serialize(): any;
  23116. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23117. protected _dumpPropertiesCode(): string;
  23118. }
  23119. }
  23120. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23121. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23122. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23123. import { Scene } from "babylonjs/scene";
  23124. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23125. import { Matrix } from "babylonjs/Maths/math.vector";
  23126. import { Mesh } from "babylonjs/Meshes/mesh";
  23127. import { Engine } from "babylonjs/Engines/engine";
  23128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23129. import { Observable } from "babylonjs/Misc/observable";
  23130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23131. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23132. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23133. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23134. import { Nullable } from "babylonjs/types";
  23135. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23136. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23137. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23138. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23139. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23140. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23141. import { Effect } from "babylonjs/Materials/effect";
  23142. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23143. import { Camera } from "babylonjs/Cameras/camera";
  23144. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23145. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23146. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23147. /**
  23148. * Interface used to configure the node material editor
  23149. */
  23150. export interface INodeMaterialEditorOptions {
  23151. /** Define the URl to load node editor script */
  23152. editorURL?: string;
  23153. }
  23154. /** @hidden */
  23155. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23156. NORMAL: boolean;
  23157. TANGENT: boolean;
  23158. UV1: boolean;
  23159. /** BONES */
  23160. NUM_BONE_INFLUENCERS: number;
  23161. BonesPerMesh: number;
  23162. BONETEXTURE: boolean;
  23163. /** MORPH TARGETS */
  23164. MORPHTARGETS: boolean;
  23165. MORPHTARGETS_NORMAL: boolean;
  23166. MORPHTARGETS_TANGENT: boolean;
  23167. MORPHTARGETS_UV: boolean;
  23168. NUM_MORPH_INFLUENCERS: number;
  23169. /** IMAGE PROCESSING */
  23170. IMAGEPROCESSING: boolean;
  23171. VIGNETTE: boolean;
  23172. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23173. VIGNETTEBLENDMODEOPAQUE: boolean;
  23174. TONEMAPPING: boolean;
  23175. TONEMAPPING_ACES: boolean;
  23176. CONTRAST: boolean;
  23177. EXPOSURE: boolean;
  23178. COLORCURVES: boolean;
  23179. COLORGRADING: boolean;
  23180. COLORGRADING3D: boolean;
  23181. SAMPLER3DGREENDEPTH: boolean;
  23182. SAMPLER3DBGRMAP: boolean;
  23183. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23184. /** MISC. */
  23185. BUMPDIRECTUV: number;
  23186. constructor();
  23187. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23188. }
  23189. /**
  23190. * Class used to configure NodeMaterial
  23191. */
  23192. export interface INodeMaterialOptions {
  23193. /**
  23194. * Defines if blocks should emit comments
  23195. */
  23196. emitComments: boolean;
  23197. }
  23198. /**
  23199. * Class used to create a node based material built by assembling shader blocks
  23200. */
  23201. export class NodeMaterial extends PushMaterial {
  23202. private static _BuildIdGenerator;
  23203. private _options;
  23204. private _vertexCompilationState;
  23205. private _fragmentCompilationState;
  23206. private _sharedData;
  23207. private _buildId;
  23208. private _buildWasSuccessful;
  23209. private _cachedWorldViewMatrix;
  23210. private _cachedWorldViewProjectionMatrix;
  23211. private _optimizers;
  23212. private _animationFrame;
  23213. /** Define the Url to load node editor script */
  23214. static EditorURL: string;
  23215. /** Define the Url to load snippets */
  23216. static SnippetUrl: string;
  23217. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23218. static IgnoreTexturesAtLoadTime: boolean;
  23219. private BJSNODEMATERIALEDITOR;
  23220. /** Get the inspector from bundle or global */
  23221. private _getGlobalNodeMaterialEditor;
  23222. /**
  23223. * Snippet ID if the material was created from the snippet server
  23224. */
  23225. snippetId: string;
  23226. /**
  23227. * Gets or sets data used by visual editor
  23228. * @see https://nme.babylonjs.com
  23229. */
  23230. editorData: any;
  23231. /**
  23232. * 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)
  23233. */
  23234. ignoreAlpha: boolean;
  23235. /**
  23236. * Defines the maximum number of lights that can be used in the material
  23237. */
  23238. maxSimultaneousLights: number;
  23239. /**
  23240. * Observable raised when the material is built
  23241. */
  23242. onBuildObservable: Observable<NodeMaterial>;
  23243. /**
  23244. * Gets or sets the root nodes of the material vertex shader
  23245. */
  23246. _vertexOutputNodes: NodeMaterialBlock[];
  23247. /**
  23248. * Gets or sets the root nodes of the material fragment (pixel) shader
  23249. */
  23250. _fragmentOutputNodes: NodeMaterialBlock[];
  23251. /** Gets or sets options to control the node material overall behavior */
  23252. get options(): INodeMaterialOptions;
  23253. set options(options: INodeMaterialOptions);
  23254. /**
  23255. * Default configuration related to image processing available in the standard Material.
  23256. */
  23257. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23258. /**
  23259. * Gets the image processing configuration used either in this material.
  23260. */
  23261. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23262. /**
  23263. * Sets the Default image processing configuration used either in the this material.
  23264. *
  23265. * If sets to null, the scene one is in use.
  23266. */
  23267. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23268. /**
  23269. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23270. */
  23271. attachedBlocks: NodeMaterialBlock[];
  23272. /**
  23273. * Specifies the mode of the node material
  23274. * @hidden
  23275. */
  23276. _mode: NodeMaterialModes;
  23277. /**
  23278. * Gets the mode property
  23279. */
  23280. get mode(): NodeMaterialModes;
  23281. /**
  23282. * Create a new node based material
  23283. * @param name defines the material name
  23284. * @param scene defines the hosting scene
  23285. * @param options defines creation option
  23286. */
  23287. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23288. /**
  23289. * Gets the current class name of the material e.g. "NodeMaterial"
  23290. * @returns the class name
  23291. */
  23292. getClassName(): string;
  23293. /**
  23294. * Keep track of the image processing observer to allow dispose and replace.
  23295. */
  23296. private _imageProcessingObserver;
  23297. /**
  23298. * Attaches a new image processing configuration to the Standard Material.
  23299. * @param configuration
  23300. */
  23301. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23302. /**
  23303. * Get a block by its name
  23304. * @param name defines the name of the block to retrieve
  23305. * @returns the required block or null if not found
  23306. */
  23307. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23308. /**
  23309. * Get a block by its name
  23310. * @param predicate defines the predicate used to find the good candidate
  23311. * @returns the required block or null if not found
  23312. */
  23313. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23314. /**
  23315. * Get an input block by its name
  23316. * @param predicate defines the predicate used to find the good candidate
  23317. * @returns the required input block or null if not found
  23318. */
  23319. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23320. /**
  23321. * Gets the list of input blocks attached to this material
  23322. * @returns an array of InputBlocks
  23323. */
  23324. getInputBlocks(): InputBlock[];
  23325. /**
  23326. * Adds a new optimizer to the list of optimizers
  23327. * @param optimizer defines the optimizers to add
  23328. * @returns the current material
  23329. */
  23330. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23331. /**
  23332. * Remove an optimizer from the list of optimizers
  23333. * @param optimizer defines the optimizers to remove
  23334. * @returns the current material
  23335. */
  23336. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23337. /**
  23338. * Add a new block to the list of output nodes
  23339. * @param node defines the node to add
  23340. * @returns the current material
  23341. */
  23342. addOutputNode(node: NodeMaterialBlock): this;
  23343. /**
  23344. * Remove a block from the list of root nodes
  23345. * @param node defines the node to remove
  23346. * @returns the current material
  23347. */
  23348. removeOutputNode(node: NodeMaterialBlock): this;
  23349. private _addVertexOutputNode;
  23350. private _removeVertexOutputNode;
  23351. private _addFragmentOutputNode;
  23352. private _removeFragmentOutputNode;
  23353. /**
  23354. * Specifies if the material will require alpha blending
  23355. * @returns a boolean specifying if alpha blending is needed
  23356. */
  23357. needAlphaBlending(): boolean;
  23358. /**
  23359. * Specifies if this material should be rendered in alpha test mode
  23360. * @returns a boolean specifying if an alpha test is needed.
  23361. */
  23362. needAlphaTesting(): boolean;
  23363. private _initializeBlock;
  23364. private _resetDualBlocks;
  23365. /**
  23366. * Remove a block from the current node material
  23367. * @param block defines the block to remove
  23368. */
  23369. removeBlock(block: NodeMaterialBlock): void;
  23370. /**
  23371. * Build the material and generates the inner effect
  23372. * @param verbose defines if the build should log activity
  23373. */
  23374. build(verbose?: boolean): void;
  23375. /**
  23376. * Runs an otpimization phase to try to improve the shader code
  23377. */
  23378. optimize(): void;
  23379. private _prepareDefinesForAttributes;
  23380. /**
  23381. * Create a post process from the material
  23382. * @param camera The camera to apply the render pass to.
  23383. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23384. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23385. * @param engine The engine which the post process will be applied. (default: current engine)
  23386. * @param reusable If the post process can be reused on the same frame. (default: false)
  23387. * @param textureType Type of textures used when performing the post process. (default: 0)
  23388. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23389. * @returns the post process created
  23390. */
  23391. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23392. /**
  23393. * Create the post process effect from the material
  23394. * @param postProcess The post process to create the effect for
  23395. */
  23396. createEffectForPostProcess(postProcess: PostProcess): void;
  23397. private _createEffectForPostProcess;
  23398. /**
  23399. * Create a new procedural texture based on this node material
  23400. * @param size defines the size of the texture
  23401. * @param scene defines the hosting scene
  23402. * @returns the new procedural texture attached to this node material
  23403. */
  23404. createProceduralTexture(size: number | {
  23405. width: number;
  23406. height: number;
  23407. layers?: number;
  23408. }, scene: Scene): Nullable<ProceduralTexture>;
  23409. private _createEffectForParticles;
  23410. private _checkInternals;
  23411. /**
  23412. * Create the effect to be used as the custom effect for a particle system
  23413. * @param particleSystem Particle system to create the effect for
  23414. * @param onCompiled defines a function to call when the effect creation is successful
  23415. * @param onError defines a function to call when the effect creation has failed
  23416. */
  23417. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23418. private _processDefines;
  23419. /**
  23420. * Get if the submesh is ready to be used and all its information available.
  23421. * Child classes can use it to update shaders
  23422. * @param mesh defines the mesh to check
  23423. * @param subMesh defines which submesh to check
  23424. * @param useInstances specifies that instances should be used
  23425. * @returns a boolean indicating that the submesh is ready or not
  23426. */
  23427. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23428. /**
  23429. * Get a string representing the shaders built by the current node graph
  23430. */
  23431. get compiledShaders(): string;
  23432. /**
  23433. * Binds the world matrix to the material
  23434. * @param world defines the world transformation matrix
  23435. */
  23436. bindOnlyWorldMatrix(world: Matrix): void;
  23437. /**
  23438. * Binds the submesh to this material by preparing the effect and shader to draw
  23439. * @param world defines the world transformation matrix
  23440. * @param mesh defines the mesh containing the submesh
  23441. * @param subMesh defines the submesh to bind the material to
  23442. */
  23443. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23444. /**
  23445. * Gets the active textures from the material
  23446. * @returns an array of textures
  23447. */
  23448. getActiveTextures(): BaseTexture[];
  23449. /**
  23450. * Gets the list of texture blocks
  23451. * @returns an array of texture blocks
  23452. */
  23453. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23454. /**
  23455. * Specifies if the material uses a texture
  23456. * @param texture defines the texture to check against the material
  23457. * @returns a boolean specifying if the material uses the texture
  23458. */
  23459. hasTexture(texture: BaseTexture): boolean;
  23460. /**
  23461. * Disposes the material
  23462. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23463. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23464. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23465. */
  23466. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23467. /** Creates the node editor window. */
  23468. private _createNodeEditor;
  23469. /**
  23470. * Launch the node material editor
  23471. * @param config Define the configuration of the editor
  23472. * @return a promise fulfilled when the node editor is visible
  23473. */
  23474. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23475. /**
  23476. * Clear the current material
  23477. */
  23478. clear(): void;
  23479. /**
  23480. * Clear the current material and set it to a default state
  23481. */
  23482. setToDefault(): void;
  23483. /**
  23484. * Clear the current material and set it to a default state for post process
  23485. */
  23486. setToDefaultPostProcess(): void;
  23487. /**
  23488. * Clear the current material and set it to a default state for procedural texture
  23489. */
  23490. setToDefaultProceduralTexture(): void;
  23491. /**
  23492. * Clear the current material and set it to a default state for particle
  23493. */
  23494. setToDefaultParticle(): void;
  23495. /**
  23496. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23497. * @param url defines the url to load from
  23498. * @returns a promise that will fullfil when the material is fully loaded
  23499. */
  23500. loadAsync(url: string): Promise<void>;
  23501. private _gatherBlocks;
  23502. /**
  23503. * Generate a string containing the code declaration required to create an equivalent of this material
  23504. * @returns a string
  23505. */
  23506. generateCode(): string;
  23507. /**
  23508. * Serializes this material in a JSON representation
  23509. * @returns the serialized material object
  23510. */
  23511. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23512. private _restoreConnections;
  23513. /**
  23514. * Clear the current graph and load a new one from a serialization object
  23515. * @param source defines the JSON representation of the material
  23516. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23517. * @param merge defines whether or not the source must be merged or replace the current content
  23518. */
  23519. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23520. /**
  23521. * Makes a duplicate of the current material.
  23522. * @param name - name to use for the new material.
  23523. */
  23524. clone(name: string): NodeMaterial;
  23525. /**
  23526. * Creates a node material from parsed material data
  23527. * @param source defines the JSON representation of the material
  23528. * @param scene defines the hosting scene
  23529. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23530. * @returns a new node material
  23531. */
  23532. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23533. /**
  23534. * Creates a node material from a snippet saved in a remote file
  23535. * @param name defines the name of the material to create
  23536. * @param url defines the url to load from
  23537. * @param scene defines the hosting scene
  23538. * @returns a promise that will resolve to the new node material
  23539. */
  23540. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23541. /**
  23542. * Creates a node material from a snippet saved by the node material editor
  23543. * @param snippetId defines the snippet to load
  23544. * @param scene defines the hosting scene
  23545. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23546. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23547. * @returns a promise that will resolve to the new node material
  23548. */
  23549. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23550. /**
  23551. * Creates a new node material set to default basic configuration
  23552. * @param name defines the name of the material
  23553. * @param scene defines the hosting scene
  23554. * @returns a new NodeMaterial
  23555. */
  23556. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23557. }
  23558. }
  23559. declare module "babylonjs/PostProcesses/postProcess" {
  23560. import { Nullable } from "babylonjs/types";
  23561. import { SmartArray } from "babylonjs/Misc/smartArray";
  23562. import { Observable } from "babylonjs/Misc/observable";
  23563. import { Vector2 } from "babylonjs/Maths/math.vector";
  23564. import { Camera } from "babylonjs/Cameras/camera";
  23565. import { Effect } from "babylonjs/Materials/effect";
  23566. import "babylonjs/Shaders/postprocess.vertex";
  23567. import { IInspectable } from "babylonjs/Misc/iInspectable";
  23568. import { Engine } from "babylonjs/Engines/engine";
  23569. import { Color4 } from "babylonjs/Maths/math.color";
  23570. import "babylonjs/Engines/Extensions/engine.renderTarget";
  23571. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  23572. import { Scene } from "babylonjs/scene";
  23573. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23574. /**
  23575. * Size options for a post process
  23576. */
  23577. export type PostProcessOptions = {
  23578. width: number;
  23579. height: number;
  23580. };
  23581. /**
  23582. * PostProcess can be used to apply a shader to a texture after it has been rendered
  23583. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  23584. */
  23585. export class PostProcess {
  23586. /**
  23587. * Gets or sets the unique id of the post process
  23588. */
  23589. uniqueId: number;
  23590. /** Name of the PostProcess. */
  23591. name: string;
  23592. /**
  23593. * Width of the texture to apply the post process on
  23594. */
  23595. width: number;
  23596. /**
  23597. * Height of the texture to apply the post process on
  23598. */
  23599. height: number;
  23600. /**
  23601. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  23602. */
  23603. nodeMaterialSource: Nullable<NodeMaterial>;
  23604. /**
  23605. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  23606. * @hidden
  23607. */
  23608. _outputTexture: Nullable<InternalTexture>;
  23609. /**
  23610. * Sampling mode used by the shader
  23611. * See https://doc.babylonjs.com/classes/3.1/texture
  23612. */
  23613. renderTargetSamplingMode: number;
  23614. /**
  23615. * Clear color to use when screen clearing
  23616. */
  23617. clearColor: Color4;
  23618. /**
  23619. * If the buffer needs to be cleared before applying the post process. (default: true)
  23620. * Should be set to false if shader will overwrite all previous pixels.
  23621. */
  23622. autoClear: boolean;
  23623. /**
  23624. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  23625. */
  23626. alphaMode: number;
  23627. /**
  23628. * Sets the setAlphaBlendConstants of the babylon engine
  23629. */
  23630. alphaConstants: Color4;
  23631. /**
  23632. * Animations to be used for the post processing
  23633. */
  23634. animations: import("babylonjs/Animations/animation").Animation[];
  23635. /**
  23636. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  23637. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  23638. */
  23639. enablePixelPerfectMode: boolean;
  23640. /**
  23641. * Force the postprocess to be applied without taking in account viewport
  23642. */
  23643. forceFullscreenViewport: boolean;
  23644. /**
  23645. * List of inspectable custom properties (used by the Inspector)
  23646. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  23647. */
  23648. inspectableCustomProperties: IInspectable[];
  23649. /**
  23650. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  23651. *
  23652. * | Value | Type | Description |
  23653. * | ----- | ----------------------------------- | ----------- |
  23654. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  23655. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  23656. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  23657. *
  23658. */
  23659. scaleMode: number;
  23660. /**
  23661. * Force textures to be a power of two (default: false)
  23662. */
  23663. alwaysForcePOT: boolean;
  23664. private _samples;
  23665. /**
  23666. * Number of sample textures (default: 1)
  23667. */
  23668. get samples(): number;
  23669. set samples(n: number);
  23670. /**
  23671. * Modify the scale of the post process to be the same as the viewport (default: false)
  23672. */
  23673. adaptScaleToCurrentViewport: boolean;
  23674. private _camera;
  23675. protected _scene: Scene;
  23676. private _engine;
  23677. private _options;
  23678. private _reusable;
  23679. private _textureType;
  23680. private _textureFormat;
  23681. /**
  23682. * Smart array of input and output textures for the post process.
  23683. * @hidden
  23684. */
  23685. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  23686. /**
  23687. * The index in _textures that corresponds to the output texture.
  23688. * @hidden
  23689. */
  23690. _currentRenderTextureInd: number;
  23691. private _effect;
  23692. private _samplers;
  23693. private _fragmentUrl;
  23694. private _vertexUrl;
  23695. private _parameters;
  23696. private _scaleRatio;
  23697. protected _indexParameters: any;
  23698. private _shareOutputWithPostProcess;
  23699. private _texelSize;
  23700. private _forcedOutputTexture;
  23701. /**
  23702. * Returns the fragment url or shader name used in the post process.
  23703. * @returns the fragment url or name in the shader store.
  23704. */
  23705. getEffectName(): string;
  23706. /**
  23707. * An event triggered when the postprocess is activated.
  23708. */
  23709. onActivateObservable: Observable<Camera>;
  23710. private _onActivateObserver;
  23711. /**
  23712. * A function that is added to the onActivateObservable
  23713. */
  23714. set onActivate(callback: Nullable<(camera: Camera) => void>);
  23715. /**
  23716. * An event triggered when the postprocess changes its size.
  23717. */
  23718. onSizeChangedObservable: Observable<PostProcess>;
  23719. private _onSizeChangedObserver;
  23720. /**
  23721. * A function that is added to the onSizeChangedObservable
  23722. */
  23723. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  23724. /**
  23725. * An event triggered when the postprocess applies its effect.
  23726. */
  23727. onApplyObservable: Observable<Effect>;
  23728. private _onApplyObserver;
  23729. /**
  23730. * A function that is added to the onApplyObservable
  23731. */
  23732. set onApply(callback: (effect: Effect) => void);
  23733. /**
  23734. * An event triggered before rendering the postprocess
  23735. */
  23736. onBeforeRenderObservable: Observable<Effect>;
  23737. private _onBeforeRenderObserver;
  23738. /**
  23739. * A function that is added to the onBeforeRenderObservable
  23740. */
  23741. set onBeforeRender(callback: (effect: Effect) => void);
  23742. /**
  23743. * An event triggered after rendering the postprocess
  23744. */
  23745. onAfterRenderObservable: Observable<Effect>;
  23746. private _onAfterRenderObserver;
  23747. /**
  23748. * A function that is added to the onAfterRenderObservable
  23749. */
  23750. set onAfterRender(callback: (efect: Effect) => void);
  23751. /**
  23752. * 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
  23753. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  23754. */
  23755. get inputTexture(): InternalTexture;
  23756. set inputTexture(value: InternalTexture);
  23757. /**
  23758. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  23759. * the only way to unset it is to use this function to restore its internal state
  23760. */
  23761. restoreDefaultInputTexture(): void;
  23762. /**
  23763. * Gets the camera which post process is applied to.
  23764. * @returns The camera the post process is applied to.
  23765. */
  23766. getCamera(): Camera;
  23767. /**
  23768. * Gets the texel size of the postprocess.
  23769. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  23770. */
  23771. get texelSize(): Vector2;
  23772. /**
  23773. * Creates a new instance PostProcess
  23774. * @param name The name of the PostProcess.
  23775. * @param fragmentUrl The url of the fragment shader to be used.
  23776. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  23777. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  23778. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23779. * @param camera The camera to apply the render pass to.
  23780. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23781. * @param engine The engine which the post process will be applied. (default: current engine)
  23782. * @param reusable If the post process can be reused on the same frame. (default: false)
  23783. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  23784. * @param textureType Type of textures used when performing the post process. (default: 0)
  23785. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  23786. * @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
  23787. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  23788. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23789. */
  23790. constructor(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);
  23791. /**
  23792. * Gets a string identifying the name of the class
  23793. * @returns "PostProcess" string
  23794. */
  23795. getClassName(): string;
  23796. /**
  23797. * Gets the engine which this post process belongs to.
  23798. * @returns The engine the post process was enabled with.
  23799. */
  23800. getEngine(): Engine;
  23801. /**
  23802. * The effect that is created when initializing the post process.
  23803. * @returns The created effect corresponding the the postprocess.
  23804. */
  23805. getEffect(): Effect;
  23806. /**
  23807. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  23808. * @param postProcess The post process to share the output with.
  23809. * @returns This post process.
  23810. */
  23811. shareOutputWith(postProcess: PostProcess): PostProcess;
  23812. /**
  23813. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  23814. * This should be called if the post process that shares output with this post process is disabled/disposed.
  23815. */
  23816. useOwnOutput(): void;
  23817. /**
  23818. * Updates the effect with the current post process compile time values and recompiles the shader.
  23819. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23820. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23821. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23822. * @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
  23823. * @param onCompiled Called when the shader has been compiled.
  23824. * @param onError Called if there is an error when compiling a shader.
  23825. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  23826. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  23827. */
  23828. 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;
  23829. /**
  23830. * The post process is reusable if it can be used multiple times within one frame.
  23831. * @returns If the post process is reusable
  23832. */
  23833. isReusable(): boolean;
  23834. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  23835. markTextureDirty(): void;
  23836. /**
  23837. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  23838. * 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.
  23839. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  23840. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  23841. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  23842. * @returns The target texture that was bound to be written to.
  23843. */
  23844. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  23845. /**
  23846. * If the post process is supported.
  23847. */
  23848. get isSupported(): boolean;
  23849. /**
  23850. * The aspect ratio of the output texture.
  23851. */
  23852. get aspectRatio(): number;
  23853. /**
  23854. * Get a value indicating if the post-process is ready to be used
  23855. * @returns true if the post-process is ready (shader is compiled)
  23856. */
  23857. isReady(): boolean;
  23858. /**
  23859. * Binds all textures and uniforms to the shader, this will be run on every pass.
  23860. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  23861. */
  23862. apply(): Nullable<Effect>;
  23863. private _disposeTextures;
  23864. /**
  23865. * Disposes the post process.
  23866. * @param camera The camera to dispose the post process on.
  23867. */
  23868. dispose(camera?: Camera): void;
  23869. /**
  23870. * Serializes the particle system to a JSON object
  23871. * @returns the JSON object
  23872. */
  23873. serialize(): any;
  23874. /**
  23875. * Creates a material from parsed material data
  23876. * @param parsedPostProcess defines parsed post process data
  23877. * @param scene defines the hosting scene
  23878. * @param rootUrl defines the root URL to use to load textures
  23879. * @returns a new post process
  23880. */
  23881. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  23882. }
  23883. }
  23884. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  23885. /** @hidden */
  23886. export var kernelBlurVaryingDeclaration: {
  23887. name: string;
  23888. shader: string;
  23889. };
  23890. }
  23891. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  23892. /** @hidden */
  23893. export var kernelBlurFragment: {
  23894. name: string;
  23895. shader: string;
  23896. };
  23897. }
  23898. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  23899. /** @hidden */
  23900. export var kernelBlurFragment2: {
  23901. name: string;
  23902. shader: string;
  23903. };
  23904. }
  23905. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  23906. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23907. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  23908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  23909. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  23910. /** @hidden */
  23911. export var kernelBlurPixelShader: {
  23912. name: string;
  23913. shader: string;
  23914. };
  23915. }
  23916. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  23917. /** @hidden */
  23918. export var kernelBlurVertex: {
  23919. name: string;
  23920. shader: string;
  23921. };
  23922. }
  23923. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  23924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  23925. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  23926. /** @hidden */
  23927. export var kernelBlurVertexShader: {
  23928. name: string;
  23929. shader: string;
  23930. };
  23931. }
  23932. declare module "babylonjs/PostProcesses/blurPostProcess" {
  23933. import { Vector2 } from "babylonjs/Maths/math.vector";
  23934. import { Nullable } from "babylonjs/types";
  23935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23936. import { Camera } from "babylonjs/Cameras/camera";
  23937. import { Effect } from "babylonjs/Materials/effect";
  23938. import { Engine } from "babylonjs/Engines/engine";
  23939. import "babylonjs/Shaders/kernelBlur.fragment";
  23940. import "babylonjs/Shaders/kernelBlur.vertex";
  23941. import { Scene } from "babylonjs/scene";
  23942. /**
  23943. * The Blur Post Process which blurs an image based on a kernel and direction.
  23944. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  23945. */
  23946. export class BlurPostProcess extends PostProcess {
  23947. private blockCompilation;
  23948. protected _kernel: number;
  23949. protected _idealKernel: number;
  23950. protected _packedFloat: boolean;
  23951. private _staticDefines;
  23952. /** The direction in which to blur the image. */
  23953. direction: Vector2;
  23954. /**
  23955. * Sets the length in pixels of the blur sample region
  23956. */
  23957. set kernel(v: number);
  23958. /**
  23959. * Gets the length in pixels of the blur sample region
  23960. */
  23961. get kernel(): number;
  23962. /**
  23963. * Sets wether or not the blur needs to unpack/repack floats
  23964. */
  23965. set packedFloat(v: boolean);
  23966. /**
  23967. * Gets wether or not the blur is unpacking/repacking floats
  23968. */
  23969. get packedFloat(): boolean;
  23970. /**
  23971. * Gets a string identifying the name of the class
  23972. * @returns "BlurPostProcess" string
  23973. */
  23974. getClassName(): string;
  23975. /**
  23976. * Creates a new instance BlurPostProcess
  23977. * @param name The name of the effect.
  23978. * @param direction The direction in which to blur the image.
  23979. * @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.
  23980. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23981. * @param camera The camera to apply the render pass to.
  23982. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23983. * @param engine The engine which the post process will be applied. (default: current engine)
  23984. * @param reusable If the post process can be reused on the same frame. (default: false)
  23985. * @param textureType Type of textures used when performing the post process. (default: 0)
  23986. * @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)
  23987. */
  23988. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  23989. /**
  23990. * Updates the effect with the current post process compile time values and recompiles the shader.
  23991. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  23992. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  23993. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  23994. * @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
  23995. * @param onCompiled Called when the shader has been compiled.
  23996. * @param onError Called if there is an error when compiling a shader.
  23997. */
  23998. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23999. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24000. /**
  24001. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24002. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24003. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24004. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24005. * The gaps between physical kernels are compensated for in the weighting of the samples
  24006. * @param idealKernel Ideal blur kernel.
  24007. * @return Nearest best kernel.
  24008. */
  24009. protected _nearestBestKernel(idealKernel: number): number;
  24010. /**
  24011. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24012. * @param x The point on the Gaussian distribution to sample.
  24013. * @return the value of the Gaussian function at x.
  24014. */
  24015. protected _gaussianWeight(x: number): number;
  24016. /**
  24017. * Generates a string that can be used as a floating point number in GLSL.
  24018. * @param x Value to print.
  24019. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24020. * @return GLSL float string.
  24021. */
  24022. protected _glslFloat(x: number, decimalFigures?: number): string;
  24023. /** @hidden */
  24024. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24025. }
  24026. }
  24027. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24028. import { Scene } from "babylonjs/scene";
  24029. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24030. import { Plane } from "babylonjs/Maths/math.plane";
  24031. /**
  24032. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24033. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24034. * You can then easily use it as a reflectionTexture on a flat surface.
  24035. * In case the surface is not a plane, please consider relying on reflection probes.
  24036. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24037. */
  24038. export class MirrorTexture extends RenderTargetTexture {
  24039. private scene;
  24040. /**
  24041. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24042. * 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.
  24043. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24044. */
  24045. mirrorPlane: Plane;
  24046. /**
  24047. * Define the blur ratio used to blur the reflection if needed.
  24048. */
  24049. set blurRatio(value: number);
  24050. get blurRatio(): number;
  24051. /**
  24052. * Define the adaptive blur kernel used to blur the reflection if needed.
  24053. * This will autocompute the closest best match for the `blurKernel`
  24054. */
  24055. set adaptiveBlurKernel(value: number);
  24056. /**
  24057. * Define the blur kernel used to blur the reflection if needed.
  24058. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24059. */
  24060. set blurKernel(value: number);
  24061. /**
  24062. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24063. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24064. */
  24065. set blurKernelX(value: number);
  24066. get blurKernelX(): number;
  24067. /**
  24068. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24069. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24070. */
  24071. set blurKernelY(value: number);
  24072. get blurKernelY(): number;
  24073. private _autoComputeBlurKernel;
  24074. protected _onRatioRescale(): void;
  24075. private _updateGammaSpace;
  24076. private _imageProcessingConfigChangeObserver;
  24077. private _transformMatrix;
  24078. private _mirrorMatrix;
  24079. private _savedViewMatrix;
  24080. private _blurX;
  24081. private _blurY;
  24082. private _adaptiveBlurKernel;
  24083. private _blurKernelX;
  24084. private _blurKernelY;
  24085. private _blurRatio;
  24086. /**
  24087. * Instantiates a Mirror Texture.
  24088. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24089. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24090. * You can then easily use it as a reflectionTexture on a flat surface.
  24091. * In case the surface is not a plane, please consider relying on reflection probes.
  24092. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24093. * @param name
  24094. * @param size
  24095. * @param scene
  24096. * @param generateMipMaps
  24097. * @param type
  24098. * @param samplingMode
  24099. * @param generateDepthBuffer
  24100. */
  24101. constructor(name: string, size: number | {
  24102. width: number;
  24103. height: number;
  24104. } | {
  24105. ratio: number;
  24106. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24107. private _preparePostProcesses;
  24108. /**
  24109. * Clone the mirror texture.
  24110. * @returns the cloned texture
  24111. */
  24112. clone(): MirrorTexture;
  24113. /**
  24114. * Serialize the texture to a JSON representation you could use in Parse later on
  24115. * @returns the serialized JSON representation
  24116. */
  24117. serialize(): any;
  24118. /**
  24119. * Dispose the texture and release its associated resources.
  24120. */
  24121. dispose(): void;
  24122. }
  24123. }
  24124. declare module "babylonjs/Materials/Textures/texture" {
  24125. import { Observable } from "babylonjs/Misc/observable";
  24126. import { Nullable } from "babylonjs/types";
  24127. import { Matrix } from "babylonjs/Maths/math.vector";
  24128. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24129. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24130. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24131. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24132. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24134. import { Scene } from "babylonjs/scene";
  24135. /**
  24136. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24137. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24138. */
  24139. export class Texture extends BaseTexture {
  24140. /**
  24141. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24142. */
  24143. static SerializeBuffers: boolean;
  24144. /** @hidden */
  24145. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24146. /** @hidden */
  24147. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24148. /** @hidden */
  24149. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24150. /** nearest is mag = nearest and min = nearest and mip = linear */
  24151. static readonly NEAREST_SAMPLINGMODE: number;
  24152. /** nearest is mag = nearest and min = nearest and mip = linear */
  24153. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24154. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24155. static readonly BILINEAR_SAMPLINGMODE: number;
  24156. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24157. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24158. /** Trilinear is mag = linear and min = linear and mip = linear */
  24159. static readonly TRILINEAR_SAMPLINGMODE: number;
  24160. /** Trilinear is mag = linear and min = linear and mip = linear */
  24161. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24162. /** mag = nearest and min = nearest and mip = nearest */
  24163. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24164. /** mag = nearest and min = linear and mip = nearest */
  24165. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24166. /** mag = nearest and min = linear and mip = linear */
  24167. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24168. /** mag = nearest and min = linear and mip = none */
  24169. static readonly NEAREST_LINEAR: number;
  24170. /** mag = nearest and min = nearest and mip = none */
  24171. static readonly NEAREST_NEAREST: number;
  24172. /** mag = linear and min = nearest and mip = nearest */
  24173. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24174. /** mag = linear and min = nearest and mip = linear */
  24175. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24176. /** mag = linear and min = linear and mip = none */
  24177. static readonly LINEAR_LINEAR: number;
  24178. /** mag = linear and min = nearest and mip = none */
  24179. static readonly LINEAR_NEAREST: number;
  24180. /** Explicit coordinates mode */
  24181. static readonly EXPLICIT_MODE: number;
  24182. /** Spherical coordinates mode */
  24183. static readonly SPHERICAL_MODE: number;
  24184. /** Planar coordinates mode */
  24185. static readonly PLANAR_MODE: number;
  24186. /** Cubic coordinates mode */
  24187. static readonly CUBIC_MODE: number;
  24188. /** Projection coordinates mode */
  24189. static readonly PROJECTION_MODE: number;
  24190. /** Inverse Cubic coordinates mode */
  24191. static readonly SKYBOX_MODE: number;
  24192. /** Inverse Cubic coordinates mode */
  24193. static readonly INVCUBIC_MODE: number;
  24194. /** Equirectangular coordinates mode */
  24195. static readonly EQUIRECTANGULAR_MODE: number;
  24196. /** Equirectangular Fixed coordinates mode */
  24197. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24198. /** Equirectangular Fixed Mirrored coordinates mode */
  24199. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24200. /** Texture is not repeating outside of 0..1 UVs */
  24201. static readonly CLAMP_ADDRESSMODE: number;
  24202. /** Texture is repeating outside of 0..1 UVs */
  24203. static readonly WRAP_ADDRESSMODE: number;
  24204. /** Texture is repeating and mirrored */
  24205. static readonly MIRROR_ADDRESSMODE: number;
  24206. /**
  24207. * 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
  24208. */
  24209. static UseSerializedUrlIfAny: boolean;
  24210. /**
  24211. * Define the url of the texture.
  24212. */
  24213. url: Nullable<string>;
  24214. /**
  24215. * Define an offset on the texture to offset the u coordinates of the UVs
  24216. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24217. */
  24218. uOffset: number;
  24219. /**
  24220. * Define an offset on the texture to offset the v coordinates of the UVs
  24221. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24222. */
  24223. vOffset: number;
  24224. /**
  24225. * Define an offset on the texture to scale the u coordinates of the UVs
  24226. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24227. */
  24228. uScale: number;
  24229. /**
  24230. * Define an offset on the texture to scale the v coordinates of the UVs
  24231. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24232. */
  24233. vScale: number;
  24234. /**
  24235. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24236. * @see https://doc.babylonjs.com/how_to/more_materials
  24237. */
  24238. uAng: number;
  24239. /**
  24240. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24241. * @see https://doc.babylonjs.com/how_to/more_materials
  24242. */
  24243. vAng: number;
  24244. /**
  24245. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24246. * @see https://doc.babylonjs.com/how_to/more_materials
  24247. */
  24248. wAng: number;
  24249. /**
  24250. * Defines the center of rotation (U)
  24251. */
  24252. uRotationCenter: number;
  24253. /**
  24254. * Defines the center of rotation (V)
  24255. */
  24256. vRotationCenter: number;
  24257. /**
  24258. * Defines the center of rotation (W)
  24259. */
  24260. wRotationCenter: number;
  24261. /**
  24262. * Are mip maps generated for this texture or not.
  24263. */
  24264. get noMipmap(): boolean;
  24265. /**
  24266. * List of inspectable custom properties (used by the Inspector)
  24267. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24268. */
  24269. inspectableCustomProperties: Nullable<IInspectable[]>;
  24270. private _noMipmap;
  24271. /** @hidden */
  24272. _invertY: boolean;
  24273. private _rowGenerationMatrix;
  24274. private _cachedTextureMatrix;
  24275. private _projectionModeMatrix;
  24276. private _t0;
  24277. private _t1;
  24278. private _t2;
  24279. private _cachedUOffset;
  24280. private _cachedVOffset;
  24281. private _cachedUScale;
  24282. private _cachedVScale;
  24283. private _cachedUAng;
  24284. private _cachedVAng;
  24285. private _cachedWAng;
  24286. private _cachedProjectionMatrixId;
  24287. private _cachedCoordinatesMode;
  24288. /** @hidden */
  24289. protected _initialSamplingMode: number;
  24290. /** @hidden */
  24291. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24292. private _deleteBuffer;
  24293. protected _format: Nullable<number>;
  24294. private _delayedOnLoad;
  24295. private _delayedOnError;
  24296. private _mimeType?;
  24297. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24298. get mimeType(): string | undefined;
  24299. /**
  24300. * Observable triggered once the texture has been loaded.
  24301. */
  24302. onLoadObservable: Observable<Texture>;
  24303. protected _isBlocking: boolean;
  24304. /**
  24305. * Is the texture preventing material to render while loading.
  24306. * If false, a default texture will be used instead of the loading one during the preparation step.
  24307. */
  24308. set isBlocking(value: boolean);
  24309. get isBlocking(): boolean;
  24310. /**
  24311. * Get the current sampling mode associated with the texture.
  24312. */
  24313. get samplingMode(): number;
  24314. /**
  24315. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24316. */
  24317. get invertY(): boolean;
  24318. /**
  24319. * Instantiates a new texture.
  24320. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24321. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24322. * @param url defines the url of the picture to load as a texture
  24323. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24324. * @param noMipmap defines if the texture will require mip maps or not
  24325. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24326. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24327. * @param onLoad defines a callback triggered when the texture has been loaded
  24328. * @param onError defines a callback triggered when an error occurred during the loading session
  24329. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24330. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24331. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24332. * @param mimeType defines an optional mime type information
  24333. */
  24334. 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);
  24335. /**
  24336. * Update the url (and optional buffer) of this texture if url was null during construction.
  24337. * @param url the url of the texture
  24338. * @param buffer the buffer of the texture (defaults to null)
  24339. * @param onLoad callback called when the texture is loaded (defaults to null)
  24340. */
  24341. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24342. /**
  24343. * Finish the loading sequence of a texture flagged as delayed load.
  24344. * @hidden
  24345. */
  24346. delayLoad(): void;
  24347. private _prepareRowForTextureGeneration;
  24348. /**
  24349. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24350. * @returns the transform matrix of the texture.
  24351. */
  24352. getTextureMatrix(uBase?: number): Matrix;
  24353. /**
  24354. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24355. * @returns The reflection texture transform
  24356. */
  24357. getReflectionTextureMatrix(): Matrix;
  24358. /**
  24359. * Clones the texture.
  24360. * @returns the cloned texture
  24361. */
  24362. clone(): Texture;
  24363. /**
  24364. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24365. * @returns The JSON representation of the texture
  24366. */
  24367. serialize(): any;
  24368. /**
  24369. * Get the current class name of the texture useful for serialization or dynamic coding.
  24370. * @returns "Texture"
  24371. */
  24372. getClassName(): string;
  24373. /**
  24374. * Dispose the texture and release its associated resources.
  24375. */
  24376. dispose(): void;
  24377. /**
  24378. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24379. * @param parsedTexture Define the JSON representation of the texture
  24380. * @param scene Define the scene the parsed texture should be instantiated in
  24381. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24382. * @returns The parsed texture if successful
  24383. */
  24384. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24385. /**
  24386. * Creates a texture from its base 64 representation.
  24387. * @param data Define the base64 payload without the data: prefix
  24388. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24389. * @param scene Define the scene the texture should belong to
  24390. * @param noMipmap Forces the texture to not create mip map information if true
  24391. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24392. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24393. * @param onLoad define a callback triggered when the texture has been loaded
  24394. * @param onError define a callback triggered when an error occurred during the loading session
  24395. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24396. * @returns the created texture
  24397. */
  24398. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  24399. /**
  24400. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  24401. * @param data Define the base64 payload without the data: prefix
  24402. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  24403. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  24404. * @param scene Define the scene the texture should belong to
  24405. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  24406. * @param noMipmap Forces the texture to not create mip map information if true
  24407. * @param invertY define if the texture needs to be inverted on the y axis during loading
  24408. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24409. * @param onLoad define a callback triggered when the texture has been loaded
  24410. * @param onError define a callback triggered when an error occurred during the loading session
  24411. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24412. * @returns the created texture
  24413. */
  24414. 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;
  24415. }
  24416. }
  24417. declare module "babylonjs/PostProcesses/postProcessManager" {
  24418. import { Nullable } from "babylonjs/types";
  24419. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24420. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24421. import { Scene } from "babylonjs/scene";
  24422. /**
  24423. * PostProcessManager is used to manage one or more post processes or post process pipelines
  24424. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24425. */
  24426. export class PostProcessManager {
  24427. private _scene;
  24428. private _indexBuffer;
  24429. private _vertexBuffers;
  24430. /**
  24431. * Creates a new instance PostProcess
  24432. * @param scene The scene that the post process is associated with.
  24433. */
  24434. constructor(scene: Scene);
  24435. private _prepareBuffers;
  24436. private _buildIndexBuffer;
  24437. /**
  24438. * Rebuilds the vertex buffers of the manager.
  24439. * @hidden
  24440. */
  24441. _rebuild(): void;
  24442. /**
  24443. * Prepares a frame to be run through a post process.
  24444. * @param sourceTexture The input texture to the post procesess. (default: null)
  24445. * @param postProcesses An array of post processes to be run. (default: null)
  24446. * @returns True if the post processes were able to be run.
  24447. * @hidden
  24448. */
  24449. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  24450. /**
  24451. * Manually render a set of post processes to a texture.
  24452. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  24453. * @param postProcesses An array of post processes to be run.
  24454. * @param targetTexture The target texture to render to.
  24455. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  24456. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  24457. * @param lodLevel defines which lod of the texture to render to
  24458. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  24459. */
  24460. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  24461. /**
  24462. * Finalize the result of the output of the postprocesses.
  24463. * @param doNotPresent If true the result will not be displayed to the screen.
  24464. * @param targetTexture The target texture to render to.
  24465. * @param faceIndex The index of the face to bind the target texture to.
  24466. * @param postProcesses The array of post processes to render.
  24467. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  24468. * @hidden
  24469. */
  24470. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  24471. /**
  24472. * Disposes of the post process manager.
  24473. */
  24474. dispose(): void;
  24475. }
  24476. }
  24477. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  24478. import { Observable } from "babylonjs/Misc/observable";
  24479. import { SmartArray } from "babylonjs/Misc/smartArray";
  24480. import { Nullable, Immutable } from "babylonjs/types";
  24481. import { Camera } from "babylonjs/Cameras/camera";
  24482. import { Scene } from "babylonjs/scene";
  24483. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  24484. import { Color4 } from "babylonjs/Maths/math.color";
  24485. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  24486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24487. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24488. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24489. import { Texture } from "babylonjs/Materials/Textures/texture";
  24490. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24491. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  24492. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24493. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  24494. import { Engine } from "babylonjs/Engines/engine";
  24495. /**
  24496. * This Helps creating a texture that will be created from a camera in your scene.
  24497. * It is basically a dynamic texture that could be used to create special effects for instance.
  24498. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  24499. */
  24500. export class RenderTargetTexture extends Texture {
  24501. /**
  24502. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  24503. */
  24504. static readonly REFRESHRATE_RENDER_ONCE: number;
  24505. /**
  24506. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  24507. */
  24508. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  24509. /**
  24510. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  24511. * the central point of your effect and can save a lot of performances.
  24512. */
  24513. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  24514. /**
  24515. * Use this predicate to dynamically define the list of mesh you want to render.
  24516. * If set, the renderList property will be overwritten.
  24517. */
  24518. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  24519. private _renderList;
  24520. /**
  24521. * Use this list to define the list of mesh you want to render.
  24522. */
  24523. get renderList(): Nullable<Array<AbstractMesh>>;
  24524. set renderList(value: Nullable<Array<AbstractMesh>>);
  24525. /**
  24526. * Use this function to overload the renderList array at rendering time.
  24527. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  24528. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  24529. * the cube (if the RTT is a cube, else layerOrFace=0).
  24530. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  24531. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  24532. * hold dummy elements!
  24533. */
  24534. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  24535. private _hookArray;
  24536. /**
  24537. * Define if particles should be rendered in your texture.
  24538. */
  24539. renderParticles: boolean;
  24540. /**
  24541. * Define if sprites should be rendered in your texture.
  24542. */
  24543. renderSprites: boolean;
  24544. /**
  24545. * Define the camera used to render the texture.
  24546. */
  24547. activeCamera: Nullable<Camera>;
  24548. /**
  24549. * Override the mesh isReady function with your own one.
  24550. */
  24551. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  24552. /**
  24553. * Override the render function of the texture with your own one.
  24554. */
  24555. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  24556. /**
  24557. * Define if camera post processes should be use while rendering the texture.
  24558. */
  24559. useCameraPostProcesses: boolean;
  24560. /**
  24561. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  24562. */
  24563. ignoreCameraViewport: boolean;
  24564. private _postProcessManager;
  24565. private _postProcesses;
  24566. private _resizeObserver;
  24567. /**
  24568. * An event triggered when the texture is unbind.
  24569. */
  24570. onBeforeBindObservable: Observable<RenderTargetTexture>;
  24571. /**
  24572. * An event triggered when the texture is unbind.
  24573. */
  24574. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  24575. private _onAfterUnbindObserver;
  24576. /**
  24577. * Set a after unbind callback in the texture.
  24578. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  24579. */
  24580. set onAfterUnbind(callback: () => void);
  24581. /**
  24582. * An event triggered before rendering the texture
  24583. */
  24584. onBeforeRenderObservable: Observable<number>;
  24585. private _onBeforeRenderObserver;
  24586. /**
  24587. * Set a before render callback in the texture.
  24588. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  24589. */
  24590. set onBeforeRender(callback: (faceIndex: number) => void);
  24591. /**
  24592. * An event triggered after rendering the texture
  24593. */
  24594. onAfterRenderObservable: Observable<number>;
  24595. private _onAfterRenderObserver;
  24596. /**
  24597. * Set a after render callback in the texture.
  24598. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  24599. */
  24600. set onAfterRender(callback: (faceIndex: number) => void);
  24601. /**
  24602. * An event triggered after the texture clear
  24603. */
  24604. onClearObservable: Observable<Engine>;
  24605. private _onClearObserver;
  24606. /**
  24607. * Set a clear callback in the texture.
  24608. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  24609. */
  24610. set onClear(callback: (Engine: Engine) => void);
  24611. /**
  24612. * An event triggered when the texture is resized.
  24613. */
  24614. onResizeObservable: Observable<RenderTargetTexture>;
  24615. /**
  24616. * Define the clear color of the Render Target if it should be different from the scene.
  24617. */
  24618. clearColor: Color4;
  24619. protected _size: number | {
  24620. width: number;
  24621. height: number;
  24622. layers?: number;
  24623. };
  24624. protected _initialSizeParameter: number | {
  24625. width: number;
  24626. height: number;
  24627. } | {
  24628. ratio: number;
  24629. };
  24630. protected _sizeRatio: Nullable<number>;
  24631. /** @hidden */
  24632. _generateMipMaps: boolean;
  24633. protected _renderingManager: RenderingManager;
  24634. /** @hidden */
  24635. _waitingRenderList?: string[];
  24636. protected _doNotChangeAspectRatio: boolean;
  24637. protected _currentRefreshId: number;
  24638. protected _refreshRate: number;
  24639. protected _textureMatrix: Matrix;
  24640. protected _samples: number;
  24641. protected _renderTargetOptions: RenderTargetCreationOptions;
  24642. /**
  24643. * Gets render target creation options that were used.
  24644. */
  24645. get renderTargetOptions(): RenderTargetCreationOptions;
  24646. protected _onRatioRescale(): void;
  24647. /**
  24648. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  24649. * It must define where the camera used to render the texture is set
  24650. */
  24651. boundingBoxPosition: Vector3;
  24652. private _boundingBoxSize;
  24653. /**
  24654. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  24655. * When defined, the cubemap will switch to local mode
  24656. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  24657. * @example https://www.babylonjs-playground.com/#RNASML
  24658. */
  24659. set boundingBoxSize(value: Vector3);
  24660. get boundingBoxSize(): Vector3;
  24661. /**
  24662. * In case the RTT has been created with a depth texture, get the associated
  24663. * depth texture.
  24664. * Otherwise, return null.
  24665. */
  24666. get depthStencilTexture(): Nullable<InternalTexture>;
  24667. /**
  24668. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  24669. * or used a shadow, depth texture...
  24670. * @param name The friendly name of the texture
  24671. * @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)
  24672. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  24673. * @param generateMipMaps True if mip maps need to be generated after render.
  24674. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  24675. * @param type The type of the buffer in the RTT (int, half float, float...)
  24676. * @param isCube True if a cube texture needs to be created
  24677. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  24678. * @param generateDepthBuffer True to generate a depth buffer
  24679. * @param generateStencilBuffer True to generate a stencil buffer
  24680. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  24681. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  24682. * @param delayAllocation if the texture allocation should be delayed (default: false)
  24683. */
  24684. constructor(name: string, size: number | {
  24685. width: number;
  24686. height: number;
  24687. layers?: number;
  24688. } | {
  24689. ratio: number;
  24690. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  24691. /**
  24692. * Creates a depth stencil texture.
  24693. * This is only available in WebGL 2 or with the depth texture extension available.
  24694. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  24695. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  24696. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  24697. */
  24698. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  24699. private _processSizeParameter;
  24700. /**
  24701. * Define the number of samples to use in case of MSAA.
  24702. * It defaults to one meaning no MSAA has been enabled.
  24703. */
  24704. get samples(): number;
  24705. set samples(value: number);
  24706. /**
  24707. * Resets the refresh counter of the texture and start bak from scratch.
  24708. * Could be useful to regenerate the texture if it is setup to render only once.
  24709. */
  24710. resetRefreshCounter(): void;
  24711. /**
  24712. * Define the refresh rate of the texture or the rendering frequency.
  24713. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  24714. */
  24715. get refreshRate(): number;
  24716. set refreshRate(value: number);
  24717. /**
  24718. * Adds a post process to the render target rendering passes.
  24719. * @param postProcess define the post process to add
  24720. */
  24721. addPostProcess(postProcess: PostProcess): void;
  24722. /**
  24723. * Clear all the post processes attached to the render target
  24724. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  24725. */
  24726. clearPostProcesses(dispose?: boolean): void;
  24727. /**
  24728. * Remove one of the post process from the list of attached post processes to the texture
  24729. * @param postProcess define the post process to remove from the list
  24730. */
  24731. removePostProcess(postProcess: PostProcess): void;
  24732. /** @hidden */
  24733. _shouldRender(): boolean;
  24734. /**
  24735. * Gets the actual render size of the texture.
  24736. * @returns the width of the render size
  24737. */
  24738. getRenderSize(): number;
  24739. /**
  24740. * Gets the actual render width of the texture.
  24741. * @returns the width of the render size
  24742. */
  24743. getRenderWidth(): number;
  24744. /**
  24745. * Gets the actual render height of the texture.
  24746. * @returns the height of the render size
  24747. */
  24748. getRenderHeight(): number;
  24749. /**
  24750. * Gets the actual number of layers of the texture.
  24751. * @returns the number of layers
  24752. */
  24753. getRenderLayers(): number;
  24754. /**
  24755. * Get if the texture can be rescaled or not.
  24756. */
  24757. get canRescale(): boolean;
  24758. /**
  24759. * Resize the texture using a ratio.
  24760. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  24761. */
  24762. scale(ratio: number): void;
  24763. /**
  24764. * Get the texture reflection matrix used to rotate/transform the reflection.
  24765. * @returns the reflection matrix
  24766. */
  24767. getReflectionTextureMatrix(): Matrix;
  24768. /**
  24769. * Resize the texture to a new desired size.
  24770. * Be carrefull as it will recreate all the data in the new texture.
  24771. * @param size Define the new size. It can be:
  24772. * - a number for squared texture,
  24773. * - an object containing { width: number, height: number }
  24774. * - or an object containing a ratio { ratio: number }
  24775. */
  24776. resize(size: number | {
  24777. width: number;
  24778. height: number;
  24779. } | {
  24780. ratio: number;
  24781. }): void;
  24782. private _defaultRenderListPrepared;
  24783. /**
  24784. * Renders all the objects from the render list into the texture.
  24785. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  24786. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  24787. */
  24788. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  24789. private _bestReflectionRenderTargetDimension;
  24790. private _prepareRenderingManager;
  24791. /**
  24792. * @hidden
  24793. * @param faceIndex face index to bind to if this is a cubetexture
  24794. * @param layer defines the index of the texture to bind in the array
  24795. */
  24796. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  24797. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  24798. private renderToTarget;
  24799. /**
  24800. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  24801. * This allowed control for front to back rendering or reversly depending of the special needs.
  24802. *
  24803. * @param renderingGroupId The rendering group id corresponding to its index
  24804. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  24805. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  24806. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  24807. */
  24808. 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;
  24809. /**
  24810. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  24811. *
  24812. * @param renderingGroupId The rendering group id corresponding to its index
  24813. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  24814. */
  24815. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  24816. /**
  24817. * Clones the texture.
  24818. * @returns the cloned texture
  24819. */
  24820. clone(): RenderTargetTexture;
  24821. /**
  24822. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24823. * @returns The JSON representation of the texture
  24824. */
  24825. serialize(): any;
  24826. /**
  24827. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  24828. */
  24829. disposeFramebufferObjects(): void;
  24830. /**
  24831. * Dispose the texture and release its associated resources.
  24832. */
  24833. dispose(): void;
  24834. /** @hidden */
  24835. _rebuild(): void;
  24836. /**
  24837. * Clear the info related to rendering groups preventing retention point in material dispose.
  24838. */
  24839. freeRenderingGroups(): void;
  24840. /**
  24841. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  24842. * @returns the view count
  24843. */
  24844. getViewCount(): number;
  24845. }
  24846. }
  24847. declare module "babylonjs/Misc/guid" {
  24848. /**
  24849. * Class used to manipulate GUIDs
  24850. */
  24851. export class GUID {
  24852. /**
  24853. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  24854. * Be aware Math.random() could cause collisions, but:
  24855. * "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"
  24856. * @returns a pseudo random id
  24857. */
  24858. static RandomId(): string;
  24859. }
  24860. }
  24861. declare module "babylonjs/Materials/shadowDepthWrapper" {
  24862. import { Nullable } from "babylonjs/types";
  24863. import { Scene } from "babylonjs/scene";
  24864. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24865. import { Material } from "babylonjs/Materials/material";
  24866. import { Effect } from "babylonjs/Materials/effect";
  24867. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  24868. /**
  24869. * Options to be used when creating a shadow depth material
  24870. */
  24871. export interface IIOptionShadowDepthMaterial {
  24872. /** Variables in the vertex shader code that need to have their names remapped.
  24873. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  24874. * "var_name" should be either: worldPos or vNormalW
  24875. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  24876. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  24877. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  24878. */
  24879. remappedVariables?: string[];
  24880. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  24881. standalone?: boolean;
  24882. }
  24883. /**
  24884. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  24885. */
  24886. export class ShadowDepthWrapper {
  24887. private _scene;
  24888. private _options?;
  24889. private _baseMaterial;
  24890. private _onEffectCreatedObserver;
  24891. private _subMeshToEffect;
  24892. private _subMeshToDepthEffect;
  24893. private _meshes;
  24894. /** @hidden */
  24895. _matriceNames: any;
  24896. /** Gets the standalone status of the wrapper */
  24897. get standalone(): boolean;
  24898. /** Gets the base material the wrapper is built upon */
  24899. get baseMaterial(): Material;
  24900. /**
  24901. * Instantiate a new shadow depth wrapper.
  24902. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  24903. * generate the shadow depth map. For more information, please refer to the documentation:
  24904. * https://doc.babylonjs.com/babylon101/shadows
  24905. * @param baseMaterial Material to wrap
  24906. * @param scene Define the scene the material belongs to
  24907. * @param options Options used to create the wrapper
  24908. */
  24909. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  24910. /**
  24911. * Gets the effect to use to generate the depth map
  24912. * @param subMesh subMesh to get the effect for
  24913. * @param shadowGenerator shadow generator to get the effect for
  24914. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  24915. */
  24916. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  24917. /**
  24918. * Specifies that the submesh is ready to be used for depth rendering
  24919. * @param subMesh submesh to check
  24920. * @param defines the list of defines to take into account when checking the effect
  24921. * @param shadowGenerator combined with subMesh, it defines the effect to check
  24922. * @param useInstances specifies that instances should be used
  24923. * @returns a boolean indicating that the submesh is ready or not
  24924. */
  24925. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  24926. /**
  24927. * Disposes the resources
  24928. */
  24929. dispose(): void;
  24930. private _makeEffect;
  24931. }
  24932. }
  24933. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  24934. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24935. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  24936. import { Nullable } from "babylonjs/types";
  24937. module "babylonjs/Engines/thinEngine" {
  24938. interface ThinEngine {
  24939. /**
  24940. * Unbind a list of render target textures from the webGL context
  24941. * This is used only when drawBuffer extension or webGL2 are active
  24942. * @param textures defines the render target textures to unbind
  24943. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  24944. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  24945. */
  24946. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  24947. /**
  24948. * Create a multi render target texture
  24949. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  24950. * @param size defines the size of the texture
  24951. * @param options defines the creation options
  24952. * @returns the cube texture as an InternalTexture
  24953. */
  24954. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  24955. /**
  24956. * Update the sample count for a given multiple render target texture
  24957. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  24958. * @param textures defines the textures to update
  24959. * @param samples defines the sample count to set
  24960. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  24961. */
  24962. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  24963. /**
  24964. * Select a subsets of attachments to draw to.
  24965. * @param attachments gl attachments
  24966. */
  24967. bindAttachments(attachments: number[]): void;
  24968. }
  24969. }
  24970. }
  24971. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  24972. import { Scene } from "babylonjs/scene";
  24973. import { Engine } from "babylonjs/Engines/engine";
  24974. import { Texture } from "babylonjs/Materials/Textures/texture";
  24975. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24976. import "babylonjs/Engines/Extensions/engine.multiRender";
  24977. /**
  24978. * Creation options of the multi render target texture.
  24979. */
  24980. export interface IMultiRenderTargetOptions {
  24981. /**
  24982. * Define if the texture needs to create mip maps after render.
  24983. */
  24984. generateMipMaps?: boolean;
  24985. /**
  24986. * Define the types of all the draw buffers we want to create
  24987. */
  24988. types?: number[];
  24989. /**
  24990. * Define the sampling modes of all the draw buffers we want to create
  24991. */
  24992. samplingModes?: number[];
  24993. /**
  24994. * Define if a depth buffer is required
  24995. */
  24996. generateDepthBuffer?: boolean;
  24997. /**
  24998. * Define if a stencil buffer is required
  24999. */
  25000. generateStencilBuffer?: boolean;
  25001. /**
  25002. * Define if a depth texture is required instead of a depth buffer
  25003. */
  25004. generateDepthTexture?: boolean;
  25005. /**
  25006. * Define the number of desired draw buffers
  25007. */
  25008. textureCount?: number;
  25009. /**
  25010. * Define if aspect ratio should be adapted to the texture or stay the scene one
  25011. */
  25012. doNotChangeAspectRatio?: boolean;
  25013. /**
  25014. * Define the default type of the buffers we are creating
  25015. */
  25016. defaultType?: number;
  25017. }
  25018. /**
  25019. * A multi render target, like a render target provides the ability to render to a texture.
  25020. * Unlike the render target, it can render to several draw buffers in one draw.
  25021. * This is specially interesting in deferred rendering or for any effects requiring more than
  25022. * just one color from a single pass.
  25023. */
  25024. export class MultiRenderTarget extends RenderTargetTexture {
  25025. private _internalTextures;
  25026. private _textures;
  25027. private _multiRenderTargetOptions;
  25028. private _count;
  25029. /**
  25030. * Get if draw buffers are currently supported by the used hardware and browser.
  25031. */
  25032. get isSupported(): boolean;
  25033. /**
  25034. * Get the list of textures generated by the multi render target.
  25035. */
  25036. get textures(): Texture[];
  25037. /**
  25038. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  25039. */
  25040. get count(): number;
  25041. /**
  25042. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  25043. */
  25044. get depthTexture(): Texture;
  25045. /**
  25046. * Set the wrapping mode on U of all the textures we are rendering to.
  25047. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25048. */
  25049. set wrapU(wrap: number);
  25050. /**
  25051. * Set the wrapping mode on V of all the textures we are rendering to.
  25052. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  25053. */
  25054. set wrapV(wrap: number);
  25055. /**
  25056. * Instantiate a new multi render target texture.
  25057. * A multi render target, like a render target provides the ability to render to a texture.
  25058. * Unlike the render target, it can render to several draw buffers in one draw.
  25059. * This is specially interesting in deferred rendering or for any effects requiring more than
  25060. * just one color from a single pass.
  25061. * @param name Define the name of the texture
  25062. * @param size Define the size of the buffers to render to
  25063. * @param count Define the number of target we are rendering into
  25064. * @param scene Define the scene the texture belongs to
  25065. * @param options Define the options used to create the multi render target
  25066. */
  25067. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  25068. private _initTypes;
  25069. /** @hidden */
  25070. _rebuild(forceFullRebuild?: boolean): void;
  25071. private _createInternalTextures;
  25072. private _createTextures;
  25073. /**
  25074. * Define the number of samples used if MSAA is enabled.
  25075. */
  25076. get samples(): number;
  25077. set samples(value: number);
  25078. /**
  25079. * Resize all the textures in the multi render target.
  25080. * Be careful as it will recreate all the data in the new texture.
  25081. * @param size Define the new size
  25082. */
  25083. resize(size: any): void;
  25084. /**
  25085. * Changes the number of render targets in this MRT
  25086. * Be careful as it will recreate all the data in the new texture.
  25087. * @param count new texture count
  25088. * @param options Specifies texture types and sampling modes for new textures
  25089. */
  25090. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  25091. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25092. /**
  25093. * Dispose the render targets and their associated resources
  25094. */
  25095. dispose(): void;
  25096. /**
  25097. * Release all the underlying texture used as draw buffers.
  25098. */
  25099. releaseInternalTextures(): void;
  25100. }
  25101. }
  25102. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  25103. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  25104. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  25105. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  25106. /** @hidden */
  25107. export var imageProcessingPixelShader: {
  25108. name: string;
  25109. shader: string;
  25110. };
  25111. }
  25112. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  25113. import { Nullable } from "babylonjs/types";
  25114. import { Color4 } from "babylonjs/Maths/math.color";
  25115. import { Camera } from "babylonjs/Cameras/camera";
  25116. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25117. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  25118. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  25119. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  25120. import { Engine } from "babylonjs/Engines/engine";
  25121. import "babylonjs/Shaders/imageProcessing.fragment";
  25122. import "babylonjs/Shaders/postprocess.vertex";
  25123. /**
  25124. * ImageProcessingPostProcess
  25125. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  25126. */
  25127. export class ImageProcessingPostProcess extends PostProcess {
  25128. /**
  25129. * Default configuration related to image processing available in the PBR Material.
  25130. */
  25131. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  25132. /**
  25133. * Gets the image processing configuration used either in this material.
  25134. */
  25135. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  25136. /**
  25137. * Sets the Default image processing configuration used either in the this material.
  25138. *
  25139. * If sets to null, the scene one is in use.
  25140. */
  25141. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  25142. /**
  25143. * Keep track of the image processing observer to allow dispose and replace.
  25144. */
  25145. private _imageProcessingObserver;
  25146. /**
  25147. * Attaches a new image processing configuration to the PBR Material.
  25148. * @param configuration
  25149. */
  25150. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  25151. /**
  25152. * If the post process is supported.
  25153. */
  25154. get isSupported(): boolean;
  25155. /**
  25156. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25157. */
  25158. get colorCurves(): Nullable<ColorCurves>;
  25159. /**
  25160. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  25161. */
  25162. set colorCurves(value: Nullable<ColorCurves>);
  25163. /**
  25164. * Gets wether the color curves effect is enabled.
  25165. */
  25166. get colorCurvesEnabled(): boolean;
  25167. /**
  25168. * Sets wether the color curves effect is enabled.
  25169. */
  25170. set colorCurvesEnabled(value: boolean);
  25171. /**
  25172. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25173. */
  25174. get colorGradingTexture(): Nullable<BaseTexture>;
  25175. /**
  25176. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  25177. */
  25178. set colorGradingTexture(value: Nullable<BaseTexture>);
  25179. /**
  25180. * Gets wether the color grading effect is enabled.
  25181. */
  25182. get colorGradingEnabled(): boolean;
  25183. /**
  25184. * Gets wether the color grading effect is enabled.
  25185. */
  25186. set colorGradingEnabled(value: boolean);
  25187. /**
  25188. * Gets exposure used in the effect.
  25189. */
  25190. get exposure(): number;
  25191. /**
  25192. * Sets exposure used in the effect.
  25193. */
  25194. set exposure(value: number);
  25195. /**
  25196. * Gets wether tonemapping is enabled or not.
  25197. */
  25198. get toneMappingEnabled(): boolean;
  25199. /**
  25200. * Sets wether tonemapping is enabled or not
  25201. */
  25202. set toneMappingEnabled(value: boolean);
  25203. /**
  25204. * Gets the type of tone mapping effect.
  25205. */
  25206. get toneMappingType(): number;
  25207. /**
  25208. * Sets the type of tone mapping effect.
  25209. */
  25210. set toneMappingType(value: number);
  25211. /**
  25212. * Gets contrast used in the effect.
  25213. */
  25214. get contrast(): number;
  25215. /**
  25216. * Sets contrast used in the effect.
  25217. */
  25218. set contrast(value: number);
  25219. /**
  25220. * Gets Vignette stretch size.
  25221. */
  25222. get vignetteStretch(): number;
  25223. /**
  25224. * Sets Vignette stretch size.
  25225. */
  25226. set vignetteStretch(value: number);
  25227. /**
  25228. * Gets Vignette centre X Offset.
  25229. */
  25230. get vignetteCentreX(): number;
  25231. /**
  25232. * Sets Vignette centre X Offset.
  25233. */
  25234. set vignetteCentreX(value: number);
  25235. /**
  25236. * Gets Vignette centre Y Offset.
  25237. */
  25238. get vignetteCentreY(): number;
  25239. /**
  25240. * Sets Vignette centre Y Offset.
  25241. */
  25242. set vignetteCentreY(value: number);
  25243. /**
  25244. * Gets Vignette weight or intensity of the vignette effect.
  25245. */
  25246. get vignetteWeight(): number;
  25247. /**
  25248. * Sets Vignette weight or intensity of the vignette effect.
  25249. */
  25250. set vignetteWeight(value: number);
  25251. /**
  25252. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25253. * if vignetteEnabled is set to true.
  25254. */
  25255. get vignetteColor(): Color4;
  25256. /**
  25257. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  25258. * if vignetteEnabled is set to true.
  25259. */
  25260. set vignetteColor(value: Color4);
  25261. /**
  25262. * Gets Camera field of view used by the Vignette effect.
  25263. */
  25264. get vignetteCameraFov(): number;
  25265. /**
  25266. * Sets Camera field of view used by the Vignette effect.
  25267. */
  25268. set vignetteCameraFov(value: number);
  25269. /**
  25270. * Gets the vignette blend mode allowing different kind of effect.
  25271. */
  25272. get vignetteBlendMode(): number;
  25273. /**
  25274. * Sets the vignette blend mode allowing different kind of effect.
  25275. */
  25276. set vignetteBlendMode(value: number);
  25277. /**
  25278. * Gets wether the vignette effect is enabled.
  25279. */
  25280. get vignetteEnabled(): boolean;
  25281. /**
  25282. * Sets wether the vignette effect is enabled.
  25283. */
  25284. set vignetteEnabled(value: boolean);
  25285. private _fromLinearSpace;
  25286. /**
  25287. * Gets wether the input of the processing is in Gamma or Linear Space.
  25288. */
  25289. get fromLinearSpace(): boolean;
  25290. /**
  25291. * Sets wether the input of the processing is in Gamma or Linear Space.
  25292. */
  25293. set fromLinearSpace(value: boolean);
  25294. /**
  25295. * Defines cache preventing GC.
  25296. */
  25297. private _defines;
  25298. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  25299. /**
  25300. * "ImageProcessingPostProcess"
  25301. * @returns "ImageProcessingPostProcess"
  25302. */
  25303. getClassName(): string;
  25304. /**
  25305. * @hidden
  25306. */
  25307. _updateParameters(): void;
  25308. dispose(camera?: Camera): void;
  25309. }
  25310. }
  25311. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  25312. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25313. /**
  25314. * Interface for defining prepass effects in the prepass post-process pipeline
  25315. */
  25316. export interface PrePassEffectConfiguration {
  25317. /**
  25318. * Name of the effect
  25319. */
  25320. name: string;
  25321. /**
  25322. * Post process to attach for this effect
  25323. */
  25324. postProcess?: PostProcess;
  25325. /**
  25326. * Textures required in the MRT
  25327. */
  25328. texturesRequired: number[];
  25329. /**
  25330. * Is the effect enabled
  25331. */
  25332. enabled: boolean;
  25333. /**
  25334. * Disposes the effect configuration
  25335. */
  25336. dispose(): void;
  25337. /**
  25338. * Creates the associated post process
  25339. */
  25340. createPostProcess?: () => PostProcess;
  25341. }
  25342. }
  25343. declare module "babylonjs/Rendering/prePassRenderer" {
  25344. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  25345. import { Scene } from "babylonjs/scene";
  25346. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  25347. import { Effect } from "babylonjs/Materials/effect";
  25348. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  25349. /**
  25350. * Renders a pre pass of the scene
  25351. * This means every mesh in the scene will be rendered to a render target texture
  25352. * And then this texture will be composited to the rendering canvas with post processes
  25353. * It is necessary for effects like subsurface scattering or deferred shading
  25354. */
  25355. export class PrePassRenderer {
  25356. /** @hidden */
  25357. static _SceneComponentInitialization: (scene: Scene) => void;
  25358. private _textureFormats;
  25359. private _textureIndices;
  25360. private _scene;
  25361. private _engine;
  25362. private _isDirty;
  25363. /**
  25364. * Number of textures in the multi render target texture where the scene is directly rendered
  25365. */
  25366. mrtCount: number;
  25367. /**
  25368. * The render target where the scene is directly rendered
  25369. */
  25370. prePassRT: MultiRenderTarget;
  25371. private _multiRenderAttachments;
  25372. private _defaultAttachments;
  25373. private _clearAttachments;
  25374. private _postProcesses;
  25375. private readonly _clearColor;
  25376. /**
  25377. * Image processing post process for composition
  25378. */
  25379. imageProcessingPostProcess: ImageProcessingPostProcess;
  25380. /**
  25381. * Configuration for prepass effects
  25382. */
  25383. private _effectConfigurations;
  25384. /**
  25385. * Should materials render their geometry on the MRT
  25386. */
  25387. materialsShouldRenderGeometry: boolean;
  25388. /**
  25389. * Should materials render the irradiance information on the MRT
  25390. */
  25391. materialsShouldRenderIrradiance: boolean;
  25392. private _mrtFormats;
  25393. private _mrtLayout;
  25394. private _enabled;
  25395. /**
  25396. * Indicates if the prepass is enabled
  25397. */
  25398. get enabled(): boolean;
  25399. /**
  25400. * How many samples are used for MSAA of the scene render target
  25401. */
  25402. get samples(): number;
  25403. set samples(n: number);
  25404. /**
  25405. * Instanciates a prepass renderer
  25406. * @param scene The scene
  25407. */
  25408. constructor(scene: Scene);
  25409. private _initializeAttachments;
  25410. private _createCompositionEffect;
  25411. /**
  25412. * Indicates if rendering a prepass is supported
  25413. */
  25414. get isSupported(): boolean;
  25415. /**
  25416. * Sets the proper output textures to draw in the engine.
  25417. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  25418. */
  25419. bindAttachmentsForEffect(effect: Effect): void;
  25420. /**
  25421. * @hidden
  25422. */
  25423. _beforeCameraDraw(): void;
  25424. /**
  25425. * @hidden
  25426. */
  25427. _afterCameraDraw(): void;
  25428. private _checkRTSize;
  25429. private _bindFrameBuffer;
  25430. /**
  25431. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  25432. */
  25433. clear(): void;
  25434. private _setState;
  25435. private _checkTextureType;
  25436. /**
  25437. * Adds an effect configuration to the prepass.
  25438. * If an effect has already been added, it won't add it twice and will return the configuration
  25439. * already present.
  25440. * @param cfg the effect configuration
  25441. * @return the effect configuration now used by the prepass
  25442. */
  25443. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  25444. /**
  25445. * Returns the index of a texture in the multi render target texture array.
  25446. * @param type Texture type
  25447. * @return The index
  25448. */
  25449. getIndex(type: number): number;
  25450. private _enable;
  25451. private _disable;
  25452. private _resetLayout;
  25453. private _resetPostProcessChain;
  25454. private _bindPostProcessChain;
  25455. /**
  25456. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  25457. */
  25458. markAsDirty(): void;
  25459. /**
  25460. * Enables a texture on the MultiRenderTarget for prepass
  25461. */
  25462. private _enableTextures;
  25463. private _update;
  25464. /**
  25465. * Disposes the prepass renderer.
  25466. */
  25467. dispose(): void;
  25468. }
  25469. }
  25470. declare module "babylonjs/Materials/material" {
  25471. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25472. import { SmartArray } from "babylonjs/Misc/smartArray";
  25473. import { Observable } from "babylonjs/Misc/observable";
  25474. import { Nullable } from "babylonjs/types";
  25475. import { Scene } from "babylonjs/scene";
  25476. import { Matrix } from "babylonjs/Maths/math.vector";
  25477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25479. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25480. import { Effect } from "babylonjs/Materials/effect";
  25481. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25482. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25483. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25484. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25485. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25486. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25487. import { Mesh } from "babylonjs/Meshes/mesh";
  25488. import { Animation } from "babylonjs/Animations/animation";
  25489. /**
  25490. * Options for compiling materials.
  25491. */
  25492. export interface IMaterialCompilationOptions {
  25493. /**
  25494. * Defines whether clip planes are enabled.
  25495. */
  25496. clipPlane: boolean;
  25497. /**
  25498. * Defines whether instances are enabled.
  25499. */
  25500. useInstances: boolean;
  25501. }
  25502. /**
  25503. * Options passed when calling customShaderNameResolve
  25504. */
  25505. export interface ICustomShaderNameResolveOptions {
  25506. /**
  25507. * 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
  25508. */
  25509. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25510. }
  25511. /**
  25512. * Base class for the main features of a material in Babylon.js
  25513. */
  25514. export class Material implements IAnimatable {
  25515. /**
  25516. * Returns the triangle fill mode
  25517. */
  25518. static readonly TriangleFillMode: number;
  25519. /**
  25520. * Returns the wireframe mode
  25521. */
  25522. static readonly WireFrameFillMode: number;
  25523. /**
  25524. * Returns the point fill mode
  25525. */
  25526. static readonly PointFillMode: number;
  25527. /**
  25528. * Returns the point list draw mode
  25529. */
  25530. static readonly PointListDrawMode: number;
  25531. /**
  25532. * Returns the line list draw mode
  25533. */
  25534. static readonly LineListDrawMode: number;
  25535. /**
  25536. * Returns the line loop draw mode
  25537. */
  25538. static readonly LineLoopDrawMode: number;
  25539. /**
  25540. * Returns the line strip draw mode
  25541. */
  25542. static readonly LineStripDrawMode: number;
  25543. /**
  25544. * Returns the triangle strip draw mode
  25545. */
  25546. static readonly TriangleStripDrawMode: number;
  25547. /**
  25548. * Returns the triangle fan draw mode
  25549. */
  25550. static readonly TriangleFanDrawMode: number;
  25551. /**
  25552. * Stores the clock-wise side orientation
  25553. */
  25554. static readonly ClockWiseSideOrientation: number;
  25555. /**
  25556. * Stores the counter clock-wise side orientation
  25557. */
  25558. static readonly CounterClockWiseSideOrientation: number;
  25559. /**
  25560. * The dirty texture flag value
  25561. */
  25562. static readonly TextureDirtyFlag: number;
  25563. /**
  25564. * The dirty light flag value
  25565. */
  25566. static readonly LightDirtyFlag: number;
  25567. /**
  25568. * The dirty fresnel flag value
  25569. */
  25570. static readonly FresnelDirtyFlag: number;
  25571. /**
  25572. * The dirty attribute flag value
  25573. */
  25574. static readonly AttributesDirtyFlag: number;
  25575. /**
  25576. * The dirty misc flag value
  25577. */
  25578. static readonly MiscDirtyFlag: number;
  25579. /**
  25580. * The all dirty flag value
  25581. */
  25582. static readonly AllDirtyFlag: number;
  25583. /**
  25584. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25585. */
  25586. static readonly MATERIAL_OPAQUE: number;
  25587. /**
  25588. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25589. */
  25590. static readonly MATERIAL_ALPHATEST: number;
  25591. /**
  25592. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25593. */
  25594. static readonly MATERIAL_ALPHABLEND: number;
  25595. /**
  25596. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25597. * They are also discarded below the alpha cutoff threshold to improve performances.
  25598. */
  25599. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25600. /**
  25601. * The Whiteout method is used to blend normals.
  25602. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25603. */
  25604. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25605. /**
  25606. * The Reoriented Normal Mapping method is used to blend normals.
  25607. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25608. */
  25609. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25610. /**
  25611. * Custom callback helping to override the default shader used in the material.
  25612. */
  25613. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25614. /**
  25615. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25616. */
  25617. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25618. /**
  25619. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25620. * This means that the material can keep using a previous shader while a new one is being compiled.
  25621. * This is mostly used when shader parallel compilation is supported (true by default)
  25622. */
  25623. allowShaderHotSwapping: boolean;
  25624. /**
  25625. * The ID of the material
  25626. */
  25627. id: string;
  25628. /**
  25629. * Gets or sets the unique id of the material
  25630. */
  25631. uniqueId: number;
  25632. /**
  25633. * The name of the material
  25634. */
  25635. name: string;
  25636. /**
  25637. * Gets or sets user defined metadata
  25638. */
  25639. metadata: any;
  25640. /**
  25641. * For internal use only. Please do not use.
  25642. */
  25643. reservedDataStore: any;
  25644. /**
  25645. * Specifies if the ready state should be checked on each call
  25646. */
  25647. checkReadyOnEveryCall: boolean;
  25648. /**
  25649. * Specifies if the ready state should be checked once
  25650. */
  25651. checkReadyOnlyOnce: boolean;
  25652. /**
  25653. * The state of the material
  25654. */
  25655. state: string;
  25656. /**
  25657. * If the material can be rendered to several textures with MRT extension
  25658. */
  25659. get canRenderToMRT(): boolean;
  25660. /**
  25661. * The alpha value of the material
  25662. */
  25663. protected _alpha: number;
  25664. /**
  25665. * List of inspectable custom properties (used by the Inspector)
  25666. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25667. */
  25668. inspectableCustomProperties: IInspectable[];
  25669. /**
  25670. * Sets the alpha value of the material
  25671. */
  25672. set alpha(value: number);
  25673. /**
  25674. * Gets the alpha value of the material
  25675. */
  25676. get alpha(): number;
  25677. /**
  25678. * Specifies if back face culling is enabled
  25679. */
  25680. protected _backFaceCulling: boolean;
  25681. /**
  25682. * Sets the back-face culling state
  25683. */
  25684. set backFaceCulling(value: boolean);
  25685. /**
  25686. * Gets the back-face culling state
  25687. */
  25688. get backFaceCulling(): boolean;
  25689. /**
  25690. * Stores the value for side orientation
  25691. */
  25692. sideOrientation: number;
  25693. /**
  25694. * Callback triggered when the material is compiled
  25695. */
  25696. onCompiled: Nullable<(effect: Effect) => void>;
  25697. /**
  25698. * Callback triggered when an error occurs
  25699. */
  25700. onError: Nullable<(effect: Effect, errors: string) => void>;
  25701. /**
  25702. * Callback triggered to get the render target textures
  25703. */
  25704. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25705. /**
  25706. * Gets a boolean indicating that current material needs to register RTT
  25707. */
  25708. get hasRenderTargetTextures(): boolean;
  25709. /**
  25710. * Specifies if the material should be serialized
  25711. */
  25712. doNotSerialize: boolean;
  25713. /**
  25714. * @hidden
  25715. */
  25716. _storeEffectOnSubMeshes: boolean;
  25717. /**
  25718. * Stores the animations for the material
  25719. */
  25720. animations: Nullable<Array<Animation>>;
  25721. /**
  25722. * An event triggered when the material is disposed
  25723. */
  25724. onDisposeObservable: Observable<Material>;
  25725. /**
  25726. * An observer which watches for dispose events
  25727. */
  25728. private _onDisposeObserver;
  25729. private _onUnBindObservable;
  25730. /**
  25731. * Called during a dispose event
  25732. */
  25733. set onDispose(callback: () => void);
  25734. private _onBindObservable;
  25735. /**
  25736. * An event triggered when the material is bound
  25737. */
  25738. get onBindObservable(): Observable<AbstractMesh>;
  25739. /**
  25740. * An observer which watches for bind events
  25741. */
  25742. private _onBindObserver;
  25743. /**
  25744. * Called during a bind event
  25745. */
  25746. set onBind(callback: (Mesh: AbstractMesh) => void);
  25747. /**
  25748. * An event triggered when the material is unbound
  25749. */
  25750. get onUnBindObservable(): Observable<Material>;
  25751. protected _onEffectCreatedObservable: Nullable<Observable<{
  25752. effect: Effect;
  25753. subMesh: Nullable<SubMesh>;
  25754. }>>;
  25755. /**
  25756. * An event triggered when the effect is (re)created
  25757. */
  25758. get onEffectCreatedObservable(): Observable<{
  25759. effect: Effect;
  25760. subMesh: Nullable<SubMesh>;
  25761. }>;
  25762. /**
  25763. * Stores the value of the alpha mode
  25764. */
  25765. private _alphaMode;
  25766. /**
  25767. * Sets the value of the alpha mode.
  25768. *
  25769. * | Value | Type | Description |
  25770. * | --- | --- | --- |
  25771. * | 0 | ALPHA_DISABLE | |
  25772. * | 1 | ALPHA_ADD | |
  25773. * | 2 | ALPHA_COMBINE | |
  25774. * | 3 | ALPHA_SUBTRACT | |
  25775. * | 4 | ALPHA_MULTIPLY | |
  25776. * | 5 | ALPHA_MAXIMIZED | |
  25777. * | 6 | ALPHA_ONEONE | |
  25778. * | 7 | ALPHA_PREMULTIPLIED | |
  25779. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25780. * | 9 | ALPHA_INTERPOLATE | |
  25781. * | 10 | ALPHA_SCREENMODE | |
  25782. *
  25783. */
  25784. set alphaMode(value: number);
  25785. /**
  25786. * Gets the value of the alpha mode
  25787. */
  25788. get alphaMode(): number;
  25789. /**
  25790. * Stores the state of the need depth pre-pass value
  25791. */
  25792. private _needDepthPrePass;
  25793. /**
  25794. * Sets the need depth pre-pass value
  25795. */
  25796. set needDepthPrePass(value: boolean);
  25797. /**
  25798. * Gets the depth pre-pass value
  25799. */
  25800. get needDepthPrePass(): boolean;
  25801. /**
  25802. * Specifies if depth writing should be disabled
  25803. */
  25804. disableDepthWrite: boolean;
  25805. /**
  25806. * Specifies if color writing should be disabled
  25807. */
  25808. disableColorWrite: boolean;
  25809. /**
  25810. * Specifies if depth writing should be forced
  25811. */
  25812. forceDepthWrite: boolean;
  25813. /**
  25814. * Specifies the depth function that should be used. 0 means the default engine function
  25815. */
  25816. depthFunction: number;
  25817. /**
  25818. * Specifies if there should be a separate pass for culling
  25819. */
  25820. separateCullingPass: boolean;
  25821. /**
  25822. * Stores the state specifing if fog should be enabled
  25823. */
  25824. private _fogEnabled;
  25825. /**
  25826. * Sets the state for enabling fog
  25827. */
  25828. set fogEnabled(value: boolean);
  25829. /**
  25830. * Gets the value of the fog enabled state
  25831. */
  25832. get fogEnabled(): boolean;
  25833. /**
  25834. * Stores the size of points
  25835. */
  25836. pointSize: number;
  25837. /**
  25838. * Stores the z offset value
  25839. */
  25840. zOffset: number;
  25841. get wireframe(): boolean;
  25842. /**
  25843. * Sets the state of wireframe mode
  25844. */
  25845. set wireframe(value: boolean);
  25846. /**
  25847. * Gets the value specifying if point clouds are enabled
  25848. */
  25849. get pointsCloud(): boolean;
  25850. /**
  25851. * Sets the state of point cloud mode
  25852. */
  25853. set pointsCloud(value: boolean);
  25854. /**
  25855. * Gets the material fill mode
  25856. */
  25857. get fillMode(): number;
  25858. /**
  25859. * Sets the material fill mode
  25860. */
  25861. set fillMode(value: number);
  25862. /**
  25863. * @hidden
  25864. * Stores the effects for the material
  25865. */
  25866. _effect: Nullable<Effect>;
  25867. /**
  25868. * Specifies if uniform buffers should be used
  25869. */
  25870. private _useUBO;
  25871. /**
  25872. * Stores a reference to the scene
  25873. */
  25874. private _scene;
  25875. /**
  25876. * Stores the fill mode state
  25877. */
  25878. private _fillMode;
  25879. /**
  25880. * Specifies if the depth write state should be cached
  25881. */
  25882. private _cachedDepthWriteState;
  25883. /**
  25884. * Specifies if the color write state should be cached
  25885. */
  25886. private _cachedColorWriteState;
  25887. /**
  25888. * Specifies if the depth function state should be cached
  25889. */
  25890. private _cachedDepthFunctionState;
  25891. /**
  25892. * Stores the uniform buffer
  25893. */
  25894. protected _uniformBuffer: UniformBuffer;
  25895. /** @hidden */
  25896. _indexInSceneMaterialArray: number;
  25897. /** @hidden */
  25898. meshMap: Nullable<{
  25899. [id: string]: AbstractMesh | undefined;
  25900. }>;
  25901. /**
  25902. * Creates a material instance
  25903. * @param name defines the name of the material
  25904. * @param scene defines the scene to reference
  25905. * @param doNotAdd specifies if the material should be added to the scene
  25906. */
  25907. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25908. /**
  25909. * Returns a string representation of the current material
  25910. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25911. * @returns a string with material information
  25912. */
  25913. toString(fullDetails?: boolean): string;
  25914. /**
  25915. * Gets the class name of the material
  25916. * @returns a string with the class name of the material
  25917. */
  25918. getClassName(): string;
  25919. /**
  25920. * Specifies if updates for the material been locked
  25921. */
  25922. get isFrozen(): boolean;
  25923. /**
  25924. * Locks updates for the material
  25925. */
  25926. freeze(): void;
  25927. /**
  25928. * Unlocks updates for the material
  25929. */
  25930. unfreeze(): void;
  25931. /**
  25932. * Specifies if the material is ready to be used
  25933. * @param mesh defines the mesh to check
  25934. * @param useInstances specifies if instances should be used
  25935. * @returns a boolean indicating if the material is ready to be used
  25936. */
  25937. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  25938. /**
  25939. * Specifies that the submesh is ready to be used
  25940. * @param mesh defines the mesh to check
  25941. * @param subMesh defines which submesh to check
  25942. * @param useInstances specifies that instances should be used
  25943. * @returns a boolean indicating that the submesh is ready or not
  25944. */
  25945. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  25946. /**
  25947. * Returns the material effect
  25948. * @returns the effect associated with the material
  25949. */
  25950. getEffect(): Nullable<Effect>;
  25951. /**
  25952. * Returns the current scene
  25953. * @returns a Scene
  25954. */
  25955. getScene(): Scene;
  25956. /**
  25957. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  25958. */
  25959. protected _forceAlphaTest: boolean;
  25960. /**
  25961. * The transparency mode of the material.
  25962. */
  25963. protected _transparencyMode: Nullable<number>;
  25964. /**
  25965. * Gets the current transparency mode.
  25966. */
  25967. get transparencyMode(): Nullable<number>;
  25968. /**
  25969. * Sets the transparency mode of the material.
  25970. *
  25971. * | Value | Type | Description |
  25972. * | ----- | ----------------------------------- | ----------- |
  25973. * | 0 | OPAQUE | |
  25974. * | 1 | ALPHATEST | |
  25975. * | 2 | ALPHABLEND | |
  25976. * | 3 | ALPHATESTANDBLEND | |
  25977. *
  25978. */
  25979. set transparencyMode(value: Nullable<number>);
  25980. /**
  25981. * Returns true if alpha blending should be disabled.
  25982. */
  25983. protected get _disableAlphaBlending(): boolean;
  25984. /**
  25985. * Specifies whether or not this material should be rendered in alpha blend mode.
  25986. * @returns a boolean specifying if alpha blending is needed
  25987. */
  25988. needAlphaBlending(): boolean;
  25989. /**
  25990. * Specifies if the mesh will require alpha blending
  25991. * @param mesh defines the mesh to check
  25992. * @returns a boolean specifying if alpha blending is needed for the mesh
  25993. */
  25994. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  25995. /**
  25996. * Specifies whether or not this material should be rendered in alpha test mode.
  25997. * @returns a boolean specifying if an alpha test is needed.
  25998. */
  25999. needAlphaTesting(): boolean;
  26000. /**
  26001. * Specifies if material alpha testing should be turned on for the mesh
  26002. * @param mesh defines the mesh to check
  26003. */
  26004. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26005. /**
  26006. * Gets the texture used for the alpha test
  26007. * @returns the texture to use for alpha testing
  26008. */
  26009. getAlphaTestTexture(): Nullable<BaseTexture>;
  26010. /**
  26011. * Marks the material to indicate that it needs to be re-calculated
  26012. */
  26013. markDirty(): void;
  26014. /** @hidden */
  26015. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26016. /**
  26017. * Binds the material to the mesh
  26018. * @param world defines the world transformation matrix
  26019. * @param mesh defines the mesh to bind the material to
  26020. */
  26021. bind(world: Matrix, mesh?: Mesh): void;
  26022. /**
  26023. * Binds the submesh to the material
  26024. * @param world defines the world transformation matrix
  26025. * @param mesh defines the mesh containing the submesh
  26026. * @param subMesh defines the submesh to bind the material to
  26027. */
  26028. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26029. /**
  26030. * Binds the world matrix to the material
  26031. * @param world defines the world transformation matrix
  26032. */
  26033. bindOnlyWorldMatrix(world: Matrix): void;
  26034. /**
  26035. * Binds the scene's uniform buffer to the effect.
  26036. * @param effect defines the effect to bind to the scene uniform buffer
  26037. * @param sceneUbo defines the uniform buffer storing scene data
  26038. */
  26039. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26040. /**
  26041. * Binds the view matrix to the effect
  26042. * @param effect defines the effect to bind the view matrix to
  26043. */
  26044. bindView(effect: Effect): void;
  26045. /**
  26046. * Binds the view projection matrix to the effect
  26047. * @param effect defines the effect to bind the view projection matrix to
  26048. */
  26049. bindViewProjection(effect: Effect): void;
  26050. /**
  26051. * Processes to execute after binding the material to a mesh
  26052. * @param mesh defines the rendered mesh
  26053. */
  26054. protected _afterBind(mesh?: Mesh): void;
  26055. /**
  26056. * Unbinds the material from the mesh
  26057. */
  26058. unbind(): void;
  26059. /**
  26060. * Gets the active textures from the material
  26061. * @returns an array of textures
  26062. */
  26063. getActiveTextures(): BaseTexture[];
  26064. /**
  26065. * Specifies if the material uses a texture
  26066. * @param texture defines the texture to check against the material
  26067. * @returns a boolean specifying if the material uses the texture
  26068. */
  26069. hasTexture(texture: BaseTexture): boolean;
  26070. /**
  26071. * Makes a duplicate of the material, and gives it a new name
  26072. * @param name defines the new name for the duplicated material
  26073. * @returns the cloned material
  26074. */
  26075. clone(name: string): Nullable<Material>;
  26076. /**
  26077. * Gets the meshes bound to the material
  26078. * @returns an array of meshes bound to the material
  26079. */
  26080. getBindedMeshes(): AbstractMesh[];
  26081. /**
  26082. * Force shader compilation
  26083. * @param mesh defines the mesh associated with this material
  26084. * @param onCompiled defines a function to execute once the material is compiled
  26085. * @param options defines the options to configure the compilation
  26086. * @param onError defines a function to execute if the material fails compiling
  26087. */
  26088. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26089. /**
  26090. * Force shader compilation
  26091. * @param mesh defines the mesh that will use this material
  26092. * @param options defines additional options for compiling the shaders
  26093. * @returns a promise that resolves when the compilation completes
  26094. */
  26095. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26096. private static readonly _AllDirtyCallBack;
  26097. private static readonly _ImageProcessingDirtyCallBack;
  26098. private static readonly _TextureDirtyCallBack;
  26099. private static readonly _FresnelDirtyCallBack;
  26100. private static readonly _MiscDirtyCallBack;
  26101. private static readonly _LightsDirtyCallBack;
  26102. private static readonly _AttributeDirtyCallBack;
  26103. private static _FresnelAndMiscDirtyCallBack;
  26104. private static _TextureAndMiscDirtyCallBack;
  26105. private static readonly _DirtyCallbackArray;
  26106. private static readonly _RunDirtyCallBacks;
  26107. /**
  26108. * Marks a define in the material to indicate that it needs to be re-computed
  26109. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26110. */
  26111. markAsDirty(flag: number): void;
  26112. /**
  26113. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26114. * @param func defines a function which checks material defines against the submeshes
  26115. */
  26116. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26117. /**
  26118. * Indicates that the scene should check if the rendering now needs a prepass
  26119. */
  26120. protected _markScenePrePassDirty(): void;
  26121. /**
  26122. * Indicates that we need to re-calculated for all submeshes
  26123. */
  26124. protected _markAllSubMeshesAsAllDirty(): void;
  26125. /**
  26126. * Indicates that image processing needs to be re-calculated for all submeshes
  26127. */
  26128. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26129. /**
  26130. * Indicates that textures need to be re-calculated for all submeshes
  26131. */
  26132. protected _markAllSubMeshesAsTexturesDirty(): void;
  26133. /**
  26134. * Indicates that fresnel needs to be re-calculated for all submeshes
  26135. */
  26136. protected _markAllSubMeshesAsFresnelDirty(): void;
  26137. /**
  26138. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26139. */
  26140. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26141. /**
  26142. * Indicates that lights need to be re-calculated for all submeshes
  26143. */
  26144. protected _markAllSubMeshesAsLightsDirty(): void;
  26145. /**
  26146. * Indicates that attributes need to be re-calculated for all submeshes
  26147. */
  26148. protected _markAllSubMeshesAsAttributesDirty(): void;
  26149. /**
  26150. * Indicates that misc needs to be re-calculated for all submeshes
  26151. */
  26152. protected _markAllSubMeshesAsMiscDirty(): void;
  26153. /**
  26154. * Indicates that textures and misc need to be re-calculated for all submeshes
  26155. */
  26156. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26157. /**
  26158. * Sets the required values to the prepass renderer.
  26159. * @param prePassRenderer defines the prepass renderer to setup.
  26160. * @returns true if the pre pass is needed.
  26161. */
  26162. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26163. /**
  26164. * Disposes the material
  26165. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26166. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26167. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26168. */
  26169. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26170. /** @hidden */
  26171. private releaseVertexArrayObject;
  26172. /**
  26173. * Serializes this material
  26174. * @returns the serialized material object
  26175. */
  26176. serialize(): any;
  26177. /**
  26178. * Creates a material from parsed material data
  26179. * @param parsedMaterial defines parsed material data
  26180. * @param scene defines the hosting scene
  26181. * @param rootUrl defines the root URL to use to load textures
  26182. * @returns a new material
  26183. */
  26184. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26185. }
  26186. }
  26187. declare module "babylonjs/Materials/multiMaterial" {
  26188. import { Nullable } from "babylonjs/types";
  26189. import { Scene } from "babylonjs/scene";
  26190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26191. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26192. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26193. import { Material } from "babylonjs/Materials/material";
  26194. /**
  26195. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26196. * separate meshes. This can be use to improve performances.
  26197. * @see https://doc.babylonjs.com/how_to/multi_materials
  26198. */
  26199. export class MultiMaterial extends Material {
  26200. private _subMaterials;
  26201. /**
  26202. * Gets or Sets the list of Materials used within the multi material.
  26203. * They need to be ordered according to the submeshes order in the associated mesh
  26204. */
  26205. get subMaterials(): Nullable<Material>[];
  26206. set subMaterials(value: Nullable<Material>[]);
  26207. /**
  26208. * Function used to align with Node.getChildren()
  26209. * @returns the list of Materials used within the multi material
  26210. */
  26211. getChildren(): Nullable<Material>[];
  26212. /**
  26213. * Instantiates a new Multi Material
  26214. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26215. * separate meshes. This can be use to improve performances.
  26216. * @see https://doc.babylonjs.com/how_to/multi_materials
  26217. * @param name Define the name in the scene
  26218. * @param scene Define the scene the material belongs to
  26219. */
  26220. constructor(name: string, scene: Scene);
  26221. private _hookArray;
  26222. /**
  26223. * Get one of the submaterial by its index in the submaterials array
  26224. * @param index The index to look the sub material at
  26225. * @returns The Material if the index has been defined
  26226. */
  26227. getSubMaterial(index: number): Nullable<Material>;
  26228. /**
  26229. * Get the list of active textures for the whole sub materials list.
  26230. * @returns All the textures that will be used during the rendering
  26231. */
  26232. getActiveTextures(): BaseTexture[];
  26233. /**
  26234. * Gets the current class name of the material e.g. "MultiMaterial"
  26235. * Mainly use in serialization.
  26236. * @returns the class name
  26237. */
  26238. getClassName(): string;
  26239. /**
  26240. * Checks if the material is ready to render the requested sub mesh
  26241. * @param mesh Define the mesh the submesh belongs to
  26242. * @param subMesh Define the sub mesh to look readyness for
  26243. * @param useInstances Define whether or not the material is used with instances
  26244. * @returns true if ready, otherwise false
  26245. */
  26246. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26247. /**
  26248. * Clones the current material and its related sub materials
  26249. * @param name Define the name of the newly cloned material
  26250. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26251. * @returns the cloned material
  26252. */
  26253. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26254. /**
  26255. * Serializes the materials into a JSON representation.
  26256. * @returns the JSON representation
  26257. */
  26258. serialize(): any;
  26259. /**
  26260. * Dispose the material and release its associated resources
  26261. * @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)
  26262. * @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)
  26263. * @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)
  26264. */
  26265. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26266. /**
  26267. * Creates a MultiMaterial from parsed MultiMaterial data.
  26268. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26269. * @param scene defines the hosting scene
  26270. * @returns a new MultiMaterial
  26271. */
  26272. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26273. }
  26274. }
  26275. declare module "babylonjs/Meshes/subMesh" {
  26276. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26277. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26278. import { Engine } from "babylonjs/Engines/engine";
  26279. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26280. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26281. import { Effect } from "babylonjs/Materials/effect";
  26282. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26283. import { Plane } from "babylonjs/Maths/math.plane";
  26284. import { Collider } from "babylonjs/Collisions/collider";
  26285. import { Material } from "babylonjs/Materials/material";
  26286. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26287. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26288. import { Mesh } from "babylonjs/Meshes/mesh";
  26289. import { Ray } from "babylonjs/Culling/ray";
  26290. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26291. /**
  26292. * Defines a subdivision inside a mesh
  26293. */
  26294. export class SubMesh implements ICullable {
  26295. /** the material index to use */
  26296. materialIndex: number;
  26297. /** vertex index start */
  26298. verticesStart: number;
  26299. /** vertices count */
  26300. verticesCount: number;
  26301. /** index start */
  26302. indexStart: number;
  26303. /** indices count */
  26304. indexCount: number;
  26305. /** @hidden */
  26306. _materialDefines: Nullable<MaterialDefines>;
  26307. /** @hidden */
  26308. _materialEffect: Nullable<Effect>;
  26309. /** @hidden */
  26310. _effectOverride: Nullable<Effect>;
  26311. /**
  26312. * Gets material defines used by the effect associated to the sub mesh
  26313. */
  26314. get materialDefines(): Nullable<MaterialDefines>;
  26315. /**
  26316. * Sets material defines used by the effect associated to the sub mesh
  26317. */
  26318. set materialDefines(defines: Nullable<MaterialDefines>);
  26319. /**
  26320. * Gets associated effect
  26321. */
  26322. get effect(): Nullable<Effect>;
  26323. /**
  26324. * Sets associated effect (effect used to render this submesh)
  26325. * @param effect defines the effect to associate with
  26326. * @param defines defines the set of defines used to compile this effect
  26327. */
  26328. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26329. /** @hidden */
  26330. _linesIndexCount: number;
  26331. private _mesh;
  26332. private _renderingMesh;
  26333. private _boundingInfo;
  26334. private _linesIndexBuffer;
  26335. /** @hidden */
  26336. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26337. /** @hidden */
  26338. _trianglePlanes: Plane[];
  26339. /** @hidden */
  26340. _lastColliderTransformMatrix: Nullable<Matrix>;
  26341. /** @hidden */
  26342. _renderId: number;
  26343. /** @hidden */
  26344. _alphaIndex: number;
  26345. /** @hidden */
  26346. _distanceToCamera: number;
  26347. /** @hidden */
  26348. _id: number;
  26349. private _currentMaterial;
  26350. /**
  26351. * Add a new submesh to a mesh
  26352. * @param materialIndex defines the material index to use
  26353. * @param verticesStart defines vertex index start
  26354. * @param verticesCount defines vertices count
  26355. * @param indexStart defines index start
  26356. * @param indexCount defines indices count
  26357. * @param mesh defines the parent mesh
  26358. * @param renderingMesh defines an optional rendering mesh
  26359. * @param createBoundingBox defines if bounding box should be created for this submesh
  26360. * @returns the new submesh
  26361. */
  26362. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26363. /**
  26364. * Creates a new submesh
  26365. * @param materialIndex defines the material index to use
  26366. * @param verticesStart defines vertex index start
  26367. * @param verticesCount defines vertices count
  26368. * @param indexStart defines index start
  26369. * @param indexCount defines indices count
  26370. * @param mesh defines the parent mesh
  26371. * @param renderingMesh defines an optional rendering mesh
  26372. * @param createBoundingBox defines if bounding box should be created for this submesh
  26373. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26374. */
  26375. constructor(
  26376. /** the material index to use */
  26377. materialIndex: number,
  26378. /** vertex index start */
  26379. verticesStart: number,
  26380. /** vertices count */
  26381. verticesCount: number,
  26382. /** index start */
  26383. indexStart: number,
  26384. /** indices count */
  26385. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26386. /**
  26387. * Returns true if this submesh covers the entire parent mesh
  26388. * @ignorenaming
  26389. */
  26390. get IsGlobal(): boolean;
  26391. /**
  26392. * Returns the submesh BoudingInfo object
  26393. * @returns current bounding info (or mesh's one if the submesh is global)
  26394. */
  26395. getBoundingInfo(): BoundingInfo;
  26396. /**
  26397. * Sets the submesh BoundingInfo
  26398. * @param boundingInfo defines the new bounding info to use
  26399. * @returns the SubMesh
  26400. */
  26401. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26402. /**
  26403. * Returns the mesh of the current submesh
  26404. * @return the parent mesh
  26405. */
  26406. getMesh(): AbstractMesh;
  26407. /**
  26408. * Returns the rendering mesh of the submesh
  26409. * @returns the rendering mesh (could be different from parent mesh)
  26410. */
  26411. getRenderingMesh(): Mesh;
  26412. /**
  26413. * Returns the replacement mesh of the submesh
  26414. * @returns the replacement mesh (could be different from parent mesh)
  26415. */
  26416. getReplacementMesh(): Nullable<AbstractMesh>;
  26417. /**
  26418. * Returns the effective mesh of the submesh
  26419. * @returns the effective mesh (could be different from parent mesh)
  26420. */
  26421. getEffectiveMesh(): AbstractMesh;
  26422. /**
  26423. * Returns the submesh material
  26424. * @returns null or the current material
  26425. */
  26426. getMaterial(): Nullable<Material>;
  26427. private _IsMultiMaterial;
  26428. /**
  26429. * Sets a new updated BoundingInfo object to the submesh
  26430. * @param data defines an optional position array to use to determine the bounding info
  26431. * @returns the SubMesh
  26432. */
  26433. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26434. /** @hidden */
  26435. _checkCollision(collider: Collider): boolean;
  26436. /**
  26437. * Updates the submesh BoundingInfo
  26438. * @param world defines the world matrix to use to update the bounding info
  26439. * @returns the submesh
  26440. */
  26441. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26442. /**
  26443. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26444. * @param frustumPlanes defines the frustum planes
  26445. * @returns true if the submesh is intersecting with the frustum
  26446. */
  26447. isInFrustum(frustumPlanes: Plane[]): boolean;
  26448. /**
  26449. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26450. * @param frustumPlanes defines the frustum planes
  26451. * @returns true if the submesh is inside the frustum
  26452. */
  26453. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26454. /**
  26455. * Renders the submesh
  26456. * @param enableAlphaMode defines if alpha needs to be used
  26457. * @returns the submesh
  26458. */
  26459. render(enableAlphaMode: boolean): SubMesh;
  26460. /**
  26461. * @hidden
  26462. */
  26463. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26464. /**
  26465. * Checks if the submesh intersects with a ray
  26466. * @param ray defines the ray to test
  26467. * @returns true is the passed ray intersects the submesh bounding box
  26468. */
  26469. canIntersects(ray: Ray): boolean;
  26470. /**
  26471. * Intersects current submesh with a ray
  26472. * @param ray defines the ray to test
  26473. * @param positions defines mesh's positions array
  26474. * @param indices defines mesh's indices array
  26475. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26476. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26477. * @returns intersection info or null if no intersection
  26478. */
  26479. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26480. /** @hidden */
  26481. private _intersectLines;
  26482. /** @hidden */
  26483. private _intersectUnIndexedLines;
  26484. /** @hidden */
  26485. private _intersectTriangles;
  26486. /** @hidden */
  26487. private _intersectUnIndexedTriangles;
  26488. /** @hidden */
  26489. _rebuild(): void;
  26490. /**
  26491. * Creates a new submesh from the passed mesh
  26492. * @param newMesh defines the new hosting mesh
  26493. * @param newRenderingMesh defines an optional rendering mesh
  26494. * @returns the new submesh
  26495. */
  26496. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26497. /**
  26498. * Release associated resources
  26499. */
  26500. dispose(): void;
  26501. /**
  26502. * Gets the class name
  26503. * @returns the string "SubMesh".
  26504. */
  26505. getClassName(): string;
  26506. /**
  26507. * Creates a new submesh from indices data
  26508. * @param materialIndex the index of the main mesh material
  26509. * @param startIndex the index where to start the copy in the mesh indices array
  26510. * @param indexCount the number of indices to copy then from the startIndex
  26511. * @param mesh the main mesh to create the submesh from
  26512. * @param renderingMesh the optional rendering mesh
  26513. * @returns a new submesh
  26514. */
  26515. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26516. }
  26517. }
  26518. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26519. /**
  26520. * Class used to represent data loading progression
  26521. */
  26522. export class SceneLoaderFlags {
  26523. private static _ForceFullSceneLoadingForIncremental;
  26524. private static _ShowLoadingScreen;
  26525. private static _CleanBoneMatrixWeights;
  26526. private static _loggingLevel;
  26527. /**
  26528. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26529. */
  26530. static get ForceFullSceneLoadingForIncremental(): boolean;
  26531. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26532. /**
  26533. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26534. */
  26535. static get ShowLoadingScreen(): boolean;
  26536. static set ShowLoadingScreen(value: boolean);
  26537. /**
  26538. * Defines the current logging level (while loading the scene)
  26539. * @ignorenaming
  26540. */
  26541. static get loggingLevel(): number;
  26542. static set loggingLevel(value: number);
  26543. /**
  26544. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26545. */
  26546. static get CleanBoneMatrixWeights(): boolean;
  26547. static set CleanBoneMatrixWeights(value: boolean);
  26548. }
  26549. }
  26550. declare module "babylonjs/Meshes/geometry" {
  26551. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26552. import { Scene } from "babylonjs/scene";
  26553. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26554. import { Engine } from "babylonjs/Engines/engine";
  26555. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26556. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26557. import { Effect } from "babylonjs/Materials/effect";
  26558. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26559. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26560. import { Mesh } from "babylonjs/Meshes/mesh";
  26561. /**
  26562. * Class used to store geometry data (vertex buffers + index buffer)
  26563. */
  26564. export class Geometry implements IGetSetVerticesData {
  26565. /**
  26566. * Gets or sets the ID of the geometry
  26567. */
  26568. id: string;
  26569. /**
  26570. * Gets or sets the unique ID of the geometry
  26571. */
  26572. uniqueId: number;
  26573. /**
  26574. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26575. */
  26576. delayLoadState: number;
  26577. /**
  26578. * Gets the file containing the data to load when running in delay load state
  26579. */
  26580. delayLoadingFile: Nullable<string>;
  26581. /**
  26582. * Callback called when the geometry is updated
  26583. */
  26584. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26585. private _scene;
  26586. private _engine;
  26587. private _meshes;
  26588. private _totalVertices;
  26589. /** @hidden */
  26590. _indices: IndicesArray;
  26591. /** @hidden */
  26592. _vertexBuffers: {
  26593. [key: string]: VertexBuffer;
  26594. };
  26595. private _isDisposed;
  26596. private _extend;
  26597. private _boundingBias;
  26598. /** @hidden */
  26599. _delayInfo: Array<string>;
  26600. private _indexBuffer;
  26601. private _indexBufferIsUpdatable;
  26602. /** @hidden */
  26603. _boundingInfo: Nullable<BoundingInfo>;
  26604. /** @hidden */
  26605. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26606. /** @hidden */
  26607. _softwareSkinningFrameId: number;
  26608. private _vertexArrayObjects;
  26609. private _updatable;
  26610. /** @hidden */
  26611. _positions: Nullable<Vector3[]>;
  26612. /**
  26613. * 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
  26614. */
  26615. get boundingBias(): Vector2;
  26616. /**
  26617. * 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
  26618. */
  26619. set boundingBias(value: Vector2);
  26620. /**
  26621. * Static function used to attach a new empty geometry to a mesh
  26622. * @param mesh defines the mesh to attach the geometry to
  26623. * @returns the new Geometry
  26624. */
  26625. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26626. /** Get the list of meshes using this geometry */
  26627. get meshes(): Mesh[];
  26628. /**
  26629. * 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
  26630. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26631. */
  26632. useBoundingInfoFromGeometry: boolean;
  26633. /**
  26634. * Creates a new geometry
  26635. * @param id defines the unique ID
  26636. * @param scene defines the hosting scene
  26637. * @param vertexData defines the VertexData used to get geometry data
  26638. * @param updatable defines if geometry must be updatable (false by default)
  26639. * @param mesh defines the mesh that will be associated with the geometry
  26640. */
  26641. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26642. /**
  26643. * Gets the current extend of the geometry
  26644. */
  26645. get extend(): {
  26646. minimum: Vector3;
  26647. maximum: Vector3;
  26648. };
  26649. /**
  26650. * Gets the hosting scene
  26651. * @returns the hosting Scene
  26652. */
  26653. getScene(): Scene;
  26654. /**
  26655. * Gets the hosting engine
  26656. * @returns the hosting Engine
  26657. */
  26658. getEngine(): Engine;
  26659. /**
  26660. * Defines if the geometry is ready to use
  26661. * @returns true if the geometry is ready to be used
  26662. */
  26663. isReady(): boolean;
  26664. /**
  26665. * Gets a value indicating that the geometry should not be serialized
  26666. */
  26667. get doNotSerialize(): boolean;
  26668. /** @hidden */
  26669. _rebuild(): void;
  26670. /**
  26671. * Affects all geometry data in one call
  26672. * @param vertexData defines the geometry data
  26673. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26674. */
  26675. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26676. /**
  26677. * Set specific vertex data
  26678. * @param kind defines the data kind (Position, normal, etc...)
  26679. * @param data defines the vertex data to use
  26680. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26681. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26682. */
  26683. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26684. /**
  26685. * Removes a specific vertex data
  26686. * @param kind defines the data kind (Position, normal, etc...)
  26687. */
  26688. removeVerticesData(kind: string): void;
  26689. /**
  26690. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26691. * @param buffer defines the vertex buffer to use
  26692. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26693. */
  26694. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26695. /**
  26696. * Update a specific vertex buffer
  26697. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26698. * It will do nothing if the buffer is not updatable
  26699. * @param kind defines the data kind (Position, normal, etc...)
  26700. * @param data defines the data to use
  26701. * @param offset defines the offset in the target buffer where to store the data
  26702. * @param useBytes set to true if the offset is in bytes
  26703. */
  26704. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26705. /**
  26706. * Update a specific vertex buffer
  26707. * This function will create a new buffer if the current one is not updatable
  26708. * @param kind defines the data kind (Position, normal, etc...)
  26709. * @param data defines the data to use
  26710. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26711. */
  26712. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26713. private _updateBoundingInfo;
  26714. /** @hidden */
  26715. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26716. /**
  26717. * Gets total number of vertices
  26718. * @returns the total number of vertices
  26719. */
  26720. getTotalVertices(): number;
  26721. /**
  26722. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26723. * @param kind defines the data kind (Position, normal, etc...)
  26724. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26725. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26726. * @returns a float array containing vertex data
  26727. */
  26728. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26729. /**
  26730. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26731. * @param kind defines the data kind (Position, normal, etc...)
  26732. * @returns true if the vertex buffer with the specified kind is updatable
  26733. */
  26734. isVertexBufferUpdatable(kind: string): boolean;
  26735. /**
  26736. * Gets a specific vertex buffer
  26737. * @param kind defines the data kind (Position, normal, etc...)
  26738. * @returns a VertexBuffer
  26739. */
  26740. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26741. /**
  26742. * Returns all vertex buffers
  26743. * @return an object holding all vertex buffers indexed by kind
  26744. */
  26745. getVertexBuffers(): Nullable<{
  26746. [key: string]: VertexBuffer;
  26747. }>;
  26748. /**
  26749. * Gets a boolean indicating if specific vertex buffer is present
  26750. * @param kind defines the data kind (Position, normal, etc...)
  26751. * @returns true if data is present
  26752. */
  26753. isVerticesDataPresent(kind: string): boolean;
  26754. /**
  26755. * Gets a list of all attached data kinds (Position, normal, etc...)
  26756. * @returns a list of string containing all kinds
  26757. */
  26758. getVerticesDataKinds(): string[];
  26759. /**
  26760. * Update index buffer
  26761. * @param indices defines the indices to store in the index buffer
  26762. * @param offset defines the offset in the target buffer where to store the data
  26763. * @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)
  26764. */
  26765. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26766. /**
  26767. * Creates a new index buffer
  26768. * @param indices defines the indices to store in the index buffer
  26769. * @param totalVertices defines the total number of vertices (could be null)
  26770. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26771. */
  26772. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26773. /**
  26774. * Return the total number of indices
  26775. * @returns the total number of indices
  26776. */
  26777. getTotalIndices(): number;
  26778. /**
  26779. * Gets the index buffer array
  26780. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26781. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26782. * @returns the index buffer array
  26783. */
  26784. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26785. /**
  26786. * Gets the index buffer
  26787. * @return the index buffer
  26788. */
  26789. getIndexBuffer(): Nullable<DataBuffer>;
  26790. /** @hidden */
  26791. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26792. /**
  26793. * Release the associated resources for a specific mesh
  26794. * @param mesh defines the source mesh
  26795. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26796. */
  26797. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26798. /**
  26799. * Apply current geometry to a given mesh
  26800. * @param mesh defines the mesh to apply geometry to
  26801. */
  26802. applyToMesh(mesh: Mesh): void;
  26803. private _updateExtend;
  26804. private _applyToMesh;
  26805. private notifyUpdate;
  26806. /**
  26807. * Load the geometry if it was flagged as delay loaded
  26808. * @param scene defines the hosting scene
  26809. * @param onLoaded defines a callback called when the geometry is loaded
  26810. */
  26811. load(scene: Scene, onLoaded?: () => void): void;
  26812. private _queueLoad;
  26813. /**
  26814. * Invert the geometry to move from a right handed system to a left handed one.
  26815. */
  26816. toLeftHanded(): void;
  26817. /** @hidden */
  26818. _resetPointsArrayCache(): void;
  26819. /** @hidden */
  26820. _generatePointsArray(): boolean;
  26821. /**
  26822. * Gets a value indicating if the geometry is disposed
  26823. * @returns true if the geometry was disposed
  26824. */
  26825. isDisposed(): boolean;
  26826. private _disposeVertexArrayObjects;
  26827. /**
  26828. * Free all associated resources
  26829. */
  26830. dispose(): void;
  26831. /**
  26832. * Clone the current geometry into a new geometry
  26833. * @param id defines the unique ID of the new geometry
  26834. * @returns a new geometry object
  26835. */
  26836. copy(id: string): Geometry;
  26837. /**
  26838. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26839. * @return a JSON representation of the current geometry data (without the vertices data)
  26840. */
  26841. serialize(): any;
  26842. private toNumberArray;
  26843. /**
  26844. * Serialize all vertices data into a JSON oject
  26845. * @returns a JSON representation of the current geometry data
  26846. */
  26847. serializeVerticeData(): any;
  26848. /**
  26849. * Extracts a clone of a mesh geometry
  26850. * @param mesh defines the source mesh
  26851. * @param id defines the unique ID of the new geometry object
  26852. * @returns the new geometry object
  26853. */
  26854. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26855. /**
  26856. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26857. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26858. * Be aware Math.random() could cause collisions, but:
  26859. * "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"
  26860. * @returns a string containing a new GUID
  26861. */
  26862. static RandomId(): string;
  26863. /** @hidden */
  26864. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26865. private static _CleanMatricesWeights;
  26866. /**
  26867. * Create a new geometry from persisted data (Using .babylon file format)
  26868. * @param parsedVertexData defines the persisted data
  26869. * @param scene defines the hosting scene
  26870. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26871. * @returns the new geometry object
  26872. */
  26873. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26874. }
  26875. }
  26876. declare module "babylonjs/Meshes/mesh.vertexData" {
  26877. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26879. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26880. import { Geometry } from "babylonjs/Meshes/geometry";
  26881. import { Mesh } from "babylonjs/Meshes/mesh";
  26882. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26883. /**
  26884. * Define an interface for all classes that will get and set the data on vertices
  26885. */
  26886. export interface IGetSetVerticesData {
  26887. /**
  26888. * Gets a boolean indicating if specific vertex data is present
  26889. * @param kind defines the vertex data kind to use
  26890. * @returns true is data kind is present
  26891. */
  26892. isVerticesDataPresent(kind: string): boolean;
  26893. /**
  26894. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26895. * @param kind defines the data kind (Position, normal, etc...)
  26896. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26897. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26898. * @returns a float array containing vertex data
  26899. */
  26900. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26901. /**
  26902. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26903. * @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.
  26904. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26905. * @returns the indices array or an empty array if the mesh has no geometry
  26906. */
  26907. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26908. /**
  26909. * Set specific vertex data
  26910. * @param kind defines the data kind (Position, normal, etc...)
  26911. * @param data defines the vertex data to use
  26912. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26913. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26914. */
  26915. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  26916. /**
  26917. * Update a specific associated vertex buffer
  26918. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  26919. * - VertexBuffer.PositionKind
  26920. * - VertexBuffer.UVKind
  26921. * - VertexBuffer.UV2Kind
  26922. * - VertexBuffer.UV3Kind
  26923. * - VertexBuffer.UV4Kind
  26924. * - VertexBuffer.UV5Kind
  26925. * - VertexBuffer.UV6Kind
  26926. * - VertexBuffer.ColorKind
  26927. * - VertexBuffer.MatricesIndicesKind
  26928. * - VertexBuffer.MatricesIndicesExtraKind
  26929. * - VertexBuffer.MatricesWeightsKind
  26930. * - VertexBuffer.MatricesWeightsExtraKind
  26931. * @param data defines the data source
  26932. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  26933. * @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)
  26934. */
  26935. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  26936. /**
  26937. * Creates a new index buffer
  26938. * @param indices defines the indices to store in the index buffer
  26939. * @param totalVertices defines the total number of vertices (could be null)
  26940. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26941. */
  26942. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  26943. }
  26944. /**
  26945. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  26946. */
  26947. export class VertexData {
  26948. /**
  26949. * Mesh side orientation : usually the external or front surface
  26950. */
  26951. static readonly FRONTSIDE: number;
  26952. /**
  26953. * Mesh side orientation : usually the internal or back surface
  26954. */
  26955. static readonly BACKSIDE: number;
  26956. /**
  26957. * Mesh side orientation : both internal and external or front and back surfaces
  26958. */
  26959. static readonly DOUBLESIDE: number;
  26960. /**
  26961. * Mesh side orientation : by default, `FRONTSIDE`
  26962. */
  26963. static readonly DEFAULTSIDE: number;
  26964. /**
  26965. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  26966. */
  26967. positions: Nullable<FloatArray>;
  26968. /**
  26969. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  26970. */
  26971. normals: Nullable<FloatArray>;
  26972. /**
  26973. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  26974. */
  26975. tangents: Nullable<FloatArray>;
  26976. /**
  26977. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26978. */
  26979. uvs: Nullable<FloatArray>;
  26980. /**
  26981. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26982. */
  26983. uvs2: Nullable<FloatArray>;
  26984. /**
  26985. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26986. */
  26987. uvs3: Nullable<FloatArray>;
  26988. /**
  26989. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26990. */
  26991. uvs4: Nullable<FloatArray>;
  26992. /**
  26993. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26994. */
  26995. uvs5: Nullable<FloatArray>;
  26996. /**
  26997. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  26998. */
  26999. uvs6: Nullable<FloatArray>;
  27000. /**
  27001. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27002. */
  27003. colors: Nullable<FloatArray>;
  27004. /**
  27005. * 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).
  27006. */
  27007. matricesIndices: Nullable<FloatArray>;
  27008. /**
  27009. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27010. */
  27011. matricesWeights: Nullable<FloatArray>;
  27012. /**
  27013. * An array extending the number of possible indices
  27014. */
  27015. matricesIndicesExtra: Nullable<FloatArray>;
  27016. /**
  27017. * An array extending the number of possible weights when the number of indices is extended
  27018. */
  27019. matricesWeightsExtra: Nullable<FloatArray>;
  27020. /**
  27021. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27022. */
  27023. indices: Nullable<IndicesArray>;
  27024. /**
  27025. * Uses the passed data array to set the set the values for the specified kind of data
  27026. * @param data a linear array of floating numbers
  27027. * @param kind the type of data that is being set, eg positions, colors etc
  27028. */
  27029. set(data: FloatArray, kind: string): void;
  27030. /**
  27031. * Associates the vertexData to the passed Mesh.
  27032. * Sets it as updatable or not (default `false`)
  27033. * @param mesh the mesh the vertexData is applied to
  27034. * @param updatable when used and having the value true allows new data to update the vertexData
  27035. * @returns the VertexData
  27036. */
  27037. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27038. /**
  27039. * Associates the vertexData to the passed Geometry.
  27040. * Sets it as updatable or not (default `false`)
  27041. * @param geometry the geometry the vertexData is applied to
  27042. * @param updatable when used and having the value true allows new data to update the vertexData
  27043. * @returns VertexData
  27044. */
  27045. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27046. /**
  27047. * Updates the associated mesh
  27048. * @param mesh the mesh to be updated
  27049. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27050. * @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
  27051. * @returns VertexData
  27052. */
  27053. updateMesh(mesh: Mesh): VertexData;
  27054. /**
  27055. * Updates the associated geometry
  27056. * @param geometry the geometry to be updated
  27057. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27058. * @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
  27059. * @returns VertexData.
  27060. */
  27061. updateGeometry(geometry: Geometry): VertexData;
  27062. private _applyTo;
  27063. private _update;
  27064. /**
  27065. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27066. * @param matrix the transforming matrix
  27067. * @returns the VertexData
  27068. */
  27069. transform(matrix: Matrix): VertexData;
  27070. /**
  27071. * Merges the passed VertexData into the current one
  27072. * @param other the VertexData to be merged into the current one
  27073. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27074. * @returns the modified VertexData
  27075. */
  27076. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27077. private _mergeElement;
  27078. private _validate;
  27079. /**
  27080. * Serializes the VertexData
  27081. * @returns a serialized object
  27082. */
  27083. serialize(): any;
  27084. /**
  27085. * Extracts the vertexData from a mesh
  27086. * @param mesh the mesh from which to extract the VertexData
  27087. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27088. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27089. * @returns the object VertexData associated to the passed mesh
  27090. */
  27091. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27092. /**
  27093. * Extracts the vertexData from the geometry
  27094. * @param geometry the geometry from which to extract the VertexData
  27095. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27096. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27097. * @returns the object VertexData associated to the passed mesh
  27098. */
  27099. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27100. private static _ExtractFrom;
  27101. /**
  27102. * Creates the VertexData for a Ribbon
  27103. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27104. * * pathArray array of paths, each of which an array of successive Vector3
  27105. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27106. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27107. * * 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
  27108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27109. * * 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)
  27110. * * 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)
  27111. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27112. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27113. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27114. * @returns the VertexData of the ribbon
  27115. */
  27116. static CreateRibbon(options: {
  27117. pathArray: Vector3[][];
  27118. closeArray?: boolean;
  27119. closePath?: boolean;
  27120. offset?: number;
  27121. sideOrientation?: number;
  27122. frontUVs?: Vector4;
  27123. backUVs?: Vector4;
  27124. invertUV?: boolean;
  27125. uvs?: Vector2[];
  27126. colors?: Color4[];
  27127. }): VertexData;
  27128. /**
  27129. * Creates the VertexData for a box
  27130. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27131. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27132. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27133. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27134. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27135. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27136. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27137. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27138. * * 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)
  27139. * * 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)
  27140. * @returns the VertexData of the box
  27141. */
  27142. static CreateBox(options: {
  27143. size?: number;
  27144. width?: number;
  27145. height?: number;
  27146. depth?: number;
  27147. faceUV?: Vector4[];
  27148. faceColors?: Color4[];
  27149. sideOrientation?: number;
  27150. frontUVs?: Vector4;
  27151. backUVs?: Vector4;
  27152. }): VertexData;
  27153. /**
  27154. * Creates the VertexData for a tiled box
  27155. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27156. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27157. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27158. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27159. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27160. * @returns the VertexData of the box
  27161. */
  27162. static CreateTiledBox(options: {
  27163. pattern?: number;
  27164. width?: number;
  27165. height?: number;
  27166. depth?: number;
  27167. tileSize?: number;
  27168. tileWidth?: number;
  27169. tileHeight?: number;
  27170. alignHorizontal?: number;
  27171. alignVertical?: number;
  27172. faceUV?: Vector4[];
  27173. faceColors?: Color4[];
  27174. sideOrientation?: number;
  27175. }): VertexData;
  27176. /**
  27177. * Creates the VertexData for a tiled plane
  27178. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27179. * * pattern a limited pattern arrangement depending on the number
  27180. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27181. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27182. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27183. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27184. * * 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)
  27185. * * 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)
  27186. * @returns the VertexData of the tiled plane
  27187. */
  27188. static CreateTiledPlane(options: {
  27189. pattern?: number;
  27190. tileSize?: number;
  27191. tileWidth?: number;
  27192. tileHeight?: number;
  27193. size?: number;
  27194. width?: number;
  27195. height?: number;
  27196. alignHorizontal?: number;
  27197. alignVertical?: number;
  27198. sideOrientation?: number;
  27199. frontUVs?: Vector4;
  27200. backUVs?: Vector4;
  27201. }): VertexData;
  27202. /**
  27203. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27204. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27205. * * segments sets the number of horizontal strips optional, default 32
  27206. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27207. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27208. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27209. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27210. * * 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
  27211. * * 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
  27212. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27213. * * 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)
  27214. * * 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)
  27215. * @returns the VertexData of the ellipsoid
  27216. */
  27217. static CreateSphere(options: {
  27218. segments?: number;
  27219. diameter?: number;
  27220. diameterX?: number;
  27221. diameterY?: number;
  27222. diameterZ?: number;
  27223. arc?: number;
  27224. slice?: number;
  27225. sideOrientation?: number;
  27226. frontUVs?: Vector4;
  27227. backUVs?: Vector4;
  27228. }): VertexData;
  27229. /**
  27230. * Creates the VertexData for a cylinder, cone or prism
  27231. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27232. * * height sets the height (y direction) of the cylinder, optional, default 2
  27233. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27234. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27235. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27236. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27237. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27238. * * 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
  27239. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27240. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27241. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27242. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27243. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27244. * * 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)
  27245. * * 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)
  27246. * @returns the VertexData of the cylinder, cone or prism
  27247. */
  27248. static CreateCylinder(options: {
  27249. height?: number;
  27250. diameterTop?: number;
  27251. diameterBottom?: number;
  27252. diameter?: number;
  27253. tessellation?: number;
  27254. subdivisions?: number;
  27255. arc?: number;
  27256. faceColors?: Color4[];
  27257. faceUV?: Vector4[];
  27258. hasRings?: boolean;
  27259. enclose?: boolean;
  27260. sideOrientation?: number;
  27261. frontUVs?: Vector4;
  27262. backUVs?: Vector4;
  27263. }): VertexData;
  27264. /**
  27265. * Creates the VertexData for a torus
  27266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27267. * * diameter the diameter of the torus, optional default 1
  27268. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27269. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27270. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27271. * * 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)
  27272. * * 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)
  27273. * @returns the VertexData of the torus
  27274. */
  27275. static CreateTorus(options: {
  27276. diameter?: number;
  27277. thickness?: number;
  27278. tessellation?: number;
  27279. sideOrientation?: number;
  27280. frontUVs?: Vector4;
  27281. backUVs?: Vector4;
  27282. }): VertexData;
  27283. /**
  27284. * Creates the VertexData of the LineSystem
  27285. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27286. * - lines an array of lines, each line being an array of successive Vector3
  27287. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27288. * @returns the VertexData of the LineSystem
  27289. */
  27290. static CreateLineSystem(options: {
  27291. lines: Vector3[][];
  27292. colors?: Nullable<Color4[][]>;
  27293. }): VertexData;
  27294. /**
  27295. * Create the VertexData for a DashedLines
  27296. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27297. * - points an array successive Vector3
  27298. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27299. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27300. * - dashNb the intended total number of dashes, optional, default 200
  27301. * @returns the VertexData for the DashedLines
  27302. */
  27303. static CreateDashedLines(options: {
  27304. points: Vector3[];
  27305. dashSize?: number;
  27306. gapSize?: number;
  27307. dashNb?: number;
  27308. }): VertexData;
  27309. /**
  27310. * Creates the VertexData for a Ground
  27311. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27312. * - width the width (x direction) of the ground, optional, default 1
  27313. * - height the height (z direction) of the ground, optional, default 1
  27314. * - subdivisions the number of subdivisions per side, optional, default 1
  27315. * @returns the VertexData of the Ground
  27316. */
  27317. static CreateGround(options: {
  27318. width?: number;
  27319. height?: number;
  27320. subdivisions?: number;
  27321. subdivisionsX?: number;
  27322. subdivisionsY?: number;
  27323. }): VertexData;
  27324. /**
  27325. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27326. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27327. * * xmin the ground minimum X coordinate, optional, default -1
  27328. * * zmin the ground minimum Z coordinate, optional, default -1
  27329. * * xmax the ground maximum X coordinate, optional, default 1
  27330. * * zmax the ground maximum Z coordinate, optional, default 1
  27331. * * 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}
  27332. * * 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}
  27333. * @returns the VertexData of the TiledGround
  27334. */
  27335. static CreateTiledGround(options: {
  27336. xmin: number;
  27337. zmin: number;
  27338. xmax: number;
  27339. zmax: number;
  27340. subdivisions?: {
  27341. w: number;
  27342. h: number;
  27343. };
  27344. precision?: {
  27345. w: number;
  27346. h: number;
  27347. };
  27348. }): VertexData;
  27349. /**
  27350. * Creates the VertexData of the Ground designed from a heightmap
  27351. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27352. * * width the width (x direction) of the ground
  27353. * * height the height (z direction) of the ground
  27354. * * subdivisions the number of subdivisions per side
  27355. * * minHeight the minimum altitude on the ground, optional, default 0
  27356. * * maxHeight the maximum altitude on the ground, optional default 1
  27357. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27358. * * buffer the array holding the image color data
  27359. * * bufferWidth the width of image
  27360. * * bufferHeight the height of image
  27361. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27362. * @returns the VertexData of the Ground designed from a heightmap
  27363. */
  27364. static CreateGroundFromHeightMap(options: {
  27365. width: number;
  27366. height: number;
  27367. subdivisions: number;
  27368. minHeight: number;
  27369. maxHeight: number;
  27370. colorFilter: Color3;
  27371. buffer: Uint8Array;
  27372. bufferWidth: number;
  27373. bufferHeight: number;
  27374. alphaFilter: number;
  27375. }): VertexData;
  27376. /**
  27377. * Creates the VertexData for a Plane
  27378. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27379. * * size sets the width and height of the plane to the value of size, optional default 1
  27380. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27381. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  27382. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27383. * * 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)
  27384. * * 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)
  27385. * @returns the VertexData of the box
  27386. */
  27387. static CreatePlane(options: {
  27388. size?: number;
  27389. width?: number;
  27390. height?: number;
  27391. sideOrientation?: number;
  27392. frontUVs?: Vector4;
  27393. backUVs?: Vector4;
  27394. }): VertexData;
  27395. /**
  27396. * Creates the VertexData of the Disc or regular Polygon
  27397. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27398. * * radius the radius of the disc, optional default 0.5
  27399. * * tessellation the number of polygon sides, optional, default 64
  27400. * * 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
  27401. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27402. * * 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)
  27403. * * 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)
  27404. * @returns the VertexData of the box
  27405. */
  27406. static CreateDisc(options: {
  27407. radius?: number;
  27408. tessellation?: number;
  27409. arc?: number;
  27410. sideOrientation?: number;
  27411. frontUVs?: Vector4;
  27412. backUVs?: Vector4;
  27413. }): VertexData;
  27414. /**
  27415. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27416. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27417. * @param polygon a mesh built from polygonTriangulation.build()
  27418. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27419. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27420. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27421. * @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)
  27422. * @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)
  27423. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27424. * @returns the VertexData of the Polygon
  27425. */
  27426. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27427. /**
  27428. * Creates the VertexData of the IcoSphere
  27429. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27430. * * radius the radius of the IcoSphere, optional default 1
  27431. * * radiusX allows stretching in the x direction, optional, default radius
  27432. * * radiusY allows stretching in the y direction, optional, default radius
  27433. * * radiusZ allows stretching in the z direction, optional, default radius
  27434. * * flat when true creates a flat shaded mesh, optional, default true
  27435. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27437. * * 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)
  27438. * * 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)
  27439. * @returns the VertexData of the IcoSphere
  27440. */
  27441. static CreateIcoSphere(options: {
  27442. radius?: number;
  27443. radiusX?: number;
  27444. radiusY?: number;
  27445. radiusZ?: number;
  27446. flat?: boolean;
  27447. subdivisions?: number;
  27448. sideOrientation?: number;
  27449. frontUVs?: Vector4;
  27450. backUVs?: Vector4;
  27451. }): VertexData;
  27452. /**
  27453. * Creates the VertexData for a Polyhedron
  27454. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27455. * * type provided types are:
  27456. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27457. * * 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)
  27458. * * size the size of the IcoSphere, optional default 1
  27459. * * sizeX allows stretching in the x direction, optional, default size
  27460. * * sizeY allows stretching in the y direction, optional, default size
  27461. * * sizeZ allows stretching in the z direction, optional, default size
  27462. * * 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
  27463. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27464. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27465. * * flat when true creates a flat shaded mesh, optional, default true
  27466. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27468. * * 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)
  27469. * * 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)
  27470. * @returns the VertexData of the Polyhedron
  27471. */
  27472. static CreatePolyhedron(options: {
  27473. type?: number;
  27474. size?: number;
  27475. sizeX?: number;
  27476. sizeY?: number;
  27477. sizeZ?: number;
  27478. custom?: any;
  27479. faceUV?: Vector4[];
  27480. faceColors?: Color4[];
  27481. flat?: boolean;
  27482. sideOrientation?: number;
  27483. frontUVs?: Vector4;
  27484. backUVs?: Vector4;
  27485. }): VertexData;
  27486. /**
  27487. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27488. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27489. * @returns the VertexData of the Capsule
  27490. */
  27491. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27492. /**
  27493. * Creates the VertexData for a TorusKnot
  27494. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27495. * * radius the radius of the torus knot, optional, default 2
  27496. * * tube the thickness of the tube, optional, default 0.5
  27497. * * radialSegments the number of sides on each tube segments, optional, default 32
  27498. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27499. * * p the number of windings around the z axis, optional, default 2
  27500. * * q the number of windings around the x axis, optional, default 3
  27501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27502. * * 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)
  27503. * * 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)
  27504. * @returns the VertexData of the Torus Knot
  27505. */
  27506. static CreateTorusKnot(options: {
  27507. radius?: number;
  27508. tube?: number;
  27509. radialSegments?: number;
  27510. tubularSegments?: number;
  27511. p?: number;
  27512. q?: number;
  27513. sideOrientation?: number;
  27514. frontUVs?: Vector4;
  27515. backUVs?: Vector4;
  27516. }): VertexData;
  27517. /**
  27518. * Compute normals for given positions and indices
  27519. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27520. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27521. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27522. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27523. * * facetNormals : optional array of facet normals (vector3)
  27524. * * facetPositions : optional array of facet positions (vector3)
  27525. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27526. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27527. * * bInfo : optional bounding info, required for facetPartitioning computation
  27528. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27529. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27530. * * useRightHandedSystem: optional boolean to for right handed system computation
  27531. * * depthSort : optional boolean to enable the facet depth sort computation
  27532. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27533. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27534. */
  27535. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27536. facetNormals?: any;
  27537. facetPositions?: any;
  27538. facetPartitioning?: any;
  27539. ratio?: number;
  27540. bInfo?: any;
  27541. bbSize?: Vector3;
  27542. subDiv?: any;
  27543. useRightHandedSystem?: boolean;
  27544. depthSort?: boolean;
  27545. distanceTo?: Vector3;
  27546. depthSortedFacets?: any;
  27547. }): void;
  27548. /** @hidden */
  27549. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27550. /**
  27551. * Applies VertexData created from the imported parameters to the geometry
  27552. * @param parsedVertexData the parsed data from an imported file
  27553. * @param geometry the geometry to apply the VertexData to
  27554. */
  27555. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27556. }
  27557. }
  27558. declare module "babylonjs/Morph/morphTarget" {
  27559. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27560. import { Observable } from "babylonjs/Misc/observable";
  27561. import { Nullable, FloatArray } from "babylonjs/types";
  27562. import { Scene } from "babylonjs/scene";
  27563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27564. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27565. /**
  27566. * Defines a target to use with MorphTargetManager
  27567. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27568. */
  27569. export class MorphTarget implements IAnimatable {
  27570. /** defines the name of the target */
  27571. name: string;
  27572. /**
  27573. * Gets or sets the list of animations
  27574. */
  27575. animations: import("babylonjs/Animations/animation").Animation[];
  27576. private _scene;
  27577. private _positions;
  27578. private _normals;
  27579. private _tangents;
  27580. private _uvs;
  27581. private _influence;
  27582. private _uniqueId;
  27583. /**
  27584. * Observable raised when the influence changes
  27585. */
  27586. onInfluenceChanged: Observable<boolean>;
  27587. /** @hidden */
  27588. _onDataLayoutChanged: Observable<void>;
  27589. /**
  27590. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27591. */
  27592. get influence(): number;
  27593. set influence(influence: number);
  27594. /**
  27595. * Gets or sets the id of the morph Target
  27596. */
  27597. id: string;
  27598. private _animationPropertiesOverride;
  27599. /**
  27600. * Gets or sets the animation properties override
  27601. */
  27602. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27603. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27604. /**
  27605. * Creates a new MorphTarget
  27606. * @param name defines the name of the target
  27607. * @param influence defines the influence to use
  27608. * @param scene defines the scene the morphtarget belongs to
  27609. */
  27610. constructor(
  27611. /** defines the name of the target */
  27612. name: string, influence?: number, scene?: Nullable<Scene>);
  27613. /**
  27614. * Gets the unique ID of this manager
  27615. */
  27616. get uniqueId(): number;
  27617. /**
  27618. * Gets a boolean defining if the target contains position data
  27619. */
  27620. get hasPositions(): boolean;
  27621. /**
  27622. * Gets a boolean defining if the target contains normal data
  27623. */
  27624. get hasNormals(): boolean;
  27625. /**
  27626. * Gets a boolean defining if the target contains tangent data
  27627. */
  27628. get hasTangents(): boolean;
  27629. /**
  27630. * Gets a boolean defining if the target contains texture coordinates data
  27631. */
  27632. get hasUVs(): boolean;
  27633. /**
  27634. * Affects position data to this target
  27635. * @param data defines the position data to use
  27636. */
  27637. setPositions(data: Nullable<FloatArray>): void;
  27638. /**
  27639. * Gets the position data stored in this target
  27640. * @returns a FloatArray containing the position data (or null if not present)
  27641. */
  27642. getPositions(): Nullable<FloatArray>;
  27643. /**
  27644. * Affects normal data to this target
  27645. * @param data defines the normal data to use
  27646. */
  27647. setNormals(data: Nullable<FloatArray>): void;
  27648. /**
  27649. * Gets the normal data stored in this target
  27650. * @returns a FloatArray containing the normal data (or null if not present)
  27651. */
  27652. getNormals(): Nullable<FloatArray>;
  27653. /**
  27654. * Affects tangent data to this target
  27655. * @param data defines the tangent data to use
  27656. */
  27657. setTangents(data: Nullable<FloatArray>): void;
  27658. /**
  27659. * Gets the tangent data stored in this target
  27660. * @returns a FloatArray containing the tangent data (or null if not present)
  27661. */
  27662. getTangents(): Nullable<FloatArray>;
  27663. /**
  27664. * Affects texture coordinates data to this target
  27665. * @param data defines the texture coordinates data to use
  27666. */
  27667. setUVs(data: Nullable<FloatArray>): void;
  27668. /**
  27669. * Gets the texture coordinates data stored in this target
  27670. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27671. */
  27672. getUVs(): Nullable<FloatArray>;
  27673. /**
  27674. * Clone the current target
  27675. * @returns a new MorphTarget
  27676. */
  27677. clone(): MorphTarget;
  27678. /**
  27679. * Serializes the current target into a Serialization object
  27680. * @returns the serialized object
  27681. */
  27682. serialize(): any;
  27683. /**
  27684. * Returns the string "MorphTarget"
  27685. * @returns "MorphTarget"
  27686. */
  27687. getClassName(): string;
  27688. /**
  27689. * Creates a new target from serialized data
  27690. * @param serializationObject defines the serialized data to use
  27691. * @returns a new MorphTarget
  27692. */
  27693. static Parse(serializationObject: any): MorphTarget;
  27694. /**
  27695. * Creates a MorphTarget from mesh data
  27696. * @param mesh defines the source mesh
  27697. * @param name defines the name to use for the new target
  27698. * @param influence defines the influence to attach to the target
  27699. * @returns a new MorphTarget
  27700. */
  27701. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27702. }
  27703. }
  27704. declare module "babylonjs/Morph/morphTargetManager" {
  27705. import { Nullable } from "babylonjs/types";
  27706. import { Scene } from "babylonjs/scene";
  27707. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27708. /**
  27709. * This class is used to deform meshes using morphing between different targets
  27710. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27711. */
  27712. export class MorphTargetManager {
  27713. private _targets;
  27714. private _targetInfluenceChangedObservers;
  27715. private _targetDataLayoutChangedObservers;
  27716. private _activeTargets;
  27717. private _scene;
  27718. private _influences;
  27719. private _supportsNormals;
  27720. private _supportsTangents;
  27721. private _supportsUVs;
  27722. private _vertexCount;
  27723. private _uniqueId;
  27724. private _tempInfluences;
  27725. /**
  27726. * Gets or sets a boolean indicating if normals must be morphed
  27727. */
  27728. enableNormalMorphing: boolean;
  27729. /**
  27730. * Gets or sets a boolean indicating if tangents must be morphed
  27731. */
  27732. enableTangentMorphing: boolean;
  27733. /**
  27734. * Gets or sets a boolean indicating if UV must be morphed
  27735. */
  27736. enableUVMorphing: boolean;
  27737. /**
  27738. * Creates a new MorphTargetManager
  27739. * @param scene defines the current scene
  27740. */
  27741. constructor(scene?: Nullable<Scene>);
  27742. /**
  27743. * Gets the unique ID of this manager
  27744. */
  27745. get uniqueId(): number;
  27746. /**
  27747. * Gets the number of vertices handled by this manager
  27748. */
  27749. get vertexCount(): number;
  27750. /**
  27751. * Gets a boolean indicating if this manager supports morphing of normals
  27752. */
  27753. get supportsNormals(): boolean;
  27754. /**
  27755. * Gets a boolean indicating if this manager supports morphing of tangents
  27756. */
  27757. get supportsTangents(): boolean;
  27758. /**
  27759. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27760. */
  27761. get supportsUVs(): boolean;
  27762. /**
  27763. * Gets the number of targets stored in this manager
  27764. */
  27765. get numTargets(): number;
  27766. /**
  27767. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27768. */
  27769. get numInfluencers(): number;
  27770. /**
  27771. * Gets the list of influences (one per target)
  27772. */
  27773. get influences(): Float32Array;
  27774. /**
  27775. * Gets the active target at specified index. An active target is a target with an influence > 0
  27776. * @param index defines the index to check
  27777. * @returns the requested target
  27778. */
  27779. getActiveTarget(index: number): MorphTarget;
  27780. /**
  27781. * Gets the target at specified index
  27782. * @param index defines the index to check
  27783. * @returns the requested target
  27784. */
  27785. getTarget(index: number): MorphTarget;
  27786. /**
  27787. * Add a new target to this manager
  27788. * @param target defines the target to add
  27789. */
  27790. addTarget(target: MorphTarget): void;
  27791. /**
  27792. * Removes a target from the manager
  27793. * @param target defines the target to remove
  27794. */
  27795. removeTarget(target: MorphTarget): void;
  27796. /**
  27797. * Clone the current manager
  27798. * @returns a new MorphTargetManager
  27799. */
  27800. clone(): MorphTargetManager;
  27801. /**
  27802. * Serializes the current manager into a Serialization object
  27803. * @returns the serialized object
  27804. */
  27805. serialize(): any;
  27806. private _syncActiveTargets;
  27807. /**
  27808. * Syncrhonize the targets with all the meshes using this morph target manager
  27809. */
  27810. synchronize(): void;
  27811. /**
  27812. * Creates a new MorphTargetManager from serialized data
  27813. * @param serializationObject defines the serialized data
  27814. * @param scene defines the hosting scene
  27815. * @returns the new MorphTargetManager
  27816. */
  27817. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27818. }
  27819. }
  27820. declare module "babylonjs/Meshes/meshLODLevel" {
  27821. import { Mesh } from "babylonjs/Meshes/mesh";
  27822. import { Nullable } from "babylonjs/types";
  27823. /**
  27824. * Class used to represent a specific level of detail of a mesh
  27825. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27826. */
  27827. export class MeshLODLevel {
  27828. /** Defines the distance where this level should start being displayed */
  27829. distance: number;
  27830. /** Defines the mesh to use to render this level */
  27831. mesh: Nullable<Mesh>;
  27832. /**
  27833. * Creates a new LOD level
  27834. * @param distance defines the distance where this level should star being displayed
  27835. * @param mesh defines the mesh to use to render this level
  27836. */
  27837. constructor(
  27838. /** Defines the distance where this level should start being displayed */
  27839. distance: number,
  27840. /** Defines the mesh to use to render this level */
  27841. mesh: Nullable<Mesh>);
  27842. }
  27843. }
  27844. declare module "babylonjs/Misc/canvasGenerator" {
  27845. /**
  27846. * Helper class used to generate a canvas to manipulate images
  27847. */
  27848. export class CanvasGenerator {
  27849. /**
  27850. * Create a new canvas (or offscreen canvas depending on the context)
  27851. * @param width defines the expected width
  27852. * @param height defines the expected height
  27853. * @return a new canvas or offscreen canvas
  27854. */
  27855. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27856. }
  27857. }
  27858. declare module "babylonjs/Meshes/groundMesh" {
  27859. import { Scene } from "babylonjs/scene";
  27860. import { Vector3 } from "babylonjs/Maths/math.vector";
  27861. import { Mesh } from "babylonjs/Meshes/mesh";
  27862. /**
  27863. * Mesh representing the gorund
  27864. */
  27865. export class GroundMesh extends Mesh {
  27866. /** If octree should be generated */
  27867. generateOctree: boolean;
  27868. private _heightQuads;
  27869. /** @hidden */
  27870. _subdivisionsX: number;
  27871. /** @hidden */
  27872. _subdivisionsY: number;
  27873. /** @hidden */
  27874. _width: number;
  27875. /** @hidden */
  27876. _height: number;
  27877. /** @hidden */
  27878. _minX: number;
  27879. /** @hidden */
  27880. _maxX: number;
  27881. /** @hidden */
  27882. _minZ: number;
  27883. /** @hidden */
  27884. _maxZ: number;
  27885. constructor(name: string, scene: Scene);
  27886. /**
  27887. * "GroundMesh"
  27888. * @returns "GroundMesh"
  27889. */
  27890. getClassName(): string;
  27891. /**
  27892. * The minimum of x and y subdivisions
  27893. */
  27894. get subdivisions(): number;
  27895. /**
  27896. * X subdivisions
  27897. */
  27898. get subdivisionsX(): number;
  27899. /**
  27900. * Y subdivisions
  27901. */
  27902. get subdivisionsY(): number;
  27903. /**
  27904. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27905. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27906. * @param chunksCount the number of subdivisions for x and y
  27907. * @param octreeBlocksSize (Default: 32)
  27908. */
  27909. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27910. /**
  27911. * Returns a height (y) value in the Worl system :
  27912. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27913. * @param x x coordinate
  27914. * @param z z coordinate
  27915. * @returns the ground y position if (x, z) are outside the ground surface.
  27916. */
  27917. getHeightAtCoordinates(x: number, z: number): number;
  27918. /**
  27919. * Returns a normalized vector (Vector3) orthogonal to the ground
  27920. * at the ground coordinates (x, z) expressed in the World system.
  27921. * @param x x coordinate
  27922. * @param z z coordinate
  27923. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  27924. */
  27925. getNormalAtCoordinates(x: number, z: number): Vector3;
  27926. /**
  27927. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  27928. * at the ground coordinates (x, z) expressed in the World system.
  27929. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  27930. * @param x x coordinate
  27931. * @param z z coordinate
  27932. * @param ref vector to store the result
  27933. * @returns the GroundMesh.
  27934. */
  27935. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  27936. /**
  27937. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  27938. * if the ground has been updated.
  27939. * This can be used in the render loop.
  27940. * @returns the GroundMesh.
  27941. */
  27942. updateCoordinateHeights(): GroundMesh;
  27943. private _getFacetAt;
  27944. private _initHeightQuads;
  27945. private _computeHeightQuads;
  27946. /**
  27947. * Serializes this ground mesh
  27948. * @param serializationObject object to write serialization to
  27949. */
  27950. serialize(serializationObject: any): void;
  27951. /**
  27952. * Parses a serialized ground mesh
  27953. * @param parsedMesh the serialized mesh
  27954. * @param scene the scene to create the ground mesh in
  27955. * @returns the created ground mesh
  27956. */
  27957. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  27958. }
  27959. }
  27960. declare module "babylonjs/Physics/physicsJoint" {
  27961. import { Vector3 } from "babylonjs/Maths/math.vector";
  27962. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  27963. /**
  27964. * Interface for Physics-Joint data
  27965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27966. */
  27967. export interface PhysicsJointData {
  27968. /**
  27969. * The main pivot of the joint
  27970. */
  27971. mainPivot?: Vector3;
  27972. /**
  27973. * The connected pivot of the joint
  27974. */
  27975. connectedPivot?: Vector3;
  27976. /**
  27977. * The main axis of the joint
  27978. */
  27979. mainAxis?: Vector3;
  27980. /**
  27981. * The connected axis of the joint
  27982. */
  27983. connectedAxis?: Vector3;
  27984. /**
  27985. * The collision of the joint
  27986. */
  27987. collision?: boolean;
  27988. /**
  27989. * Native Oimo/Cannon/Energy data
  27990. */
  27991. nativeParams?: any;
  27992. }
  27993. /**
  27994. * This is a holder class for the physics joint created by the physics plugin
  27995. * It holds a set of functions to control the underlying joint
  27996. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  27997. */
  27998. export class PhysicsJoint {
  27999. /**
  28000. * The type of the physics joint
  28001. */
  28002. type: number;
  28003. /**
  28004. * The data for the physics joint
  28005. */
  28006. jointData: PhysicsJointData;
  28007. private _physicsJoint;
  28008. protected _physicsPlugin: IPhysicsEnginePlugin;
  28009. /**
  28010. * Initializes the physics joint
  28011. * @param type The type of the physics joint
  28012. * @param jointData The data for the physics joint
  28013. */
  28014. constructor(
  28015. /**
  28016. * The type of the physics joint
  28017. */
  28018. type: number,
  28019. /**
  28020. * The data for the physics joint
  28021. */
  28022. jointData: PhysicsJointData);
  28023. /**
  28024. * Gets the physics joint
  28025. */
  28026. get physicsJoint(): any;
  28027. /**
  28028. * Sets the physics joint
  28029. */
  28030. set physicsJoint(newJoint: any);
  28031. /**
  28032. * Sets the physics plugin
  28033. */
  28034. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28035. /**
  28036. * Execute a function that is physics-plugin specific.
  28037. * @param {Function} func the function that will be executed.
  28038. * It accepts two parameters: the physics world and the physics joint
  28039. */
  28040. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28041. /**
  28042. * Distance-Joint type
  28043. */
  28044. static DistanceJoint: number;
  28045. /**
  28046. * Hinge-Joint type
  28047. */
  28048. static HingeJoint: number;
  28049. /**
  28050. * Ball-and-Socket joint type
  28051. */
  28052. static BallAndSocketJoint: number;
  28053. /**
  28054. * Wheel-Joint type
  28055. */
  28056. static WheelJoint: number;
  28057. /**
  28058. * Slider-Joint type
  28059. */
  28060. static SliderJoint: number;
  28061. /**
  28062. * Prismatic-Joint type
  28063. */
  28064. static PrismaticJoint: number;
  28065. /**
  28066. * Universal-Joint type
  28067. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28068. */
  28069. static UniversalJoint: number;
  28070. /**
  28071. * Hinge-Joint 2 type
  28072. */
  28073. static Hinge2Joint: number;
  28074. /**
  28075. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28076. */
  28077. static PointToPointJoint: number;
  28078. /**
  28079. * Spring-Joint type
  28080. */
  28081. static SpringJoint: number;
  28082. /**
  28083. * Lock-Joint type
  28084. */
  28085. static LockJoint: number;
  28086. }
  28087. /**
  28088. * A class representing a physics distance joint
  28089. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28090. */
  28091. export class DistanceJoint extends PhysicsJoint {
  28092. /**
  28093. *
  28094. * @param jointData The data for the Distance-Joint
  28095. */
  28096. constructor(jointData: DistanceJointData);
  28097. /**
  28098. * Update the predefined distance.
  28099. * @param maxDistance The maximum preferred distance
  28100. * @param minDistance The minimum preferred distance
  28101. */
  28102. updateDistance(maxDistance: number, minDistance?: number): void;
  28103. }
  28104. /**
  28105. * Represents a Motor-Enabled Joint
  28106. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28107. */
  28108. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28109. /**
  28110. * Initializes the Motor-Enabled Joint
  28111. * @param type The type of the joint
  28112. * @param jointData The physica joint data for the joint
  28113. */
  28114. constructor(type: number, jointData: PhysicsJointData);
  28115. /**
  28116. * Set the motor values.
  28117. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28118. * @param force the force to apply
  28119. * @param maxForce max force for this motor.
  28120. */
  28121. setMotor(force?: number, maxForce?: number): void;
  28122. /**
  28123. * Set the motor's limits.
  28124. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28125. * @param upperLimit The upper limit of the motor
  28126. * @param lowerLimit The lower limit of the motor
  28127. */
  28128. setLimit(upperLimit: number, lowerLimit?: number): void;
  28129. }
  28130. /**
  28131. * This class represents a single physics Hinge-Joint
  28132. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28133. */
  28134. export class HingeJoint extends MotorEnabledJoint {
  28135. /**
  28136. * Initializes the Hinge-Joint
  28137. * @param jointData The joint data for the Hinge-Joint
  28138. */
  28139. constructor(jointData: PhysicsJointData);
  28140. /**
  28141. * Set the motor values.
  28142. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28143. * @param {number} force the force to apply
  28144. * @param {number} maxForce max force for this motor.
  28145. */
  28146. setMotor(force?: number, maxForce?: number): void;
  28147. /**
  28148. * Set the motor's limits.
  28149. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28150. * @param upperLimit The upper limit of the motor
  28151. * @param lowerLimit The lower limit of the motor
  28152. */
  28153. setLimit(upperLimit: number, lowerLimit?: number): void;
  28154. }
  28155. /**
  28156. * This class represents a dual hinge physics joint (same as wheel joint)
  28157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28158. */
  28159. export class Hinge2Joint extends MotorEnabledJoint {
  28160. /**
  28161. * Initializes the Hinge2-Joint
  28162. * @param jointData The joint data for the Hinge2-Joint
  28163. */
  28164. constructor(jointData: PhysicsJointData);
  28165. /**
  28166. * Set the motor values.
  28167. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28168. * @param {number} targetSpeed the speed the motor is to reach
  28169. * @param {number} maxForce max force for this motor.
  28170. * @param {motorIndex} the motor's index, 0 or 1.
  28171. */
  28172. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28173. /**
  28174. * Set the motor limits.
  28175. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28176. * @param {number} upperLimit the upper limit
  28177. * @param {number} lowerLimit lower limit
  28178. * @param {motorIndex} the motor's index, 0 or 1.
  28179. */
  28180. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28181. }
  28182. /**
  28183. * Interface for a motor enabled joint
  28184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28185. */
  28186. export interface IMotorEnabledJoint {
  28187. /**
  28188. * Physics joint
  28189. */
  28190. physicsJoint: any;
  28191. /**
  28192. * Sets the motor of the motor-enabled joint
  28193. * @param force The force of the motor
  28194. * @param maxForce The maximum force of the motor
  28195. * @param motorIndex The index of the motor
  28196. */
  28197. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28198. /**
  28199. * Sets the limit of the motor
  28200. * @param upperLimit The upper limit of the motor
  28201. * @param lowerLimit The lower limit of the motor
  28202. * @param motorIndex The index of the motor
  28203. */
  28204. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28205. }
  28206. /**
  28207. * Joint data for a Distance-Joint
  28208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28209. */
  28210. export interface DistanceJointData extends PhysicsJointData {
  28211. /**
  28212. * Max distance the 2 joint objects can be apart
  28213. */
  28214. maxDistance: number;
  28215. }
  28216. /**
  28217. * Joint data from a spring joint
  28218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28219. */
  28220. export interface SpringJointData extends PhysicsJointData {
  28221. /**
  28222. * Length of the spring
  28223. */
  28224. length: number;
  28225. /**
  28226. * Stiffness of the spring
  28227. */
  28228. stiffness: number;
  28229. /**
  28230. * Damping of the spring
  28231. */
  28232. damping: number;
  28233. /** this callback will be called when applying the force to the impostors. */
  28234. forceApplicationCallback: () => void;
  28235. }
  28236. }
  28237. declare module "babylonjs/Physics/physicsRaycastResult" {
  28238. import { Vector3 } from "babylonjs/Maths/math.vector";
  28239. /**
  28240. * Holds the data for the raycast result
  28241. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28242. */
  28243. export class PhysicsRaycastResult {
  28244. private _hasHit;
  28245. private _hitDistance;
  28246. private _hitNormalWorld;
  28247. private _hitPointWorld;
  28248. private _rayFromWorld;
  28249. private _rayToWorld;
  28250. /**
  28251. * Gets if there was a hit
  28252. */
  28253. get hasHit(): boolean;
  28254. /**
  28255. * Gets the distance from the hit
  28256. */
  28257. get hitDistance(): number;
  28258. /**
  28259. * Gets the hit normal/direction in the world
  28260. */
  28261. get hitNormalWorld(): Vector3;
  28262. /**
  28263. * Gets the hit point in the world
  28264. */
  28265. get hitPointWorld(): Vector3;
  28266. /**
  28267. * Gets the ray "start point" of the ray in the world
  28268. */
  28269. get rayFromWorld(): Vector3;
  28270. /**
  28271. * Gets the ray "end point" of the ray in the world
  28272. */
  28273. get rayToWorld(): Vector3;
  28274. /**
  28275. * Sets the hit data (normal & point in world space)
  28276. * @param hitNormalWorld defines the normal in world space
  28277. * @param hitPointWorld defines the point in world space
  28278. */
  28279. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28280. /**
  28281. * Sets the distance from the start point to the hit point
  28282. * @param distance
  28283. */
  28284. setHitDistance(distance: number): void;
  28285. /**
  28286. * Calculates the distance manually
  28287. */
  28288. calculateHitDistance(): void;
  28289. /**
  28290. * Resets all the values to default
  28291. * @param from The from point on world space
  28292. * @param to The to point on world space
  28293. */
  28294. reset(from?: Vector3, to?: Vector3): void;
  28295. }
  28296. /**
  28297. * Interface for the size containing width and height
  28298. */
  28299. interface IXYZ {
  28300. /**
  28301. * X
  28302. */
  28303. x: number;
  28304. /**
  28305. * Y
  28306. */
  28307. y: number;
  28308. /**
  28309. * Z
  28310. */
  28311. z: number;
  28312. }
  28313. }
  28314. declare module "babylonjs/Physics/IPhysicsEngine" {
  28315. import { Nullable } from "babylonjs/types";
  28316. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28318. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28319. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28321. /**
  28322. * Interface used to describe a physics joint
  28323. */
  28324. export interface PhysicsImpostorJoint {
  28325. /** Defines the main impostor to which the joint is linked */
  28326. mainImpostor: PhysicsImpostor;
  28327. /** Defines the impostor that is connected to the main impostor using this joint */
  28328. connectedImpostor: PhysicsImpostor;
  28329. /** Defines the joint itself */
  28330. joint: PhysicsJoint;
  28331. }
  28332. /** @hidden */
  28333. export interface IPhysicsEnginePlugin {
  28334. world: any;
  28335. name: string;
  28336. setGravity(gravity: Vector3): void;
  28337. setTimeStep(timeStep: number): void;
  28338. getTimeStep(): number;
  28339. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28340. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28341. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28342. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28343. removePhysicsBody(impostor: PhysicsImpostor): void;
  28344. generateJoint(joint: PhysicsImpostorJoint): void;
  28345. removeJoint(joint: PhysicsImpostorJoint): void;
  28346. isSupported(): boolean;
  28347. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28348. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28349. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28350. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28351. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28352. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28353. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28354. getBodyMass(impostor: PhysicsImpostor): number;
  28355. getBodyFriction(impostor: PhysicsImpostor): number;
  28356. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28357. getBodyRestitution(impostor: PhysicsImpostor): number;
  28358. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28359. getBodyPressure?(impostor: PhysicsImpostor): number;
  28360. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28361. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28362. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28363. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28364. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28365. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28366. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28367. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28368. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28369. sleepBody(impostor: PhysicsImpostor): void;
  28370. wakeUpBody(impostor: PhysicsImpostor): void;
  28371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28372. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28373. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28374. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28375. getRadius(impostor: PhysicsImpostor): number;
  28376. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28377. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28378. dispose(): void;
  28379. }
  28380. /**
  28381. * Interface used to define a physics engine
  28382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28383. */
  28384. export interface IPhysicsEngine {
  28385. /**
  28386. * Gets the gravity vector used by the simulation
  28387. */
  28388. gravity: Vector3;
  28389. /**
  28390. * Sets the gravity vector used by the simulation
  28391. * @param gravity defines the gravity vector to use
  28392. */
  28393. setGravity(gravity: Vector3): void;
  28394. /**
  28395. * Set the time step of the physics engine.
  28396. * Default is 1/60.
  28397. * To slow it down, enter 1/600 for example.
  28398. * To speed it up, 1/30
  28399. * @param newTimeStep the new timestep to apply to this world.
  28400. */
  28401. setTimeStep(newTimeStep: number): void;
  28402. /**
  28403. * Get the time step of the physics engine.
  28404. * @returns the current time step
  28405. */
  28406. getTimeStep(): number;
  28407. /**
  28408. * Set the sub time step of the physics engine.
  28409. * Default is 0 meaning there is no sub steps
  28410. * To increase physics resolution precision, set a small value (like 1 ms)
  28411. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28412. */
  28413. setSubTimeStep(subTimeStep: number): void;
  28414. /**
  28415. * Get the sub time step of the physics engine.
  28416. * @returns the current sub time step
  28417. */
  28418. getSubTimeStep(): number;
  28419. /**
  28420. * Release all resources
  28421. */
  28422. dispose(): void;
  28423. /**
  28424. * Gets the name of the current physics plugin
  28425. * @returns the name of the plugin
  28426. */
  28427. getPhysicsPluginName(): string;
  28428. /**
  28429. * Adding a new impostor for the impostor tracking.
  28430. * This will be done by the impostor itself.
  28431. * @param impostor the impostor to add
  28432. */
  28433. addImpostor(impostor: PhysicsImpostor): void;
  28434. /**
  28435. * Remove an impostor from the engine.
  28436. * This impostor and its mesh will not longer be updated by the physics engine.
  28437. * @param impostor the impostor to remove
  28438. */
  28439. removeImpostor(impostor: PhysicsImpostor): void;
  28440. /**
  28441. * Add a joint to the physics engine
  28442. * @param mainImpostor defines the main impostor to which the joint is added.
  28443. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28444. * @param joint defines the joint that will connect both impostors.
  28445. */
  28446. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28447. /**
  28448. * Removes a joint from the simulation
  28449. * @param mainImpostor defines the impostor used with the joint
  28450. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28451. * @param joint defines the joint to remove
  28452. */
  28453. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28454. /**
  28455. * Gets the current plugin used to run the simulation
  28456. * @returns current plugin
  28457. */
  28458. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28459. /**
  28460. * Gets the list of physic impostors
  28461. * @returns an array of PhysicsImpostor
  28462. */
  28463. getImpostors(): Array<PhysicsImpostor>;
  28464. /**
  28465. * Gets the impostor for a physics enabled object
  28466. * @param object defines the object impersonated by the impostor
  28467. * @returns the PhysicsImpostor or null if not found
  28468. */
  28469. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28470. /**
  28471. * Gets the impostor for a physics body object
  28472. * @param body defines physics body used by the impostor
  28473. * @returns the PhysicsImpostor or null if not found
  28474. */
  28475. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28476. /**
  28477. * Does a raycast in the physics world
  28478. * @param from when should the ray start?
  28479. * @param to when should the ray end?
  28480. * @returns PhysicsRaycastResult
  28481. */
  28482. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28483. /**
  28484. * Called by the scene. No need to call it.
  28485. * @param delta defines the timespam between frames
  28486. */
  28487. _step(delta: number): void;
  28488. }
  28489. }
  28490. declare module "babylonjs/Physics/physicsImpostor" {
  28491. import { Nullable, IndicesArray } from "babylonjs/types";
  28492. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28493. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28494. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28495. import { Scene } from "babylonjs/scene";
  28496. import { Bone } from "babylonjs/Bones/bone";
  28497. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28498. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28499. import { Space } from "babylonjs/Maths/math.axis";
  28500. /**
  28501. * The interface for the physics imposter parameters
  28502. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28503. */
  28504. export interface PhysicsImpostorParameters {
  28505. /**
  28506. * The mass of the physics imposter
  28507. */
  28508. mass: number;
  28509. /**
  28510. * The friction of the physics imposter
  28511. */
  28512. friction?: number;
  28513. /**
  28514. * The coefficient of restitution of the physics imposter
  28515. */
  28516. restitution?: number;
  28517. /**
  28518. * The native options of the physics imposter
  28519. */
  28520. nativeOptions?: any;
  28521. /**
  28522. * Specifies if the parent should be ignored
  28523. */
  28524. ignoreParent?: boolean;
  28525. /**
  28526. * Specifies if bi-directional transformations should be disabled
  28527. */
  28528. disableBidirectionalTransformation?: boolean;
  28529. /**
  28530. * The pressure inside the physics imposter, soft object only
  28531. */
  28532. pressure?: number;
  28533. /**
  28534. * The stiffness the physics imposter, soft object only
  28535. */
  28536. stiffness?: number;
  28537. /**
  28538. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28539. */
  28540. velocityIterations?: number;
  28541. /**
  28542. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28543. */
  28544. positionIterations?: number;
  28545. /**
  28546. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28547. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28548. * Add to fix multiple points
  28549. */
  28550. fixedPoints?: number;
  28551. /**
  28552. * The collision margin around a soft object
  28553. */
  28554. margin?: number;
  28555. /**
  28556. * The collision margin around a soft object
  28557. */
  28558. damping?: number;
  28559. /**
  28560. * The path for a rope based on an extrusion
  28561. */
  28562. path?: any;
  28563. /**
  28564. * The shape of an extrusion used for a rope based on an extrusion
  28565. */
  28566. shape?: any;
  28567. }
  28568. /**
  28569. * Interface for a physics-enabled object
  28570. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28571. */
  28572. export interface IPhysicsEnabledObject {
  28573. /**
  28574. * The position of the physics-enabled object
  28575. */
  28576. position: Vector3;
  28577. /**
  28578. * The rotation of the physics-enabled object
  28579. */
  28580. rotationQuaternion: Nullable<Quaternion>;
  28581. /**
  28582. * The scale of the physics-enabled object
  28583. */
  28584. scaling: Vector3;
  28585. /**
  28586. * The rotation of the physics-enabled object
  28587. */
  28588. rotation?: Vector3;
  28589. /**
  28590. * The parent of the physics-enabled object
  28591. */
  28592. parent?: any;
  28593. /**
  28594. * The bounding info of the physics-enabled object
  28595. * @returns The bounding info of the physics-enabled object
  28596. */
  28597. getBoundingInfo(): BoundingInfo;
  28598. /**
  28599. * Computes the world matrix
  28600. * @param force Specifies if the world matrix should be computed by force
  28601. * @returns A world matrix
  28602. */
  28603. computeWorldMatrix(force: boolean): Matrix;
  28604. /**
  28605. * Gets the world matrix
  28606. * @returns A world matrix
  28607. */
  28608. getWorldMatrix?(): Matrix;
  28609. /**
  28610. * Gets the child meshes
  28611. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28612. * @returns An array of abstract meshes
  28613. */
  28614. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28615. /**
  28616. * Gets the vertex data
  28617. * @param kind The type of vertex data
  28618. * @returns A nullable array of numbers, or a float32 array
  28619. */
  28620. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28621. /**
  28622. * Gets the indices from the mesh
  28623. * @returns A nullable array of index arrays
  28624. */
  28625. getIndices?(): Nullable<IndicesArray>;
  28626. /**
  28627. * Gets the scene from the mesh
  28628. * @returns the indices array or null
  28629. */
  28630. getScene?(): Scene;
  28631. /**
  28632. * Gets the absolute position from the mesh
  28633. * @returns the absolute position
  28634. */
  28635. getAbsolutePosition(): Vector3;
  28636. /**
  28637. * Gets the absolute pivot point from the mesh
  28638. * @returns the absolute pivot point
  28639. */
  28640. getAbsolutePivotPoint(): Vector3;
  28641. /**
  28642. * Rotates the mesh
  28643. * @param axis The axis of rotation
  28644. * @param amount The amount of rotation
  28645. * @param space The space of the rotation
  28646. * @returns The rotation transform node
  28647. */
  28648. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28649. /**
  28650. * Translates the mesh
  28651. * @param axis The axis of translation
  28652. * @param distance The distance of translation
  28653. * @param space The space of the translation
  28654. * @returns The transform node
  28655. */
  28656. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28657. /**
  28658. * Sets the absolute position of the mesh
  28659. * @param absolutePosition The absolute position of the mesh
  28660. * @returns The transform node
  28661. */
  28662. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28663. /**
  28664. * Gets the class name of the mesh
  28665. * @returns The class name
  28666. */
  28667. getClassName(): string;
  28668. }
  28669. /**
  28670. * Represents a physics imposter
  28671. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28672. */
  28673. export class PhysicsImpostor {
  28674. /**
  28675. * The physics-enabled object used as the physics imposter
  28676. */
  28677. object: IPhysicsEnabledObject;
  28678. /**
  28679. * The type of the physics imposter
  28680. */
  28681. type: number;
  28682. private _options;
  28683. private _scene?;
  28684. /**
  28685. * The default object size of the imposter
  28686. */
  28687. static DEFAULT_OBJECT_SIZE: Vector3;
  28688. /**
  28689. * The identity quaternion of the imposter
  28690. */
  28691. static IDENTITY_QUATERNION: Quaternion;
  28692. /** @hidden */
  28693. _pluginData: any;
  28694. private _physicsEngine;
  28695. private _physicsBody;
  28696. private _bodyUpdateRequired;
  28697. private _onBeforePhysicsStepCallbacks;
  28698. private _onAfterPhysicsStepCallbacks;
  28699. /** @hidden */
  28700. _onPhysicsCollideCallbacks: Array<{
  28701. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28702. otherImpostors: Array<PhysicsImpostor>;
  28703. }>;
  28704. private _deltaPosition;
  28705. private _deltaRotation;
  28706. private _deltaRotationConjugated;
  28707. /** @hidden */
  28708. _isFromLine: boolean;
  28709. private _parent;
  28710. private _isDisposed;
  28711. private static _tmpVecs;
  28712. private static _tmpQuat;
  28713. /**
  28714. * Specifies if the physics imposter is disposed
  28715. */
  28716. get isDisposed(): boolean;
  28717. /**
  28718. * Gets the mass of the physics imposter
  28719. */
  28720. get mass(): number;
  28721. set mass(value: number);
  28722. /**
  28723. * Gets the coefficient of friction
  28724. */
  28725. get friction(): number;
  28726. /**
  28727. * Sets the coefficient of friction
  28728. */
  28729. set friction(value: number);
  28730. /**
  28731. * Gets the coefficient of restitution
  28732. */
  28733. get restitution(): number;
  28734. /**
  28735. * Sets the coefficient of restitution
  28736. */
  28737. set restitution(value: number);
  28738. /**
  28739. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28740. */
  28741. get pressure(): number;
  28742. /**
  28743. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28744. */
  28745. set pressure(value: number);
  28746. /**
  28747. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28748. */
  28749. get stiffness(): number;
  28750. /**
  28751. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28752. */
  28753. set stiffness(value: number);
  28754. /**
  28755. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28756. */
  28757. get velocityIterations(): number;
  28758. /**
  28759. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28760. */
  28761. set velocityIterations(value: number);
  28762. /**
  28763. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28764. */
  28765. get positionIterations(): number;
  28766. /**
  28767. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28768. */
  28769. set positionIterations(value: number);
  28770. /**
  28771. * The unique id of the physics imposter
  28772. * set by the physics engine when adding this impostor to the array
  28773. */
  28774. uniqueId: number;
  28775. /**
  28776. * @hidden
  28777. */
  28778. soft: boolean;
  28779. /**
  28780. * @hidden
  28781. */
  28782. segments: number;
  28783. private _joints;
  28784. /**
  28785. * Initializes the physics imposter
  28786. * @param object The physics-enabled object used as the physics imposter
  28787. * @param type The type of the physics imposter
  28788. * @param _options The options for the physics imposter
  28789. * @param _scene The Babylon scene
  28790. */
  28791. constructor(
  28792. /**
  28793. * The physics-enabled object used as the physics imposter
  28794. */
  28795. object: IPhysicsEnabledObject,
  28796. /**
  28797. * The type of the physics imposter
  28798. */
  28799. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28800. /**
  28801. * This function will completly initialize this impostor.
  28802. * It will create a new body - but only if this mesh has no parent.
  28803. * If it has, this impostor will not be used other than to define the impostor
  28804. * of the child mesh.
  28805. * @hidden
  28806. */
  28807. _init(): void;
  28808. private _getPhysicsParent;
  28809. /**
  28810. * Should a new body be generated.
  28811. * @returns boolean specifying if body initialization is required
  28812. */
  28813. isBodyInitRequired(): boolean;
  28814. /**
  28815. * Sets the updated scaling
  28816. * @param updated Specifies if the scaling is updated
  28817. */
  28818. setScalingUpdated(): void;
  28819. /**
  28820. * Force a regeneration of this or the parent's impostor's body.
  28821. * Use under cautious - This will remove all joints already implemented.
  28822. */
  28823. forceUpdate(): void;
  28824. /**
  28825. * Gets the body that holds this impostor. Either its own, or its parent.
  28826. */
  28827. get physicsBody(): any;
  28828. /**
  28829. * Get the parent of the physics imposter
  28830. * @returns Physics imposter or null
  28831. */
  28832. get parent(): Nullable<PhysicsImpostor>;
  28833. /**
  28834. * Sets the parent of the physics imposter
  28835. */
  28836. set parent(value: Nullable<PhysicsImpostor>);
  28837. /**
  28838. * Set the physics body. Used mainly by the physics engine/plugin
  28839. */
  28840. set physicsBody(physicsBody: any);
  28841. /**
  28842. * Resets the update flags
  28843. */
  28844. resetUpdateFlags(): void;
  28845. /**
  28846. * Gets the object extend size
  28847. * @returns the object extend size
  28848. */
  28849. getObjectExtendSize(): Vector3;
  28850. /**
  28851. * Gets the object center
  28852. * @returns The object center
  28853. */
  28854. getObjectCenter(): Vector3;
  28855. /**
  28856. * Get a specific parameter from the options parameters
  28857. * @param paramName The object parameter name
  28858. * @returns The object parameter
  28859. */
  28860. getParam(paramName: string): any;
  28861. /**
  28862. * Sets a specific parameter in the options given to the physics plugin
  28863. * @param paramName The parameter name
  28864. * @param value The value of the parameter
  28865. */
  28866. setParam(paramName: string, value: number): void;
  28867. /**
  28868. * Specifically change the body's mass option. Won't recreate the physics body object
  28869. * @param mass The mass of the physics imposter
  28870. */
  28871. setMass(mass: number): void;
  28872. /**
  28873. * Gets the linear velocity
  28874. * @returns linear velocity or null
  28875. */
  28876. getLinearVelocity(): Nullable<Vector3>;
  28877. /**
  28878. * Sets the linear velocity
  28879. * @param velocity linear velocity or null
  28880. */
  28881. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28882. /**
  28883. * Gets the angular velocity
  28884. * @returns angular velocity or null
  28885. */
  28886. getAngularVelocity(): Nullable<Vector3>;
  28887. /**
  28888. * Sets the angular velocity
  28889. * @param velocity The velocity or null
  28890. */
  28891. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28892. /**
  28893. * Execute a function with the physics plugin native code
  28894. * Provide a function the will have two variables - the world object and the physics body object
  28895. * @param func The function to execute with the physics plugin native code
  28896. */
  28897. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28898. /**
  28899. * Register a function that will be executed before the physics world is stepping forward
  28900. * @param func The function to execute before the physics world is stepped forward
  28901. */
  28902. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28903. /**
  28904. * Unregister a function that will be executed before the physics world is stepping forward
  28905. * @param func The function to execute before the physics world is stepped forward
  28906. */
  28907. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28908. /**
  28909. * Register a function that will be executed after the physics step
  28910. * @param func The function to execute after physics step
  28911. */
  28912. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28913. /**
  28914. * Unregisters a function that will be executed after the physics step
  28915. * @param func The function to execute after physics step
  28916. */
  28917. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28918. /**
  28919. * register a function that will be executed when this impostor collides against a different body
  28920. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  28921. * @param func Callback that is executed on collision
  28922. */
  28923. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  28924. /**
  28925. * Unregisters the physics imposter on contact
  28926. * @param collideAgainst The physics object to collide against
  28927. * @param func Callback to execute on collision
  28928. */
  28929. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  28930. private _tmpQuat;
  28931. private _tmpQuat2;
  28932. /**
  28933. * Get the parent rotation
  28934. * @returns The parent rotation
  28935. */
  28936. getParentsRotation(): Quaternion;
  28937. /**
  28938. * this function is executed by the physics engine.
  28939. */
  28940. beforeStep: () => void;
  28941. /**
  28942. * this function is executed by the physics engine
  28943. */
  28944. afterStep: () => void;
  28945. /**
  28946. * Legacy collision detection event support
  28947. */
  28948. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  28949. /**
  28950. * event and body object due to cannon's event-based architecture.
  28951. */
  28952. onCollide: (e: {
  28953. body: any;
  28954. }) => void;
  28955. /**
  28956. * Apply a force
  28957. * @param force The force to apply
  28958. * @param contactPoint The contact point for the force
  28959. * @returns The physics imposter
  28960. */
  28961. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28962. /**
  28963. * Apply an impulse
  28964. * @param force The impulse force
  28965. * @param contactPoint The contact point for the impulse force
  28966. * @returns The physics imposter
  28967. */
  28968. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  28969. /**
  28970. * A help function to create a joint
  28971. * @param otherImpostor A physics imposter used to create a joint
  28972. * @param jointType The type of joint
  28973. * @param jointData The data for the joint
  28974. * @returns The physics imposter
  28975. */
  28976. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  28977. /**
  28978. * Add a joint to this impostor with a different impostor
  28979. * @param otherImpostor A physics imposter used to add a joint
  28980. * @param joint The joint to add
  28981. * @returns The physics imposter
  28982. */
  28983. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  28984. /**
  28985. * Add an anchor to a cloth impostor
  28986. * @param otherImpostor rigid impostor to anchor to
  28987. * @param width ratio across width from 0 to 1
  28988. * @param height ratio up height from 0 to 1
  28989. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  28990. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  28991. * @returns impostor the soft imposter
  28992. */
  28993. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  28994. /**
  28995. * Add a hook to a rope impostor
  28996. * @param otherImpostor rigid impostor to anchor to
  28997. * @param length ratio across rope from 0 to 1
  28998. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  28999. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29000. * @returns impostor the rope imposter
  29001. */
  29002. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29003. /**
  29004. * Will keep this body still, in a sleep mode.
  29005. * @returns the physics imposter
  29006. */
  29007. sleep(): PhysicsImpostor;
  29008. /**
  29009. * Wake the body up.
  29010. * @returns The physics imposter
  29011. */
  29012. wakeUp(): PhysicsImpostor;
  29013. /**
  29014. * Clones the physics imposter
  29015. * @param newObject The physics imposter clones to this physics-enabled object
  29016. * @returns A nullable physics imposter
  29017. */
  29018. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29019. /**
  29020. * Disposes the physics imposter
  29021. */
  29022. dispose(): void;
  29023. /**
  29024. * Sets the delta position
  29025. * @param position The delta position amount
  29026. */
  29027. setDeltaPosition(position: Vector3): void;
  29028. /**
  29029. * Sets the delta rotation
  29030. * @param rotation The delta rotation amount
  29031. */
  29032. setDeltaRotation(rotation: Quaternion): void;
  29033. /**
  29034. * Gets the box size of the physics imposter and stores the result in the input parameter
  29035. * @param result Stores the box size
  29036. * @returns The physics imposter
  29037. */
  29038. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29039. /**
  29040. * Gets the radius of the physics imposter
  29041. * @returns Radius of the physics imposter
  29042. */
  29043. getRadius(): number;
  29044. /**
  29045. * Sync a bone with this impostor
  29046. * @param bone The bone to sync to the impostor.
  29047. * @param boneMesh The mesh that the bone is influencing.
  29048. * @param jointPivot The pivot of the joint / bone in local space.
  29049. * @param distToJoint Optional distance from the impostor to the joint.
  29050. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29051. */
  29052. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29053. /**
  29054. * Sync impostor to a bone
  29055. * @param bone The bone that the impostor will be synced to.
  29056. * @param boneMesh The mesh that the bone is influencing.
  29057. * @param jointPivot The pivot of the joint / bone in local space.
  29058. * @param distToJoint Optional distance from the impostor to the joint.
  29059. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29060. * @param boneAxis Optional vector3 axis the bone is aligned with
  29061. */
  29062. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29063. /**
  29064. * No-Imposter type
  29065. */
  29066. static NoImpostor: number;
  29067. /**
  29068. * Sphere-Imposter type
  29069. */
  29070. static SphereImpostor: number;
  29071. /**
  29072. * Box-Imposter type
  29073. */
  29074. static BoxImpostor: number;
  29075. /**
  29076. * Plane-Imposter type
  29077. */
  29078. static PlaneImpostor: number;
  29079. /**
  29080. * Mesh-imposter type
  29081. */
  29082. static MeshImpostor: number;
  29083. /**
  29084. * Capsule-Impostor type (Ammo.js plugin only)
  29085. */
  29086. static CapsuleImpostor: number;
  29087. /**
  29088. * Cylinder-Imposter type
  29089. */
  29090. static CylinderImpostor: number;
  29091. /**
  29092. * Particle-Imposter type
  29093. */
  29094. static ParticleImpostor: number;
  29095. /**
  29096. * Heightmap-Imposter type
  29097. */
  29098. static HeightmapImpostor: number;
  29099. /**
  29100. * ConvexHull-Impostor type (Ammo.js plugin only)
  29101. */
  29102. static ConvexHullImpostor: number;
  29103. /**
  29104. * Custom-Imposter type (Ammo.js plugin only)
  29105. */
  29106. static CustomImpostor: number;
  29107. /**
  29108. * Rope-Imposter type
  29109. */
  29110. static RopeImpostor: number;
  29111. /**
  29112. * Cloth-Imposter type
  29113. */
  29114. static ClothImpostor: number;
  29115. /**
  29116. * Softbody-Imposter type
  29117. */
  29118. static SoftbodyImpostor: number;
  29119. }
  29120. }
  29121. declare module "babylonjs/Meshes/mesh" {
  29122. import { Observable } from "babylonjs/Misc/observable";
  29123. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29124. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29125. import { Camera } from "babylonjs/Cameras/camera";
  29126. import { Scene } from "babylonjs/scene";
  29127. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29128. import { Color4 } from "babylonjs/Maths/math.color";
  29129. import { Engine } from "babylonjs/Engines/engine";
  29130. import { Node } from "babylonjs/node";
  29131. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29132. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29133. import { Buffer } from "babylonjs/Meshes/buffer";
  29134. import { Geometry } from "babylonjs/Meshes/geometry";
  29135. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29136. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29137. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29138. import { Effect } from "babylonjs/Materials/effect";
  29139. import { Material } from "babylonjs/Materials/material";
  29140. import { Skeleton } from "babylonjs/Bones/skeleton";
  29141. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29142. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29143. import { Path3D } from "babylonjs/Maths/math.path";
  29144. import { Plane } from "babylonjs/Maths/math.plane";
  29145. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29146. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29147. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29148. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29149. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29150. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29151. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29152. /**
  29153. * @hidden
  29154. **/
  29155. export class _CreationDataStorage {
  29156. closePath?: boolean;
  29157. closeArray?: boolean;
  29158. idx: number[];
  29159. dashSize: number;
  29160. gapSize: number;
  29161. path3D: Path3D;
  29162. pathArray: Vector3[][];
  29163. arc: number;
  29164. radius: number;
  29165. cap: number;
  29166. tessellation: number;
  29167. }
  29168. /**
  29169. * @hidden
  29170. **/
  29171. class _InstanceDataStorage {
  29172. visibleInstances: any;
  29173. batchCache: _InstancesBatch;
  29174. instancesBufferSize: number;
  29175. instancesBuffer: Nullable<Buffer>;
  29176. instancesData: Float32Array;
  29177. overridenInstanceCount: number;
  29178. isFrozen: boolean;
  29179. previousBatch: Nullable<_InstancesBatch>;
  29180. hardwareInstancedRendering: boolean;
  29181. sideOrientation: number;
  29182. manualUpdate: boolean;
  29183. previousRenderId: number;
  29184. }
  29185. /**
  29186. * @hidden
  29187. **/
  29188. export class _InstancesBatch {
  29189. mustReturn: boolean;
  29190. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29191. renderSelf: boolean[];
  29192. hardwareInstancedRendering: boolean[];
  29193. }
  29194. /**
  29195. * @hidden
  29196. **/
  29197. class _ThinInstanceDataStorage {
  29198. instancesCount: number;
  29199. matrixBuffer: Nullable<Buffer>;
  29200. matrixBufferSize: number;
  29201. matrixData: Nullable<Float32Array>;
  29202. boundingVectors: Array<Vector3>;
  29203. worldMatrices: Nullable<Matrix[]>;
  29204. }
  29205. /**
  29206. * Class used to represent renderable models
  29207. */
  29208. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29209. /**
  29210. * Mesh side orientation : usually the external or front surface
  29211. */
  29212. static readonly FRONTSIDE: number;
  29213. /**
  29214. * Mesh side orientation : usually the internal or back surface
  29215. */
  29216. static readonly BACKSIDE: number;
  29217. /**
  29218. * Mesh side orientation : both internal and external or front and back surfaces
  29219. */
  29220. static readonly DOUBLESIDE: number;
  29221. /**
  29222. * Mesh side orientation : by default, `FRONTSIDE`
  29223. */
  29224. static readonly DEFAULTSIDE: number;
  29225. /**
  29226. * Mesh cap setting : no cap
  29227. */
  29228. static readonly NO_CAP: number;
  29229. /**
  29230. * Mesh cap setting : one cap at the beginning of the mesh
  29231. */
  29232. static readonly CAP_START: number;
  29233. /**
  29234. * Mesh cap setting : one cap at the end of the mesh
  29235. */
  29236. static readonly CAP_END: number;
  29237. /**
  29238. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29239. */
  29240. static readonly CAP_ALL: number;
  29241. /**
  29242. * Mesh pattern setting : no flip or rotate
  29243. */
  29244. static readonly NO_FLIP: number;
  29245. /**
  29246. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29247. */
  29248. static readonly FLIP_TILE: number;
  29249. /**
  29250. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29251. */
  29252. static readonly ROTATE_TILE: number;
  29253. /**
  29254. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29255. */
  29256. static readonly FLIP_ROW: number;
  29257. /**
  29258. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29259. */
  29260. static readonly ROTATE_ROW: number;
  29261. /**
  29262. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29263. */
  29264. static readonly FLIP_N_ROTATE_TILE: number;
  29265. /**
  29266. * Mesh pattern setting : rotate pattern and rotate
  29267. */
  29268. static readonly FLIP_N_ROTATE_ROW: number;
  29269. /**
  29270. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29271. */
  29272. static readonly CENTER: number;
  29273. /**
  29274. * Mesh tile positioning : part tiles on left
  29275. */
  29276. static readonly LEFT: number;
  29277. /**
  29278. * Mesh tile positioning : part tiles on right
  29279. */
  29280. static readonly RIGHT: number;
  29281. /**
  29282. * Mesh tile positioning : part tiles on top
  29283. */
  29284. static readonly TOP: number;
  29285. /**
  29286. * Mesh tile positioning : part tiles on bottom
  29287. */
  29288. static readonly BOTTOM: number;
  29289. /**
  29290. * Gets the default side orientation.
  29291. * @param orientation the orientation to value to attempt to get
  29292. * @returns the default orientation
  29293. * @hidden
  29294. */
  29295. static _GetDefaultSideOrientation(orientation?: number): number;
  29296. private _internalMeshDataInfo;
  29297. get computeBonesUsingShaders(): boolean;
  29298. set computeBonesUsingShaders(value: boolean);
  29299. /**
  29300. * An event triggered before rendering the mesh
  29301. */
  29302. get onBeforeRenderObservable(): Observable<Mesh>;
  29303. /**
  29304. * An event triggered before binding the mesh
  29305. */
  29306. get onBeforeBindObservable(): Observable<Mesh>;
  29307. /**
  29308. * An event triggered after rendering the mesh
  29309. */
  29310. get onAfterRenderObservable(): Observable<Mesh>;
  29311. /**
  29312. * An event triggered before drawing the mesh
  29313. */
  29314. get onBeforeDrawObservable(): Observable<Mesh>;
  29315. private _onBeforeDrawObserver;
  29316. /**
  29317. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29318. */
  29319. set onBeforeDraw(callback: () => void);
  29320. get hasInstances(): boolean;
  29321. get hasThinInstances(): boolean;
  29322. /**
  29323. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29324. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29325. */
  29326. delayLoadState: number;
  29327. /**
  29328. * Gets the list of instances created from this mesh
  29329. * it is not supposed to be modified manually.
  29330. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29331. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29332. */
  29333. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29334. /**
  29335. * Gets the file containing delay loading data for this mesh
  29336. */
  29337. delayLoadingFile: string;
  29338. /** @hidden */
  29339. _binaryInfo: any;
  29340. /**
  29341. * User defined function used to change how LOD level selection is done
  29342. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29343. */
  29344. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29345. /**
  29346. * Gets or sets the morph target manager
  29347. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29348. */
  29349. get morphTargetManager(): Nullable<MorphTargetManager>;
  29350. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29351. /** @hidden */
  29352. _creationDataStorage: Nullable<_CreationDataStorage>;
  29353. /** @hidden */
  29354. _geometry: Nullable<Geometry>;
  29355. /** @hidden */
  29356. _delayInfo: Array<string>;
  29357. /** @hidden */
  29358. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29359. /** @hidden */
  29360. _instanceDataStorage: _InstanceDataStorage;
  29361. /** @hidden */
  29362. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29363. private _effectiveMaterial;
  29364. /** @hidden */
  29365. _shouldGenerateFlatShading: boolean;
  29366. /** @hidden */
  29367. _originalBuilderSideOrientation: number;
  29368. /**
  29369. * Use this property to change the original side orientation defined at construction time
  29370. */
  29371. overrideMaterialSideOrientation: Nullable<number>;
  29372. /**
  29373. * Gets the source mesh (the one used to clone this one from)
  29374. */
  29375. get source(): Nullable<Mesh>;
  29376. /**
  29377. * Gets the list of clones of this mesh
  29378. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29379. * Note that useClonedMeshMap=true is the default setting
  29380. */
  29381. get cloneMeshMap(): Nullable<{
  29382. [id: string]: Mesh | undefined;
  29383. }>;
  29384. /**
  29385. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29386. */
  29387. get isUnIndexed(): boolean;
  29388. set isUnIndexed(value: boolean);
  29389. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29390. get worldMatrixInstancedBuffer(): Float32Array;
  29391. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29392. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29393. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29394. /**
  29395. * @constructor
  29396. * @param name The value used by scene.getMeshByName() to do a lookup.
  29397. * @param scene The scene to add this mesh to.
  29398. * @param parent The parent of this mesh, if it has one
  29399. * @param source An optional Mesh from which geometry is shared, cloned.
  29400. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29401. * When false, achieved by calling a clone(), also passing False.
  29402. * This will make creation of children, recursive.
  29403. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29404. */
  29405. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29406. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29407. doNotInstantiate: boolean;
  29408. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29409. /**
  29410. * Gets the class name
  29411. * @returns the string "Mesh".
  29412. */
  29413. getClassName(): string;
  29414. /** @hidden */
  29415. get _isMesh(): boolean;
  29416. /**
  29417. * Returns a description of this mesh
  29418. * @param fullDetails define if full details about this mesh must be used
  29419. * @returns a descriptive string representing this mesh
  29420. */
  29421. toString(fullDetails?: boolean): string;
  29422. /** @hidden */
  29423. _unBindEffect(): void;
  29424. /**
  29425. * Gets a boolean indicating if this mesh has LOD
  29426. */
  29427. get hasLODLevels(): boolean;
  29428. /**
  29429. * Gets the list of MeshLODLevel associated with the current mesh
  29430. * @returns an array of MeshLODLevel
  29431. */
  29432. getLODLevels(): MeshLODLevel[];
  29433. private _sortLODLevels;
  29434. /**
  29435. * Add a mesh as LOD level triggered at the given distance.
  29436. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29437. * @param distance The distance from the center of the object to show this level
  29438. * @param mesh The mesh to be added as LOD level (can be null)
  29439. * @return This mesh (for chaining)
  29440. */
  29441. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29442. /**
  29443. * Returns the LOD level mesh at the passed distance or null if not found.
  29444. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29445. * @param distance The distance from the center of the object to show this level
  29446. * @returns a Mesh or `null`
  29447. */
  29448. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29449. /**
  29450. * Remove a mesh from the LOD array
  29451. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29452. * @param mesh defines the mesh to be removed
  29453. * @return This mesh (for chaining)
  29454. */
  29455. removeLODLevel(mesh: Mesh): Mesh;
  29456. /**
  29457. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29458. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29459. * @param camera defines the camera to use to compute distance
  29460. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29461. * @return This mesh (for chaining)
  29462. */
  29463. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29464. /**
  29465. * Gets the mesh internal Geometry object
  29466. */
  29467. get geometry(): Nullable<Geometry>;
  29468. /**
  29469. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29470. * @returns the total number of vertices
  29471. */
  29472. getTotalVertices(): number;
  29473. /**
  29474. * Returns the content of an associated vertex buffer
  29475. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29476. * - VertexBuffer.PositionKind
  29477. * - VertexBuffer.UVKind
  29478. * - VertexBuffer.UV2Kind
  29479. * - VertexBuffer.UV3Kind
  29480. * - VertexBuffer.UV4Kind
  29481. * - VertexBuffer.UV5Kind
  29482. * - VertexBuffer.UV6Kind
  29483. * - VertexBuffer.ColorKind
  29484. * - VertexBuffer.MatricesIndicesKind
  29485. * - VertexBuffer.MatricesIndicesExtraKind
  29486. * - VertexBuffer.MatricesWeightsKind
  29487. * - VertexBuffer.MatricesWeightsExtraKind
  29488. * @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
  29489. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29490. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29491. */
  29492. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29493. /**
  29494. * Returns the mesh VertexBuffer object from the requested `kind`
  29495. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29496. * - VertexBuffer.PositionKind
  29497. * - VertexBuffer.NormalKind
  29498. * - VertexBuffer.UVKind
  29499. * - VertexBuffer.UV2Kind
  29500. * - VertexBuffer.UV3Kind
  29501. * - VertexBuffer.UV4Kind
  29502. * - VertexBuffer.UV5Kind
  29503. * - VertexBuffer.UV6Kind
  29504. * - VertexBuffer.ColorKind
  29505. * - VertexBuffer.MatricesIndicesKind
  29506. * - VertexBuffer.MatricesIndicesExtraKind
  29507. * - VertexBuffer.MatricesWeightsKind
  29508. * - VertexBuffer.MatricesWeightsExtraKind
  29509. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29510. */
  29511. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29512. /**
  29513. * Tests if a specific vertex buffer is associated with this mesh
  29514. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29515. * - VertexBuffer.PositionKind
  29516. * - VertexBuffer.NormalKind
  29517. * - VertexBuffer.UVKind
  29518. * - VertexBuffer.UV2Kind
  29519. * - VertexBuffer.UV3Kind
  29520. * - VertexBuffer.UV4Kind
  29521. * - VertexBuffer.UV5Kind
  29522. * - VertexBuffer.UV6Kind
  29523. * - VertexBuffer.ColorKind
  29524. * - VertexBuffer.MatricesIndicesKind
  29525. * - VertexBuffer.MatricesIndicesExtraKind
  29526. * - VertexBuffer.MatricesWeightsKind
  29527. * - VertexBuffer.MatricesWeightsExtraKind
  29528. * @returns a boolean
  29529. */
  29530. isVerticesDataPresent(kind: string): boolean;
  29531. /**
  29532. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29533. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29534. * - VertexBuffer.PositionKind
  29535. * - VertexBuffer.UVKind
  29536. * - VertexBuffer.UV2Kind
  29537. * - VertexBuffer.UV3Kind
  29538. * - VertexBuffer.UV4Kind
  29539. * - VertexBuffer.UV5Kind
  29540. * - VertexBuffer.UV6Kind
  29541. * - VertexBuffer.ColorKind
  29542. * - VertexBuffer.MatricesIndicesKind
  29543. * - VertexBuffer.MatricesIndicesExtraKind
  29544. * - VertexBuffer.MatricesWeightsKind
  29545. * - VertexBuffer.MatricesWeightsExtraKind
  29546. * @returns a boolean
  29547. */
  29548. isVertexBufferUpdatable(kind: string): boolean;
  29549. /**
  29550. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29551. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29552. * - VertexBuffer.PositionKind
  29553. * - VertexBuffer.NormalKind
  29554. * - VertexBuffer.UVKind
  29555. * - VertexBuffer.UV2Kind
  29556. * - VertexBuffer.UV3Kind
  29557. * - VertexBuffer.UV4Kind
  29558. * - VertexBuffer.UV5Kind
  29559. * - VertexBuffer.UV6Kind
  29560. * - VertexBuffer.ColorKind
  29561. * - VertexBuffer.MatricesIndicesKind
  29562. * - VertexBuffer.MatricesIndicesExtraKind
  29563. * - VertexBuffer.MatricesWeightsKind
  29564. * - VertexBuffer.MatricesWeightsExtraKind
  29565. * @returns an array of strings
  29566. */
  29567. getVerticesDataKinds(): string[];
  29568. /**
  29569. * Returns a positive integer : the total number of indices in this mesh geometry.
  29570. * @returns the numner of indices or zero if the mesh has no geometry.
  29571. */
  29572. getTotalIndices(): number;
  29573. /**
  29574. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29575. * @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.
  29576. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29577. * @returns the indices array or an empty array if the mesh has no geometry
  29578. */
  29579. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29580. get isBlocked(): boolean;
  29581. /**
  29582. * Determine if the current mesh is ready to be rendered
  29583. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29584. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29585. * @returns true if all associated assets are ready (material, textures, shaders)
  29586. */
  29587. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29588. /**
  29589. * 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.
  29590. */
  29591. get areNormalsFrozen(): boolean;
  29592. /**
  29593. * 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.
  29594. * @returns the current mesh
  29595. */
  29596. freezeNormals(): Mesh;
  29597. /**
  29598. * 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
  29599. * @returns the current mesh
  29600. */
  29601. unfreezeNormals(): Mesh;
  29602. /**
  29603. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29604. */
  29605. set overridenInstanceCount(count: number);
  29606. /** @hidden */
  29607. _preActivate(): Mesh;
  29608. /** @hidden */
  29609. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29610. /** @hidden */
  29611. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29612. protected _afterComputeWorldMatrix(): void;
  29613. /** @hidden */
  29614. _postActivate(): void;
  29615. /**
  29616. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29617. * This means the mesh underlying bounding box and sphere are recomputed.
  29618. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29619. * @returns the current mesh
  29620. */
  29621. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29622. /** @hidden */
  29623. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29624. /**
  29625. * This function will subdivide the mesh into multiple submeshes
  29626. * @param count defines the expected number of submeshes
  29627. */
  29628. subdivide(count: number): void;
  29629. /**
  29630. * Copy a FloatArray into a specific associated vertex buffer
  29631. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29632. * - VertexBuffer.PositionKind
  29633. * - VertexBuffer.UVKind
  29634. * - VertexBuffer.UV2Kind
  29635. * - VertexBuffer.UV3Kind
  29636. * - VertexBuffer.UV4Kind
  29637. * - VertexBuffer.UV5Kind
  29638. * - VertexBuffer.UV6Kind
  29639. * - VertexBuffer.ColorKind
  29640. * - VertexBuffer.MatricesIndicesKind
  29641. * - VertexBuffer.MatricesIndicesExtraKind
  29642. * - VertexBuffer.MatricesWeightsKind
  29643. * - VertexBuffer.MatricesWeightsExtraKind
  29644. * @param data defines the data source
  29645. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29646. * @param stride defines the data stride size (can be null)
  29647. * @returns the current mesh
  29648. */
  29649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29650. /**
  29651. * Delete a vertex buffer associated with this mesh
  29652. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29653. * - VertexBuffer.PositionKind
  29654. * - VertexBuffer.UVKind
  29655. * - VertexBuffer.UV2Kind
  29656. * - VertexBuffer.UV3Kind
  29657. * - VertexBuffer.UV4Kind
  29658. * - VertexBuffer.UV5Kind
  29659. * - VertexBuffer.UV6Kind
  29660. * - VertexBuffer.ColorKind
  29661. * - VertexBuffer.MatricesIndicesKind
  29662. * - VertexBuffer.MatricesIndicesExtraKind
  29663. * - VertexBuffer.MatricesWeightsKind
  29664. * - VertexBuffer.MatricesWeightsExtraKind
  29665. */
  29666. removeVerticesData(kind: string): void;
  29667. /**
  29668. * Flags an associated vertex buffer as updatable
  29669. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29670. * - VertexBuffer.PositionKind
  29671. * - VertexBuffer.UVKind
  29672. * - VertexBuffer.UV2Kind
  29673. * - VertexBuffer.UV3Kind
  29674. * - VertexBuffer.UV4Kind
  29675. * - VertexBuffer.UV5Kind
  29676. * - VertexBuffer.UV6Kind
  29677. * - VertexBuffer.ColorKind
  29678. * - VertexBuffer.MatricesIndicesKind
  29679. * - VertexBuffer.MatricesIndicesExtraKind
  29680. * - VertexBuffer.MatricesWeightsKind
  29681. * - VertexBuffer.MatricesWeightsExtraKind
  29682. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29683. */
  29684. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29685. /**
  29686. * Sets the mesh global Vertex Buffer
  29687. * @param buffer defines the buffer to use
  29688. * @returns the current mesh
  29689. */
  29690. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29691. /**
  29692. * Update a specific associated vertex buffer
  29693. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29694. * - VertexBuffer.PositionKind
  29695. * - VertexBuffer.UVKind
  29696. * - VertexBuffer.UV2Kind
  29697. * - VertexBuffer.UV3Kind
  29698. * - VertexBuffer.UV4Kind
  29699. * - VertexBuffer.UV5Kind
  29700. * - VertexBuffer.UV6Kind
  29701. * - VertexBuffer.ColorKind
  29702. * - VertexBuffer.MatricesIndicesKind
  29703. * - VertexBuffer.MatricesIndicesExtraKind
  29704. * - VertexBuffer.MatricesWeightsKind
  29705. * - VertexBuffer.MatricesWeightsExtraKind
  29706. * @param data defines the data source
  29707. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29708. * @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)
  29709. * @returns the current mesh
  29710. */
  29711. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29712. /**
  29713. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29714. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29715. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29716. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29717. * @returns the current mesh
  29718. */
  29719. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29720. /**
  29721. * Creates a un-shared specific occurence of the geometry for the mesh.
  29722. * @returns the current mesh
  29723. */
  29724. makeGeometryUnique(): Mesh;
  29725. /**
  29726. * Set the index buffer of this mesh
  29727. * @param indices defines the source data
  29728. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29729. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29730. * @returns the current mesh
  29731. */
  29732. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29733. /**
  29734. * Update the current index buffer
  29735. * @param indices defines the source data
  29736. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29737. * @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)
  29738. * @returns the current mesh
  29739. */
  29740. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29741. /**
  29742. * Invert the geometry to move from a right handed system to a left handed one.
  29743. * @returns the current mesh
  29744. */
  29745. toLeftHanded(): Mesh;
  29746. /** @hidden */
  29747. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29748. /** @hidden */
  29749. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29750. /**
  29751. * Registers for this mesh a javascript function called just before the rendering process
  29752. * @param func defines the function to call before rendering this mesh
  29753. * @returns the current mesh
  29754. */
  29755. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29756. /**
  29757. * Disposes a previously registered javascript function called before the rendering
  29758. * @param func defines the function to remove
  29759. * @returns the current mesh
  29760. */
  29761. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29762. /**
  29763. * Registers for this mesh a javascript function called just after the rendering is complete
  29764. * @param func defines the function to call after rendering this mesh
  29765. * @returns the current mesh
  29766. */
  29767. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29768. /**
  29769. * Disposes a previously registered javascript function called after the rendering.
  29770. * @param func defines the function to remove
  29771. * @returns the current mesh
  29772. */
  29773. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29774. /** @hidden */
  29775. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29776. /** @hidden */
  29777. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29778. /** @hidden */
  29779. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29780. /** @hidden */
  29781. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29782. /** @hidden */
  29783. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29784. /** @hidden */
  29785. _rebuild(): void;
  29786. /** @hidden */
  29787. _freeze(): void;
  29788. /** @hidden */
  29789. _unFreeze(): void;
  29790. /**
  29791. * 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
  29792. * @param subMesh defines the subMesh to render
  29793. * @param enableAlphaMode defines if alpha mode can be changed
  29794. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29795. * @returns the current mesh
  29796. */
  29797. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29798. private _onBeforeDraw;
  29799. /**
  29800. * Renormalize the mesh and patch it up if there are no weights
  29801. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29802. * However in the case of zero weights then we set just a single influence to 1.
  29803. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29804. */
  29805. cleanMatrixWeights(): void;
  29806. private normalizeSkinFourWeights;
  29807. private normalizeSkinWeightsAndExtra;
  29808. /**
  29809. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29810. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29811. * the user know there was an issue with importing the mesh
  29812. * @returns a validation object with skinned, valid and report string
  29813. */
  29814. validateSkinning(): {
  29815. skinned: boolean;
  29816. valid: boolean;
  29817. report: string;
  29818. };
  29819. /** @hidden */
  29820. _checkDelayState(): Mesh;
  29821. private _queueLoad;
  29822. /**
  29823. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29824. * A mesh is in the frustum if its bounding box intersects the frustum
  29825. * @param frustumPlanes defines the frustum to test
  29826. * @returns true if the mesh is in the frustum planes
  29827. */
  29828. isInFrustum(frustumPlanes: Plane[]): boolean;
  29829. /**
  29830. * Sets the mesh material by the material or multiMaterial `id` property
  29831. * @param id is a string identifying the material or the multiMaterial
  29832. * @returns the current mesh
  29833. */
  29834. setMaterialByID(id: string): Mesh;
  29835. /**
  29836. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29837. * @returns an array of IAnimatable
  29838. */
  29839. getAnimatables(): IAnimatable[];
  29840. /**
  29841. * Modifies the mesh geometry according to the passed transformation matrix.
  29842. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29843. * The mesh normals are modified using the same transformation.
  29844. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29845. * @param transform defines the transform matrix to use
  29846. * @see https://doc.babylonjs.com/resources/baking_transformations
  29847. * @returns the current mesh
  29848. */
  29849. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29850. /**
  29851. * Modifies the mesh geometry according to its own current World Matrix.
  29852. * The mesh World Matrix is then reset.
  29853. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29854. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29855. * @see https://doc.babylonjs.com/resources/baking_transformations
  29856. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29857. * @returns the current mesh
  29858. */
  29859. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29860. /** @hidden */
  29861. get _positions(): Nullable<Vector3[]>;
  29862. /** @hidden */
  29863. _resetPointsArrayCache(): Mesh;
  29864. /** @hidden */
  29865. _generatePointsArray(): boolean;
  29866. /**
  29867. * Returns a new Mesh object generated from the current mesh properties.
  29868. * This method must not get confused with createInstance()
  29869. * @param name is a string, the name given to the new mesh
  29870. * @param newParent can be any Node object (default `null`)
  29871. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29872. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29873. * @returns a new mesh
  29874. */
  29875. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29876. /**
  29877. * Releases resources associated with this mesh.
  29878. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29879. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29880. */
  29881. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29882. /** @hidden */
  29883. _disposeInstanceSpecificData(): void;
  29884. /** @hidden */
  29885. _disposeThinInstanceSpecificData(): void;
  29886. /**
  29887. * Modifies the mesh geometry according to a displacement map.
  29888. * 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.
  29889. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29890. * @param url is a string, the URL from the image file is to be downloaded.
  29891. * @param minHeight is the lower limit of the displacement.
  29892. * @param maxHeight is the upper limit of the displacement.
  29893. * @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.
  29894. * @param uvOffset is an optional vector2 used to offset UV.
  29895. * @param uvScale is an optional vector2 used to scale UV.
  29896. * @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.
  29897. * @returns the Mesh.
  29898. */
  29899. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29900. /**
  29901. * Modifies the mesh geometry according to a displacementMap buffer.
  29902. * 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.
  29903. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29904. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29905. * @param heightMapWidth is the width of the buffer image.
  29906. * @param heightMapHeight is the height of the buffer image.
  29907. * @param minHeight is the lower limit of the displacement.
  29908. * @param maxHeight is the upper limit of the displacement.
  29909. * @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.
  29910. * @param uvOffset is an optional vector2 used to offset UV.
  29911. * @param uvScale is an optional vector2 used to scale UV.
  29912. * @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.
  29913. * @returns the Mesh.
  29914. */
  29915. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29916. /**
  29917. * Modify the mesh to get a flat shading rendering.
  29918. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  29919. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  29920. * @returns current mesh
  29921. */
  29922. convertToFlatShadedMesh(): Mesh;
  29923. /**
  29924. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  29925. * In other words, more vertices, no more indices and a single bigger VBO.
  29926. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  29927. * @returns current mesh
  29928. */
  29929. convertToUnIndexedMesh(): Mesh;
  29930. /**
  29931. * Inverses facet orientations.
  29932. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29933. * @param flipNormals will also inverts the normals
  29934. * @returns current mesh
  29935. */
  29936. flipFaces(flipNormals?: boolean): Mesh;
  29937. /**
  29938. * Increase the number of facets and hence vertices in a mesh
  29939. * Vertex normals are interpolated from existing vertex normals
  29940. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29941. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  29942. */
  29943. increaseVertices(numberPerEdge: number): void;
  29944. /**
  29945. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  29946. * This will undo any application of covertToFlatShadedMesh
  29947. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  29948. */
  29949. forceSharedVertices(): void;
  29950. /** @hidden */
  29951. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  29952. /** @hidden */
  29953. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  29954. /**
  29955. * Creates a new InstancedMesh object from the mesh model.
  29956. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29957. * @param name defines the name of the new instance
  29958. * @returns a new InstancedMesh
  29959. */
  29960. createInstance(name: string): InstancedMesh;
  29961. /**
  29962. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  29963. * After this call, all the mesh instances have the same submeshes than the current mesh.
  29964. * @returns the current mesh
  29965. */
  29966. synchronizeInstances(): Mesh;
  29967. /**
  29968. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  29969. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  29970. * This should be used together with the simplification to avoid disappearing triangles.
  29971. * @param successCallback an optional success callback to be called after the optimization finished.
  29972. * @returns the current mesh
  29973. */
  29974. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  29975. /**
  29976. * Serialize current mesh
  29977. * @param serializationObject defines the object which will receive the serialization data
  29978. */
  29979. serialize(serializationObject: any): void;
  29980. /** @hidden */
  29981. _syncGeometryWithMorphTargetManager(): void;
  29982. /** @hidden */
  29983. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  29984. /**
  29985. * Returns a new Mesh object parsed from the source provided.
  29986. * @param parsedMesh is the source
  29987. * @param scene defines the hosting scene
  29988. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  29989. * @returns a new Mesh
  29990. */
  29991. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  29992. /**
  29993. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  29994. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  29995. * @param name defines the name of the mesh to create
  29996. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  29997. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  29998. * @param closePath creates a seam between the first and the last points of each path of the path array
  29999. * @param offset is taken in account only if the `pathArray` is containing a single path
  30000. * @param scene defines the hosting scene
  30001. * @param updatable defines if the mesh must be flagged as updatable
  30002. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30003. * @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)
  30004. * @returns a new Mesh
  30005. */
  30006. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30007. /**
  30008. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30009. * @param name defines the name of the mesh to create
  30010. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30011. * @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
  30012. * @param scene defines the hosting scene
  30013. * @param updatable defines if the mesh must be flagged as updatable
  30014. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30015. * @returns a new Mesh
  30016. */
  30017. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30018. /**
  30019. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30020. * @param name defines the name of the mesh to create
  30021. * @param size sets the size (float) of each box side (default 1)
  30022. * @param scene defines the hosting scene
  30023. * @param updatable defines if the mesh must be flagged as updatable
  30024. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30025. * @returns a new Mesh
  30026. */
  30027. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30028. /**
  30029. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30030. * @param name defines the name of the mesh to create
  30031. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30032. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30033. * @param scene defines the hosting scene
  30034. * @param updatable defines if the mesh must be flagged as updatable
  30035. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30036. * @returns a new Mesh
  30037. */
  30038. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30039. /**
  30040. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30041. * @param name defines the name of the mesh to create
  30042. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30043. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30044. * @param scene defines the hosting scene
  30045. * @returns a new Mesh
  30046. */
  30047. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30048. /**
  30049. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30050. * @param name defines the name of the mesh to create
  30051. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30052. * @param diameterTop set the top cap diameter (floats, default 1)
  30053. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30054. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30055. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30056. * @param scene defines the hosting scene
  30057. * @param updatable defines if the mesh must be flagged as updatable
  30058. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30059. * @returns a new Mesh
  30060. */
  30061. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30062. /**
  30063. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30064. * @param name defines the name of the mesh to create
  30065. * @param diameter sets the diameter size (float) of the torus (default 1)
  30066. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30067. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30068. * @param scene defines the hosting scene
  30069. * @param updatable defines if the mesh must be flagged as updatable
  30070. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30071. * @returns a new Mesh
  30072. */
  30073. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30074. /**
  30075. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30076. * @param name defines the name of the mesh to create
  30077. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30078. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30079. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30080. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30081. * @param p the number of windings on X axis (positive integers, default 2)
  30082. * @param q the number of windings on Y axis (positive integers, default 3)
  30083. * @param scene defines the hosting scene
  30084. * @param updatable defines if the mesh must be flagged as updatable
  30085. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30086. * @returns a new Mesh
  30087. */
  30088. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30089. /**
  30090. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30091. * @param name defines the name of the mesh to create
  30092. * @param points is an array successive Vector3
  30093. * @param scene defines the hosting scene
  30094. * @param updatable defines if the mesh must be flagged as updatable
  30095. * @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).
  30096. * @returns a new Mesh
  30097. */
  30098. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30099. /**
  30100. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30101. * @param name defines the name of the mesh to create
  30102. * @param points is an array successive Vector3
  30103. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30104. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30105. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30106. * @param scene defines the hosting scene
  30107. * @param updatable defines if the mesh must be flagged as updatable
  30108. * @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)
  30109. * @returns a new Mesh
  30110. */
  30111. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30112. /**
  30113. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30114. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30115. * 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.
  30116. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30117. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30118. * Remember you can only change the shape positions, not their number when updating a polygon.
  30119. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30120. * @param name defines the name of the mesh to create
  30121. * @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
  30122. * @param scene defines the hosting scene
  30123. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30124. * @param updatable defines if the mesh must be flagged as updatable
  30125. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30126. * @param earcutInjection can be used to inject your own earcut reference
  30127. * @returns a new Mesh
  30128. */
  30129. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30130. /**
  30131. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30133. * @param name defines the name of the mesh to create
  30134. * @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
  30135. * @param depth defines the height of extrusion
  30136. * @param scene defines the hosting scene
  30137. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30138. * @param updatable defines if the mesh must be flagged as updatable
  30139. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30140. * @param earcutInjection can be used to inject your own earcut reference
  30141. * @returns a new Mesh
  30142. */
  30143. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30144. /**
  30145. * Creates an extruded shape mesh.
  30146. * 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
  30147. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30148. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30149. * @param name defines the name of the mesh to create
  30150. * @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
  30151. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30152. * @param scale is the value to scale the shape
  30153. * @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
  30154. * @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
  30155. * @param scene defines the hosting scene
  30156. * @param updatable defines if the mesh must be flagged as updatable
  30157. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30158. * @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)
  30159. * @returns a new Mesh
  30160. */
  30161. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30162. /**
  30163. * Creates an custom extruded shape mesh.
  30164. * The custom extrusion is a parametric shape.
  30165. * It has no predefined shape. Its final shape will depend on the input parameters.
  30166. * Please consider using the same method from the MeshBuilder class instead
  30167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30168. * @param name defines the name of the mesh to create
  30169. * @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
  30170. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30171. * @param scaleFunction is a custom Javascript function called on each path point
  30172. * @param rotationFunction is a custom Javascript function called on each path point
  30173. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30174. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30175. * @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
  30176. * @param scene defines the hosting scene
  30177. * @param updatable defines if the mesh must be flagged as updatable
  30178. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30179. * @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)
  30180. * @returns a new Mesh
  30181. */
  30182. 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;
  30183. /**
  30184. * Creates lathe mesh.
  30185. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30186. * Please consider using the same method from the MeshBuilder class instead
  30187. * @param name defines the name of the mesh to create
  30188. * @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
  30189. * @param radius is the radius value of the lathe
  30190. * @param tessellation is the side number of the lathe.
  30191. * @param scene defines the hosting scene
  30192. * @param updatable defines if the mesh must be flagged as updatable
  30193. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30194. * @returns a new Mesh
  30195. */
  30196. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30197. /**
  30198. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30199. * @param name defines the name of the mesh to create
  30200. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30201. * @param scene defines the hosting scene
  30202. * @param updatable defines if the mesh must be flagged as updatable
  30203. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30204. * @returns a new Mesh
  30205. */
  30206. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30207. /**
  30208. * Creates a ground mesh.
  30209. * Please consider using the same method from the MeshBuilder class instead
  30210. * @param name defines the name of the mesh to create
  30211. * @param width set the width of the ground
  30212. * @param height set the height of the ground
  30213. * @param subdivisions sets the number of subdivisions per side
  30214. * @param scene defines the hosting scene
  30215. * @param updatable defines if the mesh must be flagged as updatable
  30216. * @returns a new Mesh
  30217. */
  30218. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30219. /**
  30220. * Creates a tiled ground mesh.
  30221. * Please consider using the same method from the MeshBuilder class instead
  30222. * @param name defines the name of the mesh to create
  30223. * @param xmin set the ground minimum X coordinate
  30224. * @param zmin set the ground minimum Y coordinate
  30225. * @param xmax set the ground maximum X coordinate
  30226. * @param zmax set the ground maximum Z coordinate
  30227. * @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
  30228. * @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
  30229. * @param scene defines the hosting scene
  30230. * @param updatable defines if the mesh must be flagged as updatable
  30231. * @returns a new Mesh
  30232. */
  30233. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30234. w: number;
  30235. h: number;
  30236. }, precision: {
  30237. w: number;
  30238. h: number;
  30239. }, scene: Scene, updatable?: boolean): Mesh;
  30240. /**
  30241. * Creates a ground mesh from a height map.
  30242. * Please consider using the same method from the MeshBuilder class instead
  30243. * @see https://doc.babylonjs.com/babylon101/height_map
  30244. * @param name defines the name of the mesh to create
  30245. * @param url sets the URL of the height map image resource
  30246. * @param width set the ground width size
  30247. * @param height set the ground height size
  30248. * @param subdivisions sets the number of subdivision per side
  30249. * @param minHeight is the minimum altitude on the ground
  30250. * @param maxHeight is the maximum altitude on the ground
  30251. * @param scene defines the hosting scene
  30252. * @param updatable defines if the mesh must be flagged as updatable
  30253. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30254. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30255. * @returns a new Mesh
  30256. */
  30257. 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;
  30258. /**
  30259. * Creates a tube mesh.
  30260. * The tube is a parametric shape.
  30261. * It has no predefined shape. Its final shape will depend on the input parameters.
  30262. * Please consider using the same method from the MeshBuilder class instead
  30263. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30264. * @param name defines the name of the mesh to create
  30265. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30266. * @param radius sets the tube radius size
  30267. * @param tessellation is the number of sides on the tubular surface
  30268. * @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
  30269. * @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
  30270. * @param scene defines the hosting scene
  30271. * @param updatable defines if the mesh must be flagged as updatable
  30272. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30273. * @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)
  30274. * @returns a new Mesh
  30275. */
  30276. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30277. (i: number, distance: number): number;
  30278. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30279. /**
  30280. * Creates a polyhedron mesh.
  30281. * Please consider using the same method from the MeshBuilder class instead.
  30282. * * 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
  30283. * * The parameter `size` (positive float, default 1) sets the polygon size
  30284. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30285. * * 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`
  30286. * * 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
  30287. * * 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)`)
  30288. * * 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
  30289. * * 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
  30290. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30291. * * 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
  30292. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30293. * @param name defines the name of the mesh to create
  30294. * @param options defines the options used to create the mesh
  30295. * @param scene defines the hosting scene
  30296. * @returns a new Mesh
  30297. */
  30298. static CreatePolyhedron(name: string, options: {
  30299. type?: number;
  30300. size?: number;
  30301. sizeX?: number;
  30302. sizeY?: number;
  30303. sizeZ?: number;
  30304. custom?: any;
  30305. faceUV?: Vector4[];
  30306. faceColors?: Color4[];
  30307. updatable?: boolean;
  30308. sideOrientation?: number;
  30309. }, scene: Scene): Mesh;
  30310. /**
  30311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30313. * * 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`)
  30314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30315. * * 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
  30316. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30317. * * 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
  30318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30319. * @param name defines the name of the mesh
  30320. * @param options defines the options used to create the mesh
  30321. * @param scene defines the hosting scene
  30322. * @returns a new Mesh
  30323. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30324. */
  30325. static CreateIcoSphere(name: string, options: {
  30326. radius?: number;
  30327. flat?: boolean;
  30328. subdivisions?: number;
  30329. sideOrientation?: number;
  30330. updatable?: boolean;
  30331. }, scene: Scene): Mesh;
  30332. /**
  30333. * Creates a decal mesh.
  30334. * Please consider using the same method from the MeshBuilder class instead.
  30335. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30336. * @param name defines the name of the mesh
  30337. * @param sourceMesh defines the mesh receiving the decal
  30338. * @param position sets the position of the decal in world coordinates
  30339. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30340. * @param size sets the decal scaling
  30341. * @param angle sets the angle to rotate the decal
  30342. * @returns a new Mesh
  30343. */
  30344. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30345. /** Creates a Capsule Mesh
  30346. * @param name defines the name of the mesh.
  30347. * @param options the constructors options used to shape the mesh.
  30348. * @param scene defines the scene the mesh is scoped to.
  30349. * @returns the capsule mesh
  30350. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30351. */
  30352. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30353. /**
  30354. * Prepare internal position array for software CPU skinning
  30355. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30356. */
  30357. setPositionsForCPUSkinning(): Float32Array;
  30358. /**
  30359. * Prepare internal normal array for software CPU skinning
  30360. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30361. */
  30362. setNormalsForCPUSkinning(): Float32Array;
  30363. /**
  30364. * Updates the vertex buffer by applying transformation from the bones
  30365. * @param skeleton defines the skeleton to apply to current mesh
  30366. * @returns the current mesh
  30367. */
  30368. applySkeleton(skeleton: Skeleton): Mesh;
  30369. /**
  30370. * 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
  30371. * @param meshes defines the list of meshes to scan
  30372. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30373. */
  30374. static MinMax(meshes: AbstractMesh[]): {
  30375. min: Vector3;
  30376. max: Vector3;
  30377. };
  30378. /**
  30379. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30380. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30381. * @returns a vector3
  30382. */
  30383. static Center(meshesOrMinMaxVector: {
  30384. min: Vector3;
  30385. max: Vector3;
  30386. } | AbstractMesh[]): Vector3;
  30387. /**
  30388. * Merge the array of meshes into a single mesh for performance reasons.
  30389. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30390. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30391. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30392. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30393. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30394. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30395. * @returns a new mesh
  30396. */
  30397. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30398. /** @hidden */
  30399. addInstance(instance: InstancedMesh): void;
  30400. /** @hidden */
  30401. removeInstance(instance: InstancedMesh): void;
  30402. }
  30403. }
  30404. declare module "babylonjs/Cameras/camera" {
  30405. import { SmartArray } from "babylonjs/Misc/smartArray";
  30406. import { Observable } from "babylonjs/Misc/observable";
  30407. import { Nullable } from "babylonjs/types";
  30408. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30409. import { Scene } from "babylonjs/scene";
  30410. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30411. import { Node } from "babylonjs/node";
  30412. import { Mesh } from "babylonjs/Meshes/mesh";
  30413. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30414. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30415. import { Viewport } from "babylonjs/Maths/math.viewport";
  30416. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30418. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30419. import { Ray } from "babylonjs/Culling/ray";
  30420. /**
  30421. * This is the base class of all the camera used in the application.
  30422. * @see https://doc.babylonjs.com/features/cameras
  30423. */
  30424. export class Camera extends Node {
  30425. /** @hidden */
  30426. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30427. /**
  30428. * This is the default projection mode used by the cameras.
  30429. * It helps recreating a feeling of perspective and better appreciate depth.
  30430. * This is the best way to simulate real life cameras.
  30431. */
  30432. static readonly PERSPECTIVE_CAMERA: number;
  30433. /**
  30434. * This helps creating camera with an orthographic mode.
  30435. * 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.
  30436. */
  30437. static readonly ORTHOGRAPHIC_CAMERA: number;
  30438. /**
  30439. * This is the default FOV mode for perspective cameras.
  30440. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30441. */
  30442. static readonly FOVMODE_VERTICAL_FIXED: number;
  30443. /**
  30444. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30445. */
  30446. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30447. /**
  30448. * This specifies ther is no need for a camera rig.
  30449. * Basically only one eye is rendered corresponding to the camera.
  30450. */
  30451. static readonly RIG_MODE_NONE: number;
  30452. /**
  30453. * Simulates a camera Rig with one blue eye and one red eye.
  30454. * This can be use with 3d blue and red glasses.
  30455. */
  30456. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30457. /**
  30458. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30459. */
  30460. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30461. /**
  30462. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30463. */
  30464. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30465. /**
  30466. * Defines that both eyes of the camera will be rendered over under each other.
  30467. */
  30468. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30469. /**
  30470. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30471. */
  30472. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30473. /**
  30474. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30475. */
  30476. static readonly RIG_MODE_VR: number;
  30477. /**
  30478. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30479. */
  30480. static readonly RIG_MODE_WEBVR: number;
  30481. /**
  30482. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30483. */
  30484. static readonly RIG_MODE_CUSTOM: number;
  30485. /**
  30486. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30487. */
  30488. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30489. /**
  30490. * Define the input manager associated with the camera.
  30491. */
  30492. inputs: CameraInputsManager<Camera>;
  30493. /** @hidden */
  30494. _position: Vector3;
  30495. /**
  30496. * Define the current local position of the camera in the scene
  30497. */
  30498. get position(): Vector3;
  30499. set position(newPosition: Vector3);
  30500. protected _upVector: Vector3;
  30501. /**
  30502. * The vector the camera should consider as up.
  30503. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30504. */
  30505. set upVector(vec: Vector3);
  30506. get upVector(): Vector3;
  30507. /**
  30508. * Define the current limit on the left side for an orthographic camera
  30509. * In scene unit
  30510. */
  30511. orthoLeft: Nullable<number>;
  30512. /**
  30513. * Define the current limit on the right side for an orthographic camera
  30514. * In scene unit
  30515. */
  30516. orthoRight: Nullable<number>;
  30517. /**
  30518. * Define the current limit on the bottom side for an orthographic camera
  30519. * In scene unit
  30520. */
  30521. orthoBottom: Nullable<number>;
  30522. /**
  30523. * Define the current limit on the top side for an orthographic camera
  30524. * In scene unit
  30525. */
  30526. orthoTop: Nullable<number>;
  30527. /**
  30528. * Field Of View is set in Radians. (default is 0.8)
  30529. */
  30530. fov: number;
  30531. /**
  30532. * Define the minimum distance the camera can see from.
  30533. * This is important to note that the depth buffer are not infinite and the closer it starts
  30534. * the more your scene might encounter depth fighting issue.
  30535. */
  30536. minZ: number;
  30537. /**
  30538. * Define the maximum distance the camera can see to.
  30539. * This is important to note that the depth buffer are not infinite and the further it end
  30540. * the more your scene might encounter depth fighting issue.
  30541. */
  30542. maxZ: number;
  30543. /**
  30544. * Define the default inertia of the camera.
  30545. * This helps giving a smooth feeling to the camera movement.
  30546. */
  30547. inertia: number;
  30548. /**
  30549. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30550. */
  30551. mode: number;
  30552. /**
  30553. * Define whether the camera is intermediate.
  30554. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30555. */
  30556. isIntermediate: boolean;
  30557. /**
  30558. * Define the viewport of the camera.
  30559. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30560. */
  30561. viewport: Viewport;
  30562. /**
  30563. * Restricts the camera to viewing objects with the same layerMask.
  30564. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30565. */
  30566. layerMask: number;
  30567. /**
  30568. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30569. */
  30570. fovMode: number;
  30571. /**
  30572. * Rig mode of the camera.
  30573. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30574. * This is normally controlled byt the camera themselves as internal use.
  30575. */
  30576. cameraRigMode: number;
  30577. /**
  30578. * Defines the distance between both "eyes" in case of a RIG
  30579. */
  30580. interaxialDistance: number;
  30581. /**
  30582. * Defines if stereoscopic rendering is done side by side or over under.
  30583. */
  30584. isStereoscopicSideBySide: boolean;
  30585. /**
  30586. * 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
  30587. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30588. * else in the scene. (Eg. security camera)
  30589. *
  30590. * 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)
  30591. */
  30592. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30593. /**
  30594. * When set, the camera will render to this render target instead of the default canvas
  30595. *
  30596. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30597. */
  30598. outputRenderTarget: Nullable<RenderTargetTexture>;
  30599. /**
  30600. * Observable triggered when the camera view matrix has changed.
  30601. */
  30602. onViewMatrixChangedObservable: Observable<Camera>;
  30603. /**
  30604. * Observable triggered when the camera Projection matrix has changed.
  30605. */
  30606. onProjectionMatrixChangedObservable: Observable<Camera>;
  30607. /**
  30608. * Observable triggered when the inputs have been processed.
  30609. */
  30610. onAfterCheckInputsObservable: Observable<Camera>;
  30611. /**
  30612. * Observable triggered when reset has been called and applied to the camera.
  30613. */
  30614. onRestoreStateObservable: Observable<Camera>;
  30615. /**
  30616. * Is this camera a part of a rig system?
  30617. */
  30618. isRigCamera: boolean;
  30619. /**
  30620. * If isRigCamera set to true this will be set with the parent camera.
  30621. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30622. */
  30623. rigParent?: Camera;
  30624. /** @hidden */
  30625. _cameraRigParams: any;
  30626. /** @hidden */
  30627. _rigCameras: Camera[];
  30628. /** @hidden */
  30629. _rigPostProcess: Nullable<PostProcess>;
  30630. protected _webvrViewMatrix: Matrix;
  30631. /** @hidden */
  30632. _skipRendering: boolean;
  30633. /** @hidden */
  30634. _projectionMatrix: Matrix;
  30635. /** @hidden */
  30636. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30637. /** @hidden */
  30638. _activeMeshes: SmartArray<AbstractMesh>;
  30639. protected _globalPosition: Vector3;
  30640. /** @hidden */
  30641. _computedViewMatrix: Matrix;
  30642. private _doNotComputeProjectionMatrix;
  30643. private _transformMatrix;
  30644. private _frustumPlanes;
  30645. private _refreshFrustumPlanes;
  30646. private _storedFov;
  30647. private _stateStored;
  30648. /**
  30649. * Instantiates a new camera object.
  30650. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30651. * @see https://doc.babylonjs.com/features/cameras
  30652. * @param name Defines the name of the camera in the scene
  30653. * @param position Defines the position of the camera
  30654. * @param scene Defines the scene the camera belongs too
  30655. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30656. */
  30657. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30658. /**
  30659. * Store current camera state (fov, position, etc..)
  30660. * @returns the camera
  30661. */
  30662. storeState(): Camera;
  30663. /**
  30664. * Restores the camera state values if it has been stored. You must call storeState() first
  30665. */
  30666. protected _restoreStateValues(): boolean;
  30667. /**
  30668. * Restored camera state. You must call storeState() first.
  30669. * @returns true if restored and false otherwise
  30670. */
  30671. restoreState(): boolean;
  30672. /**
  30673. * Gets the class name of the camera.
  30674. * @returns the class name
  30675. */
  30676. getClassName(): string;
  30677. /** @hidden */
  30678. readonly _isCamera: boolean;
  30679. /**
  30680. * Gets a string representation of the camera useful for debug purpose.
  30681. * @param fullDetails Defines that a more verboe level of logging is required
  30682. * @returns the string representation
  30683. */
  30684. toString(fullDetails?: boolean): string;
  30685. /**
  30686. * Gets the current world space position of the camera.
  30687. */
  30688. get globalPosition(): Vector3;
  30689. /**
  30690. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30691. * @returns the active meshe list
  30692. */
  30693. getActiveMeshes(): SmartArray<AbstractMesh>;
  30694. /**
  30695. * Check whether a mesh is part of the current active mesh list of the camera
  30696. * @param mesh Defines the mesh to check
  30697. * @returns true if active, false otherwise
  30698. */
  30699. isActiveMesh(mesh: Mesh): boolean;
  30700. /**
  30701. * Is this camera ready to be used/rendered
  30702. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30703. * @return true if the camera is ready
  30704. */
  30705. isReady(completeCheck?: boolean): boolean;
  30706. /** @hidden */
  30707. _initCache(): void;
  30708. /** @hidden */
  30709. _updateCache(ignoreParentClass?: boolean): void;
  30710. /** @hidden */
  30711. _isSynchronized(): boolean;
  30712. /** @hidden */
  30713. _isSynchronizedViewMatrix(): boolean;
  30714. /** @hidden */
  30715. _isSynchronizedProjectionMatrix(): boolean;
  30716. /**
  30717. * Attach the input controls to a specific dom element to get the input from.
  30718. * @param element Defines the element the controls should be listened from
  30719. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30720. */
  30721. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30722. /**
  30723. * Detach the current controls from the specified dom element.
  30724. * @param element Defines the element to stop listening the inputs from
  30725. */
  30726. detachControl(element: HTMLElement): void;
  30727. /**
  30728. * Update the camera state according to the different inputs gathered during the frame.
  30729. */
  30730. update(): void;
  30731. /** @hidden */
  30732. _checkInputs(): void;
  30733. /** @hidden */
  30734. get rigCameras(): Camera[];
  30735. /**
  30736. * Gets the post process used by the rig cameras
  30737. */
  30738. get rigPostProcess(): Nullable<PostProcess>;
  30739. /**
  30740. * Internal, gets the first post proces.
  30741. * @returns the first post process to be run on this camera.
  30742. */
  30743. _getFirstPostProcess(): Nullable<PostProcess>;
  30744. private _cascadePostProcessesToRigCams;
  30745. /**
  30746. * Attach a post process to the camera.
  30747. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30748. * @param postProcess The post process to attach to the camera
  30749. * @param insertAt The position of the post process in case several of them are in use in the scene
  30750. * @returns the position the post process has been inserted at
  30751. */
  30752. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30753. /**
  30754. * Detach a post process to the camera.
  30755. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30756. * @param postProcess The post process to detach from the camera
  30757. */
  30758. detachPostProcess(postProcess: PostProcess): void;
  30759. /**
  30760. * Gets the current world matrix of the camera
  30761. */
  30762. getWorldMatrix(): Matrix;
  30763. /** @hidden */
  30764. _getViewMatrix(): Matrix;
  30765. /**
  30766. * Gets the current view matrix of the camera.
  30767. * @param force forces the camera to recompute the matrix without looking at the cached state
  30768. * @returns the view matrix
  30769. */
  30770. getViewMatrix(force?: boolean): Matrix;
  30771. /**
  30772. * Freeze the projection matrix.
  30773. * It will prevent the cache check of the camera projection compute and can speed up perf
  30774. * if no parameter of the camera are meant to change
  30775. * @param projection Defines manually a projection if necessary
  30776. */
  30777. freezeProjectionMatrix(projection?: Matrix): void;
  30778. /**
  30779. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30780. */
  30781. unfreezeProjectionMatrix(): void;
  30782. /**
  30783. * Gets the current projection matrix of the camera.
  30784. * @param force forces the camera to recompute the matrix without looking at the cached state
  30785. * @returns the projection matrix
  30786. */
  30787. getProjectionMatrix(force?: boolean): Matrix;
  30788. /**
  30789. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30790. * @returns a Matrix
  30791. */
  30792. getTransformationMatrix(): Matrix;
  30793. private _updateFrustumPlanes;
  30794. /**
  30795. * Checks if a cullable object (mesh...) is in the camera frustum
  30796. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30797. * @param target The object to check
  30798. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30799. * @returns true if the object is in frustum otherwise false
  30800. */
  30801. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30802. /**
  30803. * Checks if a cullable object (mesh...) is in the camera frustum
  30804. * Unlike isInFrustum this cheks the full bounding box
  30805. * @param target The object to check
  30806. * @returns true if the object is in frustum otherwise false
  30807. */
  30808. isCompletelyInFrustum(target: ICullable): boolean;
  30809. /**
  30810. * Gets a ray in the forward direction from the camera.
  30811. * @param length Defines the length of the ray to create
  30812. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30813. * @param origin Defines the start point of the ray which defaults to the camera position
  30814. * @returns the forward ray
  30815. */
  30816. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30817. /**
  30818. * Gets a ray in the forward direction from the camera.
  30819. * @param refRay the ray to (re)use when setting the values
  30820. * @param length Defines the length of the ray to create
  30821. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30822. * @param origin Defines the start point of the ray which defaults to the camera position
  30823. * @returns the forward ray
  30824. */
  30825. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30826. /**
  30827. * Releases resources associated with this node.
  30828. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30829. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30830. */
  30831. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30832. /** @hidden */
  30833. _isLeftCamera: boolean;
  30834. /**
  30835. * Gets the left camera of a rig setup in case of Rigged Camera
  30836. */
  30837. get isLeftCamera(): boolean;
  30838. /** @hidden */
  30839. _isRightCamera: boolean;
  30840. /**
  30841. * Gets the right camera of a rig setup in case of Rigged Camera
  30842. */
  30843. get isRightCamera(): boolean;
  30844. /**
  30845. * Gets the left camera of a rig setup in case of Rigged Camera
  30846. */
  30847. get leftCamera(): Nullable<FreeCamera>;
  30848. /**
  30849. * Gets the right camera of a rig setup in case of Rigged Camera
  30850. */
  30851. get rightCamera(): Nullable<FreeCamera>;
  30852. /**
  30853. * Gets the left camera target of a rig setup in case of Rigged Camera
  30854. * @returns the target position
  30855. */
  30856. getLeftTarget(): Nullable<Vector3>;
  30857. /**
  30858. * Gets the right camera target of a rig setup in case of Rigged Camera
  30859. * @returns the target position
  30860. */
  30861. getRightTarget(): Nullable<Vector3>;
  30862. /**
  30863. * @hidden
  30864. */
  30865. setCameraRigMode(mode: number, rigParams: any): void;
  30866. /** @hidden */
  30867. static _setStereoscopicRigMode(camera: Camera): void;
  30868. /** @hidden */
  30869. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30870. /** @hidden */
  30871. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30872. /** @hidden */
  30873. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30874. /** @hidden */
  30875. _getVRProjectionMatrix(): Matrix;
  30876. protected _updateCameraRotationMatrix(): void;
  30877. protected _updateWebVRCameraRotationMatrix(): void;
  30878. /**
  30879. * This function MUST be overwritten by the different WebVR cameras available.
  30880. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30881. * @hidden
  30882. */
  30883. _getWebVRProjectionMatrix(): Matrix;
  30884. /**
  30885. * This function MUST be overwritten by the different WebVR cameras available.
  30886. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30887. * @hidden
  30888. */
  30889. _getWebVRViewMatrix(): Matrix;
  30890. /** @hidden */
  30891. setCameraRigParameter(name: string, value: any): void;
  30892. /**
  30893. * needs to be overridden by children so sub has required properties to be copied
  30894. * @hidden
  30895. */
  30896. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30897. /**
  30898. * May need to be overridden by children
  30899. * @hidden
  30900. */
  30901. _updateRigCameras(): void;
  30902. /** @hidden */
  30903. _setupInputs(): void;
  30904. /**
  30905. * Serialiaze the camera setup to a json represention
  30906. * @returns the JSON representation
  30907. */
  30908. serialize(): any;
  30909. /**
  30910. * Clones the current camera.
  30911. * @param name The cloned camera name
  30912. * @returns the cloned camera
  30913. */
  30914. clone(name: string): Camera;
  30915. /**
  30916. * Gets the direction of the camera relative to a given local axis.
  30917. * @param localAxis Defines the reference axis to provide a relative direction.
  30918. * @return the direction
  30919. */
  30920. getDirection(localAxis: Vector3): Vector3;
  30921. /**
  30922. * Returns the current camera absolute rotation
  30923. */
  30924. get absoluteRotation(): Quaternion;
  30925. /**
  30926. * Gets the direction of the camera relative to a given local axis into a passed vector.
  30927. * @param localAxis Defines the reference axis to provide a relative direction.
  30928. * @param result Defines the vector to store the result in
  30929. */
  30930. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  30931. /**
  30932. * Gets a camera constructor for a given camera type
  30933. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  30934. * @param name The name of the camera the result will be able to instantiate
  30935. * @param scene The scene the result will construct the camera in
  30936. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  30937. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  30938. * @returns a factory method to construc the camera
  30939. */
  30940. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  30941. /**
  30942. * Compute the world matrix of the camera.
  30943. * @returns the camera world matrix
  30944. */
  30945. computeWorldMatrix(): Matrix;
  30946. /**
  30947. * Parse a JSON and creates the camera from the parsed information
  30948. * @param parsedCamera The JSON to parse
  30949. * @param scene The scene to instantiate the camera in
  30950. * @returns the newly constructed camera
  30951. */
  30952. static Parse(parsedCamera: any, scene: Scene): Camera;
  30953. }
  30954. }
  30955. declare module "babylonjs/Meshes/Builders/discBuilder" {
  30956. import { Nullable } from "babylonjs/types";
  30957. import { Scene } from "babylonjs/scene";
  30958. import { Vector4 } from "babylonjs/Maths/math.vector";
  30959. import { Mesh } from "babylonjs/Meshes/mesh";
  30960. /**
  30961. * Class containing static functions to help procedurally build meshes
  30962. */
  30963. export class DiscBuilder {
  30964. /**
  30965. * Creates a plane polygonal mesh. By default, this is a disc
  30966. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  30967. * * 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
  30968. * * 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
  30969. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  30970. * * 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
  30971. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30972. * @param name defines the name of the mesh
  30973. * @param options defines the options used to create the mesh
  30974. * @param scene defines the hosting scene
  30975. * @returns the plane polygonal mesh
  30976. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  30977. */
  30978. static CreateDisc(name: string, options: {
  30979. radius?: number;
  30980. tessellation?: number;
  30981. arc?: number;
  30982. updatable?: boolean;
  30983. sideOrientation?: number;
  30984. frontUVs?: Vector4;
  30985. backUVs?: Vector4;
  30986. }, scene?: Nullable<Scene>): Mesh;
  30987. }
  30988. }
  30989. declare module "babylonjs/Materials/fresnelParameters" {
  30990. import { DeepImmutable } from "babylonjs/types";
  30991. import { Color3 } from "babylonjs/Maths/math.color";
  30992. /**
  30993. * Options to be used when creating a FresnelParameters.
  30994. */
  30995. export type IFresnelParametersCreationOptions = {
  30996. /**
  30997. * Define the color used on edges (grazing angle)
  30998. */
  30999. leftColor?: Color3;
  31000. /**
  31001. * Define the color used on center
  31002. */
  31003. rightColor?: Color3;
  31004. /**
  31005. * Define bias applied to computed fresnel term
  31006. */
  31007. bias?: number;
  31008. /**
  31009. * Defined the power exponent applied to fresnel term
  31010. */
  31011. power?: number;
  31012. /**
  31013. * Define if the fresnel effect is enable or not.
  31014. */
  31015. isEnabled?: boolean;
  31016. };
  31017. /**
  31018. * Serialized format for FresnelParameters.
  31019. */
  31020. export type IFresnelParametersSerialized = {
  31021. /**
  31022. * Define the color used on edges (grazing angle) [as an array]
  31023. */
  31024. leftColor: number[];
  31025. /**
  31026. * Define the color used on center [as an array]
  31027. */
  31028. rightColor: number[];
  31029. /**
  31030. * Define bias applied to computed fresnel term
  31031. */
  31032. bias: number;
  31033. /**
  31034. * Defined the power exponent applied to fresnel term
  31035. */
  31036. power?: number;
  31037. /**
  31038. * Define if the fresnel effect is enable or not.
  31039. */
  31040. isEnabled: boolean;
  31041. };
  31042. /**
  31043. * This represents all the required information to add a fresnel effect on a material:
  31044. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31045. */
  31046. export class FresnelParameters {
  31047. private _isEnabled;
  31048. /**
  31049. * Define if the fresnel effect is enable or not.
  31050. */
  31051. get isEnabled(): boolean;
  31052. set isEnabled(value: boolean);
  31053. /**
  31054. * Define the color used on edges (grazing angle)
  31055. */
  31056. leftColor: Color3;
  31057. /**
  31058. * Define the color used on center
  31059. */
  31060. rightColor: Color3;
  31061. /**
  31062. * Define bias applied to computed fresnel term
  31063. */
  31064. bias: number;
  31065. /**
  31066. * Defined the power exponent applied to fresnel term
  31067. */
  31068. power: number;
  31069. /**
  31070. * Creates a new FresnelParameters object.
  31071. *
  31072. * @param options provide your own settings to optionally to override defaults
  31073. */
  31074. constructor(options?: IFresnelParametersCreationOptions);
  31075. /**
  31076. * Clones the current fresnel and its valuues
  31077. * @returns a clone fresnel configuration
  31078. */
  31079. clone(): FresnelParameters;
  31080. /**
  31081. * Determines equality between FresnelParameters objects
  31082. * @param otherFresnelParameters defines the second operand
  31083. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31084. */
  31085. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31086. /**
  31087. * Serializes the current fresnel parameters to a JSON representation.
  31088. * @return the JSON serialization
  31089. */
  31090. serialize(): IFresnelParametersSerialized;
  31091. /**
  31092. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31093. * @param parsedFresnelParameters Define the JSON representation
  31094. * @returns the parsed parameters
  31095. */
  31096. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31097. }
  31098. }
  31099. declare module "babylonjs/Materials/materialFlags" {
  31100. /**
  31101. * This groups all the flags used to control the materials channel.
  31102. */
  31103. export class MaterialFlags {
  31104. private static _DiffuseTextureEnabled;
  31105. /**
  31106. * Are diffuse textures enabled in the application.
  31107. */
  31108. static get DiffuseTextureEnabled(): boolean;
  31109. static set DiffuseTextureEnabled(value: boolean);
  31110. private static _DetailTextureEnabled;
  31111. /**
  31112. * Are detail textures enabled in the application.
  31113. */
  31114. static get DetailTextureEnabled(): boolean;
  31115. static set DetailTextureEnabled(value: boolean);
  31116. private static _AmbientTextureEnabled;
  31117. /**
  31118. * Are ambient textures enabled in the application.
  31119. */
  31120. static get AmbientTextureEnabled(): boolean;
  31121. static set AmbientTextureEnabled(value: boolean);
  31122. private static _OpacityTextureEnabled;
  31123. /**
  31124. * Are opacity textures enabled in the application.
  31125. */
  31126. static get OpacityTextureEnabled(): boolean;
  31127. static set OpacityTextureEnabled(value: boolean);
  31128. private static _ReflectionTextureEnabled;
  31129. /**
  31130. * Are reflection textures enabled in the application.
  31131. */
  31132. static get ReflectionTextureEnabled(): boolean;
  31133. static set ReflectionTextureEnabled(value: boolean);
  31134. private static _EmissiveTextureEnabled;
  31135. /**
  31136. * Are emissive textures enabled in the application.
  31137. */
  31138. static get EmissiveTextureEnabled(): boolean;
  31139. static set EmissiveTextureEnabled(value: boolean);
  31140. private static _SpecularTextureEnabled;
  31141. /**
  31142. * Are specular textures enabled in the application.
  31143. */
  31144. static get SpecularTextureEnabled(): boolean;
  31145. static set SpecularTextureEnabled(value: boolean);
  31146. private static _BumpTextureEnabled;
  31147. /**
  31148. * Are bump textures enabled in the application.
  31149. */
  31150. static get BumpTextureEnabled(): boolean;
  31151. static set BumpTextureEnabled(value: boolean);
  31152. private static _LightmapTextureEnabled;
  31153. /**
  31154. * Are lightmap textures enabled in the application.
  31155. */
  31156. static get LightmapTextureEnabled(): boolean;
  31157. static set LightmapTextureEnabled(value: boolean);
  31158. private static _RefractionTextureEnabled;
  31159. /**
  31160. * Are refraction textures enabled in the application.
  31161. */
  31162. static get RefractionTextureEnabled(): boolean;
  31163. static set RefractionTextureEnabled(value: boolean);
  31164. private static _ColorGradingTextureEnabled;
  31165. /**
  31166. * Are color grading textures enabled in the application.
  31167. */
  31168. static get ColorGradingTextureEnabled(): boolean;
  31169. static set ColorGradingTextureEnabled(value: boolean);
  31170. private static _FresnelEnabled;
  31171. /**
  31172. * Are fresnels enabled in the application.
  31173. */
  31174. static get FresnelEnabled(): boolean;
  31175. static set FresnelEnabled(value: boolean);
  31176. private static _ClearCoatTextureEnabled;
  31177. /**
  31178. * Are clear coat textures enabled in the application.
  31179. */
  31180. static get ClearCoatTextureEnabled(): boolean;
  31181. static set ClearCoatTextureEnabled(value: boolean);
  31182. private static _ClearCoatBumpTextureEnabled;
  31183. /**
  31184. * Are clear coat bump textures enabled in the application.
  31185. */
  31186. static get ClearCoatBumpTextureEnabled(): boolean;
  31187. static set ClearCoatBumpTextureEnabled(value: boolean);
  31188. private static _ClearCoatTintTextureEnabled;
  31189. /**
  31190. * Are clear coat tint textures enabled in the application.
  31191. */
  31192. static get ClearCoatTintTextureEnabled(): boolean;
  31193. static set ClearCoatTintTextureEnabled(value: boolean);
  31194. private static _SheenTextureEnabled;
  31195. /**
  31196. * Are sheen textures enabled in the application.
  31197. */
  31198. static get SheenTextureEnabled(): boolean;
  31199. static set SheenTextureEnabled(value: boolean);
  31200. private static _AnisotropicTextureEnabled;
  31201. /**
  31202. * Are anisotropic textures enabled in the application.
  31203. */
  31204. static get AnisotropicTextureEnabled(): boolean;
  31205. static set AnisotropicTextureEnabled(value: boolean);
  31206. private static _ThicknessTextureEnabled;
  31207. /**
  31208. * Are thickness textures enabled in the application.
  31209. */
  31210. static get ThicknessTextureEnabled(): boolean;
  31211. static set ThicknessTextureEnabled(value: boolean);
  31212. }
  31213. }
  31214. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31215. /** @hidden */
  31216. export var defaultFragmentDeclaration: {
  31217. name: string;
  31218. shader: string;
  31219. };
  31220. }
  31221. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31222. /** @hidden */
  31223. export var defaultUboDeclaration: {
  31224. name: string;
  31225. shader: string;
  31226. };
  31227. }
  31228. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31229. /** @hidden */
  31230. export var prePassDeclaration: {
  31231. name: string;
  31232. shader: string;
  31233. };
  31234. }
  31235. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31236. /** @hidden */
  31237. export var lightFragmentDeclaration: {
  31238. name: string;
  31239. shader: string;
  31240. };
  31241. }
  31242. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31243. /** @hidden */
  31244. export var lightUboDeclaration: {
  31245. name: string;
  31246. shader: string;
  31247. };
  31248. }
  31249. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31250. /** @hidden */
  31251. export var lightsFragmentFunctions: {
  31252. name: string;
  31253. shader: string;
  31254. };
  31255. }
  31256. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31257. /** @hidden */
  31258. export var shadowsFragmentFunctions: {
  31259. name: string;
  31260. shader: string;
  31261. };
  31262. }
  31263. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31264. /** @hidden */
  31265. export var fresnelFunction: {
  31266. name: string;
  31267. shader: string;
  31268. };
  31269. }
  31270. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31271. /** @hidden */
  31272. export var bumpFragmentMainFunctions: {
  31273. name: string;
  31274. shader: string;
  31275. };
  31276. }
  31277. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31278. /** @hidden */
  31279. export var bumpFragmentFunctions: {
  31280. name: string;
  31281. shader: string;
  31282. };
  31283. }
  31284. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31285. /** @hidden */
  31286. export var logDepthDeclaration: {
  31287. name: string;
  31288. shader: string;
  31289. };
  31290. }
  31291. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31292. /** @hidden */
  31293. export var bumpFragment: {
  31294. name: string;
  31295. shader: string;
  31296. };
  31297. }
  31298. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31299. /** @hidden */
  31300. export var depthPrePass: {
  31301. name: string;
  31302. shader: string;
  31303. };
  31304. }
  31305. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31306. /** @hidden */
  31307. export var lightFragment: {
  31308. name: string;
  31309. shader: string;
  31310. };
  31311. }
  31312. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31313. /** @hidden */
  31314. export var logDepthFragment: {
  31315. name: string;
  31316. shader: string;
  31317. };
  31318. }
  31319. declare module "babylonjs/Shaders/default.fragment" {
  31320. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31321. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31322. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31323. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31324. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31325. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31326. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31327. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31328. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31329. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31330. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31331. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31332. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31333. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31334. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31335. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31336. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31337. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31338. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31339. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31340. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31341. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31342. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31343. /** @hidden */
  31344. export var defaultPixelShader: {
  31345. name: string;
  31346. shader: string;
  31347. };
  31348. }
  31349. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31350. /** @hidden */
  31351. export var defaultVertexDeclaration: {
  31352. name: string;
  31353. shader: string;
  31354. };
  31355. }
  31356. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31357. /** @hidden */
  31358. export var bumpVertexDeclaration: {
  31359. name: string;
  31360. shader: string;
  31361. };
  31362. }
  31363. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31364. /** @hidden */
  31365. export var bumpVertex: {
  31366. name: string;
  31367. shader: string;
  31368. };
  31369. }
  31370. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31371. /** @hidden */
  31372. export var fogVertex: {
  31373. name: string;
  31374. shader: string;
  31375. };
  31376. }
  31377. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31378. /** @hidden */
  31379. export var shadowsVertex: {
  31380. name: string;
  31381. shader: string;
  31382. };
  31383. }
  31384. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31385. /** @hidden */
  31386. export var pointCloudVertex: {
  31387. name: string;
  31388. shader: string;
  31389. };
  31390. }
  31391. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31392. /** @hidden */
  31393. export var logDepthVertex: {
  31394. name: string;
  31395. shader: string;
  31396. };
  31397. }
  31398. declare module "babylonjs/Shaders/default.vertex" {
  31399. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31400. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31401. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31402. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31403. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31404. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31405. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31409. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31412. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31413. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31414. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31415. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31416. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31417. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31418. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31419. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31420. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31421. /** @hidden */
  31422. export var defaultVertexShader: {
  31423. name: string;
  31424. shader: string;
  31425. };
  31426. }
  31427. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31428. import { Nullable } from "babylonjs/types";
  31429. import { Scene } from "babylonjs/scene";
  31430. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31431. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31432. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31433. /**
  31434. * @hidden
  31435. */
  31436. export interface IMaterialDetailMapDefines {
  31437. DETAIL: boolean;
  31438. DETAILDIRECTUV: number;
  31439. DETAIL_NORMALBLENDMETHOD: number;
  31440. /** @hidden */
  31441. _areTexturesDirty: boolean;
  31442. }
  31443. /**
  31444. * Define the code related to the detail map parameters of a material
  31445. *
  31446. * Inspired from:
  31447. * 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
  31448. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31449. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31450. */
  31451. export class DetailMapConfiguration {
  31452. private _texture;
  31453. /**
  31454. * The detail texture of the material.
  31455. */
  31456. texture: Nullable<BaseTexture>;
  31457. /**
  31458. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31459. * Bigger values mean stronger blending
  31460. */
  31461. diffuseBlendLevel: number;
  31462. /**
  31463. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31464. * Bigger values mean stronger blending. Only used with PBR materials
  31465. */
  31466. roughnessBlendLevel: number;
  31467. /**
  31468. * Defines how strong the bump effect from the detail map is
  31469. * Bigger values mean stronger effect
  31470. */
  31471. bumpLevel: number;
  31472. private _normalBlendMethod;
  31473. /**
  31474. * The method used to blend the bump and detail normals together
  31475. */
  31476. normalBlendMethod: number;
  31477. private _isEnabled;
  31478. /**
  31479. * Enable or disable the detail map on this material
  31480. */
  31481. isEnabled: boolean;
  31482. /** @hidden */
  31483. private _internalMarkAllSubMeshesAsTexturesDirty;
  31484. /** @hidden */
  31485. _markAllSubMeshesAsTexturesDirty(): void;
  31486. /**
  31487. * Instantiate a new detail map
  31488. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31489. */
  31490. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31491. /**
  31492. * Gets whether the submesh is ready to be used or not.
  31493. * @param defines the list of "defines" to update.
  31494. * @param scene defines the scene the material belongs to.
  31495. * @returns - boolean indicating that the submesh is ready or not.
  31496. */
  31497. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31498. /**
  31499. * Update the defines for detail map usage
  31500. * @param defines the list of "defines" to update.
  31501. * @param scene defines the scene the material belongs to.
  31502. */
  31503. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31504. /**
  31505. * Binds the material data.
  31506. * @param uniformBuffer defines the Uniform buffer to fill in.
  31507. * @param scene defines the scene the material belongs to.
  31508. * @param isFrozen defines whether the material is frozen or not.
  31509. */
  31510. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31511. /**
  31512. * Checks to see if a texture is used in the material.
  31513. * @param texture - Base texture to use.
  31514. * @returns - Boolean specifying if a texture is used in the material.
  31515. */
  31516. hasTexture(texture: BaseTexture): boolean;
  31517. /**
  31518. * Returns an array of the actively used textures.
  31519. * @param activeTextures Array of BaseTextures
  31520. */
  31521. getActiveTextures(activeTextures: BaseTexture[]): void;
  31522. /**
  31523. * Returns the animatable textures.
  31524. * @param animatables Array of animatable textures.
  31525. */
  31526. getAnimatables(animatables: IAnimatable[]): void;
  31527. /**
  31528. * Disposes the resources of the material.
  31529. * @param forceDisposeTextures - Forces the disposal of all textures.
  31530. */
  31531. dispose(forceDisposeTextures?: boolean): void;
  31532. /**
  31533. * Get the current class name useful for serialization or dynamic coding.
  31534. * @returns "DetailMap"
  31535. */
  31536. getClassName(): string;
  31537. /**
  31538. * Add the required uniforms to the current list.
  31539. * @param uniforms defines the current uniform list.
  31540. */
  31541. static AddUniforms(uniforms: string[]): void;
  31542. /**
  31543. * Add the required samplers to the current list.
  31544. * @param samplers defines the current sampler list.
  31545. */
  31546. static AddSamplers(samplers: string[]): void;
  31547. /**
  31548. * Add the required uniforms to the current buffer.
  31549. * @param uniformBuffer defines the current uniform buffer.
  31550. */
  31551. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31552. /**
  31553. * Makes a duplicate of the current instance into another one.
  31554. * @param detailMap define the instance where to copy the info
  31555. */
  31556. copyTo(detailMap: DetailMapConfiguration): void;
  31557. /**
  31558. * Serializes this detail map instance
  31559. * @returns - An object with the serialized instance.
  31560. */
  31561. serialize(): any;
  31562. /**
  31563. * Parses a detail map setting from a serialized object.
  31564. * @param source - Serialized object.
  31565. * @param scene Defines the scene we are parsing for
  31566. * @param rootUrl Defines the rootUrl to load from
  31567. */
  31568. parse(source: any, scene: Scene, rootUrl: string): void;
  31569. }
  31570. }
  31571. declare module "babylonjs/Materials/standardMaterial" {
  31572. import { SmartArray } from "babylonjs/Misc/smartArray";
  31573. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31574. import { Nullable } from "babylonjs/types";
  31575. import { Scene } from "babylonjs/scene";
  31576. import { Matrix } from "babylonjs/Maths/math.vector";
  31577. import { Color3 } from "babylonjs/Maths/math.color";
  31578. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31580. import { Mesh } from "babylonjs/Meshes/mesh";
  31581. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31582. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31583. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31585. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31586. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31587. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31588. import "babylonjs/Shaders/default.fragment";
  31589. import "babylonjs/Shaders/default.vertex";
  31590. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31591. /** @hidden */
  31592. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31593. MAINUV1: boolean;
  31594. MAINUV2: boolean;
  31595. DIFFUSE: boolean;
  31596. DIFFUSEDIRECTUV: number;
  31597. DETAIL: boolean;
  31598. DETAILDIRECTUV: number;
  31599. DETAIL_NORMALBLENDMETHOD: number;
  31600. AMBIENT: boolean;
  31601. AMBIENTDIRECTUV: number;
  31602. OPACITY: boolean;
  31603. OPACITYDIRECTUV: number;
  31604. OPACITYRGB: boolean;
  31605. REFLECTION: boolean;
  31606. EMISSIVE: boolean;
  31607. EMISSIVEDIRECTUV: number;
  31608. SPECULAR: boolean;
  31609. SPECULARDIRECTUV: number;
  31610. BUMP: boolean;
  31611. BUMPDIRECTUV: number;
  31612. PARALLAX: boolean;
  31613. PARALLAXOCCLUSION: boolean;
  31614. SPECULAROVERALPHA: boolean;
  31615. CLIPPLANE: boolean;
  31616. CLIPPLANE2: boolean;
  31617. CLIPPLANE3: boolean;
  31618. CLIPPLANE4: boolean;
  31619. CLIPPLANE5: boolean;
  31620. CLIPPLANE6: boolean;
  31621. ALPHATEST: boolean;
  31622. DEPTHPREPASS: boolean;
  31623. ALPHAFROMDIFFUSE: boolean;
  31624. POINTSIZE: boolean;
  31625. FOG: boolean;
  31626. SPECULARTERM: boolean;
  31627. DIFFUSEFRESNEL: boolean;
  31628. OPACITYFRESNEL: boolean;
  31629. REFLECTIONFRESNEL: boolean;
  31630. REFRACTIONFRESNEL: boolean;
  31631. EMISSIVEFRESNEL: boolean;
  31632. FRESNEL: boolean;
  31633. NORMAL: boolean;
  31634. UV1: boolean;
  31635. UV2: boolean;
  31636. VERTEXCOLOR: boolean;
  31637. VERTEXALPHA: boolean;
  31638. NUM_BONE_INFLUENCERS: number;
  31639. BonesPerMesh: number;
  31640. BONETEXTURE: boolean;
  31641. INSTANCES: boolean;
  31642. THIN_INSTANCES: boolean;
  31643. GLOSSINESS: boolean;
  31644. ROUGHNESS: boolean;
  31645. EMISSIVEASILLUMINATION: boolean;
  31646. LINKEMISSIVEWITHDIFFUSE: boolean;
  31647. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31648. LIGHTMAP: boolean;
  31649. LIGHTMAPDIRECTUV: number;
  31650. OBJECTSPACE_NORMALMAP: boolean;
  31651. USELIGHTMAPASSHADOWMAP: boolean;
  31652. REFLECTIONMAP_3D: boolean;
  31653. REFLECTIONMAP_SPHERICAL: boolean;
  31654. REFLECTIONMAP_PLANAR: boolean;
  31655. REFLECTIONMAP_CUBIC: boolean;
  31656. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31657. REFLECTIONMAP_PROJECTION: boolean;
  31658. REFLECTIONMAP_SKYBOX: boolean;
  31659. REFLECTIONMAP_EXPLICIT: boolean;
  31660. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31661. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31662. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31663. INVERTCUBICMAP: boolean;
  31664. LOGARITHMICDEPTH: boolean;
  31665. REFRACTION: boolean;
  31666. REFRACTIONMAP_3D: boolean;
  31667. REFLECTIONOVERALPHA: boolean;
  31668. TWOSIDEDLIGHTING: boolean;
  31669. SHADOWFLOAT: boolean;
  31670. MORPHTARGETS: boolean;
  31671. MORPHTARGETS_NORMAL: boolean;
  31672. MORPHTARGETS_TANGENT: boolean;
  31673. MORPHTARGETS_UV: boolean;
  31674. NUM_MORPH_INFLUENCERS: number;
  31675. NONUNIFORMSCALING: boolean;
  31676. PREMULTIPLYALPHA: boolean;
  31677. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31678. ALPHABLEND: boolean;
  31679. PREPASS: boolean;
  31680. PREPASS_IRRADIANCE: boolean;
  31681. PREPASS_IRRADIANCE_INDEX: number;
  31682. PREPASS_ALBEDO: boolean;
  31683. PREPASS_ALBEDO_INDEX: number;
  31684. PREPASS_DEPTHNORMAL: boolean;
  31685. PREPASS_DEPTHNORMAL_INDEX: number;
  31686. SCENE_MRT_COUNT: number;
  31687. RGBDLIGHTMAP: boolean;
  31688. RGBDREFLECTION: boolean;
  31689. RGBDREFRACTION: boolean;
  31690. IMAGEPROCESSING: boolean;
  31691. VIGNETTE: boolean;
  31692. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31693. VIGNETTEBLENDMODEOPAQUE: boolean;
  31694. TONEMAPPING: boolean;
  31695. TONEMAPPING_ACES: boolean;
  31696. CONTRAST: boolean;
  31697. COLORCURVES: boolean;
  31698. COLORGRADING: boolean;
  31699. COLORGRADING3D: boolean;
  31700. SAMPLER3DGREENDEPTH: boolean;
  31701. SAMPLER3DBGRMAP: boolean;
  31702. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31703. MULTIVIEW: boolean;
  31704. /**
  31705. * If the reflection texture on this material is in linear color space
  31706. * @hidden
  31707. */
  31708. IS_REFLECTION_LINEAR: boolean;
  31709. /**
  31710. * If the refraction texture on this material is in linear color space
  31711. * @hidden
  31712. */
  31713. IS_REFRACTION_LINEAR: boolean;
  31714. EXPOSURE: boolean;
  31715. constructor();
  31716. setReflectionMode(modeToEnable: string): void;
  31717. }
  31718. /**
  31719. * This is the default material used in Babylon. It is the best trade off between quality
  31720. * and performances.
  31721. * @see https://doc.babylonjs.com/babylon101/materials
  31722. */
  31723. export class StandardMaterial extends PushMaterial {
  31724. private _diffuseTexture;
  31725. /**
  31726. * The basic texture of the material as viewed under a light.
  31727. */
  31728. diffuseTexture: Nullable<BaseTexture>;
  31729. private _ambientTexture;
  31730. /**
  31731. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31732. */
  31733. ambientTexture: Nullable<BaseTexture>;
  31734. private _opacityTexture;
  31735. /**
  31736. * Define the transparency of the material from a texture.
  31737. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31738. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31739. */
  31740. opacityTexture: Nullable<BaseTexture>;
  31741. private _reflectionTexture;
  31742. /**
  31743. * Define the texture used to display the reflection.
  31744. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31745. */
  31746. reflectionTexture: Nullable<BaseTexture>;
  31747. private _emissiveTexture;
  31748. /**
  31749. * Define texture of the material as if self lit.
  31750. * This will be mixed in the final result even in the absence of light.
  31751. */
  31752. emissiveTexture: Nullable<BaseTexture>;
  31753. private _specularTexture;
  31754. /**
  31755. * Define how the color and intensity of the highlight given by the light in the material.
  31756. */
  31757. specularTexture: Nullable<BaseTexture>;
  31758. private _bumpTexture;
  31759. /**
  31760. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31761. * 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.
  31762. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31763. */
  31764. bumpTexture: Nullable<BaseTexture>;
  31765. private _lightmapTexture;
  31766. /**
  31767. * Complex lighting can be computationally expensive to compute at runtime.
  31768. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31769. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31770. */
  31771. lightmapTexture: Nullable<BaseTexture>;
  31772. private _refractionTexture;
  31773. /**
  31774. * Define the texture used to display the refraction.
  31775. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31776. */
  31777. refractionTexture: Nullable<BaseTexture>;
  31778. /**
  31779. * The color of the material lit by the environmental background lighting.
  31780. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31781. */
  31782. ambientColor: Color3;
  31783. /**
  31784. * The basic color of the material as viewed under a light.
  31785. */
  31786. diffuseColor: Color3;
  31787. /**
  31788. * Define how the color and intensity of the highlight given by the light in the material.
  31789. */
  31790. specularColor: Color3;
  31791. /**
  31792. * Define the color of the material as if self lit.
  31793. * This will be mixed in the final result even in the absence of light.
  31794. */
  31795. emissiveColor: Color3;
  31796. /**
  31797. * Defines how sharp are the highlights in the material.
  31798. * The bigger the value the sharper giving a more glossy feeling to the result.
  31799. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31800. */
  31801. specularPower: number;
  31802. private _useAlphaFromDiffuseTexture;
  31803. /**
  31804. * Does the transparency come from the diffuse texture alpha channel.
  31805. */
  31806. useAlphaFromDiffuseTexture: boolean;
  31807. private _useEmissiveAsIllumination;
  31808. /**
  31809. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31810. */
  31811. useEmissiveAsIllumination: boolean;
  31812. private _linkEmissiveWithDiffuse;
  31813. /**
  31814. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31815. * the emissive level when the final color is close to one.
  31816. */
  31817. linkEmissiveWithDiffuse: boolean;
  31818. private _useSpecularOverAlpha;
  31819. /**
  31820. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31821. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31822. */
  31823. useSpecularOverAlpha: boolean;
  31824. private _useReflectionOverAlpha;
  31825. /**
  31826. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31827. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31828. */
  31829. useReflectionOverAlpha: boolean;
  31830. private _disableLighting;
  31831. /**
  31832. * Does lights from the scene impacts this material.
  31833. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31834. */
  31835. disableLighting: boolean;
  31836. private _useObjectSpaceNormalMap;
  31837. /**
  31838. * Allows using an object space normal map (instead of tangent space).
  31839. */
  31840. useObjectSpaceNormalMap: boolean;
  31841. private _useParallax;
  31842. /**
  31843. * Is parallax enabled or not.
  31844. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31845. */
  31846. useParallax: boolean;
  31847. private _useParallaxOcclusion;
  31848. /**
  31849. * Is parallax occlusion enabled or not.
  31850. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31851. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31852. */
  31853. useParallaxOcclusion: boolean;
  31854. /**
  31855. * 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.
  31856. */
  31857. parallaxScaleBias: number;
  31858. private _roughness;
  31859. /**
  31860. * Helps to define how blurry the reflections should appears in the material.
  31861. */
  31862. roughness: number;
  31863. /**
  31864. * In case of refraction, define the value of the index of refraction.
  31865. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31866. */
  31867. indexOfRefraction: number;
  31868. /**
  31869. * Invert the refraction texture alongside the y axis.
  31870. * It can be useful with procedural textures or probe for instance.
  31871. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31872. */
  31873. invertRefractionY: boolean;
  31874. /**
  31875. * Defines the alpha limits in alpha test mode.
  31876. */
  31877. alphaCutOff: number;
  31878. private _useLightmapAsShadowmap;
  31879. /**
  31880. * In case of light mapping, define whether the map contains light or shadow informations.
  31881. */
  31882. useLightmapAsShadowmap: boolean;
  31883. private _diffuseFresnelParameters;
  31884. /**
  31885. * Define the diffuse fresnel parameters of the material.
  31886. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31887. */
  31888. diffuseFresnelParameters: FresnelParameters;
  31889. private _opacityFresnelParameters;
  31890. /**
  31891. * Define the opacity fresnel parameters of the material.
  31892. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31893. */
  31894. opacityFresnelParameters: FresnelParameters;
  31895. private _reflectionFresnelParameters;
  31896. /**
  31897. * Define the reflection fresnel parameters of the material.
  31898. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31899. */
  31900. reflectionFresnelParameters: FresnelParameters;
  31901. private _refractionFresnelParameters;
  31902. /**
  31903. * Define the refraction fresnel parameters of the material.
  31904. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31905. */
  31906. refractionFresnelParameters: FresnelParameters;
  31907. private _emissiveFresnelParameters;
  31908. /**
  31909. * Define the emissive fresnel parameters of the material.
  31910. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31911. */
  31912. emissiveFresnelParameters: FresnelParameters;
  31913. private _useReflectionFresnelFromSpecular;
  31914. /**
  31915. * If true automatically deducts the fresnels values from the material specularity.
  31916. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31917. */
  31918. useReflectionFresnelFromSpecular: boolean;
  31919. private _useGlossinessFromSpecularMapAlpha;
  31920. /**
  31921. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  31922. */
  31923. useGlossinessFromSpecularMapAlpha: boolean;
  31924. private _maxSimultaneousLights;
  31925. /**
  31926. * Defines the maximum number of lights that can be used in the material
  31927. */
  31928. maxSimultaneousLights: number;
  31929. private _invertNormalMapX;
  31930. /**
  31931. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  31932. */
  31933. invertNormalMapX: boolean;
  31934. private _invertNormalMapY;
  31935. /**
  31936. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  31937. */
  31938. invertNormalMapY: boolean;
  31939. private _twoSidedLighting;
  31940. /**
  31941. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  31942. */
  31943. twoSidedLighting: boolean;
  31944. /**
  31945. * Default configuration related to image processing available in the standard Material.
  31946. */
  31947. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  31948. /**
  31949. * Gets the image processing configuration used either in this material.
  31950. */
  31951. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  31952. /**
  31953. * Sets the Default image processing configuration used either in the this material.
  31954. *
  31955. * If sets to null, the scene one is in use.
  31956. */
  31957. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  31958. /**
  31959. * Keep track of the image processing observer to allow dispose and replace.
  31960. */
  31961. private _imageProcessingObserver;
  31962. /**
  31963. * Attaches a new image processing configuration to the Standard Material.
  31964. * @param configuration
  31965. */
  31966. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  31967. /**
  31968. * Gets wether the color curves effect is enabled.
  31969. */
  31970. get cameraColorCurvesEnabled(): boolean;
  31971. /**
  31972. * Sets wether the color curves effect is enabled.
  31973. */
  31974. set cameraColorCurvesEnabled(value: boolean);
  31975. /**
  31976. * Gets wether the color grading effect is enabled.
  31977. */
  31978. get cameraColorGradingEnabled(): boolean;
  31979. /**
  31980. * Gets wether the color grading effect is enabled.
  31981. */
  31982. set cameraColorGradingEnabled(value: boolean);
  31983. /**
  31984. * Gets wether tonemapping is enabled or not.
  31985. */
  31986. get cameraToneMappingEnabled(): boolean;
  31987. /**
  31988. * Sets wether tonemapping is enabled or not
  31989. */
  31990. set cameraToneMappingEnabled(value: boolean);
  31991. /**
  31992. * The camera exposure used on this material.
  31993. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  31994. * This corresponds to a photographic exposure.
  31995. */
  31996. get cameraExposure(): number;
  31997. /**
  31998. * The camera exposure used on this material.
  31999. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32000. * This corresponds to a photographic exposure.
  32001. */
  32002. set cameraExposure(value: number);
  32003. /**
  32004. * Gets The camera contrast used on this material.
  32005. */
  32006. get cameraContrast(): number;
  32007. /**
  32008. * Sets The camera contrast used on this material.
  32009. */
  32010. set cameraContrast(value: number);
  32011. /**
  32012. * Gets the Color Grading 2D Lookup Texture.
  32013. */
  32014. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32015. /**
  32016. * Sets the Color Grading 2D Lookup Texture.
  32017. */
  32018. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32019. /**
  32020. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32021. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32022. * 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;
  32023. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32024. */
  32025. get cameraColorCurves(): Nullable<ColorCurves>;
  32026. /**
  32027. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32028. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32029. * 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;
  32030. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32031. */
  32032. set cameraColorCurves(value: Nullable<ColorCurves>);
  32033. /**
  32034. * Can this material render to several textures at once
  32035. */
  32036. get canRenderToMRT(): boolean;
  32037. /**
  32038. * Defines the detail map parameters for the material.
  32039. */
  32040. readonly detailMap: DetailMapConfiguration;
  32041. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32042. protected _worldViewProjectionMatrix: Matrix;
  32043. protected _globalAmbientColor: Color3;
  32044. protected _useLogarithmicDepth: boolean;
  32045. protected _rebuildInParallel: boolean;
  32046. /**
  32047. * Instantiates a new standard material.
  32048. * This is the default material used in Babylon. It is the best trade off between quality
  32049. * and performances.
  32050. * @see https://doc.babylonjs.com/babylon101/materials
  32051. * @param name Define the name of the material in the scene
  32052. * @param scene Define the scene the material belong to
  32053. */
  32054. constructor(name: string, scene: Scene);
  32055. /**
  32056. * Gets a boolean indicating that current material needs to register RTT
  32057. */
  32058. get hasRenderTargetTextures(): boolean;
  32059. /**
  32060. * Gets the current class name of the material e.g. "StandardMaterial"
  32061. * Mainly use in serialization.
  32062. * @returns the class name
  32063. */
  32064. getClassName(): string;
  32065. /**
  32066. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32067. * You can try switching to logarithmic depth.
  32068. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32069. */
  32070. get useLogarithmicDepth(): boolean;
  32071. set useLogarithmicDepth(value: boolean);
  32072. /**
  32073. * Specifies if the material will require alpha blending
  32074. * @returns a boolean specifying if alpha blending is needed
  32075. */
  32076. needAlphaBlending(): boolean;
  32077. /**
  32078. * Specifies if this material should be rendered in alpha test mode
  32079. * @returns a boolean specifying if an alpha test is needed.
  32080. */
  32081. needAlphaTesting(): boolean;
  32082. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32083. /**
  32084. * Get the texture used for alpha test purpose.
  32085. * @returns the diffuse texture in case of the standard material.
  32086. */
  32087. getAlphaTestTexture(): Nullable<BaseTexture>;
  32088. /**
  32089. * Get if the submesh is ready to be used and all its information available.
  32090. * Child classes can use it to update shaders
  32091. * @param mesh defines the mesh to check
  32092. * @param subMesh defines which submesh to check
  32093. * @param useInstances specifies that instances should be used
  32094. * @returns a boolean indicating that the submesh is ready or not
  32095. */
  32096. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32097. /**
  32098. * Builds the material UBO layouts.
  32099. * Used internally during the effect preparation.
  32100. */
  32101. buildUniformLayout(): void;
  32102. /**
  32103. * Unbinds the material from the mesh
  32104. */
  32105. unbind(): void;
  32106. /**
  32107. * Binds the submesh to this material by preparing the effect and shader to draw
  32108. * @param world defines the world transformation matrix
  32109. * @param mesh defines the mesh containing the submesh
  32110. * @param subMesh defines the submesh to bind the material to
  32111. */
  32112. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32113. /**
  32114. * Get the list of animatables in the material.
  32115. * @returns the list of animatables object used in the material
  32116. */
  32117. getAnimatables(): IAnimatable[];
  32118. /**
  32119. * Gets the active textures from the material
  32120. * @returns an array of textures
  32121. */
  32122. getActiveTextures(): BaseTexture[];
  32123. /**
  32124. * Specifies if the material uses a texture
  32125. * @param texture defines the texture to check against the material
  32126. * @returns a boolean specifying if the material uses the texture
  32127. */
  32128. hasTexture(texture: BaseTexture): boolean;
  32129. /**
  32130. * Disposes the material
  32131. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32132. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32133. */
  32134. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32135. /**
  32136. * Makes a duplicate of the material, and gives it a new name
  32137. * @param name defines the new name for the duplicated material
  32138. * @returns the cloned material
  32139. */
  32140. clone(name: string): StandardMaterial;
  32141. /**
  32142. * Serializes this material in a JSON representation
  32143. * @returns the serialized material object
  32144. */
  32145. serialize(): any;
  32146. /**
  32147. * Creates a standard material from parsed material data
  32148. * @param source defines the JSON representation of the material
  32149. * @param scene defines the hosting scene
  32150. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32151. * @returns a new standard material
  32152. */
  32153. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32154. /**
  32155. * Are diffuse textures enabled in the application.
  32156. */
  32157. static get DiffuseTextureEnabled(): boolean;
  32158. static set DiffuseTextureEnabled(value: boolean);
  32159. /**
  32160. * Are detail textures enabled in the application.
  32161. */
  32162. static get DetailTextureEnabled(): boolean;
  32163. static set DetailTextureEnabled(value: boolean);
  32164. /**
  32165. * Are ambient textures enabled in the application.
  32166. */
  32167. static get AmbientTextureEnabled(): boolean;
  32168. static set AmbientTextureEnabled(value: boolean);
  32169. /**
  32170. * Are opacity textures enabled in the application.
  32171. */
  32172. static get OpacityTextureEnabled(): boolean;
  32173. static set OpacityTextureEnabled(value: boolean);
  32174. /**
  32175. * Are reflection textures enabled in the application.
  32176. */
  32177. static get ReflectionTextureEnabled(): boolean;
  32178. static set ReflectionTextureEnabled(value: boolean);
  32179. /**
  32180. * Are emissive textures enabled in the application.
  32181. */
  32182. static get EmissiveTextureEnabled(): boolean;
  32183. static set EmissiveTextureEnabled(value: boolean);
  32184. /**
  32185. * Are specular textures enabled in the application.
  32186. */
  32187. static get SpecularTextureEnabled(): boolean;
  32188. static set SpecularTextureEnabled(value: boolean);
  32189. /**
  32190. * Are bump textures enabled in the application.
  32191. */
  32192. static get BumpTextureEnabled(): boolean;
  32193. static set BumpTextureEnabled(value: boolean);
  32194. /**
  32195. * Are lightmap textures enabled in the application.
  32196. */
  32197. static get LightmapTextureEnabled(): boolean;
  32198. static set LightmapTextureEnabled(value: boolean);
  32199. /**
  32200. * Are refraction textures enabled in the application.
  32201. */
  32202. static get RefractionTextureEnabled(): boolean;
  32203. static set RefractionTextureEnabled(value: boolean);
  32204. /**
  32205. * Are color grading textures enabled in the application.
  32206. */
  32207. static get ColorGradingTextureEnabled(): boolean;
  32208. static set ColorGradingTextureEnabled(value: boolean);
  32209. /**
  32210. * Are fresnels enabled in the application.
  32211. */
  32212. static get FresnelEnabled(): boolean;
  32213. static set FresnelEnabled(value: boolean);
  32214. }
  32215. }
  32216. declare module "babylonjs/Particles/solidParticleSystem" {
  32217. import { Nullable } from "babylonjs/types";
  32218. import { Mesh } from "babylonjs/Meshes/mesh";
  32219. import { Scene, IDisposable } from "babylonjs/scene";
  32220. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32221. import { Material } from "babylonjs/Materials/material";
  32222. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32224. /**
  32225. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32226. *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.
  32227. * The SPS is also a particle system. It provides some methods to manage the particles.
  32228. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32229. *
  32230. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32231. */
  32232. export class SolidParticleSystem implements IDisposable {
  32233. /**
  32234. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32235. * Example : var p = SPS.particles[i];
  32236. */
  32237. particles: SolidParticle[];
  32238. /**
  32239. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32240. */
  32241. nbParticles: number;
  32242. /**
  32243. * If the particles must ever face the camera (default false). Useful for planar particles.
  32244. */
  32245. billboard: boolean;
  32246. /**
  32247. * Recompute normals when adding a shape
  32248. */
  32249. recomputeNormals: boolean;
  32250. /**
  32251. * This a counter ofr your own usage. It's not set by any SPS functions.
  32252. */
  32253. counter: number;
  32254. /**
  32255. * The SPS name. This name is also given to the underlying mesh.
  32256. */
  32257. name: string;
  32258. /**
  32259. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32260. */
  32261. mesh: Mesh;
  32262. /**
  32263. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32264. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32265. */
  32266. vars: any;
  32267. /**
  32268. * This array is populated when the SPS is set as 'pickable'.
  32269. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32270. * Each element of this array is an object `{idx: int, faceId: int}`.
  32271. * `idx` is the picked particle index in the `SPS.particles` array
  32272. * `faceId` is the picked face index counted within this particle.
  32273. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32274. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32275. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32276. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32277. */
  32278. pickedParticles: {
  32279. idx: number;
  32280. faceId: number;
  32281. }[];
  32282. /**
  32283. * This array is populated when the SPS is set as 'pickable'
  32284. * Each key of this array is a submesh index.
  32285. * Each element of this array is a second array defined like this :
  32286. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32287. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32288. * `idx` is the picked particle index in the `SPS.particles` array
  32289. * `faceId` is the picked face index counted within this particle.
  32290. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32291. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32292. */
  32293. pickedBySubMesh: {
  32294. idx: number;
  32295. faceId: number;
  32296. }[][];
  32297. /**
  32298. * This array is populated when `enableDepthSort` is set to true.
  32299. * Each element of this array is an instance of the class DepthSortedParticle.
  32300. */
  32301. depthSortedParticles: DepthSortedParticle[];
  32302. /**
  32303. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32304. * @hidden
  32305. */
  32306. _bSphereOnly: boolean;
  32307. /**
  32308. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32309. * @hidden
  32310. */
  32311. _bSphereRadiusFactor: number;
  32312. private _scene;
  32313. private _positions;
  32314. private _indices;
  32315. private _normals;
  32316. private _colors;
  32317. private _uvs;
  32318. private _indices32;
  32319. private _positions32;
  32320. private _normals32;
  32321. private _fixedNormal32;
  32322. private _colors32;
  32323. private _uvs32;
  32324. private _index;
  32325. private _updatable;
  32326. private _pickable;
  32327. private _isVisibilityBoxLocked;
  32328. private _alwaysVisible;
  32329. private _depthSort;
  32330. private _expandable;
  32331. private _shapeCounter;
  32332. private _copy;
  32333. private _color;
  32334. private _computeParticleColor;
  32335. private _computeParticleTexture;
  32336. private _computeParticleRotation;
  32337. private _computeParticleVertex;
  32338. private _computeBoundingBox;
  32339. private _depthSortParticles;
  32340. private _camera;
  32341. private _mustUnrotateFixedNormals;
  32342. private _particlesIntersect;
  32343. private _needs32Bits;
  32344. private _isNotBuilt;
  32345. private _lastParticleId;
  32346. private _idxOfId;
  32347. private _multimaterialEnabled;
  32348. private _useModelMaterial;
  32349. private _indicesByMaterial;
  32350. private _materialIndexes;
  32351. private _depthSortFunction;
  32352. private _materialSortFunction;
  32353. private _materials;
  32354. private _multimaterial;
  32355. private _materialIndexesById;
  32356. private _defaultMaterial;
  32357. private _autoUpdateSubMeshes;
  32358. private _tmpVertex;
  32359. /**
  32360. * Creates a SPS (Solid Particle System) object.
  32361. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32362. * @param scene (Scene) is the scene in which the SPS is added.
  32363. * @param options defines the options of the sps e.g.
  32364. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32365. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32366. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32367. * * 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.
  32368. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32369. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32370. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32371. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32372. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32373. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32374. */
  32375. constructor(name: string, scene: Scene, options?: {
  32376. updatable?: boolean;
  32377. isPickable?: boolean;
  32378. enableDepthSort?: boolean;
  32379. particleIntersection?: boolean;
  32380. boundingSphereOnly?: boolean;
  32381. bSphereRadiusFactor?: number;
  32382. expandable?: boolean;
  32383. useModelMaterial?: boolean;
  32384. enableMultiMaterial?: boolean;
  32385. });
  32386. /**
  32387. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32388. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32389. * @returns the created mesh
  32390. */
  32391. buildMesh(): Mesh;
  32392. /**
  32393. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32394. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32395. * Thus the particles generated from `digest()` have their property `position` set yet.
  32396. * @param mesh ( Mesh ) is the mesh to be digested
  32397. * @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
  32398. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32399. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32400. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32401. * @returns the current SPS
  32402. */
  32403. digest(mesh: Mesh, options?: {
  32404. facetNb?: number;
  32405. number?: number;
  32406. delta?: number;
  32407. storage?: [];
  32408. }): SolidParticleSystem;
  32409. /**
  32410. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32411. * @hidden
  32412. */
  32413. private _unrotateFixedNormals;
  32414. /**
  32415. * Resets the temporary working copy particle
  32416. * @hidden
  32417. */
  32418. private _resetCopy;
  32419. /**
  32420. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32421. * @param p the current index in the positions array to be updated
  32422. * @param ind the current index in the indices array
  32423. * @param shape a Vector3 array, the shape geometry
  32424. * @param positions the positions array to be updated
  32425. * @param meshInd the shape indices array
  32426. * @param indices the indices array to be updated
  32427. * @param meshUV the shape uv array
  32428. * @param uvs the uv array to be updated
  32429. * @param meshCol the shape color array
  32430. * @param colors the color array to be updated
  32431. * @param meshNor the shape normals array
  32432. * @param normals the normals array to be updated
  32433. * @param idx the particle index
  32434. * @param idxInShape the particle index in its shape
  32435. * @param options the addShape() method passed options
  32436. * @model the particle model
  32437. * @hidden
  32438. */
  32439. private _meshBuilder;
  32440. /**
  32441. * Returns a shape Vector3 array from positions float array
  32442. * @param positions float array
  32443. * @returns a vector3 array
  32444. * @hidden
  32445. */
  32446. private _posToShape;
  32447. /**
  32448. * Returns a shapeUV array from a float uvs (array deep copy)
  32449. * @param uvs as a float array
  32450. * @returns a shapeUV array
  32451. * @hidden
  32452. */
  32453. private _uvsToShapeUV;
  32454. /**
  32455. * Adds a new particle object in the particles array
  32456. * @param idx particle index in particles array
  32457. * @param id particle id
  32458. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32459. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32460. * @param model particle ModelShape object
  32461. * @param shapeId model shape identifier
  32462. * @param idxInShape index of the particle in the current model
  32463. * @param bInfo model bounding info object
  32464. * @param storage target storage array, if any
  32465. * @hidden
  32466. */
  32467. private _addParticle;
  32468. /**
  32469. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32470. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32471. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32472. * @param nb (positive integer) the number of particles to be created from this model
  32473. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32474. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32475. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32476. * @returns the number of shapes in the system
  32477. */
  32478. addShape(mesh: Mesh, nb: number, options?: {
  32479. positionFunction?: any;
  32480. vertexFunction?: any;
  32481. storage?: [];
  32482. }): number;
  32483. /**
  32484. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32485. * @hidden
  32486. */
  32487. private _rebuildParticle;
  32488. /**
  32489. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32490. * @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.
  32491. * @returns the SPS.
  32492. */
  32493. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32494. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32495. * Returns an array with the removed particles.
  32496. * 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.
  32497. * The SPS can't be empty so at least one particle needs to remain in place.
  32498. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32499. * @param start index of the first particle to remove
  32500. * @param end index of the last particle to remove (included)
  32501. * @returns an array populated with the removed particles
  32502. */
  32503. removeParticles(start: number, end: number): SolidParticle[];
  32504. /**
  32505. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32506. * @param solidParticleArray an array populated with Solid Particles objects
  32507. * @returns the SPS
  32508. */
  32509. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32510. /**
  32511. * Creates a new particle and modifies the SPS mesh geometry :
  32512. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32513. * - calls _addParticle() to populate the particle array
  32514. * factorized code from addShape() and insertParticlesFromArray()
  32515. * @param idx particle index in the particles array
  32516. * @param i particle index in its shape
  32517. * @param modelShape particle ModelShape object
  32518. * @param shape shape vertex array
  32519. * @param meshInd shape indices array
  32520. * @param meshUV shape uv array
  32521. * @param meshCol shape color array
  32522. * @param meshNor shape normals array
  32523. * @param bbInfo shape bounding info
  32524. * @param storage target particle storage
  32525. * @options addShape() passed options
  32526. * @hidden
  32527. */
  32528. private _insertNewParticle;
  32529. /**
  32530. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32531. * This method calls `updateParticle()` for each particle of the SPS.
  32532. * For an animated SPS, it is usually called within the render loop.
  32533. * 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.
  32534. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32535. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32536. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32537. * @returns the SPS.
  32538. */
  32539. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32540. /**
  32541. * Disposes the SPS.
  32542. */
  32543. dispose(): void;
  32544. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32545. * idx is the particle index in the SPS
  32546. * faceId is the picked face index counted within this particle.
  32547. * Returns null if the pickInfo can't identify a picked particle.
  32548. * @param pickingInfo (PickingInfo object)
  32549. * @returns {idx: number, faceId: number} or null
  32550. */
  32551. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32552. idx: number;
  32553. faceId: number;
  32554. }>;
  32555. /**
  32556. * Returns a SolidParticle object from its identifier : particle.id
  32557. * @param id (integer) the particle Id
  32558. * @returns the searched particle or null if not found in the SPS.
  32559. */
  32560. getParticleById(id: number): Nullable<SolidParticle>;
  32561. /**
  32562. * Returns a new array populated with the particles having the passed shapeId.
  32563. * @param shapeId (integer) the shape identifier
  32564. * @returns a new solid particle array
  32565. */
  32566. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32567. /**
  32568. * Populates the passed array "ref" with the particles having the passed shapeId.
  32569. * @param shapeId the shape identifier
  32570. * @returns the SPS
  32571. * @param ref
  32572. */
  32573. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32574. /**
  32575. * Computes the required SubMeshes according the materials assigned to the particles.
  32576. * @returns the solid particle system.
  32577. * Does nothing if called before the SPS mesh is built.
  32578. */
  32579. computeSubMeshes(): SolidParticleSystem;
  32580. /**
  32581. * Sorts the solid particles by material when MultiMaterial is enabled.
  32582. * Updates the indices32 array.
  32583. * Updates the indicesByMaterial array.
  32584. * Updates the mesh indices array.
  32585. * @returns the SPS
  32586. * @hidden
  32587. */
  32588. private _sortParticlesByMaterial;
  32589. /**
  32590. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32591. * @hidden
  32592. */
  32593. private _setMaterialIndexesById;
  32594. /**
  32595. * Returns an array with unique values of Materials from the passed array
  32596. * @param array the material array to be checked and filtered
  32597. * @hidden
  32598. */
  32599. private _filterUniqueMaterialId;
  32600. /**
  32601. * Sets a new Standard Material as _defaultMaterial if not already set.
  32602. * @hidden
  32603. */
  32604. private _setDefaultMaterial;
  32605. /**
  32606. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32607. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32608. * @returns the SPS.
  32609. */
  32610. refreshVisibleSize(): SolidParticleSystem;
  32611. /**
  32612. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32613. * @param size the size (float) of the visibility box
  32614. * note : this doesn't lock the SPS mesh bounding box.
  32615. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32616. */
  32617. setVisibilityBox(size: number): void;
  32618. /**
  32619. * Gets whether the SPS as always visible or not
  32620. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32621. */
  32622. get isAlwaysVisible(): boolean;
  32623. /**
  32624. * Sets the SPS as always visible or not
  32625. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32626. */
  32627. set isAlwaysVisible(val: boolean);
  32628. /**
  32629. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32630. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32631. */
  32632. set isVisibilityBoxLocked(val: boolean);
  32633. /**
  32634. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32635. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32636. */
  32637. get isVisibilityBoxLocked(): boolean;
  32638. /**
  32639. * Tells to `setParticles()` to compute the particle rotations or not.
  32640. * Default value : true. The SPS is faster when it's set to false.
  32641. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32642. */
  32643. set computeParticleRotation(val: boolean);
  32644. /**
  32645. * Tells to `setParticles()` to compute the particle colors or not.
  32646. * Default value : true. The SPS is faster when it's set to false.
  32647. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32648. */
  32649. set computeParticleColor(val: boolean);
  32650. set computeParticleTexture(val: boolean);
  32651. /**
  32652. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32653. * Default value : false. The SPS is faster when it's set to false.
  32654. * Note : the particle custom vertex positions aren't stored values.
  32655. */
  32656. set computeParticleVertex(val: boolean);
  32657. /**
  32658. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32659. */
  32660. set computeBoundingBox(val: boolean);
  32661. /**
  32662. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32663. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32664. * Default : `true`
  32665. */
  32666. set depthSortParticles(val: boolean);
  32667. /**
  32668. * Gets if `setParticles()` computes the particle rotations or not.
  32669. * Default value : true. The SPS is faster when it's set to false.
  32670. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32671. */
  32672. get computeParticleRotation(): boolean;
  32673. /**
  32674. * Gets if `setParticles()` computes the particle colors or not.
  32675. * Default value : true. The SPS is faster when it's set to false.
  32676. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32677. */
  32678. get computeParticleColor(): boolean;
  32679. /**
  32680. * Gets if `setParticles()` computes the particle textures or not.
  32681. * Default value : true. The SPS is faster when it's set to false.
  32682. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32683. */
  32684. get computeParticleTexture(): boolean;
  32685. /**
  32686. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32687. * Default value : false. The SPS is faster when it's set to false.
  32688. * Note : the particle custom vertex positions aren't stored values.
  32689. */
  32690. get computeParticleVertex(): boolean;
  32691. /**
  32692. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32693. */
  32694. get computeBoundingBox(): boolean;
  32695. /**
  32696. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32697. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32698. * Default : `true`
  32699. */
  32700. get depthSortParticles(): boolean;
  32701. /**
  32702. * Gets if the SPS is created as expandable at construction time.
  32703. * Default : `false`
  32704. */
  32705. get expandable(): boolean;
  32706. /**
  32707. * Gets if the SPS supports the Multi Materials
  32708. */
  32709. get multimaterialEnabled(): boolean;
  32710. /**
  32711. * Gets if the SPS uses the model materials for its own multimaterial.
  32712. */
  32713. get useModelMaterial(): boolean;
  32714. /**
  32715. * The SPS used material array.
  32716. */
  32717. get materials(): Material[];
  32718. /**
  32719. * Sets the SPS MultiMaterial from the passed materials.
  32720. * Note : the passed array is internally copied and not used then by reference.
  32721. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32722. */
  32723. setMultiMaterial(materials: Material[]): void;
  32724. /**
  32725. * The SPS computed multimaterial object
  32726. */
  32727. get multimaterial(): MultiMaterial;
  32728. set multimaterial(mm: MultiMaterial);
  32729. /**
  32730. * If the subMeshes must be updated on the next call to setParticles()
  32731. */
  32732. get autoUpdateSubMeshes(): boolean;
  32733. set autoUpdateSubMeshes(val: boolean);
  32734. /**
  32735. * This function does nothing. It may be overwritten to set all the particle first values.
  32736. * The SPS doesn't call this function, you may have to call it by your own.
  32737. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32738. */
  32739. initParticles(): void;
  32740. /**
  32741. * This function does nothing. It may be overwritten to recycle a particle.
  32742. * The SPS doesn't call this function, you may have to call it by your own.
  32743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32744. * @param particle The particle to recycle
  32745. * @returns the recycled particle
  32746. */
  32747. recycleParticle(particle: SolidParticle): SolidParticle;
  32748. /**
  32749. * Updates a particle : this function should be overwritten by the user.
  32750. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32751. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32752. * @example : just set a particle position or velocity and recycle conditions
  32753. * @param particle The particle to update
  32754. * @returns the updated particle
  32755. */
  32756. updateParticle(particle: SolidParticle): SolidParticle;
  32757. /**
  32758. * Updates a vertex of a particle : it can be overwritten by the user.
  32759. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32760. * @param particle the current particle
  32761. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32762. * @param pt the index of the current vertex in the particle shape
  32763. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32764. * @example : just set a vertex particle position or color
  32765. * @returns the sps
  32766. */
  32767. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32768. /**
  32769. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32770. * This does nothing and may be overwritten by the user.
  32771. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32772. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32773. * @param update the boolean update value actually passed to setParticles()
  32774. */
  32775. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32776. /**
  32777. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32778. * This will be passed three parameters.
  32779. * This does nothing and may be overwritten by the user.
  32780. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32781. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32782. * @param update the boolean update value actually passed to setParticles()
  32783. */
  32784. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32785. }
  32786. }
  32787. declare module "babylonjs/Particles/solidParticle" {
  32788. import { Nullable } from "babylonjs/types";
  32789. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32790. import { Color4 } from "babylonjs/Maths/math.color";
  32791. import { Mesh } from "babylonjs/Meshes/mesh";
  32792. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32793. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32794. import { Plane } from "babylonjs/Maths/math.plane";
  32795. import { Material } from "babylonjs/Materials/material";
  32796. /**
  32797. * Represents one particle of a solid particle system.
  32798. */
  32799. export class SolidParticle {
  32800. /**
  32801. * particle global index
  32802. */
  32803. idx: number;
  32804. /**
  32805. * particle identifier
  32806. */
  32807. id: number;
  32808. /**
  32809. * The color of the particle
  32810. */
  32811. color: Nullable<Color4>;
  32812. /**
  32813. * The world space position of the particle.
  32814. */
  32815. position: Vector3;
  32816. /**
  32817. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32818. */
  32819. rotation: Vector3;
  32820. /**
  32821. * The world space rotation quaternion of the particle.
  32822. */
  32823. rotationQuaternion: Nullable<Quaternion>;
  32824. /**
  32825. * The scaling of the particle.
  32826. */
  32827. scaling: Vector3;
  32828. /**
  32829. * The uvs of the particle.
  32830. */
  32831. uvs: Vector4;
  32832. /**
  32833. * The current speed of the particle.
  32834. */
  32835. velocity: Vector3;
  32836. /**
  32837. * The pivot point in the particle local space.
  32838. */
  32839. pivot: Vector3;
  32840. /**
  32841. * Must the particle be translated from its pivot point in its local space ?
  32842. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32843. * Default : false
  32844. */
  32845. translateFromPivot: boolean;
  32846. /**
  32847. * Is the particle active or not ?
  32848. */
  32849. alive: boolean;
  32850. /**
  32851. * Is the particle visible or not ?
  32852. */
  32853. isVisible: boolean;
  32854. /**
  32855. * Index of this particle in the global "positions" array (Internal use)
  32856. * @hidden
  32857. */
  32858. _pos: number;
  32859. /**
  32860. * @hidden Index of this particle in the global "indices" array (Internal use)
  32861. */
  32862. _ind: number;
  32863. /**
  32864. * @hidden ModelShape of this particle (Internal use)
  32865. */
  32866. _model: ModelShape;
  32867. /**
  32868. * ModelShape id of this particle
  32869. */
  32870. shapeId: number;
  32871. /**
  32872. * Index of the particle in its shape id
  32873. */
  32874. idxInShape: number;
  32875. /**
  32876. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32877. */
  32878. _modelBoundingInfo: BoundingInfo;
  32879. /**
  32880. * @hidden Particle BoundingInfo object (Internal use)
  32881. */
  32882. _boundingInfo: BoundingInfo;
  32883. /**
  32884. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32885. */
  32886. _sps: SolidParticleSystem;
  32887. /**
  32888. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  32889. */
  32890. _stillInvisible: boolean;
  32891. /**
  32892. * @hidden Last computed particle rotation matrix
  32893. */
  32894. _rotationMatrix: number[];
  32895. /**
  32896. * Parent particle Id, if any.
  32897. * Default null.
  32898. */
  32899. parentId: Nullable<number>;
  32900. /**
  32901. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  32902. */
  32903. materialIndex: Nullable<number>;
  32904. /**
  32905. * Custom object or properties.
  32906. */
  32907. props: Nullable<any>;
  32908. /**
  32909. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  32910. * The possible values are :
  32911. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  32912. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32913. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  32914. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  32915. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  32916. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  32917. * */
  32918. cullingStrategy: number;
  32919. /**
  32920. * @hidden Internal global position in the SPS.
  32921. */
  32922. _globalPosition: Vector3;
  32923. /**
  32924. * Creates a Solid Particle object.
  32925. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  32926. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  32927. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  32928. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  32929. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  32930. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  32931. * @param shapeId (integer) is the model shape identifier in the SPS.
  32932. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  32933. * @param sps defines the sps it is associated to
  32934. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  32935. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  32936. */
  32937. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  32938. /**
  32939. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  32940. * @param target the particle target
  32941. * @returns the current particle
  32942. */
  32943. copyToRef(target: SolidParticle): SolidParticle;
  32944. /**
  32945. * Legacy support, changed scale to scaling
  32946. */
  32947. get scale(): Vector3;
  32948. /**
  32949. * Legacy support, changed scale to scaling
  32950. */
  32951. set scale(scale: Vector3);
  32952. /**
  32953. * Legacy support, changed quaternion to rotationQuaternion
  32954. */
  32955. get quaternion(): Nullable<Quaternion>;
  32956. /**
  32957. * Legacy support, changed quaternion to rotationQuaternion
  32958. */
  32959. set quaternion(q: Nullable<Quaternion>);
  32960. /**
  32961. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  32962. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  32963. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  32964. * @returns true if it intersects
  32965. */
  32966. intersectsMesh(target: Mesh | SolidParticle): boolean;
  32967. /**
  32968. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  32969. * A particle is in the frustum if its bounding box intersects the frustum
  32970. * @param frustumPlanes defines the frustum to test
  32971. * @returns true if the particle is in the frustum planes
  32972. */
  32973. isInFrustum(frustumPlanes: Plane[]): boolean;
  32974. /**
  32975. * get the rotation matrix of the particle
  32976. * @hidden
  32977. */
  32978. getRotationMatrix(m: Matrix): void;
  32979. }
  32980. /**
  32981. * Represents the shape of the model used by one particle of a solid particle system.
  32982. * SPS internal tool, don't use it manually.
  32983. */
  32984. export class ModelShape {
  32985. /**
  32986. * The shape id
  32987. * @hidden
  32988. */
  32989. shapeID: number;
  32990. /**
  32991. * flat array of model positions (internal use)
  32992. * @hidden
  32993. */
  32994. _shape: Vector3[];
  32995. /**
  32996. * flat array of model UVs (internal use)
  32997. * @hidden
  32998. */
  32999. _shapeUV: number[];
  33000. /**
  33001. * color array of the model
  33002. * @hidden
  33003. */
  33004. _shapeColors: number[];
  33005. /**
  33006. * indices array of the model
  33007. * @hidden
  33008. */
  33009. _indices: number[];
  33010. /**
  33011. * normals array of the model
  33012. * @hidden
  33013. */
  33014. _normals: number[];
  33015. /**
  33016. * length of the shape in the model indices array (internal use)
  33017. * @hidden
  33018. */
  33019. _indicesLength: number;
  33020. /**
  33021. * Custom position function (internal use)
  33022. * @hidden
  33023. */
  33024. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33025. /**
  33026. * Custom vertex function (internal use)
  33027. * @hidden
  33028. */
  33029. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33030. /**
  33031. * Model material (internal use)
  33032. * @hidden
  33033. */
  33034. _material: Nullable<Material>;
  33035. /**
  33036. * 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.
  33037. * SPS internal tool, don't use it manually.
  33038. * @hidden
  33039. */
  33040. 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>);
  33041. }
  33042. /**
  33043. * Represents a Depth Sorted Particle in the solid particle system.
  33044. * @hidden
  33045. */
  33046. export class DepthSortedParticle {
  33047. /**
  33048. * Particle index
  33049. */
  33050. idx: number;
  33051. /**
  33052. * Index of the particle in the "indices" array
  33053. */
  33054. ind: number;
  33055. /**
  33056. * Length of the particle shape in the "indices" array
  33057. */
  33058. indicesLength: number;
  33059. /**
  33060. * Squared distance from the particle to the camera
  33061. */
  33062. sqDistance: number;
  33063. /**
  33064. * Material index when used with MultiMaterials
  33065. */
  33066. materialIndex: number;
  33067. /**
  33068. * Creates a new sorted particle
  33069. * @param materialIndex
  33070. */
  33071. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33072. }
  33073. /**
  33074. * Represents a solid particle vertex
  33075. */
  33076. export class SolidParticleVertex {
  33077. /**
  33078. * Vertex position
  33079. */
  33080. position: Vector3;
  33081. /**
  33082. * Vertex color
  33083. */
  33084. color: Color4;
  33085. /**
  33086. * Vertex UV
  33087. */
  33088. uv: Vector2;
  33089. /**
  33090. * Creates a new solid particle vertex
  33091. */
  33092. constructor();
  33093. /** Vertex x coordinate */
  33094. get x(): number;
  33095. set x(val: number);
  33096. /** Vertex y coordinate */
  33097. get y(): number;
  33098. set y(val: number);
  33099. /** Vertex z coordinate */
  33100. get z(): number;
  33101. set z(val: number);
  33102. }
  33103. }
  33104. declare module "babylonjs/Collisions/meshCollisionData" {
  33105. import { Collider } from "babylonjs/Collisions/collider";
  33106. import { Vector3 } from "babylonjs/Maths/math.vector";
  33107. import { Nullable } from "babylonjs/types";
  33108. import { Observer } from "babylonjs/Misc/observable";
  33109. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33110. /**
  33111. * @hidden
  33112. */
  33113. export class _MeshCollisionData {
  33114. _checkCollisions: boolean;
  33115. _collisionMask: number;
  33116. _collisionGroup: number;
  33117. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33118. _collider: Nullable<Collider>;
  33119. _oldPositionForCollisions: Vector3;
  33120. _diffPositionForCollisions: Vector3;
  33121. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33122. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33123. _collisionResponse: boolean;
  33124. }
  33125. }
  33126. declare module "babylonjs/Meshes/abstractMesh" {
  33127. import { Observable } from "babylonjs/Misc/observable";
  33128. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33129. import { Camera } from "babylonjs/Cameras/camera";
  33130. import { Scene, IDisposable } from "babylonjs/scene";
  33131. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33132. import { Node } from "babylonjs/node";
  33133. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33134. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33135. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33136. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33137. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33138. import { Material } from "babylonjs/Materials/material";
  33139. import { Light } from "babylonjs/Lights/light";
  33140. import { Skeleton } from "babylonjs/Bones/skeleton";
  33141. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33142. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33143. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33144. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33145. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33146. import { Plane } from "babylonjs/Maths/math.plane";
  33147. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33148. import { Ray } from "babylonjs/Culling/ray";
  33149. import { Collider } from "babylonjs/Collisions/collider";
  33150. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33151. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33152. /** @hidden */
  33153. class _FacetDataStorage {
  33154. facetPositions: Vector3[];
  33155. facetNormals: Vector3[];
  33156. facetPartitioning: number[][];
  33157. facetNb: number;
  33158. partitioningSubdivisions: number;
  33159. partitioningBBoxRatio: number;
  33160. facetDataEnabled: boolean;
  33161. facetParameters: any;
  33162. bbSize: Vector3;
  33163. subDiv: {
  33164. max: number;
  33165. X: number;
  33166. Y: number;
  33167. Z: number;
  33168. };
  33169. facetDepthSort: boolean;
  33170. facetDepthSortEnabled: boolean;
  33171. depthSortedIndices: IndicesArray;
  33172. depthSortedFacets: {
  33173. ind: number;
  33174. sqDistance: number;
  33175. }[];
  33176. facetDepthSortFunction: (f1: {
  33177. ind: number;
  33178. sqDistance: number;
  33179. }, f2: {
  33180. ind: number;
  33181. sqDistance: number;
  33182. }) => number;
  33183. facetDepthSortFrom: Vector3;
  33184. facetDepthSortOrigin: Vector3;
  33185. invertedMatrix: Matrix;
  33186. }
  33187. /**
  33188. * @hidden
  33189. **/
  33190. class _InternalAbstractMeshDataInfo {
  33191. _hasVertexAlpha: boolean;
  33192. _useVertexColors: boolean;
  33193. _numBoneInfluencers: number;
  33194. _applyFog: boolean;
  33195. _receiveShadows: boolean;
  33196. _facetData: _FacetDataStorage;
  33197. _visibility: number;
  33198. _skeleton: Nullable<Skeleton>;
  33199. _layerMask: number;
  33200. _computeBonesUsingShaders: boolean;
  33201. _isActive: boolean;
  33202. _onlyForInstances: boolean;
  33203. _isActiveIntermediate: boolean;
  33204. _onlyForInstancesIntermediate: boolean;
  33205. _actAsRegularMesh: boolean;
  33206. }
  33207. /**
  33208. * Class used to store all common mesh properties
  33209. */
  33210. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33211. /** No occlusion */
  33212. static OCCLUSION_TYPE_NONE: number;
  33213. /** Occlusion set to optimisitic */
  33214. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33215. /** Occlusion set to strict */
  33216. static OCCLUSION_TYPE_STRICT: number;
  33217. /** Use an accurante occlusion algorithm */
  33218. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33219. /** Use a conservative occlusion algorithm */
  33220. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33221. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33222. * Test order :
  33223. * Is the bounding sphere outside the frustum ?
  33224. * If not, are the bounding box vertices outside the frustum ?
  33225. * It not, then the cullable object is in the frustum.
  33226. */
  33227. static readonly CULLINGSTRATEGY_STANDARD: number;
  33228. /** Culling strategy : Bounding Sphere Only.
  33229. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33230. * It's also less accurate than the standard because some not visible objects can still be selected.
  33231. * Test : is the bounding sphere outside the frustum ?
  33232. * If not, then the cullable object is in the frustum.
  33233. */
  33234. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33235. /** Culling strategy : Optimistic Inclusion.
  33236. * This in an inclusion test first, then the standard exclusion test.
  33237. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33238. * 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.
  33239. * Anyway, it's as accurate as the standard strategy.
  33240. * Test :
  33241. * Is the cullable object bounding sphere center in the frustum ?
  33242. * If not, apply the default culling strategy.
  33243. */
  33244. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33245. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33246. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33247. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33248. * 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.
  33249. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33250. * Test :
  33251. * Is the cullable object bounding sphere center in the frustum ?
  33252. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33253. */
  33254. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33255. /**
  33256. * No billboard
  33257. */
  33258. static get BILLBOARDMODE_NONE(): number;
  33259. /** Billboard on X axis */
  33260. static get BILLBOARDMODE_X(): number;
  33261. /** Billboard on Y axis */
  33262. static get BILLBOARDMODE_Y(): number;
  33263. /** Billboard on Z axis */
  33264. static get BILLBOARDMODE_Z(): number;
  33265. /** Billboard on all axes */
  33266. static get BILLBOARDMODE_ALL(): number;
  33267. /** Billboard on using position instead of orientation */
  33268. static get BILLBOARDMODE_USE_POSITION(): number;
  33269. /** @hidden */
  33270. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33271. /**
  33272. * The culling strategy to use to check whether the mesh must be rendered or not.
  33273. * This value can be changed at any time and will be used on the next render mesh selection.
  33274. * The possible values are :
  33275. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33276. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33277. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33278. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33279. * Please read each static variable documentation to get details about the culling process.
  33280. * */
  33281. cullingStrategy: number;
  33282. /**
  33283. * Gets the number of facets in the mesh
  33284. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33285. */
  33286. get facetNb(): number;
  33287. /**
  33288. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33289. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33290. */
  33291. get partitioningSubdivisions(): number;
  33292. set partitioningSubdivisions(nb: number);
  33293. /**
  33294. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33295. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33296. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33297. */
  33298. get partitioningBBoxRatio(): number;
  33299. set partitioningBBoxRatio(ratio: number);
  33300. /**
  33301. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33302. * Works only for updatable meshes.
  33303. * Doesn't work with multi-materials
  33304. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33305. */
  33306. get mustDepthSortFacets(): boolean;
  33307. set mustDepthSortFacets(sort: boolean);
  33308. /**
  33309. * The location (Vector3) where the facet depth sort must be computed from.
  33310. * By default, the active camera position.
  33311. * Used only when facet depth sort is enabled
  33312. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33313. */
  33314. get facetDepthSortFrom(): Vector3;
  33315. set facetDepthSortFrom(location: Vector3);
  33316. /**
  33317. * gets a boolean indicating if facetData is enabled
  33318. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33319. */
  33320. get isFacetDataEnabled(): boolean;
  33321. /** @hidden */
  33322. _updateNonUniformScalingState(value: boolean): boolean;
  33323. /**
  33324. * An event triggered when this mesh collides with another one
  33325. */
  33326. onCollideObservable: Observable<AbstractMesh>;
  33327. /** Set a function to call when this mesh collides with another one */
  33328. set onCollide(callback: () => void);
  33329. /**
  33330. * An event triggered when the collision's position changes
  33331. */
  33332. onCollisionPositionChangeObservable: Observable<Vector3>;
  33333. /** Set a function to call when the collision's position changes */
  33334. set onCollisionPositionChange(callback: () => void);
  33335. /**
  33336. * An event triggered when material is changed
  33337. */
  33338. onMaterialChangedObservable: Observable<AbstractMesh>;
  33339. /**
  33340. * Gets or sets the orientation for POV movement & rotation
  33341. */
  33342. definedFacingForward: boolean;
  33343. /** @hidden */
  33344. _occlusionQuery: Nullable<WebGLQuery>;
  33345. /** @hidden */
  33346. _renderingGroup: Nullable<RenderingGroup>;
  33347. /**
  33348. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33349. */
  33350. get visibility(): number;
  33351. /**
  33352. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33353. */
  33354. set visibility(value: number);
  33355. /** Gets or sets the alpha index used to sort transparent meshes
  33356. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33357. */
  33358. alphaIndex: number;
  33359. /**
  33360. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33361. */
  33362. isVisible: boolean;
  33363. /**
  33364. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33365. */
  33366. isPickable: boolean;
  33367. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33368. showSubMeshesBoundingBox: boolean;
  33369. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33370. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33371. */
  33372. isBlocker: boolean;
  33373. /**
  33374. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33375. */
  33376. enablePointerMoveEvents: boolean;
  33377. private _renderingGroupId;
  33378. /**
  33379. * Specifies the rendering group id for this mesh (0 by default)
  33380. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33381. */
  33382. get renderingGroupId(): number;
  33383. set renderingGroupId(value: number);
  33384. private _material;
  33385. /** Gets or sets current material */
  33386. get material(): Nullable<Material>;
  33387. set material(value: Nullable<Material>);
  33388. /**
  33389. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33390. * @see https://doc.babylonjs.com/babylon101/shadows
  33391. */
  33392. get receiveShadows(): boolean;
  33393. set receiveShadows(value: boolean);
  33394. /** Defines color to use when rendering outline */
  33395. outlineColor: Color3;
  33396. /** Define width to use when rendering outline */
  33397. outlineWidth: number;
  33398. /** Defines color to use when rendering overlay */
  33399. overlayColor: Color3;
  33400. /** Defines alpha to use when rendering overlay */
  33401. overlayAlpha: number;
  33402. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33403. get hasVertexAlpha(): boolean;
  33404. set hasVertexAlpha(value: boolean);
  33405. /** 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) */
  33406. get useVertexColors(): boolean;
  33407. set useVertexColors(value: boolean);
  33408. /**
  33409. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33410. */
  33411. get computeBonesUsingShaders(): boolean;
  33412. set computeBonesUsingShaders(value: boolean);
  33413. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33414. get numBoneInfluencers(): number;
  33415. set numBoneInfluencers(value: number);
  33416. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33417. get applyFog(): boolean;
  33418. set applyFog(value: boolean);
  33419. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33420. useOctreeForRenderingSelection: boolean;
  33421. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33422. useOctreeForPicking: boolean;
  33423. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33424. useOctreeForCollisions: boolean;
  33425. /**
  33426. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33427. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33428. */
  33429. get layerMask(): number;
  33430. set layerMask(value: number);
  33431. /**
  33432. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33433. */
  33434. alwaysSelectAsActiveMesh: boolean;
  33435. /**
  33436. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33437. */
  33438. doNotSyncBoundingInfo: boolean;
  33439. /**
  33440. * Gets or sets the current action manager
  33441. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33442. */
  33443. actionManager: Nullable<AbstractActionManager>;
  33444. private _meshCollisionData;
  33445. /**
  33446. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33447. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33448. */
  33449. ellipsoid: Vector3;
  33450. /**
  33451. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33452. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33453. */
  33454. ellipsoidOffset: Vector3;
  33455. /**
  33456. * Gets or sets a collision mask used to mask collisions (default is -1).
  33457. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33458. */
  33459. get collisionMask(): number;
  33460. set collisionMask(mask: number);
  33461. /**
  33462. * Gets or sets a collision response flag (default is true).
  33463. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33464. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33465. * to respond to the collision.
  33466. */
  33467. get collisionResponse(): boolean;
  33468. set collisionResponse(response: boolean);
  33469. /**
  33470. * Gets or sets the current collision group mask (-1 by default).
  33471. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33472. */
  33473. get collisionGroup(): number;
  33474. set collisionGroup(mask: number);
  33475. /**
  33476. * Gets or sets current surrounding meshes (null by default).
  33477. *
  33478. * By default collision detection is tested against every mesh in the scene.
  33479. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33480. * meshes will be tested for the collision.
  33481. *
  33482. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33483. */
  33484. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33485. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33486. /**
  33487. * Defines edge width used when edgesRenderer is enabled
  33488. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33489. */
  33490. edgesWidth: number;
  33491. /**
  33492. * Defines edge color used when edgesRenderer is enabled
  33493. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33494. */
  33495. edgesColor: Color4;
  33496. /** @hidden */
  33497. _edgesRenderer: Nullable<IEdgesRenderer>;
  33498. /** @hidden */
  33499. _masterMesh: Nullable<AbstractMesh>;
  33500. /** @hidden */
  33501. _boundingInfo: Nullable<BoundingInfo>;
  33502. /** @hidden */
  33503. _renderId: number;
  33504. /**
  33505. * Gets or sets the list of subMeshes
  33506. * @see https://doc.babylonjs.com/how_to/multi_materials
  33507. */
  33508. subMeshes: SubMesh[];
  33509. /** @hidden */
  33510. _intersectionsInProgress: AbstractMesh[];
  33511. /** @hidden */
  33512. _unIndexed: boolean;
  33513. /** @hidden */
  33514. _lightSources: Light[];
  33515. /** Gets the list of lights affecting that mesh */
  33516. get lightSources(): Light[];
  33517. /** @hidden */
  33518. get _positions(): Nullable<Vector3[]>;
  33519. /** @hidden */
  33520. _waitingData: {
  33521. lods: Nullable<any>;
  33522. actions: Nullable<any>;
  33523. freezeWorldMatrix: Nullable<boolean>;
  33524. };
  33525. /** @hidden */
  33526. _bonesTransformMatrices: Nullable<Float32Array>;
  33527. /** @hidden */
  33528. _transformMatrixTexture: Nullable<RawTexture>;
  33529. /**
  33530. * Gets or sets a skeleton to apply skining transformations
  33531. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33532. */
  33533. set skeleton(value: Nullable<Skeleton>);
  33534. get skeleton(): Nullable<Skeleton>;
  33535. /**
  33536. * An event triggered when the mesh is rebuilt.
  33537. */
  33538. onRebuildObservable: Observable<AbstractMesh>;
  33539. /**
  33540. * Creates a new AbstractMesh
  33541. * @param name defines the name of the mesh
  33542. * @param scene defines the hosting scene
  33543. */
  33544. constructor(name: string, scene?: Nullable<Scene>);
  33545. /**
  33546. * Returns the string "AbstractMesh"
  33547. * @returns "AbstractMesh"
  33548. */
  33549. getClassName(): string;
  33550. /**
  33551. * Gets a string representation of the current mesh
  33552. * @param fullDetails defines a boolean indicating if full details must be included
  33553. * @returns a string representation of the current mesh
  33554. */
  33555. toString(fullDetails?: boolean): string;
  33556. /**
  33557. * @hidden
  33558. */
  33559. protected _getEffectiveParent(): Nullable<Node>;
  33560. /** @hidden */
  33561. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33562. /** @hidden */
  33563. _rebuild(): void;
  33564. /** @hidden */
  33565. _resyncLightSources(): void;
  33566. /** @hidden */
  33567. _resyncLightSource(light: Light): void;
  33568. /** @hidden */
  33569. _unBindEffect(): void;
  33570. /** @hidden */
  33571. _removeLightSource(light: Light, dispose: boolean): void;
  33572. private _markSubMeshesAsDirty;
  33573. /** @hidden */
  33574. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33575. /** @hidden */
  33576. _markSubMeshesAsAttributesDirty(): void;
  33577. /** @hidden */
  33578. _markSubMeshesAsMiscDirty(): void;
  33579. /**
  33580. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33581. */
  33582. get scaling(): Vector3;
  33583. set scaling(newScaling: Vector3);
  33584. /**
  33585. * Returns true if the mesh is blocked. Implemented by child classes
  33586. */
  33587. get isBlocked(): boolean;
  33588. /**
  33589. * Returns the mesh itself by default. Implemented by child classes
  33590. * @param camera defines the camera to use to pick the right LOD level
  33591. * @returns the currentAbstractMesh
  33592. */
  33593. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33594. /**
  33595. * Returns 0 by default. Implemented by child classes
  33596. * @returns an integer
  33597. */
  33598. getTotalVertices(): number;
  33599. /**
  33600. * Returns a positive integer : the total number of indices in this mesh geometry.
  33601. * @returns the numner of indices or zero if the mesh has no geometry.
  33602. */
  33603. getTotalIndices(): number;
  33604. /**
  33605. * Returns null by default. Implemented by child classes
  33606. * @returns null
  33607. */
  33608. getIndices(): Nullable<IndicesArray>;
  33609. /**
  33610. * Returns the array of the requested vertex data kind. Implemented by child classes
  33611. * @param kind defines the vertex data kind to use
  33612. * @returns null
  33613. */
  33614. getVerticesData(kind: string): Nullable<FloatArray>;
  33615. /**
  33616. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33617. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33618. * Note that a new underlying VertexBuffer object is created each call.
  33619. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33620. * @param kind defines vertex data kind:
  33621. * * VertexBuffer.PositionKind
  33622. * * VertexBuffer.UVKind
  33623. * * VertexBuffer.UV2Kind
  33624. * * VertexBuffer.UV3Kind
  33625. * * VertexBuffer.UV4Kind
  33626. * * VertexBuffer.UV5Kind
  33627. * * VertexBuffer.UV6Kind
  33628. * * VertexBuffer.ColorKind
  33629. * * VertexBuffer.MatricesIndicesKind
  33630. * * VertexBuffer.MatricesIndicesExtraKind
  33631. * * VertexBuffer.MatricesWeightsKind
  33632. * * VertexBuffer.MatricesWeightsExtraKind
  33633. * @param data defines the data source
  33634. * @param updatable defines if the data must be flagged as updatable (or static)
  33635. * @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
  33636. * @returns the current mesh
  33637. */
  33638. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33639. /**
  33640. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33641. * If the mesh has no geometry, it is simply returned as it is.
  33642. * @param kind defines vertex data kind:
  33643. * * VertexBuffer.PositionKind
  33644. * * VertexBuffer.UVKind
  33645. * * VertexBuffer.UV2Kind
  33646. * * VertexBuffer.UV3Kind
  33647. * * VertexBuffer.UV4Kind
  33648. * * VertexBuffer.UV5Kind
  33649. * * VertexBuffer.UV6Kind
  33650. * * VertexBuffer.ColorKind
  33651. * * VertexBuffer.MatricesIndicesKind
  33652. * * VertexBuffer.MatricesIndicesExtraKind
  33653. * * VertexBuffer.MatricesWeightsKind
  33654. * * VertexBuffer.MatricesWeightsExtraKind
  33655. * @param data defines the data source
  33656. * @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
  33657. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33658. * @returns the current mesh
  33659. */
  33660. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33661. /**
  33662. * Sets the mesh indices,
  33663. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33664. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33665. * @param totalVertices Defines the total number of vertices
  33666. * @returns the current mesh
  33667. */
  33668. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33669. /**
  33670. * Gets a boolean indicating if specific vertex data is present
  33671. * @param kind defines the vertex data kind to use
  33672. * @returns true is data kind is present
  33673. */
  33674. isVerticesDataPresent(kind: string): boolean;
  33675. /**
  33676. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33677. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33678. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33679. * @returns a BoundingInfo
  33680. */
  33681. getBoundingInfo(): BoundingInfo;
  33682. /**
  33683. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33684. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33685. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33686. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33687. * @returns the current mesh
  33688. */
  33689. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33690. /**
  33691. * Overwrite the current bounding info
  33692. * @param boundingInfo defines the new bounding info
  33693. * @returns the current mesh
  33694. */
  33695. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33696. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33697. get useBones(): boolean;
  33698. /** @hidden */
  33699. _preActivate(): void;
  33700. /** @hidden */
  33701. _preActivateForIntermediateRendering(renderId: number): void;
  33702. /** @hidden */
  33703. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33704. /** @hidden */
  33705. _postActivate(): void;
  33706. /** @hidden */
  33707. _freeze(): void;
  33708. /** @hidden */
  33709. _unFreeze(): void;
  33710. /**
  33711. * Gets the current world matrix
  33712. * @returns a Matrix
  33713. */
  33714. getWorldMatrix(): Matrix;
  33715. /** @hidden */
  33716. _getWorldMatrixDeterminant(): number;
  33717. /**
  33718. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33719. */
  33720. get isAnInstance(): boolean;
  33721. /**
  33722. * Gets a boolean indicating if this mesh has instances
  33723. */
  33724. get hasInstances(): boolean;
  33725. /**
  33726. * Gets a boolean indicating if this mesh has thin instances
  33727. */
  33728. get hasThinInstances(): boolean;
  33729. /**
  33730. * Perform relative position change from the point of view of behind the front of the mesh.
  33731. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33732. * Supports definition of mesh facing forward or backward
  33733. * @param amountRight defines the distance on the right axis
  33734. * @param amountUp defines the distance on the up axis
  33735. * @param amountForward defines the distance on the forward axis
  33736. * @returns the current mesh
  33737. */
  33738. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33739. /**
  33740. * Calculate relative position change from the point of view of behind the front of the mesh.
  33741. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33742. * Supports definition of mesh facing forward or backward
  33743. * @param amountRight defines the distance on the right axis
  33744. * @param amountUp defines the distance on the up axis
  33745. * @param amountForward defines the distance on the forward axis
  33746. * @returns the new displacement vector
  33747. */
  33748. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33749. /**
  33750. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33751. * Supports definition of mesh facing forward or backward
  33752. * @param flipBack defines the flip
  33753. * @param twirlClockwise defines the twirl
  33754. * @param tiltRight defines the tilt
  33755. * @returns the current mesh
  33756. */
  33757. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33758. /**
  33759. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33760. * Supports definition of mesh facing forward or backward.
  33761. * @param flipBack defines the flip
  33762. * @param twirlClockwise defines the twirl
  33763. * @param tiltRight defines the tilt
  33764. * @returns the new rotation vector
  33765. */
  33766. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33767. /**
  33768. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33769. * This means the mesh underlying bounding box and sphere are recomputed.
  33770. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33771. * @returns the current mesh
  33772. */
  33773. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33774. /** @hidden */
  33775. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33776. /** @hidden */
  33777. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33778. /** @hidden */
  33779. _updateBoundingInfo(): AbstractMesh;
  33780. /** @hidden */
  33781. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33782. /** @hidden */
  33783. protected _afterComputeWorldMatrix(): void;
  33784. /** @hidden */
  33785. get _effectiveMesh(): AbstractMesh;
  33786. /**
  33787. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33788. * A mesh is in the frustum if its bounding box intersects the frustum
  33789. * @param frustumPlanes defines the frustum to test
  33790. * @returns true if the mesh is in the frustum planes
  33791. */
  33792. isInFrustum(frustumPlanes: Plane[]): boolean;
  33793. /**
  33794. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33795. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33796. * @param frustumPlanes defines the frustum to test
  33797. * @returns true if the mesh is completely in the frustum planes
  33798. */
  33799. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33800. /**
  33801. * True if the mesh intersects another mesh or a SolidParticle object
  33802. * @param mesh defines a target mesh or SolidParticle to test
  33803. * @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)
  33804. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33805. * @returns true if there is an intersection
  33806. */
  33807. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33808. /**
  33809. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33810. * @param point defines the point to test
  33811. * @returns true if there is an intersection
  33812. */
  33813. intersectsPoint(point: Vector3): boolean;
  33814. /**
  33815. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33816. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33817. */
  33818. get checkCollisions(): boolean;
  33819. set checkCollisions(collisionEnabled: boolean);
  33820. /**
  33821. * Gets Collider object used to compute collisions (not physics)
  33822. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33823. */
  33824. get collider(): Nullable<Collider>;
  33825. /**
  33826. * Move the mesh using collision engine
  33827. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33828. * @param displacement defines the requested displacement vector
  33829. * @returns the current mesh
  33830. */
  33831. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33832. private _onCollisionPositionChange;
  33833. /** @hidden */
  33834. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33835. /** @hidden */
  33836. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33837. /** @hidden */
  33838. _checkCollision(collider: Collider): AbstractMesh;
  33839. /** @hidden */
  33840. _generatePointsArray(): boolean;
  33841. /**
  33842. * Checks if the passed Ray intersects with the mesh
  33843. * @param ray defines the ray to use
  33844. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33845. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33846. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33847. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33848. * @returns the picking info
  33849. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33850. */
  33851. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33852. /**
  33853. * Clones the current mesh
  33854. * @param name defines the mesh name
  33855. * @param newParent defines the new mesh parent
  33856. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33857. * @returns the new mesh
  33858. */
  33859. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33860. /**
  33861. * Disposes all the submeshes of the current meshnp
  33862. * @returns the current mesh
  33863. */
  33864. releaseSubMeshes(): AbstractMesh;
  33865. /**
  33866. * Releases resources associated with this abstract mesh.
  33867. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33868. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33869. */
  33870. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33871. /**
  33872. * Adds the passed mesh as a child to the current mesh
  33873. * @param mesh defines the child mesh
  33874. * @returns the current mesh
  33875. */
  33876. addChild(mesh: AbstractMesh): AbstractMesh;
  33877. /**
  33878. * Removes the passed mesh from the current mesh children list
  33879. * @param mesh defines the child mesh
  33880. * @returns the current mesh
  33881. */
  33882. removeChild(mesh: AbstractMesh): AbstractMesh;
  33883. /** @hidden */
  33884. private _initFacetData;
  33885. /**
  33886. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  33887. * This method can be called within the render loop.
  33888. * 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
  33889. * @returns the current mesh
  33890. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33891. */
  33892. updateFacetData(): AbstractMesh;
  33893. /**
  33894. * Returns the facetLocalNormals array.
  33895. * The normals are expressed in the mesh local spac
  33896. * @returns an array of Vector3
  33897. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33898. */
  33899. getFacetLocalNormals(): Vector3[];
  33900. /**
  33901. * Returns the facetLocalPositions array.
  33902. * The facet positions are expressed in the mesh local space
  33903. * @returns an array of Vector3
  33904. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33905. */
  33906. getFacetLocalPositions(): Vector3[];
  33907. /**
  33908. * Returns the facetLocalPartioning array
  33909. * @returns an array of array of numbers
  33910. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33911. */
  33912. getFacetLocalPartitioning(): number[][];
  33913. /**
  33914. * Returns the i-th facet position in the world system.
  33915. * This method allocates a new Vector3 per call
  33916. * @param i defines the facet index
  33917. * @returns a new Vector3
  33918. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33919. */
  33920. getFacetPosition(i: number): Vector3;
  33921. /**
  33922. * Sets the reference Vector3 with the i-th facet position in the world system
  33923. * @param i defines the facet index
  33924. * @param ref defines the target vector
  33925. * @returns the current mesh
  33926. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33927. */
  33928. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  33929. /**
  33930. * Returns the i-th facet normal in the world system.
  33931. * This method allocates a new Vector3 per call
  33932. * @param i defines the facet index
  33933. * @returns a new Vector3
  33934. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33935. */
  33936. getFacetNormal(i: number): Vector3;
  33937. /**
  33938. * Sets the reference Vector3 with the i-th facet normal in the world system
  33939. * @param i defines the facet index
  33940. * @param ref defines the target vector
  33941. * @returns the current mesh
  33942. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33943. */
  33944. getFacetNormalToRef(i: number, ref: Vector3): this;
  33945. /**
  33946. * 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)
  33947. * @param x defines x coordinate
  33948. * @param y defines y coordinate
  33949. * @param z defines z coordinate
  33950. * @returns the array of facet indexes
  33951. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33952. */
  33953. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  33954. /**
  33955. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  33956. * @param projected sets as the (x,y,z) world projection on the facet
  33957. * @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
  33958. * @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
  33959. * @param x defines x coordinate
  33960. * @param y defines y coordinate
  33961. * @param z defines z coordinate
  33962. * @returns the face index if found (or null instead)
  33963. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33964. */
  33965. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33966. /**
  33967. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  33968. * @param projected sets as the (x,y,z) local projection on the facet
  33969. * @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
  33970. * @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
  33971. * @param x defines x coordinate
  33972. * @param y defines y coordinate
  33973. * @param z defines z coordinate
  33974. * @returns the face index if found (or null instead)
  33975. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33976. */
  33977. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  33978. /**
  33979. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  33980. * @returns the parameters
  33981. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33982. */
  33983. getFacetDataParameters(): any;
  33984. /**
  33985. * Disables the feature FacetData and frees the related memory
  33986. * @returns the current mesh
  33987. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  33988. */
  33989. disableFacetData(): AbstractMesh;
  33990. /**
  33991. * Updates the AbstractMesh indices array
  33992. * @param indices defines the data source
  33993. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  33994. * @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)
  33995. * @returns the current mesh
  33996. */
  33997. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  33998. /**
  33999. * Creates new normals data for the mesh
  34000. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34001. * @returns the current mesh
  34002. */
  34003. createNormals(updatable: boolean): AbstractMesh;
  34004. /**
  34005. * Align the mesh with a normal
  34006. * @param normal defines the normal to use
  34007. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34008. * @returns the current mesh
  34009. */
  34010. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34011. /** @hidden */
  34012. _checkOcclusionQuery(): boolean;
  34013. /**
  34014. * Disables the mesh edge rendering mode
  34015. * @returns the currentAbstractMesh
  34016. */
  34017. disableEdgesRendering(): AbstractMesh;
  34018. /**
  34019. * Enables the edge rendering mode on the mesh.
  34020. * This mode makes the mesh edges visible
  34021. * @param epsilon defines the maximal distance between two angles to detect a face
  34022. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34023. * @returns the currentAbstractMesh
  34024. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34025. */
  34026. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34027. /**
  34028. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34029. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34030. */
  34031. getConnectedParticleSystems(): IParticleSystem[];
  34032. }
  34033. }
  34034. declare module "babylonjs/Actions/actionEvent" {
  34035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34036. import { Nullable } from "babylonjs/types";
  34037. import { Sprite } from "babylonjs/Sprites/sprite";
  34038. import { Scene } from "babylonjs/scene";
  34039. import { Vector2 } from "babylonjs/Maths/math.vector";
  34040. /**
  34041. * Interface used to define ActionEvent
  34042. */
  34043. export interface IActionEvent {
  34044. /** The mesh or sprite that triggered the action */
  34045. source: any;
  34046. /** The X mouse cursor position at the time of the event */
  34047. pointerX: number;
  34048. /** The Y mouse cursor position at the time of the event */
  34049. pointerY: number;
  34050. /** The mesh that is currently pointed at (can be null) */
  34051. meshUnderPointer: Nullable<AbstractMesh>;
  34052. /** the original (browser) event that triggered the ActionEvent */
  34053. sourceEvent?: any;
  34054. /** additional data for the event */
  34055. additionalData?: any;
  34056. }
  34057. /**
  34058. * ActionEvent is the event being sent when an action is triggered.
  34059. */
  34060. export class ActionEvent implements IActionEvent {
  34061. /** The mesh or sprite that triggered the action */
  34062. source: any;
  34063. /** The X mouse cursor position at the time of the event */
  34064. pointerX: number;
  34065. /** The Y mouse cursor position at the time of the event */
  34066. pointerY: number;
  34067. /** The mesh that is currently pointed at (can be null) */
  34068. meshUnderPointer: Nullable<AbstractMesh>;
  34069. /** the original (browser) event that triggered the ActionEvent */
  34070. sourceEvent?: any;
  34071. /** additional data for the event */
  34072. additionalData?: any;
  34073. /**
  34074. * Creates a new ActionEvent
  34075. * @param source The mesh or sprite that triggered the action
  34076. * @param pointerX The X mouse cursor position at the time of the event
  34077. * @param pointerY The Y mouse cursor position at the time of the event
  34078. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34079. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34080. * @param additionalData additional data for the event
  34081. */
  34082. constructor(
  34083. /** The mesh or sprite that triggered the action */
  34084. source: any,
  34085. /** The X mouse cursor position at the time of the event */
  34086. pointerX: number,
  34087. /** The Y mouse cursor position at the time of the event */
  34088. pointerY: number,
  34089. /** The mesh that is currently pointed at (can be null) */
  34090. meshUnderPointer: Nullable<AbstractMesh>,
  34091. /** the original (browser) event that triggered the ActionEvent */
  34092. sourceEvent?: any,
  34093. /** additional data for the event */
  34094. additionalData?: any);
  34095. /**
  34096. * Helper function to auto-create an ActionEvent from a source mesh.
  34097. * @param source The source mesh that triggered the event
  34098. * @param evt The original (browser) event
  34099. * @param additionalData additional data for the event
  34100. * @returns the new ActionEvent
  34101. */
  34102. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34103. /**
  34104. * Helper function to auto-create an ActionEvent from a source sprite
  34105. * @param source The source sprite that triggered the event
  34106. * @param scene Scene associated with the sprite
  34107. * @param evt The original (browser) event
  34108. * @param additionalData additional data for the event
  34109. * @returns the new ActionEvent
  34110. */
  34111. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34112. /**
  34113. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34114. * @param scene the scene where the event occurred
  34115. * @param evt The original (browser) event
  34116. * @returns the new ActionEvent
  34117. */
  34118. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34119. /**
  34120. * Helper function to auto-create an ActionEvent from a primitive
  34121. * @param prim defines the target primitive
  34122. * @param pointerPos defines the pointer position
  34123. * @param evt The original (browser) event
  34124. * @param additionalData additional data for the event
  34125. * @returns the new ActionEvent
  34126. */
  34127. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34128. }
  34129. }
  34130. declare module "babylonjs/Actions/abstractActionManager" {
  34131. import { IDisposable } from "babylonjs/scene";
  34132. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34133. import { IAction } from "babylonjs/Actions/action";
  34134. import { Nullable } from "babylonjs/types";
  34135. /**
  34136. * Abstract class used to decouple action Manager from scene and meshes.
  34137. * Do not instantiate.
  34138. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34139. */
  34140. export abstract class AbstractActionManager implements IDisposable {
  34141. /** Gets the list of active triggers */
  34142. static Triggers: {
  34143. [key: string]: number;
  34144. };
  34145. /** Gets the cursor to use when hovering items */
  34146. hoverCursor: string;
  34147. /** Gets the list of actions */
  34148. actions: IAction[];
  34149. /**
  34150. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34151. */
  34152. isRecursive: boolean;
  34153. /**
  34154. * Releases all associated resources
  34155. */
  34156. abstract dispose(): void;
  34157. /**
  34158. * Does this action manager has pointer triggers
  34159. */
  34160. abstract get hasPointerTriggers(): boolean;
  34161. /**
  34162. * Does this action manager has pick triggers
  34163. */
  34164. abstract get hasPickTriggers(): boolean;
  34165. /**
  34166. * Process a specific trigger
  34167. * @param trigger defines the trigger to process
  34168. * @param evt defines the event details to be processed
  34169. */
  34170. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34171. /**
  34172. * Does this action manager handles actions of any of the given triggers
  34173. * @param triggers defines the triggers to be tested
  34174. * @return a boolean indicating whether one (or more) of the triggers is handled
  34175. */
  34176. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34177. /**
  34178. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34179. * speed.
  34180. * @param triggerA defines the trigger to be tested
  34181. * @param triggerB defines the trigger to be tested
  34182. * @return a boolean indicating whether one (or more) of the triggers is handled
  34183. */
  34184. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34185. /**
  34186. * Does this action manager handles actions of a given trigger
  34187. * @param trigger defines the trigger to be tested
  34188. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34189. * @return whether the trigger is handled
  34190. */
  34191. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34192. /**
  34193. * Serialize this manager to a JSON object
  34194. * @param name defines the property name to store this manager
  34195. * @returns a JSON representation of this manager
  34196. */
  34197. abstract serialize(name: string): any;
  34198. /**
  34199. * Registers an action to this action manager
  34200. * @param action defines the action to be registered
  34201. * @return the action amended (prepared) after registration
  34202. */
  34203. abstract registerAction(action: IAction): Nullable<IAction>;
  34204. /**
  34205. * Unregisters an action to this action manager
  34206. * @param action defines the action to be unregistered
  34207. * @return a boolean indicating whether the action has been unregistered
  34208. */
  34209. abstract unregisterAction(action: IAction): Boolean;
  34210. /**
  34211. * Does exist one action manager with at least one trigger
  34212. **/
  34213. static get HasTriggers(): boolean;
  34214. /**
  34215. * Does exist one action manager with at least one pick trigger
  34216. **/
  34217. static get HasPickTriggers(): boolean;
  34218. /**
  34219. * Does exist one action manager that handles actions of a given trigger
  34220. * @param trigger defines the trigger to be tested
  34221. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34222. **/
  34223. static HasSpecificTrigger(trigger: number): boolean;
  34224. }
  34225. }
  34226. declare module "babylonjs/node" {
  34227. import { Scene } from "babylonjs/scene";
  34228. import { Nullable } from "babylonjs/types";
  34229. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34230. import { Engine } from "babylonjs/Engines/engine";
  34231. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34232. import { Observable } from "babylonjs/Misc/observable";
  34233. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34234. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34235. import { Animatable } from "babylonjs/Animations/animatable";
  34236. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34237. import { Animation } from "babylonjs/Animations/animation";
  34238. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34240. /**
  34241. * Defines how a node can be built from a string name.
  34242. */
  34243. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34244. /**
  34245. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34246. */
  34247. export class Node implements IBehaviorAware<Node> {
  34248. /** @hidden */
  34249. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34250. private static _NodeConstructors;
  34251. /**
  34252. * Add a new node constructor
  34253. * @param type defines the type name of the node to construct
  34254. * @param constructorFunc defines the constructor function
  34255. */
  34256. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34257. /**
  34258. * Returns a node constructor based on type name
  34259. * @param type defines the type name
  34260. * @param name defines the new node name
  34261. * @param scene defines the hosting scene
  34262. * @param options defines optional options to transmit to constructors
  34263. * @returns the new constructor or null
  34264. */
  34265. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34266. /**
  34267. * Gets or sets the name of the node
  34268. */
  34269. name: string;
  34270. /**
  34271. * Gets or sets the id of the node
  34272. */
  34273. id: string;
  34274. /**
  34275. * Gets or sets the unique id of the node
  34276. */
  34277. uniqueId: number;
  34278. /**
  34279. * Gets or sets a string used to store user defined state for the node
  34280. */
  34281. state: string;
  34282. /**
  34283. * Gets or sets an object used to store user defined information for the node
  34284. */
  34285. metadata: any;
  34286. /**
  34287. * For internal use only. Please do not use.
  34288. */
  34289. reservedDataStore: any;
  34290. /**
  34291. * List of inspectable custom properties (used by the Inspector)
  34292. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34293. */
  34294. inspectableCustomProperties: IInspectable[];
  34295. private _doNotSerialize;
  34296. /**
  34297. * Gets or sets a boolean used to define if the node must be serialized
  34298. */
  34299. get doNotSerialize(): boolean;
  34300. set doNotSerialize(value: boolean);
  34301. /** @hidden */
  34302. _isDisposed: boolean;
  34303. /**
  34304. * Gets a list of Animations associated with the node
  34305. */
  34306. animations: import("babylonjs/Animations/animation").Animation[];
  34307. protected _ranges: {
  34308. [name: string]: Nullable<AnimationRange>;
  34309. };
  34310. /**
  34311. * Callback raised when the node is ready to be used
  34312. */
  34313. onReady: Nullable<(node: Node) => void>;
  34314. private _isEnabled;
  34315. private _isParentEnabled;
  34316. private _isReady;
  34317. /** @hidden */
  34318. _currentRenderId: number;
  34319. private _parentUpdateId;
  34320. /** @hidden */
  34321. _childUpdateId: number;
  34322. /** @hidden */
  34323. _waitingParentId: Nullable<string>;
  34324. /** @hidden */
  34325. _scene: Scene;
  34326. /** @hidden */
  34327. _cache: any;
  34328. private _parentNode;
  34329. private _children;
  34330. /** @hidden */
  34331. _worldMatrix: Matrix;
  34332. /** @hidden */
  34333. _worldMatrixDeterminant: number;
  34334. /** @hidden */
  34335. _worldMatrixDeterminantIsDirty: boolean;
  34336. /** @hidden */
  34337. private _sceneRootNodesIndex;
  34338. /**
  34339. * Gets a boolean indicating if the node has been disposed
  34340. * @returns true if the node was disposed
  34341. */
  34342. isDisposed(): boolean;
  34343. /**
  34344. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34345. * @see https://doc.babylonjs.com/how_to/parenting
  34346. */
  34347. set parent(parent: Nullable<Node>);
  34348. get parent(): Nullable<Node>;
  34349. /** @hidden */
  34350. _addToSceneRootNodes(): void;
  34351. /** @hidden */
  34352. _removeFromSceneRootNodes(): void;
  34353. private _animationPropertiesOverride;
  34354. /**
  34355. * Gets or sets the animation properties override
  34356. */
  34357. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34358. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34359. /**
  34360. * Gets a string identifying the name of the class
  34361. * @returns "Node" string
  34362. */
  34363. getClassName(): string;
  34364. /** @hidden */
  34365. readonly _isNode: boolean;
  34366. /**
  34367. * An event triggered when the mesh is disposed
  34368. */
  34369. onDisposeObservable: Observable<Node>;
  34370. private _onDisposeObserver;
  34371. /**
  34372. * Sets a callback that will be raised when the node will be disposed
  34373. */
  34374. set onDispose(callback: () => void);
  34375. /**
  34376. * Creates a new Node
  34377. * @param name the name and id to be given to this node
  34378. * @param scene the scene this node will be added to
  34379. */
  34380. constructor(name: string, scene?: Nullable<Scene>);
  34381. /**
  34382. * Gets the scene of the node
  34383. * @returns a scene
  34384. */
  34385. getScene(): Scene;
  34386. /**
  34387. * Gets the engine of the node
  34388. * @returns a Engine
  34389. */
  34390. getEngine(): Engine;
  34391. private _behaviors;
  34392. /**
  34393. * Attach a behavior to the node
  34394. * @see https://doc.babylonjs.com/features/behaviour
  34395. * @param behavior defines the behavior to attach
  34396. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34397. * @returns the current Node
  34398. */
  34399. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34400. /**
  34401. * Remove an attached behavior
  34402. * @see https://doc.babylonjs.com/features/behaviour
  34403. * @param behavior defines the behavior to attach
  34404. * @returns the current Node
  34405. */
  34406. removeBehavior(behavior: Behavior<Node>): Node;
  34407. /**
  34408. * Gets the list of attached behaviors
  34409. * @see https://doc.babylonjs.com/features/behaviour
  34410. */
  34411. get behaviors(): Behavior<Node>[];
  34412. /**
  34413. * Gets an attached behavior by name
  34414. * @param name defines the name of the behavior to look for
  34415. * @see https://doc.babylonjs.com/features/behaviour
  34416. * @returns null if behavior was not found else the requested behavior
  34417. */
  34418. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34419. /**
  34420. * Returns the latest update of the World matrix
  34421. * @returns a Matrix
  34422. */
  34423. getWorldMatrix(): Matrix;
  34424. /** @hidden */
  34425. _getWorldMatrixDeterminant(): number;
  34426. /**
  34427. * Returns directly the latest state of the mesh World matrix.
  34428. * A Matrix is returned.
  34429. */
  34430. get worldMatrixFromCache(): Matrix;
  34431. /** @hidden */
  34432. _initCache(): void;
  34433. /** @hidden */
  34434. updateCache(force?: boolean): void;
  34435. /** @hidden */
  34436. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34437. /** @hidden */
  34438. _updateCache(ignoreParentClass?: boolean): void;
  34439. /** @hidden */
  34440. _isSynchronized(): boolean;
  34441. /** @hidden */
  34442. _markSyncedWithParent(): void;
  34443. /** @hidden */
  34444. isSynchronizedWithParent(): boolean;
  34445. /** @hidden */
  34446. isSynchronized(): boolean;
  34447. /**
  34448. * Is this node ready to be used/rendered
  34449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34450. * @return true if the node is ready
  34451. */
  34452. isReady(completeCheck?: boolean): boolean;
  34453. /**
  34454. * Is this node enabled?
  34455. * 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
  34456. * @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
  34457. * @return whether this node (and its parent) is enabled
  34458. */
  34459. isEnabled(checkAncestors?: boolean): boolean;
  34460. /** @hidden */
  34461. protected _syncParentEnabledState(): void;
  34462. /**
  34463. * Set the enabled state of this node
  34464. * @param value defines the new enabled state
  34465. */
  34466. setEnabled(value: boolean): void;
  34467. /**
  34468. * Is this node a descendant of the given node?
  34469. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34470. * @param ancestor defines the parent node to inspect
  34471. * @returns a boolean indicating if this node is a descendant of the given node
  34472. */
  34473. isDescendantOf(ancestor: Node): boolean;
  34474. /** @hidden */
  34475. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34476. /**
  34477. * Will return all nodes that have this node as ascendant
  34478. * @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
  34479. * @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
  34480. * @return all children nodes of all types
  34481. */
  34482. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34483. /**
  34484. * Get all child-meshes of this node
  34485. * @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)
  34486. * @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
  34487. * @returns an array of AbstractMesh
  34488. */
  34489. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34490. /**
  34491. * Get all direct children of this node
  34492. * @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
  34493. * @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)
  34494. * @returns an array of Node
  34495. */
  34496. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34497. /** @hidden */
  34498. _setReady(state: boolean): void;
  34499. /**
  34500. * Get an animation by name
  34501. * @param name defines the name of the animation to look for
  34502. * @returns null if not found else the requested animation
  34503. */
  34504. getAnimationByName(name: string): Nullable<Animation>;
  34505. /**
  34506. * Creates an animation range for this node
  34507. * @param name defines the name of the range
  34508. * @param from defines the starting key
  34509. * @param to defines the end key
  34510. */
  34511. createAnimationRange(name: string, from: number, to: number): void;
  34512. /**
  34513. * Delete a specific animation range
  34514. * @param name defines the name of the range to delete
  34515. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34516. */
  34517. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34518. /**
  34519. * Get an animation range by name
  34520. * @param name defines the name of the animation range to look for
  34521. * @returns null if not found else the requested animation range
  34522. */
  34523. getAnimationRange(name: string): Nullable<AnimationRange>;
  34524. /**
  34525. * Gets the list of all animation ranges defined on this node
  34526. * @returns an array
  34527. */
  34528. getAnimationRanges(): Nullable<AnimationRange>[];
  34529. /**
  34530. * Will start the animation sequence
  34531. * @param name defines the range frames for animation sequence
  34532. * @param loop defines if the animation should loop (false by default)
  34533. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34534. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34535. * @returns the object created for this animation. If range does not exist, it will return null
  34536. */
  34537. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34538. /**
  34539. * Serialize animation ranges into a JSON compatible object
  34540. * @returns serialization object
  34541. */
  34542. serializeAnimationRanges(): any;
  34543. /**
  34544. * Computes the world matrix of the node
  34545. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34546. * @returns the world matrix
  34547. */
  34548. computeWorldMatrix(force?: boolean): Matrix;
  34549. /**
  34550. * Releases resources associated with this node.
  34551. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34552. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34553. */
  34554. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34555. /**
  34556. * Parse animation range data from a serialization object and store them into a given node
  34557. * @param node defines where to store the animation ranges
  34558. * @param parsedNode defines the serialization object to read data from
  34559. * @param scene defines the hosting scene
  34560. */
  34561. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34562. /**
  34563. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34564. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34565. * @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
  34566. * @returns the new bounding vectors
  34567. */
  34568. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34569. min: Vector3;
  34570. max: Vector3;
  34571. };
  34572. }
  34573. }
  34574. declare module "babylonjs/Animations/animation" {
  34575. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34576. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34577. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34578. import { Nullable } from "babylonjs/types";
  34579. import { Scene } from "babylonjs/scene";
  34580. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34581. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34582. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34583. import { Node } from "babylonjs/node";
  34584. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34585. import { Size } from "babylonjs/Maths/math.size";
  34586. import { Animatable } from "babylonjs/Animations/animatable";
  34587. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34588. /**
  34589. * @hidden
  34590. */
  34591. export class _IAnimationState {
  34592. key: number;
  34593. repeatCount: number;
  34594. workValue?: any;
  34595. loopMode?: number;
  34596. offsetValue?: any;
  34597. highLimitValue?: any;
  34598. }
  34599. /**
  34600. * Class used to store any kind of animation
  34601. */
  34602. export class Animation {
  34603. /**Name of the animation */
  34604. name: string;
  34605. /**Property to animate */
  34606. targetProperty: string;
  34607. /**The frames per second of the animation */
  34608. framePerSecond: number;
  34609. /**The data type of the animation */
  34610. dataType: number;
  34611. /**The loop mode of the animation */
  34612. loopMode?: number | undefined;
  34613. /**Specifies if blending should be enabled */
  34614. enableBlending?: boolean | undefined;
  34615. /**
  34616. * Use matrix interpolation instead of using direct key value when animating matrices
  34617. */
  34618. static AllowMatricesInterpolation: boolean;
  34619. /**
  34620. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34621. */
  34622. static AllowMatrixDecomposeForInterpolation: boolean;
  34623. /** Define the Url to load snippets */
  34624. static SnippetUrl: string;
  34625. /** Snippet ID if the animation was created from the snippet server */
  34626. snippetId: string;
  34627. /**
  34628. * Stores the key frames of the animation
  34629. */
  34630. private _keys;
  34631. /**
  34632. * Stores the easing function of the animation
  34633. */
  34634. private _easingFunction;
  34635. /**
  34636. * @hidden Internal use only
  34637. */
  34638. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34639. /**
  34640. * The set of event that will be linked to this animation
  34641. */
  34642. private _events;
  34643. /**
  34644. * Stores an array of target property paths
  34645. */
  34646. targetPropertyPath: string[];
  34647. /**
  34648. * Stores the blending speed of the animation
  34649. */
  34650. blendingSpeed: number;
  34651. /**
  34652. * Stores the animation ranges for the animation
  34653. */
  34654. private _ranges;
  34655. /**
  34656. * @hidden Internal use
  34657. */
  34658. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34659. /**
  34660. * Sets up an animation
  34661. * @param property The property to animate
  34662. * @param animationType The animation type to apply
  34663. * @param framePerSecond The frames per second of the animation
  34664. * @param easingFunction The easing function used in the animation
  34665. * @returns The created animation
  34666. */
  34667. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34668. /**
  34669. * Create and start an animation on a node
  34670. * @param name defines the name of the global animation that will be run on all nodes
  34671. * @param node defines the root node where the animation will take place
  34672. * @param targetProperty defines property to animate
  34673. * @param framePerSecond defines the number of frame per second yo use
  34674. * @param totalFrame defines the number of frames in total
  34675. * @param from defines the initial value
  34676. * @param to defines the final value
  34677. * @param loopMode defines which loop mode you want to use (off by default)
  34678. * @param easingFunction defines the easing function to use (linear by default)
  34679. * @param onAnimationEnd defines the callback to call when animation end
  34680. * @returns the animatable created for this animation
  34681. */
  34682. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34683. /**
  34684. * Create and start an animation on a node and its descendants
  34685. * @param name defines the name of the global animation that will be run on all nodes
  34686. * @param node defines the root node where the animation will take place
  34687. * @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
  34688. * @param targetProperty defines property to animate
  34689. * @param framePerSecond defines the number of frame per second to use
  34690. * @param totalFrame defines the number of frames in total
  34691. * @param from defines the initial value
  34692. * @param to defines the final value
  34693. * @param loopMode defines which loop mode you want to use (off by default)
  34694. * @param easingFunction defines the easing function to use (linear by default)
  34695. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34696. * @returns the list of animatables created for all nodes
  34697. * @example https://www.babylonjs-playground.com/#MH0VLI
  34698. */
  34699. 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[]>;
  34700. /**
  34701. * Creates a new animation, merges it with the existing animations and starts it
  34702. * @param name Name of the animation
  34703. * @param node Node which contains the scene that begins the animations
  34704. * @param targetProperty Specifies which property to animate
  34705. * @param framePerSecond The frames per second of the animation
  34706. * @param totalFrame The total number of frames
  34707. * @param from The frame at the beginning of the animation
  34708. * @param to The frame at the end of the animation
  34709. * @param loopMode Specifies the loop mode of the animation
  34710. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34711. * @param onAnimationEnd Callback to run once the animation is complete
  34712. * @returns Nullable animation
  34713. */
  34714. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34715. /**
  34716. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34717. * @param sourceAnimation defines the Animation containing keyframes to convert
  34718. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34719. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34720. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34721. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34722. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34723. */
  34724. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34725. /**
  34726. * Transition property of an host to the target Value
  34727. * @param property The property to transition
  34728. * @param targetValue The target Value of the property
  34729. * @param host The object where the property to animate belongs
  34730. * @param scene Scene used to run the animation
  34731. * @param frameRate Framerate (in frame/s) to use
  34732. * @param transition The transition type we want to use
  34733. * @param duration The duration of the animation, in milliseconds
  34734. * @param onAnimationEnd Callback trigger at the end of the animation
  34735. * @returns Nullable animation
  34736. */
  34737. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34738. /**
  34739. * Return the array of runtime animations currently using this animation
  34740. */
  34741. get runtimeAnimations(): RuntimeAnimation[];
  34742. /**
  34743. * Specifies if any of the runtime animations are currently running
  34744. */
  34745. get hasRunningRuntimeAnimations(): boolean;
  34746. /**
  34747. * Initializes the animation
  34748. * @param name Name of the animation
  34749. * @param targetProperty Property to animate
  34750. * @param framePerSecond The frames per second of the animation
  34751. * @param dataType The data type of the animation
  34752. * @param loopMode The loop mode of the animation
  34753. * @param enableBlending Specifies if blending should be enabled
  34754. */
  34755. constructor(
  34756. /**Name of the animation */
  34757. name: string,
  34758. /**Property to animate */
  34759. targetProperty: string,
  34760. /**The frames per second of the animation */
  34761. framePerSecond: number,
  34762. /**The data type of the animation */
  34763. dataType: number,
  34764. /**The loop mode of the animation */
  34765. loopMode?: number | undefined,
  34766. /**Specifies if blending should be enabled */
  34767. enableBlending?: boolean | undefined);
  34768. /**
  34769. * Converts the animation to a string
  34770. * @param fullDetails support for multiple levels of logging within scene loading
  34771. * @returns String form of the animation
  34772. */
  34773. toString(fullDetails?: boolean): string;
  34774. /**
  34775. * Add an event to this animation
  34776. * @param event Event to add
  34777. */
  34778. addEvent(event: AnimationEvent): void;
  34779. /**
  34780. * Remove all events found at the given frame
  34781. * @param frame The frame to remove events from
  34782. */
  34783. removeEvents(frame: number): void;
  34784. /**
  34785. * Retrieves all the events from the animation
  34786. * @returns Events from the animation
  34787. */
  34788. getEvents(): AnimationEvent[];
  34789. /**
  34790. * Creates an animation range
  34791. * @param name Name of the animation range
  34792. * @param from Starting frame of the animation range
  34793. * @param to Ending frame of the animation
  34794. */
  34795. createRange(name: string, from: number, to: number): void;
  34796. /**
  34797. * Deletes an animation range by name
  34798. * @param name Name of the animation range to delete
  34799. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34800. */
  34801. deleteRange(name: string, deleteFrames?: boolean): void;
  34802. /**
  34803. * Gets the animation range by name, or null if not defined
  34804. * @param name Name of the animation range
  34805. * @returns Nullable animation range
  34806. */
  34807. getRange(name: string): Nullable<AnimationRange>;
  34808. /**
  34809. * Gets the key frames from the animation
  34810. * @returns The key frames of the animation
  34811. */
  34812. getKeys(): Array<IAnimationKey>;
  34813. /**
  34814. * Gets the highest frame rate of the animation
  34815. * @returns Highest frame rate of the animation
  34816. */
  34817. getHighestFrame(): number;
  34818. /**
  34819. * Gets the easing function of the animation
  34820. * @returns Easing function of the animation
  34821. */
  34822. getEasingFunction(): IEasingFunction;
  34823. /**
  34824. * Sets the easing function of the animation
  34825. * @param easingFunction A custom mathematical formula for animation
  34826. */
  34827. setEasingFunction(easingFunction: EasingFunction): void;
  34828. /**
  34829. * Interpolates a scalar linearly
  34830. * @param startValue Start value of the animation curve
  34831. * @param endValue End value of the animation curve
  34832. * @param gradient Scalar amount to interpolate
  34833. * @returns Interpolated scalar value
  34834. */
  34835. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34836. /**
  34837. * Interpolates a scalar cubically
  34838. * @param startValue Start value of the animation curve
  34839. * @param outTangent End tangent of the animation
  34840. * @param endValue End value of the animation curve
  34841. * @param inTangent Start tangent of the animation curve
  34842. * @param gradient Scalar amount to interpolate
  34843. * @returns Interpolated scalar value
  34844. */
  34845. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34846. /**
  34847. * Interpolates a quaternion using a spherical linear interpolation
  34848. * @param startValue Start value of the animation curve
  34849. * @param endValue End value of the animation curve
  34850. * @param gradient Scalar amount to interpolate
  34851. * @returns Interpolated quaternion value
  34852. */
  34853. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34854. /**
  34855. * Interpolates a quaternion cubically
  34856. * @param startValue Start value of the animation curve
  34857. * @param outTangent End tangent of the animation curve
  34858. * @param endValue End value of the animation curve
  34859. * @param inTangent Start tangent of the animation curve
  34860. * @param gradient Scalar amount to interpolate
  34861. * @returns Interpolated quaternion value
  34862. */
  34863. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34864. /**
  34865. * Interpolates a Vector3 linearl
  34866. * @param startValue Start value of the animation curve
  34867. * @param endValue End value of the animation curve
  34868. * @param gradient Scalar amount to interpolate
  34869. * @returns Interpolated scalar value
  34870. */
  34871. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34872. /**
  34873. * Interpolates a Vector3 cubically
  34874. * @param startValue Start value of the animation curve
  34875. * @param outTangent End tangent of the animation
  34876. * @param endValue End value of the animation curve
  34877. * @param inTangent Start tangent of the animation curve
  34878. * @param gradient Scalar amount to interpolate
  34879. * @returns InterpolatedVector3 value
  34880. */
  34881. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34882. /**
  34883. * Interpolates a Vector2 linearly
  34884. * @param startValue Start value of the animation curve
  34885. * @param endValue End value of the animation curve
  34886. * @param gradient Scalar amount to interpolate
  34887. * @returns Interpolated Vector2 value
  34888. */
  34889. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  34890. /**
  34891. * Interpolates a Vector2 cubically
  34892. * @param startValue Start value of the animation curve
  34893. * @param outTangent End tangent of the animation
  34894. * @param endValue End value of the animation curve
  34895. * @param inTangent Start tangent of the animation curve
  34896. * @param gradient Scalar amount to interpolate
  34897. * @returns Interpolated Vector2 value
  34898. */
  34899. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  34900. /**
  34901. * Interpolates a size linearly
  34902. * @param startValue Start value of the animation curve
  34903. * @param endValue End value of the animation curve
  34904. * @param gradient Scalar amount to interpolate
  34905. * @returns Interpolated Size value
  34906. */
  34907. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  34908. /**
  34909. * Interpolates a Color3 linearly
  34910. * @param startValue Start value of the animation curve
  34911. * @param endValue End value of the animation curve
  34912. * @param gradient Scalar amount to interpolate
  34913. * @returns Interpolated Color3 value
  34914. */
  34915. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  34916. /**
  34917. * Interpolates a Color4 linearly
  34918. * @param startValue Start value of the animation curve
  34919. * @param endValue End value of the animation curve
  34920. * @param gradient Scalar amount to interpolate
  34921. * @returns Interpolated Color3 value
  34922. */
  34923. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  34924. /**
  34925. * @hidden Internal use only
  34926. */
  34927. _getKeyValue(value: any): any;
  34928. /**
  34929. * @hidden Internal use only
  34930. */
  34931. _interpolate(currentFrame: number, state: _IAnimationState): any;
  34932. /**
  34933. * Defines the function to use to interpolate matrices
  34934. * @param startValue defines the start matrix
  34935. * @param endValue defines the end matrix
  34936. * @param gradient defines the gradient between both matrices
  34937. * @param result defines an optional target matrix where to store the interpolation
  34938. * @returns the interpolated matrix
  34939. */
  34940. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  34941. /**
  34942. * Makes a copy of the animation
  34943. * @returns Cloned animation
  34944. */
  34945. clone(): Animation;
  34946. /**
  34947. * Sets the key frames of the animation
  34948. * @param values The animation key frames to set
  34949. */
  34950. setKeys(values: Array<IAnimationKey>): void;
  34951. /**
  34952. * Serializes the animation to an object
  34953. * @returns Serialized object
  34954. */
  34955. serialize(): any;
  34956. /**
  34957. * Float animation type
  34958. */
  34959. static readonly ANIMATIONTYPE_FLOAT: number;
  34960. /**
  34961. * Vector3 animation type
  34962. */
  34963. static readonly ANIMATIONTYPE_VECTOR3: number;
  34964. /**
  34965. * Quaternion animation type
  34966. */
  34967. static readonly ANIMATIONTYPE_QUATERNION: number;
  34968. /**
  34969. * Matrix animation type
  34970. */
  34971. static readonly ANIMATIONTYPE_MATRIX: number;
  34972. /**
  34973. * Color3 animation type
  34974. */
  34975. static readonly ANIMATIONTYPE_COLOR3: number;
  34976. /**
  34977. * Color3 animation type
  34978. */
  34979. static readonly ANIMATIONTYPE_COLOR4: number;
  34980. /**
  34981. * Vector2 animation type
  34982. */
  34983. static readonly ANIMATIONTYPE_VECTOR2: number;
  34984. /**
  34985. * Size animation type
  34986. */
  34987. static readonly ANIMATIONTYPE_SIZE: number;
  34988. /**
  34989. * Relative Loop Mode
  34990. */
  34991. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  34992. /**
  34993. * Cycle Loop Mode
  34994. */
  34995. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  34996. /**
  34997. * Constant Loop Mode
  34998. */
  34999. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35000. /** @hidden */
  35001. static _UniversalLerp(left: any, right: any, amount: number): any;
  35002. /**
  35003. * Parses an animation object and creates an animation
  35004. * @param parsedAnimation Parsed animation object
  35005. * @returns Animation object
  35006. */
  35007. static Parse(parsedAnimation: any): Animation;
  35008. /**
  35009. * Appends the serialized animations from the source animations
  35010. * @param source Source containing the animations
  35011. * @param destination Target to store the animations
  35012. */
  35013. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35014. /**
  35015. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35016. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35017. * @param url defines the url to load from
  35018. * @returns a promise that will resolve to the new animation or an array of animations
  35019. */
  35020. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35021. /**
  35022. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35023. * @param snippetId defines the snippet to load
  35024. * @returns a promise that will resolve to the new animation or a new array of animations
  35025. */
  35026. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35027. }
  35028. }
  35029. declare module "babylonjs/Animations/animatable.interface" {
  35030. import { Nullable } from "babylonjs/types";
  35031. import { Animation } from "babylonjs/Animations/animation";
  35032. /**
  35033. * Interface containing an array of animations
  35034. */
  35035. export interface IAnimatable {
  35036. /**
  35037. * Array of animations
  35038. */
  35039. animations: Nullable<Array<Animation>>;
  35040. }
  35041. }
  35042. declare module "babylonjs/Misc/decorators" {
  35043. import { Nullable } from "babylonjs/types";
  35044. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35045. import { Scene } from "babylonjs/scene";
  35046. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35047. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35048. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35049. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35050. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35051. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35052. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35053. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35054. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35055. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35056. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35057. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35058. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35059. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35060. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35061. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35062. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35063. /**
  35064. * Decorator used to define property that can be serialized as reference to a camera
  35065. * @param sourceName defines the name of the property to decorate
  35066. */
  35067. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35068. /**
  35069. * Class used to help serialization objects
  35070. */
  35071. export class SerializationHelper {
  35072. /** @hidden */
  35073. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35074. /** @hidden */
  35075. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35076. /** @hidden */
  35077. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35078. /** @hidden */
  35079. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35080. /**
  35081. * Appends the serialized animations from the source animations
  35082. * @param source Source containing the animations
  35083. * @param destination Target to store the animations
  35084. */
  35085. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35086. /**
  35087. * Static function used to serialized a specific entity
  35088. * @param entity defines the entity to serialize
  35089. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35090. * @returns a JSON compatible object representing the serialization of the entity
  35091. */
  35092. static Serialize<T>(entity: T, serializationObject?: any): any;
  35093. /**
  35094. * Creates a new entity from a serialization data object
  35095. * @param creationFunction defines a function used to instanciated the new entity
  35096. * @param source defines the source serialization data
  35097. * @param scene defines the hosting scene
  35098. * @param rootUrl defines the root url for resources
  35099. * @returns a new entity
  35100. */
  35101. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35102. /**
  35103. * Clones an object
  35104. * @param creationFunction defines the function used to instanciate the new object
  35105. * @param source defines the source object
  35106. * @returns the cloned object
  35107. */
  35108. static Clone<T>(creationFunction: () => T, source: T): T;
  35109. /**
  35110. * Instanciates a new object based on a source one (some data will be shared between both object)
  35111. * @param creationFunction defines the function used to instanciate the new object
  35112. * @param source defines the source object
  35113. * @returns the new object
  35114. */
  35115. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35116. }
  35117. }
  35118. declare module "babylonjs/Materials/Textures/baseTexture" {
  35119. import { Observable } from "babylonjs/Misc/observable";
  35120. import { Nullable } from "babylonjs/types";
  35121. import { Scene } from "babylonjs/scene";
  35122. import { Matrix } from "babylonjs/Maths/math.vector";
  35123. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35124. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35125. import { ISize } from "babylonjs/Maths/math.size";
  35126. import "babylonjs/Misc/fileTools";
  35127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35128. /**
  35129. * Base class of all the textures in babylon.
  35130. * It groups all the common properties the materials, post process, lights... might need
  35131. * in order to make a correct use of the texture.
  35132. */
  35133. export class BaseTexture implements IAnimatable {
  35134. /**
  35135. * Default anisotropic filtering level for the application.
  35136. * It is set to 4 as a good tradeoff between perf and quality.
  35137. */
  35138. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35139. /**
  35140. * Gets or sets the unique id of the texture
  35141. */
  35142. uniqueId: number;
  35143. /**
  35144. * Define the name of the texture.
  35145. */
  35146. name: string;
  35147. /**
  35148. * Gets or sets an object used to store user defined information.
  35149. */
  35150. metadata: any;
  35151. /**
  35152. * For internal use only. Please do not use.
  35153. */
  35154. reservedDataStore: any;
  35155. private _hasAlpha;
  35156. /**
  35157. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35158. */
  35159. set hasAlpha(value: boolean);
  35160. get hasAlpha(): boolean;
  35161. /**
  35162. * Defines if the alpha value should be determined via the rgb values.
  35163. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35164. */
  35165. getAlphaFromRGB: boolean;
  35166. /**
  35167. * Intensity or strength of the texture.
  35168. * It is commonly used by materials to fine tune the intensity of the texture
  35169. */
  35170. level: number;
  35171. /**
  35172. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35173. * This is part of the texture as textures usually maps to one uv set.
  35174. */
  35175. coordinatesIndex: number;
  35176. protected _coordinatesMode: number;
  35177. /**
  35178. * How a texture is mapped.
  35179. *
  35180. * | Value | Type | Description |
  35181. * | ----- | ----------------------------------- | ----------- |
  35182. * | 0 | EXPLICIT_MODE | |
  35183. * | 1 | SPHERICAL_MODE | |
  35184. * | 2 | PLANAR_MODE | |
  35185. * | 3 | CUBIC_MODE | |
  35186. * | 4 | PROJECTION_MODE | |
  35187. * | 5 | SKYBOX_MODE | |
  35188. * | 6 | INVCUBIC_MODE | |
  35189. * | 7 | EQUIRECTANGULAR_MODE | |
  35190. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35191. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35192. */
  35193. set coordinatesMode(value: number);
  35194. get coordinatesMode(): number;
  35195. private _wrapU;
  35196. /**
  35197. * | Value | Type | Description |
  35198. * | ----- | ------------------ | ----------- |
  35199. * | 0 | CLAMP_ADDRESSMODE | |
  35200. * | 1 | WRAP_ADDRESSMODE | |
  35201. * | 2 | MIRROR_ADDRESSMODE | |
  35202. */
  35203. get wrapU(): number;
  35204. set wrapU(value: number);
  35205. private _wrapV;
  35206. /**
  35207. * | Value | Type | Description |
  35208. * | ----- | ------------------ | ----------- |
  35209. * | 0 | CLAMP_ADDRESSMODE | |
  35210. * | 1 | WRAP_ADDRESSMODE | |
  35211. * | 2 | MIRROR_ADDRESSMODE | |
  35212. */
  35213. get wrapV(): number;
  35214. set wrapV(value: number);
  35215. /**
  35216. * | Value | Type | Description |
  35217. * | ----- | ------------------ | ----------- |
  35218. * | 0 | CLAMP_ADDRESSMODE | |
  35219. * | 1 | WRAP_ADDRESSMODE | |
  35220. * | 2 | MIRROR_ADDRESSMODE | |
  35221. */
  35222. wrapR: number;
  35223. /**
  35224. * With compliant hardware and browser (supporting anisotropic filtering)
  35225. * this defines the level of anisotropic filtering in the texture.
  35226. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35227. */
  35228. anisotropicFilteringLevel: number;
  35229. /**
  35230. * Define if the texture is a cube texture or if false a 2d texture.
  35231. */
  35232. get isCube(): boolean;
  35233. set isCube(value: boolean);
  35234. /**
  35235. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35236. */
  35237. get is3D(): boolean;
  35238. set is3D(value: boolean);
  35239. /**
  35240. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35241. */
  35242. get is2DArray(): boolean;
  35243. set is2DArray(value: boolean);
  35244. private _gammaSpace;
  35245. /**
  35246. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35247. * HDR texture are usually stored in linear space.
  35248. * This only impacts the PBR and Background materials
  35249. */
  35250. get gammaSpace(): boolean;
  35251. set gammaSpace(gamma: boolean);
  35252. /**
  35253. * Gets or sets whether or not the texture contains RGBD data.
  35254. */
  35255. get isRGBD(): boolean;
  35256. set isRGBD(value: boolean);
  35257. /**
  35258. * Is Z inverted in the texture (useful in a cube texture).
  35259. */
  35260. invertZ: boolean;
  35261. /**
  35262. * Are mip maps generated for this texture or not.
  35263. */
  35264. get noMipmap(): boolean;
  35265. /**
  35266. * @hidden
  35267. */
  35268. lodLevelInAlpha: boolean;
  35269. /**
  35270. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35271. */
  35272. get lodGenerationOffset(): number;
  35273. set lodGenerationOffset(value: number);
  35274. /**
  35275. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35276. */
  35277. get lodGenerationScale(): number;
  35278. set lodGenerationScale(value: number);
  35279. /**
  35280. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35281. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35282. * average roughness values.
  35283. */
  35284. get linearSpecularLOD(): boolean;
  35285. set linearSpecularLOD(value: boolean);
  35286. /**
  35287. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35288. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35289. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35290. */
  35291. get irradianceTexture(): Nullable<BaseTexture>;
  35292. set irradianceTexture(value: Nullable<BaseTexture>);
  35293. /**
  35294. * Define if the texture is a render target.
  35295. */
  35296. isRenderTarget: boolean;
  35297. /**
  35298. * Define the unique id of the texture in the scene.
  35299. */
  35300. get uid(): string;
  35301. /** @hidden */
  35302. _prefiltered: boolean;
  35303. /**
  35304. * Return a string representation of the texture.
  35305. * @returns the texture as a string
  35306. */
  35307. toString(): string;
  35308. /**
  35309. * Get the class name of the texture.
  35310. * @returns "BaseTexture"
  35311. */
  35312. getClassName(): string;
  35313. /**
  35314. * Define the list of animation attached to the texture.
  35315. */
  35316. animations: import("babylonjs/Animations/animation").Animation[];
  35317. /**
  35318. * An event triggered when the texture is disposed.
  35319. */
  35320. onDisposeObservable: Observable<BaseTexture>;
  35321. private _onDisposeObserver;
  35322. /**
  35323. * Callback triggered when the texture has been disposed.
  35324. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35325. */
  35326. set onDispose(callback: () => void);
  35327. /**
  35328. * Define the current state of the loading sequence when in delayed load mode.
  35329. */
  35330. delayLoadState: number;
  35331. protected _scene: Nullable<Scene>;
  35332. protected _engine: Nullable<ThinEngine>;
  35333. /** @hidden */
  35334. _texture: Nullable<InternalTexture>;
  35335. private _uid;
  35336. /**
  35337. * Define if the texture is preventinga material to render or not.
  35338. * If not and the texture is not ready, the engine will use a default black texture instead.
  35339. */
  35340. get isBlocking(): boolean;
  35341. /**
  35342. * Instantiates a new BaseTexture.
  35343. * Base class of all the textures in babylon.
  35344. * It groups all the common properties the materials, post process, lights... might need
  35345. * in order to make a correct use of the texture.
  35346. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35347. */
  35348. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35349. /**
  35350. * Get the scene the texture belongs to.
  35351. * @returns the scene or null if undefined
  35352. */
  35353. getScene(): Nullable<Scene>;
  35354. /** @hidden */
  35355. protected _getEngine(): Nullable<ThinEngine>;
  35356. /**
  35357. * Get the texture transform matrix used to offset tile the texture for istance.
  35358. * @returns the transformation matrix
  35359. */
  35360. getTextureMatrix(): Matrix;
  35361. /**
  35362. * Get the texture reflection matrix used to rotate/transform the reflection.
  35363. * @returns the reflection matrix
  35364. */
  35365. getReflectionTextureMatrix(): Matrix;
  35366. /**
  35367. * Get the underlying lower level texture from Babylon.
  35368. * @returns the insternal texture
  35369. */
  35370. getInternalTexture(): Nullable<InternalTexture>;
  35371. /**
  35372. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35373. * @returns true if ready or not blocking
  35374. */
  35375. isReadyOrNotBlocking(): boolean;
  35376. /**
  35377. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35378. * @returns true if fully ready
  35379. */
  35380. isReady(): boolean;
  35381. private _cachedSize;
  35382. /**
  35383. * Get the size of the texture.
  35384. * @returns the texture size.
  35385. */
  35386. getSize(): ISize;
  35387. /**
  35388. * Get the base size of the texture.
  35389. * It can be different from the size if the texture has been resized for POT for instance
  35390. * @returns the base size
  35391. */
  35392. getBaseSize(): ISize;
  35393. /**
  35394. * Update the sampling mode of the texture.
  35395. * Default is Trilinear mode.
  35396. *
  35397. * | Value | Type | Description |
  35398. * | ----- | ------------------ | ----------- |
  35399. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35400. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35401. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35402. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35403. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35404. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35405. * | 7 | NEAREST_LINEAR | |
  35406. * | 8 | NEAREST_NEAREST | |
  35407. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35408. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35409. * | 11 | LINEAR_LINEAR | |
  35410. * | 12 | LINEAR_NEAREST | |
  35411. *
  35412. * > _mag_: magnification filter (close to the viewer)
  35413. * > _min_: minification filter (far from the viewer)
  35414. * > _mip_: filter used between mip map levels
  35415. *@param samplingMode Define the new sampling mode of the texture
  35416. */
  35417. updateSamplingMode(samplingMode: number): void;
  35418. /**
  35419. * Scales the texture if is `canRescale()`
  35420. * @param ratio the resize factor we want to use to rescale
  35421. */
  35422. scale(ratio: number): void;
  35423. /**
  35424. * Get if the texture can rescale.
  35425. */
  35426. get canRescale(): boolean;
  35427. /** @hidden */
  35428. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35429. /** @hidden */
  35430. _rebuild(): void;
  35431. /**
  35432. * Triggers the load sequence in delayed load mode.
  35433. */
  35434. delayLoad(): void;
  35435. /**
  35436. * Clones the texture.
  35437. * @returns the cloned texture
  35438. */
  35439. clone(): Nullable<BaseTexture>;
  35440. /**
  35441. * Get the texture underlying type (INT, FLOAT...)
  35442. */
  35443. get textureType(): number;
  35444. /**
  35445. * Get the texture underlying format (RGB, RGBA...)
  35446. */
  35447. get textureFormat(): number;
  35448. /**
  35449. * Indicates that textures need to be re-calculated for all materials
  35450. */
  35451. protected _markAllSubMeshesAsTexturesDirty(): void;
  35452. /**
  35453. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35454. * This will returns an RGBA array buffer containing either in values (0-255) or
  35455. * float values (0-1) depending of the underlying buffer type.
  35456. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35457. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35458. * @param buffer defines a user defined buffer to fill with data (can be null)
  35459. * @returns The Array buffer containing the pixels data.
  35460. */
  35461. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35462. /**
  35463. * Release and destroy the underlying lower level texture aka internalTexture.
  35464. */
  35465. releaseInternalTexture(): void;
  35466. /** @hidden */
  35467. get _lodTextureHigh(): Nullable<BaseTexture>;
  35468. /** @hidden */
  35469. get _lodTextureMid(): Nullable<BaseTexture>;
  35470. /** @hidden */
  35471. get _lodTextureLow(): Nullable<BaseTexture>;
  35472. /**
  35473. * Dispose the texture and release its associated resources.
  35474. */
  35475. dispose(): void;
  35476. /**
  35477. * Serialize the texture into a JSON representation that can be parsed later on.
  35478. * @returns the JSON representation of the texture
  35479. */
  35480. serialize(): any;
  35481. /**
  35482. * Helper function to be called back once a list of texture contains only ready textures.
  35483. * @param textures Define the list of textures to wait for
  35484. * @param callback Define the callback triggered once the entire list will be ready
  35485. */
  35486. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35487. private static _isScene;
  35488. }
  35489. }
  35490. declare module "babylonjs/Materials/effect" {
  35491. import { Observable } from "babylonjs/Misc/observable";
  35492. import { Nullable } from "babylonjs/types";
  35493. import { IDisposable } from "babylonjs/scene";
  35494. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35495. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35496. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35497. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35498. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35499. import { Engine } from "babylonjs/Engines/engine";
  35500. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35501. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35503. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35504. /**
  35505. * Options to be used when creating an effect.
  35506. */
  35507. export interface IEffectCreationOptions {
  35508. /**
  35509. * Atrributes that will be used in the shader.
  35510. */
  35511. attributes: string[];
  35512. /**
  35513. * Uniform varible names that will be set in the shader.
  35514. */
  35515. uniformsNames: string[];
  35516. /**
  35517. * Uniform buffer variable names that will be set in the shader.
  35518. */
  35519. uniformBuffersNames: string[];
  35520. /**
  35521. * Sampler texture variable names that will be set in the shader.
  35522. */
  35523. samplers: string[];
  35524. /**
  35525. * Define statements that will be set in the shader.
  35526. */
  35527. defines: any;
  35528. /**
  35529. * Possible fallbacks for this effect to improve performance when needed.
  35530. */
  35531. fallbacks: Nullable<IEffectFallbacks>;
  35532. /**
  35533. * Callback that will be called when the shader is compiled.
  35534. */
  35535. onCompiled: Nullable<(effect: Effect) => void>;
  35536. /**
  35537. * Callback that will be called if an error occurs during shader compilation.
  35538. */
  35539. onError: Nullable<(effect: Effect, errors: string) => void>;
  35540. /**
  35541. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35542. */
  35543. indexParameters?: any;
  35544. /**
  35545. * Max number of lights that can be used in the shader.
  35546. */
  35547. maxSimultaneousLights?: number;
  35548. /**
  35549. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35550. */
  35551. transformFeedbackVaryings?: Nullable<string[]>;
  35552. /**
  35553. * 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
  35554. */
  35555. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35556. /**
  35557. * Is this effect rendering to several color attachments ?
  35558. */
  35559. multiTarget?: boolean;
  35560. }
  35561. /**
  35562. * Effect containing vertex and fragment shader that can be executed on an object.
  35563. */
  35564. export class Effect implements IDisposable {
  35565. /**
  35566. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35567. */
  35568. static ShadersRepository: string;
  35569. /**
  35570. * Enable logging of the shader code when a compilation error occurs
  35571. */
  35572. static LogShaderCodeOnCompilationError: boolean;
  35573. /**
  35574. * Name of the effect.
  35575. */
  35576. name: any;
  35577. /**
  35578. * String container all the define statements that should be set on the shader.
  35579. */
  35580. defines: string;
  35581. /**
  35582. * Callback that will be called when the shader is compiled.
  35583. */
  35584. onCompiled: Nullable<(effect: Effect) => void>;
  35585. /**
  35586. * Callback that will be called if an error occurs during shader compilation.
  35587. */
  35588. onError: Nullable<(effect: Effect, errors: string) => void>;
  35589. /**
  35590. * Callback that will be called when effect is bound.
  35591. */
  35592. onBind: Nullable<(effect: Effect) => void>;
  35593. /**
  35594. * Unique ID of the effect.
  35595. */
  35596. uniqueId: number;
  35597. /**
  35598. * Observable that will be called when the shader is compiled.
  35599. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35600. */
  35601. onCompileObservable: Observable<Effect>;
  35602. /**
  35603. * Observable that will be called if an error occurs during shader compilation.
  35604. */
  35605. onErrorObservable: Observable<Effect>;
  35606. /** @hidden */
  35607. _onBindObservable: Nullable<Observable<Effect>>;
  35608. /**
  35609. * @hidden
  35610. * Specifies if the effect was previously ready
  35611. */
  35612. _wasPreviouslyReady: boolean;
  35613. /**
  35614. * Observable that will be called when effect is bound.
  35615. */
  35616. get onBindObservable(): Observable<Effect>;
  35617. /** @hidden */
  35618. _bonesComputationForcedToCPU: boolean;
  35619. /** @hidden */
  35620. _multiTarget: boolean;
  35621. private static _uniqueIdSeed;
  35622. private _engine;
  35623. private _uniformBuffersNames;
  35624. private _uniformBuffersNamesList;
  35625. private _uniformsNames;
  35626. private _samplerList;
  35627. private _samplers;
  35628. private _isReady;
  35629. private _compilationError;
  35630. private _allFallbacksProcessed;
  35631. private _attributesNames;
  35632. private _attributes;
  35633. private _attributeLocationByName;
  35634. private _uniforms;
  35635. /**
  35636. * Key for the effect.
  35637. * @hidden
  35638. */
  35639. _key: string;
  35640. private _indexParameters;
  35641. private _fallbacks;
  35642. private _vertexSourceCode;
  35643. private _fragmentSourceCode;
  35644. private _vertexSourceCodeOverride;
  35645. private _fragmentSourceCodeOverride;
  35646. private _transformFeedbackVaryings;
  35647. /**
  35648. * Compiled shader to webGL program.
  35649. * @hidden
  35650. */
  35651. _pipelineContext: Nullable<IPipelineContext>;
  35652. private _valueCache;
  35653. private static _baseCache;
  35654. /**
  35655. * Instantiates an effect.
  35656. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35657. * @param baseName Name of the effect.
  35658. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35659. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35660. * @param samplers List of sampler variables that will be passed to the shader.
  35661. * @param engine Engine to be used to render the effect
  35662. * @param defines Define statements to be added to the shader.
  35663. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35664. * @param onCompiled Callback that will be called when the shader is compiled.
  35665. * @param onError Callback that will be called if an error occurs during shader compilation.
  35666. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35667. */
  35668. 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);
  35669. private _useFinalCode;
  35670. /**
  35671. * Unique key for this effect
  35672. */
  35673. get key(): string;
  35674. /**
  35675. * If the effect has been compiled and prepared.
  35676. * @returns if the effect is compiled and prepared.
  35677. */
  35678. isReady(): boolean;
  35679. private _isReadyInternal;
  35680. /**
  35681. * The engine the effect was initialized with.
  35682. * @returns the engine.
  35683. */
  35684. getEngine(): Engine;
  35685. /**
  35686. * The pipeline context for this effect
  35687. * @returns the associated pipeline context
  35688. */
  35689. getPipelineContext(): Nullable<IPipelineContext>;
  35690. /**
  35691. * The set of names of attribute variables for the shader.
  35692. * @returns An array of attribute names.
  35693. */
  35694. getAttributesNames(): string[];
  35695. /**
  35696. * Returns the attribute at the given index.
  35697. * @param index The index of the attribute.
  35698. * @returns The location of the attribute.
  35699. */
  35700. getAttributeLocation(index: number): number;
  35701. /**
  35702. * Returns the attribute based on the name of the variable.
  35703. * @param name of the attribute to look up.
  35704. * @returns the attribute location.
  35705. */
  35706. getAttributeLocationByName(name: string): number;
  35707. /**
  35708. * The number of attributes.
  35709. * @returns the numnber of attributes.
  35710. */
  35711. getAttributesCount(): number;
  35712. /**
  35713. * Gets the index of a uniform variable.
  35714. * @param uniformName of the uniform to look up.
  35715. * @returns the index.
  35716. */
  35717. getUniformIndex(uniformName: string): number;
  35718. /**
  35719. * Returns the attribute based on the name of the variable.
  35720. * @param uniformName of the uniform to look up.
  35721. * @returns the location of the uniform.
  35722. */
  35723. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35724. /**
  35725. * Returns an array of sampler variable names
  35726. * @returns The array of sampler variable names.
  35727. */
  35728. getSamplers(): string[];
  35729. /**
  35730. * Returns an array of uniform variable names
  35731. * @returns The array of uniform variable names.
  35732. */
  35733. getUniformNames(): string[];
  35734. /**
  35735. * Returns an array of uniform buffer variable names
  35736. * @returns The array of uniform buffer variable names.
  35737. */
  35738. getUniformBuffersNames(): string[];
  35739. /**
  35740. * Returns the index parameters used to create the effect
  35741. * @returns The index parameters object
  35742. */
  35743. getIndexParameters(): any;
  35744. /**
  35745. * The error from the last compilation.
  35746. * @returns the error string.
  35747. */
  35748. getCompilationError(): string;
  35749. /**
  35750. * Gets a boolean indicating that all fallbacks were used during compilation
  35751. * @returns true if all fallbacks were used
  35752. */
  35753. allFallbacksProcessed(): boolean;
  35754. /**
  35755. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35756. * @param func The callback to be used.
  35757. */
  35758. executeWhenCompiled(func: (effect: Effect) => void): void;
  35759. private _checkIsReady;
  35760. private _loadShader;
  35761. /**
  35762. * Gets the vertex shader source code of this effect
  35763. */
  35764. get vertexSourceCode(): string;
  35765. /**
  35766. * Gets the fragment shader source code of this effect
  35767. */
  35768. get fragmentSourceCode(): string;
  35769. /**
  35770. * Recompiles the webGL program
  35771. * @param vertexSourceCode The source code for the vertex shader.
  35772. * @param fragmentSourceCode The source code for the fragment shader.
  35773. * @param onCompiled Callback called when completed.
  35774. * @param onError Callback called on error.
  35775. * @hidden
  35776. */
  35777. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35778. /**
  35779. * Prepares the effect
  35780. * @hidden
  35781. */
  35782. _prepareEffect(): void;
  35783. private _getShaderCodeAndErrorLine;
  35784. private _processCompilationErrors;
  35785. /**
  35786. * Checks if the effect is supported. (Must be called after compilation)
  35787. */
  35788. get isSupported(): boolean;
  35789. /**
  35790. * Binds a texture to the engine to be used as output of the shader.
  35791. * @param channel Name of the output variable.
  35792. * @param texture Texture to bind.
  35793. * @hidden
  35794. */
  35795. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35796. /**
  35797. * Sets a texture on the engine to be used in the shader.
  35798. * @param channel Name of the sampler variable.
  35799. * @param texture Texture to set.
  35800. */
  35801. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35802. /**
  35803. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35804. * @param channel Name of the sampler variable.
  35805. * @param texture Texture to set.
  35806. */
  35807. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35808. /**
  35809. * Sets an array of textures on the engine to be used in the shader.
  35810. * @param channel Name of the variable.
  35811. * @param textures Textures to set.
  35812. */
  35813. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35814. /**
  35815. * 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)
  35816. * @param channel Name of the sampler variable.
  35817. * @param postProcess Post process to get the input texture from.
  35818. */
  35819. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35820. /**
  35821. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35822. * 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)
  35823. * @param channel Name of the sampler variable.
  35824. * @param postProcess Post process to get the output texture from.
  35825. */
  35826. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35827. /** @hidden */
  35828. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35829. /** @hidden */
  35830. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35831. /** @hidden */
  35832. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35833. /** @hidden */
  35834. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35835. /**
  35836. * Binds a buffer to a uniform.
  35837. * @param buffer Buffer to bind.
  35838. * @param name Name of the uniform variable to bind to.
  35839. */
  35840. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35841. /**
  35842. * Binds block to a uniform.
  35843. * @param blockName Name of the block to bind.
  35844. * @param index Index to bind.
  35845. */
  35846. bindUniformBlock(blockName: string, index: number): void;
  35847. /**
  35848. * Sets an interger value on a uniform variable.
  35849. * @param uniformName Name of the variable.
  35850. * @param value Value to be set.
  35851. * @returns this effect.
  35852. */
  35853. setInt(uniformName: string, value: number): Effect;
  35854. /**
  35855. * Sets an int array on a uniform variable.
  35856. * @param uniformName Name of the variable.
  35857. * @param array array to be set.
  35858. * @returns this effect.
  35859. */
  35860. setIntArray(uniformName: string, array: Int32Array): Effect;
  35861. /**
  35862. * 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)
  35863. * @param uniformName Name of the variable.
  35864. * @param array array to be set.
  35865. * @returns this effect.
  35866. */
  35867. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35868. /**
  35869. * 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)
  35870. * @param uniformName Name of the variable.
  35871. * @param array array to be set.
  35872. * @returns this effect.
  35873. */
  35874. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35875. /**
  35876. * 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)
  35877. * @param uniformName Name of the variable.
  35878. * @param array array to be set.
  35879. * @returns this effect.
  35880. */
  35881. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35882. /**
  35883. * Sets an float array on a uniform variable.
  35884. * @param uniformName Name of the variable.
  35885. * @param array array to be set.
  35886. * @returns this effect.
  35887. */
  35888. setFloatArray(uniformName: string, array: Float32Array): Effect;
  35889. /**
  35890. * 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)
  35891. * @param uniformName Name of the variable.
  35892. * @param array array to be set.
  35893. * @returns this effect.
  35894. */
  35895. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  35896. /**
  35897. * 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)
  35898. * @param uniformName Name of the variable.
  35899. * @param array array to be set.
  35900. * @returns this effect.
  35901. */
  35902. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  35903. /**
  35904. * 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)
  35905. * @param uniformName Name of the variable.
  35906. * @param array array to be set.
  35907. * @returns this effect.
  35908. */
  35909. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  35910. /**
  35911. * Sets an array on a uniform variable.
  35912. * @param uniformName Name of the variable.
  35913. * @param array array to be set.
  35914. * @returns this effect.
  35915. */
  35916. setArray(uniformName: string, array: number[]): Effect;
  35917. /**
  35918. * 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)
  35919. * @param uniformName Name of the variable.
  35920. * @param array array to be set.
  35921. * @returns this effect.
  35922. */
  35923. setArray2(uniformName: string, array: number[]): Effect;
  35924. /**
  35925. * 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)
  35926. * @param uniformName Name of the variable.
  35927. * @param array array to be set.
  35928. * @returns this effect.
  35929. */
  35930. setArray3(uniformName: string, array: number[]): Effect;
  35931. /**
  35932. * 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)
  35933. * @param uniformName Name of the variable.
  35934. * @param array array to be set.
  35935. * @returns this effect.
  35936. */
  35937. setArray4(uniformName: string, array: number[]): Effect;
  35938. /**
  35939. * Sets matrices on a uniform variable.
  35940. * @param uniformName Name of the variable.
  35941. * @param matrices matrices to be set.
  35942. * @returns this effect.
  35943. */
  35944. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  35945. /**
  35946. * Sets matrix on a uniform variable.
  35947. * @param uniformName Name of the variable.
  35948. * @param matrix matrix to be set.
  35949. * @returns this effect.
  35950. */
  35951. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  35952. /**
  35953. * 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)
  35954. * @param uniformName Name of the variable.
  35955. * @param matrix matrix to be set.
  35956. * @returns this effect.
  35957. */
  35958. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35959. /**
  35960. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  35961. * @param uniformName Name of the variable.
  35962. * @param matrix matrix to be set.
  35963. * @returns this effect.
  35964. */
  35965. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  35966. /**
  35967. * Sets a float on a uniform variable.
  35968. * @param uniformName Name of the variable.
  35969. * @param value value to be set.
  35970. * @returns this effect.
  35971. */
  35972. setFloat(uniformName: string, value: number): Effect;
  35973. /**
  35974. * Sets a boolean on a uniform variable.
  35975. * @param uniformName Name of the variable.
  35976. * @param bool value to be set.
  35977. * @returns this effect.
  35978. */
  35979. setBool(uniformName: string, bool: boolean): Effect;
  35980. /**
  35981. * Sets a Vector2 on a uniform variable.
  35982. * @param uniformName Name of the variable.
  35983. * @param vector2 vector2 to be set.
  35984. * @returns this effect.
  35985. */
  35986. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  35987. /**
  35988. * Sets a float2 on a uniform variable.
  35989. * @param uniformName Name of the variable.
  35990. * @param x First float in float2.
  35991. * @param y Second float in float2.
  35992. * @returns this effect.
  35993. */
  35994. setFloat2(uniformName: string, x: number, y: number): Effect;
  35995. /**
  35996. * Sets a Vector3 on a uniform variable.
  35997. * @param uniformName Name of the variable.
  35998. * @param vector3 Value to be set.
  35999. * @returns this effect.
  36000. */
  36001. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36002. /**
  36003. * Sets a float3 on a uniform variable.
  36004. * @param uniformName Name of the variable.
  36005. * @param x First float in float3.
  36006. * @param y Second float in float3.
  36007. * @param z Third float in float3.
  36008. * @returns this effect.
  36009. */
  36010. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36011. /**
  36012. * Sets a Vector4 on a uniform variable.
  36013. * @param uniformName Name of the variable.
  36014. * @param vector4 Value to be set.
  36015. * @returns this effect.
  36016. */
  36017. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36018. /**
  36019. * Sets a float4 on a uniform variable.
  36020. * @param uniformName Name of the variable.
  36021. * @param x First float in float4.
  36022. * @param y Second float in float4.
  36023. * @param z Third float in float4.
  36024. * @param w Fourth float in float4.
  36025. * @returns this effect.
  36026. */
  36027. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36028. /**
  36029. * Sets a Color3 on a uniform variable.
  36030. * @param uniformName Name of the variable.
  36031. * @param color3 Value to be set.
  36032. * @returns this effect.
  36033. */
  36034. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36035. /**
  36036. * Sets a Color4 on a uniform variable.
  36037. * @param uniformName Name of the variable.
  36038. * @param color3 Value to be set.
  36039. * @param alpha Alpha value to be set.
  36040. * @returns this effect.
  36041. */
  36042. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36043. /**
  36044. * Sets a Color4 on a uniform variable
  36045. * @param uniformName defines the name of the variable
  36046. * @param color4 defines the value to be set
  36047. * @returns this effect.
  36048. */
  36049. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36050. /** Release all associated resources */
  36051. dispose(): void;
  36052. /**
  36053. * This function will add a new shader to the shader store
  36054. * @param name the name of the shader
  36055. * @param pixelShader optional pixel shader content
  36056. * @param vertexShader optional vertex shader content
  36057. */
  36058. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36059. /**
  36060. * Store of each shader (The can be looked up using effect.key)
  36061. */
  36062. static ShadersStore: {
  36063. [key: string]: string;
  36064. };
  36065. /**
  36066. * Store of each included file for a shader (The can be looked up using effect.key)
  36067. */
  36068. static IncludesShadersStore: {
  36069. [key: string]: string;
  36070. };
  36071. /**
  36072. * Resets the cache of effects.
  36073. */
  36074. static ResetCache(): void;
  36075. }
  36076. }
  36077. declare module "babylonjs/Engines/engineCapabilities" {
  36078. /**
  36079. * Interface used to describe the capabilities of the engine relatively to the current browser
  36080. */
  36081. export interface EngineCapabilities {
  36082. /** Maximum textures units per fragment shader */
  36083. maxTexturesImageUnits: number;
  36084. /** Maximum texture units per vertex shader */
  36085. maxVertexTextureImageUnits: number;
  36086. /** Maximum textures units in the entire pipeline */
  36087. maxCombinedTexturesImageUnits: number;
  36088. /** Maximum texture size */
  36089. maxTextureSize: number;
  36090. /** Maximum texture samples */
  36091. maxSamples?: number;
  36092. /** Maximum cube texture size */
  36093. maxCubemapTextureSize: number;
  36094. /** Maximum render texture size */
  36095. maxRenderTextureSize: number;
  36096. /** Maximum number of vertex attributes */
  36097. maxVertexAttribs: number;
  36098. /** Maximum number of varyings */
  36099. maxVaryingVectors: number;
  36100. /** Maximum number of uniforms per vertex shader */
  36101. maxVertexUniformVectors: number;
  36102. /** Maximum number of uniforms per fragment shader */
  36103. maxFragmentUniformVectors: number;
  36104. /** Defines if standard derivates (dx/dy) are supported */
  36105. standardDerivatives: boolean;
  36106. /** Defines if s3tc texture compression is supported */
  36107. s3tc?: WEBGL_compressed_texture_s3tc;
  36108. /** Defines if pvrtc texture compression is supported */
  36109. pvrtc: any;
  36110. /** Defines if etc1 texture compression is supported */
  36111. etc1: any;
  36112. /** Defines if etc2 texture compression is supported */
  36113. etc2: any;
  36114. /** Defines if astc texture compression is supported */
  36115. astc: any;
  36116. /** Defines if bptc texture compression is supported */
  36117. bptc: any;
  36118. /** Defines if float textures are supported */
  36119. textureFloat: boolean;
  36120. /** Defines if vertex array objects are supported */
  36121. vertexArrayObject: boolean;
  36122. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36123. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36124. /** Gets the maximum level of anisotropy supported */
  36125. maxAnisotropy: number;
  36126. /** Defines if instancing is supported */
  36127. instancedArrays: boolean;
  36128. /** Defines if 32 bits indices are supported */
  36129. uintIndices: boolean;
  36130. /** Defines if high precision shaders are supported */
  36131. highPrecisionShaderSupported: boolean;
  36132. /** Defines if depth reading in the fragment shader is supported */
  36133. fragmentDepthSupported: boolean;
  36134. /** Defines if float texture linear filtering is supported*/
  36135. textureFloatLinearFiltering: boolean;
  36136. /** Defines if rendering to float textures is supported */
  36137. textureFloatRender: boolean;
  36138. /** Defines if half float textures are supported*/
  36139. textureHalfFloat: boolean;
  36140. /** Defines if half float texture linear filtering is supported*/
  36141. textureHalfFloatLinearFiltering: boolean;
  36142. /** Defines if rendering to half float textures is supported */
  36143. textureHalfFloatRender: boolean;
  36144. /** Defines if textureLOD shader command is supported */
  36145. textureLOD: boolean;
  36146. /** Defines if draw buffers extension is supported */
  36147. drawBuffersExtension: boolean;
  36148. /** Defines if depth textures are supported */
  36149. depthTextureExtension: boolean;
  36150. /** Defines if float color buffer are supported */
  36151. colorBufferFloat: boolean;
  36152. /** Gets disjoint timer query extension (null if not supported) */
  36153. timerQuery?: EXT_disjoint_timer_query;
  36154. /** Defines if timestamp can be used with timer query */
  36155. canUseTimestampForTimerQuery: boolean;
  36156. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36157. multiview?: any;
  36158. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36159. oculusMultiview?: any;
  36160. /** Function used to let the system compiles shaders in background */
  36161. parallelShaderCompile?: {
  36162. COMPLETION_STATUS_KHR: number;
  36163. };
  36164. /** Max number of texture samples for MSAA */
  36165. maxMSAASamples: number;
  36166. /** Defines if the blend min max extension is supported */
  36167. blendMinMax: boolean;
  36168. }
  36169. }
  36170. declare module "babylonjs/States/depthCullingState" {
  36171. import { Nullable } from "babylonjs/types";
  36172. /**
  36173. * @hidden
  36174. **/
  36175. export class DepthCullingState {
  36176. private _isDepthTestDirty;
  36177. private _isDepthMaskDirty;
  36178. private _isDepthFuncDirty;
  36179. private _isCullFaceDirty;
  36180. private _isCullDirty;
  36181. private _isZOffsetDirty;
  36182. private _isFrontFaceDirty;
  36183. private _depthTest;
  36184. private _depthMask;
  36185. private _depthFunc;
  36186. private _cull;
  36187. private _cullFace;
  36188. private _zOffset;
  36189. private _frontFace;
  36190. /**
  36191. * Initializes the state.
  36192. */
  36193. constructor();
  36194. get isDirty(): boolean;
  36195. get zOffset(): number;
  36196. set zOffset(value: number);
  36197. get cullFace(): Nullable<number>;
  36198. set cullFace(value: Nullable<number>);
  36199. get cull(): Nullable<boolean>;
  36200. set cull(value: Nullable<boolean>);
  36201. get depthFunc(): Nullable<number>;
  36202. set depthFunc(value: Nullable<number>);
  36203. get depthMask(): boolean;
  36204. set depthMask(value: boolean);
  36205. get depthTest(): boolean;
  36206. set depthTest(value: boolean);
  36207. get frontFace(): Nullable<number>;
  36208. set frontFace(value: Nullable<number>);
  36209. reset(): void;
  36210. apply(gl: WebGLRenderingContext): void;
  36211. }
  36212. }
  36213. declare module "babylonjs/States/stencilState" {
  36214. /**
  36215. * @hidden
  36216. **/
  36217. export class StencilState {
  36218. /** 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 */
  36219. static readonly ALWAYS: number;
  36220. /** Passed to stencilOperation to specify that stencil value must be kept */
  36221. static readonly KEEP: number;
  36222. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36223. static readonly REPLACE: number;
  36224. private _isStencilTestDirty;
  36225. private _isStencilMaskDirty;
  36226. private _isStencilFuncDirty;
  36227. private _isStencilOpDirty;
  36228. private _stencilTest;
  36229. private _stencilMask;
  36230. private _stencilFunc;
  36231. private _stencilFuncRef;
  36232. private _stencilFuncMask;
  36233. private _stencilOpStencilFail;
  36234. private _stencilOpDepthFail;
  36235. private _stencilOpStencilDepthPass;
  36236. get isDirty(): boolean;
  36237. get stencilFunc(): number;
  36238. set stencilFunc(value: number);
  36239. get stencilFuncRef(): number;
  36240. set stencilFuncRef(value: number);
  36241. get stencilFuncMask(): number;
  36242. set stencilFuncMask(value: number);
  36243. get stencilOpStencilFail(): number;
  36244. set stencilOpStencilFail(value: number);
  36245. get stencilOpDepthFail(): number;
  36246. set stencilOpDepthFail(value: number);
  36247. get stencilOpStencilDepthPass(): number;
  36248. set stencilOpStencilDepthPass(value: number);
  36249. get stencilMask(): number;
  36250. set stencilMask(value: number);
  36251. get stencilTest(): boolean;
  36252. set stencilTest(value: boolean);
  36253. constructor();
  36254. reset(): void;
  36255. apply(gl: WebGLRenderingContext): void;
  36256. }
  36257. }
  36258. declare module "babylonjs/States/alphaCullingState" {
  36259. /**
  36260. * @hidden
  36261. **/
  36262. export class AlphaState {
  36263. private _isAlphaBlendDirty;
  36264. private _isBlendFunctionParametersDirty;
  36265. private _isBlendEquationParametersDirty;
  36266. private _isBlendConstantsDirty;
  36267. private _alphaBlend;
  36268. private _blendFunctionParameters;
  36269. private _blendEquationParameters;
  36270. private _blendConstants;
  36271. /**
  36272. * Initializes the state.
  36273. */
  36274. constructor();
  36275. get isDirty(): boolean;
  36276. get alphaBlend(): boolean;
  36277. set alphaBlend(value: boolean);
  36278. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36279. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36280. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36281. reset(): void;
  36282. apply(gl: WebGLRenderingContext): void;
  36283. }
  36284. }
  36285. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36286. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36287. /** @hidden */
  36288. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36289. attributeProcessor(attribute: string): string;
  36290. varyingProcessor(varying: string, isFragment: boolean): string;
  36291. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36292. }
  36293. }
  36294. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36295. /**
  36296. * Interface for attribute information associated with buffer instanciation
  36297. */
  36298. export interface InstancingAttributeInfo {
  36299. /**
  36300. * Name of the GLSL attribute
  36301. * if attribute index is not specified, this is used to retrieve the index from the effect
  36302. */
  36303. attributeName: string;
  36304. /**
  36305. * Index/offset of the attribute in the vertex shader
  36306. * if not specified, this will be computes from the name.
  36307. */
  36308. index?: number;
  36309. /**
  36310. * size of the attribute, 1, 2, 3 or 4
  36311. */
  36312. attributeSize: number;
  36313. /**
  36314. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36315. */
  36316. offset: number;
  36317. /**
  36318. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36319. * default to 1
  36320. */
  36321. divisor?: number;
  36322. /**
  36323. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36324. * default is FLOAT
  36325. */
  36326. attributeType?: number;
  36327. /**
  36328. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36329. */
  36330. normalized?: boolean;
  36331. }
  36332. }
  36333. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36334. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36335. import { Nullable } from "babylonjs/types";
  36336. module "babylonjs/Engines/thinEngine" {
  36337. interface ThinEngine {
  36338. /**
  36339. * Update a video texture
  36340. * @param texture defines the texture to update
  36341. * @param video defines the video element to use
  36342. * @param invertY defines if data must be stored with Y axis inverted
  36343. */
  36344. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36345. }
  36346. }
  36347. }
  36348. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36350. import { Nullable } from "babylonjs/types";
  36351. module "babylonjs/Engines/thinEngine" {
  36352. interface ThinEngine {
  36353. /**
  36354. * Creates a dynamic texture
  36355. * @param width defines the width of the texture
  36356. * @param height defines the height of the texture
  36357. * @param generateMipMaps defines if the engine should generate the mip levels
  36358. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36359. * @returns the dynamic texture inside an InternalTexture
  36360. */
  36361. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36362. /**
  36363. * Update the content of a dynamic texture
  36364. * @param texture defines the texture to update
  36365. * @param canvas defines the canvas containing the source
  36366. * @param invertY defines if data must be stored with Y axis inverted
  36367. * @param premulAlpha defines if alpha is stored as premultiplied
  36368. * @param format defines the format of the data
  36369. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36370. */
  36371. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36372. }
  36373. }
  36374. }
  36375. declare module "babylonjs/Materials/Textures/videoTexture" {
  36376. import { Observable } from "babylonjs/Misc/observable";
  36377. import { Nullable } from "babylonjs/types";
  36378. import { Scene } from "babylonjs/scene";
  36379. import { Texture } from "babylonjs/Materials/Textures/texture";
  36380. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36381. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36382. /**
  36383. * Settings for finer control over video usage
  36384. */
  36385. export interface VideoTextureSettings {
  36386. /**
  36387. * Applies `autoplay` to video, if specified
  36388. */
  36389. autoPlay?: boolean;
  36390. /**
  36391. * Applies `loop` to video, if specified
  36392. */
  36393. loop?: boolean;
  36394. /**
  36395. * Automatically updates internal texture from video at every frame in the render loop
  36396. */
  36397. autoUpdateTexture: boolean;
  36398. /**
  36399. * Image src displayed during the video loading or until the user interacts with the video.
  36400. */
  36401. poster?: string;
  36402. }
  36403. /**
  36404. * If you want to display a video in your scene, this is the special texture for that.
  36405. * This special texture works similar to other textures, with the exception of a few parameters.
  36406. * @see https://doc.babylonjs.com/how_to/video_texture
  36407. */
  36408. export class VideoTexture extends Texture {
  36409. /**
  36410. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36411. */
  36412. readonly autoUpdateTexture: boolean;
  36413. /**
  36414. * The video instance used by the texture internally
  36415. */
  36416. readonly video: HTMLVideoElement;
  36417. private _onUserActionRequestedObservable;
  36418. /**
  36419. * Event triggerd when a dom action is required by the user to play the video.
  36420. * This happens due to recent changes in browser policies preventing video to auto start.
  36421. */
  36422. get onUserActionRequestedObservable(): Observable<Texture>;
  36423. private _generateMipMaps;
  36424. private _stillImageCaptured;
  36425. private _displayingPosterTexture;
  36426. private _settings;
  36427. private _createInternalTextureOnEvent;
  36428. private _frameId;
  36429. private _currentSrc;
  36430. /**
  36431. * Creates a video texture.
  36432. * If you want to display a video in your scene, this is the special texture for that.
  36433. * This special texture works similar to other textures, with the exception of a few parameters.
  36434. * @see https://doc.babylonjs.com/how_to/video_texture
  36435. * @param name optional name, will detect from video source, if not defined
  36436. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36437. * @param scene is obviously the current scene.
  36438. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36439. * @param invertY is false by default but can be used to invert video on Y axis
  36440. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36441. * @param settings allows finer control over video usage
  36442. */
  36443. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36444. private _getName;
  36445. private _getVideo;
  36446. private _createInternalTexture;
  36447. private reset;
  36448. /**
  36449. * @hidden Internal method to initiate `update`.
  36450. */
  36451. _rebuild(): void;
  36452. /**
  36453. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36454. */
  36455. update(): void;
  36456. /**
  36457. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36458. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36459. */
  36460. updateTexture(isVisible: boolean): void;
  36461. protected _updateInternalTexture: () => void;
  36462. /**
  36463. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36464. * @param url New url.
  36465. */
  36466. updateURL(url: string): void;
  36467. /**
  36468. * Clones the texture.
  36469. * @returns the cloned texture
  36470. */
  36471. clone(): VideoTexture;
  36472. /**
  36473. * Dispose the texture and release its associated resources.
  36474. */
  36475. dispose(): void;
  36476. /**
  36477. * Creates a video texture straight from a stream.
  36478. * @param scene Define the scene the texture should be created in
  36479. * @param stream Define the stream the texture should be created from
  36480. * @returns The created video texture as a promise
  36481. */
  36482. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36483. /**
  36484. * Creates a video texture straight from your WebCam video feed.
  36485. * @param scene Define the scene the texture should be created in
  36486. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36487. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36488. * @returns The created video texture as a promise
  36489. */
  36490. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36491. minWidth: number;
  36492. maxWidth: number;
  36493. minHeight: number;
  36494. maxHeight: number;
  36495. deviceId: string;
  36496. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36497. /**
  36498. * Creates a video texture straight from your WebCam video feed.
  36499. * @param scene Define the scene the texture should be created in
  36500. * @param onReady Define a callback to triggered once the texture will be ready
  36501. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36502. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36503. */
  36504. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36505. minWidth: number;
  36506. maxWidth: number;
  36507. minHeight: number;
  36508. maxHeight: number;
  36509. deviceId: string;
  36510. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36511. }
  36512. }
  36513. declare module "babylonjs/Engines/thinEngine" {
  36514. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36515. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36516. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36517. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36518. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36519. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36520. import { Observable } from "babylonjs/Misc/observable";
  36521. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36522. import { StencilState } from "babylonjs/States/stencilState";
  36523. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36525. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36526. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36527. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36528. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36529. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36530. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36531. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36533. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36534. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36535. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36536. import { WebRequest } from "babylonjs/Misc/webRequest";
  36537. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36538. /**
  36539. * Defines the interface used by objects working like Scene
  36540. * @hidden
  36541. */
  36542. export interface ISceneLike {
  36543. _addPendingData(data: any): void;
  36544. _removePendingData(data: any): void;
  36545. offlineProvider: IOfflineProvider;
  36546. }
  36547. /**
  36548. * Information about the current host
  36549. */
  36550. export interface HostInformation {
  36551. /**
  36552. * Defines if the current host is a mobile
  36553. */
  36554. isMobile: boolean;
  36555. }
  36556. /** Interface defining initialization parameters for Engine class */
  36557. export interface EngineOptions extends WebGLContextAttributes {
  36558. /**
  36559. * Defines if the engine should no exceed a specified device ratio
  36560. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36561. */
  36562. limitDeviceRatio?: number;
  36563. /**
  36564. * Defines if webvr should be enabled automatically
  36565. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36566. */
  36567. autoEnableWebVR?: boolean;
  36568. /**
  36569. * Defines if webgl2 should be turned off even if supported
  36570. * @see https://doc.babylonjs.com/features/webgl2
  36571. */
  36572. disableWebGL2Support?: boolean;
  36573. /**
  36574. * Defines if webaudio should be initialized as well
  36575. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36576. */
  36577. audioEngine?: boolean;
  36578. /**
  36579. * Defines if animations should run using a deterministic lock step
  36580. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36581. */
  36582. deterministicLockstep?: boolean;
  36583. /** Defines the maximum steps to use with deterministic lock step mode */
  36584. lockstepMaxSteps?: number;
  36585. /** Defines the seconds between each deterministic lock step */
  36586. timeStep?: number;
  36587. /**
  36588. * Defines that engine should ignore context lost events
  36589. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36590. */
  36591. doNotHandleContextLost?: boolean;
  36592. /**
  36593. * Defines that engine should ignore modifying touch action attribute and style
  36594. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36595. */
  36596. doNotHandleTouchAction?: boolean;
  36597. /**
  36598. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36599. */
  36600. useHighPrecisionFloats?: boolean;
  36601. /**
  36602. * Make the canvas XR Compatible for XR sessions
  36603. */
  36604. xrCompatible?: boolean;
  36605. /**
  36606. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36607. */
  36608. useHighPrecisionMatrix?: boolean;
  36609. }
  36610. /**
  36611. * The base engine class (root of all engines)
  36612. */
  36613. export class ThinEngine {
  36614. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36615. static ExceptionList: ({
  36616. key: string;
  36617. capture: string;
  36618. captureConstraint: number;
  36619. targets: string[];
  36620. } | {
  36621. key: string;
  36622. capture: null;
  36623. captureConstraint: null;
  36624. targets: string[];
  36625. })[];
  36626. /** @hidden */
  36627. static _TextureLoaders: IInternalTextureLoader[];
  36628. /**
  36629. * Returns the current npm package of the sdk
  36630. */
  36631. static get NpmPackage(): string;
  36632. /**
  36633. * Returns the current version of the framework
  36634. */
  36635. static get Version(): string;
  36636. /**
  36637. * Returns a string describing the current engine
  36638. */
  36639. get description(): string;
  36640. /**
  36641. * Gets or sets the epsilon value used by collision engine
  36642. */
  36643. static CollisionsEpsilon: number;
  36644. /**
  36645. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36646. */
  36647. static get ShadersRepository(): string;
  36648. static set ShadersRepository(value: string);
  36649. /** @hidden */
  36650. _shaderProcessor: IShaderProcessor;
  36651. /**
  36652. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36653. */
  36654. forcePOTTextures: boolean;
  36655. /**
  36656. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36657. */
  36658. isFullscreen: boolean;
  36659. /**
  36660. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36661. */
  36662. cullBackFaces: boolean;
  36663. /**
  36664. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36665. */
  36666. renderEvenInBackground: boolean;
  36667. /**
  36668. * Gets or sets a boolean indicating that cache can be kept between frames
  36669. */
  36670. preventCacheWipeBetweenFrames: boolean;
  36671. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36672. validateShaderPrograms: boolean;
  36673. /**
  36674. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36675. * This can provide greater z depth for distant objects.
  36676. */
  36677. useReverseDepthBuffer: boolean;
  36678. /**
  36679. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36680. */
  36681. disableUniformBuffers: boolean;
  36682. /** @hidden */
  36683. _uniformBuffers: UniformBuffer[];
  36684. /**
  36685. * Gets a boolean indicating that the engine supports uniform buffers
  36686. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36687. */
  36688. get supportsUniformBuffers(): boolean;
  36689. /** @hidden */
  36690. _gl: WebGLRenderingContext;
  36691. /** @hidden */
  36692. _webGLVersion: number;
  36693. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36694. protected _windowIsBackground: boolean;
  36695. protected _creationOptions: EngineOptions;
  36696. protected _highPrecisionShadersAllowed: boolean;
  36697. /** @hidden */
  36698. get _shouldUseHighPrecisionShader(): boolean;
  36699. /**
  36700. * Gets a boolean indicating that only power of 2 textures are supported
  36701. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36702. */
  36703. get needPOTTextures(): boolean;
  36704. /** @hidden */
  36705. _badOS: boolean;
  36706. /** @hidden */
  36707. _badDesktopOS: boolean;
  36708. private _hardwareScalingLevel;
  36709. /** @hidden */
  36710. _caps: EngineCapabilities;
  36711. private _isStencilEnable;
  36712. private _glVersion;
  36713. private _glRenderer;
  36714. private _glVendor;
  36715. /** @hidden */
  36716. _videoTextureSupported: boolean;
  36717. protected _renderingQueueLaunched: boolean;
  36718. protected _activeRenderLoops: (() => void)[];
  36719. /**
  36720. * Observable signaled when a context lost event is raised
  36721. */
  36722. onContextLostObservable: Observable<ThinEngine>;
  36723. /**
  36724. * Observable signaled when a context restored event is raised
  36725. */
  36726. onContextRestoredObservable: Observable<ThinEngine>;
  36727. private _onContextLost;
  36728. private _onContextRestored;
  36729. protected _contextWasLost: boolean;
  36730. /** @hidden */
  36731. _doNotHandleContextLost: boolean;
  36732. /**
  36733. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36734. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36735. */
  36736. get doNotHandleContextLost(): boolean;
  36737. set doNotHandleContextLost(value: boolean);
  36738. /**
  36739. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36740. */
  36741. disableVertexArrayObjects: boolean;
  36742. /** @hidden */
  36743. protected _colorWrite: boolean;
  36744. /** @hidden */
  36745. protected _colorWriteChanged: boolean;
  36746. /** @hidden */
  36747. protected _depthCullingState: DepthCullingState;
  36748. /** @hidden */
  36749. protected _stencilState: StencilState;
  36750. /** @hidden */
  36751. _alphaState: AlphaState;
  36752. /** @hidden */
  36753. _alphaMode: number;
  36754. /** @hidden */
  36755. _alphaEquation: number;
  36756. /** @hidden */
  36757. _internalTexturesCache: InternalTexture[];
  36758. /** @hidden */
  36759. protected _activeChannel: number;
  36760. private _currentTextureChannel;
  36761. /** @hidden */
  36762. protected _boundTexturesCache: {
  36763. [key: string]: Nullable<InternalTexture>;
  36764. };
  36765. /** @hidden */
  36766. protected _currentEffect: Nullable<Effect>;
  36767. /** @hidden */
  36768. protected _currentProgram: Nullable<WebGLProgram>;
  36769. private _compiledEffects;
  36770. private _vertexAttribArraysEnabled;
  36771. /** @hidden */
  36772. protected _cachedViewport: Nullable<IViewportLike>;
  36773. private _cachedVertexArrayObject;
  36774. /** @hidden */
  36775. protected _cachedVertexBuffers: any;
  36776. /** @hidden */
  36777. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36778. /** @hidden */
  36779. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36780. /** @hidden */
  36781. _currentRenderTarget: Nullable<InternalTexture>;
  36782. private _uintIndicesCurrentlySet;
  36783. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36784. /** @hidden */
  36785. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36786. /** @hidden */
  36787. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36788. private _currentBufferPointers;
  36789. private _currentInstanceLocations;
  36790. private _currentInstanceBuffers;
  36791. private _textureUnits;
  36792. /** @hidden */
  36793. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36794. /** @hidden */
  36795. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36796. /** @hidden */
  36797. _boundRenderFunction: any;
  36798. private _vaoRecordInProgress;
  36799. private _mustWipeVertexAttributes;
  36800. private _emptyTexture;
  36801. private _emptyCubeTexture;
  36802. private _emptyTexture3D;
  36803. private _emptyTexture2DArray;
  36804. /** @hidden */
  36805. _frameHandler: number;
  36806. private _nextFreeTextureSlots;
  36807. private _maxSimultaneousTextures;
  36808. private _activeRequests;
  36809. /** @hidden */
  36810. _transformTextureUrl: Nullable<(url: string) => string>;
  36811. /**
  36812. * Gets information about the current host
  36813. */
  36814. hostInformation: HostInformation;
  36815. protected get _supportsHardwareTextureRescaling(): boolean;
  36816. private _framebufferDimensionsObject;
  36817. /**
  36818. * sets the object from which width and height will be taken from when getting render width and height
  36819. * Will fallback to the gl object
  36820. * @param dimensions the framebuffer width and height that will be used.
  36821. */
  36822. set framebufferDimensionsObject(dimensions: Nullable<{
  36823. framebufferWidth: number;
  36824. framebufferHeight: number;
  36825. }>);
  36826. /**
  36827. * Gets the current viewport
  36828. */
  36829. get currentViewport(): Nullable<IViewportLike>;
  36830. /**
  36831. * Gets the default empty texture
  36832. */
  36833. get emptyTexture(): InternalTexture;
  36834. /**
  36835. * Gets the default empty 3D texture
  36836. */
  36837. get emptyTexture3D(): InternalTexture;
  36838. /**
  36839. * Gets the default empty 2D array texture
  36840. */
  36841. get emptyTexture2DArray(): InternalTexture;
  36842. /**
  36843. * Gets the default empty cube texture
  36844. */
  36845. get emptyCubeTexture(): InternalTexture;
  36846. /**
  36847. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36848. */
  36849. readonly premultipliedAlpha: boolean;
  36850. /**
  36851. * Observable event triggered before each texture is initialized
  36852. */
  36853. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36854. /**
  36855. * Creates a new engine
  36856. * @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
  36857. * @param antialias defines enable antialiasing (default: false)
  36858. * @param options defines further options to be sent to the getContext() function
  36859. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36860. */
  36861. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36862. private _rebuildInternalTextures;
  36863. private _rebuildEffects;
  36864. /**
  36865. * Gets a boolean indicating if all created effects are ready
  36866. * @returns true if all effects are ready
  36867. */
  36868. areAllEffectsReady(): boolean;
  36869. protected _rebuildBuffers(): void;
  36870. protected _initGLContext(): void;
  36871. /**
  36872. * Gets version of the current webGL context
  36873. */
  36874. get webGLVersion(): number;
  36875. /**
  36876. * Gets a string identifying the name of the class
  36877. * @returns "Engine" string
  36878. */
  36879. getClassName(): string;
  36880. /**
  36881. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36882. */
  36883. get isStencilEnable(): boolean;
  36884. /** @hidden */
  36885. _prepareWorkingCanvas(): void;
  36886. /**
  36887. * Reset the texture cache to empty state
  36888. */
  36889. resetTextureCache(): void;
  36890. /**
  36891. * Gets an object containing information about the current webGL context
  36892. * @returns an object containing the vender, the renderer and the version of the current webGL context
  36893. */
  36894. getGlInfo(): {
  36895. vendor: string;
  36896. renderer: string;
  36897. version: string;
  36898. };
  36899. /**
  36900. * Defines the hardware scaling level.
  36901. * By default the hardware scaling level is computed from the window device ratio.
  36902. * 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.
  36903. * @param level defines the level to use
  36904. */
  36905. setHardwareScalingLevel(level: number): void;
  36906. /**
  36907. * Gets the current hardware scaling level.
  36908. * By default the hardware scaling level is computed from the window device ratio.
  36909. * 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.
  36910. * @returns a number indicating the current hardware scaling level
  36911. */
  36912. getHardwareScalingLevel(): number;
  36913. /**
  36914. * Gets the list of loaded textures
  36915. * @returns an array containing all loaded textures
  36916. */
  36917. getLoadedTexturesCache(): InternalTexture[];
  36918. /**
  36919. * Gets the object containing all engine capabilities
  36920. * @returns the EngineCapabilities object
  36921. */
  36922. getCaps(): EngineCapabilities;
  36923. /**
  36924. * stop executing a render loop function and remove it from the execution array
  36925. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  36926. */
  36927. stopRenderLoop(renderFunction?: () => void): void;
  36928. /** @hidden */
  36929. _renderLoop(): void;
  36930. /**
  36931. * Gets the HTML canvas attached with the current webGL context
  36932. * @returns a HTML canvas
  36933. */
  36934. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  36935. /**
  36936. * Gets host window
  36937. * @returns the host window object
  36938. */
  36939. getHostWindow(): Nullable<Window>;
  36940. /**
  36941. * Gets the current render width
  36942. * @param useScreen defines if screen size must be used (or the current render target if any)
  36943. * @returns a number defining the current render width
  36944. */
  36945. getRenderWidth(useScreen?: boolean): number;
  36946. /**
  36947. * Gets the current render height
  36948. * @param useScreen defines if screen size must be used (or the current render target if any)
  36949. * @returns a number defining the current render height
  36950. */
  36951. getRenderHeight(useScreen?: boolean): number;
  36952. /**
  36953. * Can be used to override the current requestAnimationFrame requester.
  36954. * @hidden
  36955. */
  36956. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  36957. /**
  36958. * Register and execute a render loop. The engine can have more than one render function
  36959. * @param renderFunction defines the function to continuously execute
  36960. */
  36961. runRenderLoop(renderFunction: () => void): void;
  36962. /**
  36963. * Clear the current render buffer or the current render target (if any is set up)
  36964. * @param color defines the color to use
  36965. * @param backBuffer defines if the back buffer must be cleared
  36966. * @param depth defines if the depth buffer must be cleared
  36967. * @param stencil defines if the stencil buffer must be cleared
  36968. */
  36969. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  36970. private _viewportCached;
  36971. /** @hidden */
  36972. _viewport(x: number, y: number, width: number, height: number): void;
  36973. /**
  36974. * Set the WebGL's viewport
  36975. * @param viewport defines the viewport element to be used
  36976. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  36977. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  36978. */
  36979. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  36980. /**
  36981. * Begin a new frame
  36982. */
  36983. beginFrame(): void;
  36984. /**
  36985. * Enf the current frame
  36986. */
  36987. endFrame(): void;
  36988. /**
  36989. * Resize the view according to the canvas' size
  36990. */
  36991. resize(): void;
  36992. /**
  36993. * Force a specific size of the canvas
  36994. * @param width defines the new canvas' width
  36995. * @param height defines the new canvas' height
  36996. * @returns true if the size was changed
  36997. */
  36998. setSize(width: number, height: number): boolean;
  36999. /**
  37000. * Binds the frame buffer to the specified texture.
  37001. * @param texture The texture to render to or null for the default canvas
  37002. * @param faceIndex The face of the texture to render to in case of cube texture
  37003. * @param requiredWidth The width of the target to render to
  37004. * @param requiredHeight The height of the target to render to
  37005. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37006. * @param lodLevel defines the lod level to bind to the frame buffer
  37007. * @param layer defines the 2d array index to bind to frame buffer to
  37008. */
  37009. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37010. /** @hidden */
  37011. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37012. /**
  37013. * Unbind the current render target texture from the webGL context
  37014. * @param texture defines the render target texture to unbind
  37015. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37016. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37017. */
  37018. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37019. /**
  37020. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37021. */
  37022. flushFramebuffer(): void;
  37023. /**
  37024. * Unbind the current render target and bind the default framebuffer
  37025. */
  37026. restoreDefaultFramebuffer(): void;
  37027. /** @hidden */
  37028. protected _resetVertexBufferBinding(): void;
  37029. /**
  37030. * Creates a vertex buffer
  37031. * @param data the data for the vertex buffer
  37032. * @returns the new WebGL static buffer
  37033. */
  37034. createVertexBuffer(data: DataArray): DataBuffer;
  37035. private _createVertexBuffer;
  37036. /**
  37037. * Creates a dynamic vertex buffer
  37038. * @param data the data for the dynamic vertex buffer
  37039. * @returns the new WebGL dynamic buffer
  37040. */
  37041. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37042. protected _resetIndexBufferBinding(): void;
  37043. /**
  37044. * Creates a new index buffer
  37045. * @param indices defines the content of the index buffer
  37046. * @param updatable defines if the index buffer must be updatable
  37047. * @returns a new webGL buffer
  37048. */
  37049. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37050. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37051. /**
  37052. * Bind a webGL buffer to the webGL context
  37053. * @param buffer defines the buffer to bind
  37054. */
  37055. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37056. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37057. private bindBuffer;
  37058. /**
  37059. * update the bound buffer with the given data
  37060. * @param data defines the data to update
  37061. */
  37062. updateArrayBuffer(data: Float32Array): void;
  37063. private _vertexAttribPointer;
  37064. /** @hidden */
  37065. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37066. private _bindVertexBuffersAttributes;
  37067. /**
  37068. * Records a vertex array object
  37069. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37070. * @param vertexBuffers defines the list of vertex buffers to store
  37071. * @param indexBuffer defines the index buffer to store
  37072. * @param effect defines the effect to store
  37073. * @returns the new vertex array object
  37074. */
  37075. recordVertexArrayObject(vertexBuffers: {
  37076. [key: string]: VertexBuffer;
  37077. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37078. /**
  37079. * Bind a specific vertex array object
  37080. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37081. * @param vertexArrayObject defines the vertex array object to bind
  37082. * @param indexBuffer defines the index buffer to bind
  37083. */
  37084. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37085. /**
  37086. * Bind webGl buffers directly to the webGL context
  37087. * @param vertexBuffer defines the vertex buffer to bind
  37088. * @param indexBuffer defines the index buffer to bind
  37089. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37090. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37091. * @param effect defines the effect associated with the vertex buffer
  37092. */
  37093. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37094. private _unbindVertexArrayObject;
  37095. /**
  37096. * Bind a list of vertex buffers to the webGL context
  37097. * @param vertexBuffers defines the list of vertex buffers to bind
  37098. * @param indexBuffer defines the index buffer to bind
  37099. * @param effect defines the effect associated with the vertex buffers
  37100. */
  37101. bindBuffers(vertexBuffers: {
  37102. [key: string]: Nullable<VertexBuffer>;
  37103. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37104. /**
  37105. * Unbind all instance attributes
  37106. */
  37107. unbindInstanceAttributes(): void;
  37108. /**
  37109. * Release and free the memory of a vertex array object
  37110. * @param vao defines the vertex array object to delete
  37111. */
  37112. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37113. /** @hidden */
  37114. _releaseBuffer(buffer: DataBuffer): boolean;
  37115. protected _deleteBuffer(buffer: DataBuffer): void;
  37116. /**
  37117. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37118. * @param instancesBuffer defines the webGL buffer to update and bind
  37119. * @param data defines the data to store in the buffer
  37120. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37121. */
  37122. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37123. /**
  37124. * Bind the content of a webGL buffer used with instantiation
  37125. * @param instancesBuffer defines the webGL buffer to bind
  37126. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37127. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37128. */
  37129. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37130. /**
  37131. * Disable the instance attribute corresponding to the name in parameter
  37132. * @param name defines the name of the attribute to disable
  37133. */
  37134. disableInstanceAttributeByName(name: string): void;
  37135. /**
  37136. * Disable the instance attribute corresponding to the location in parameter
  37137. * @param attributeLocation defines the attribute location of the attribute to disable
  37138. */
  37139. disableInstanceAttribute(attributeLocation: number): void;
  37140. /**
  37141. * Disable the attribute corresponding to the location in parameter
  37142. * @param attributeLocation defines the attribute location of the attribute to disable
  37143. */
  37144. disableAttributeByIndex(attributeLocation: number): void;
  37145. /**
  37146. * Send a draw order
  37147. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37148. * @param indexStart defines the starting index
  37149. * @param indexCount defines the number of index to draw
  37150. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37151. */
  37152. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37153. /**
  37154. * Draw a list of points
  37155. * @param verticesStart defines the index of first vertex to draw
  37156. * @param verticesCount defines the count of vertices to draw
  37157. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37158. */
  37159. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37160. /**
  37161. * Draw a list of unindexed primitives
  37162. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37163. * @param verticesStart defines the index of first vertex to draw
  37164. * @param verticesCount defines the count of vertices to draw
  37165. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37166. */
  37167. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37168. /**
  37169. * Draw a list of indexed primitives
  37170. * @param fillMode defines the primitive to use
  37171. * @param indexStart defines the starting index
  37172. * @param indexCount defines the number of index to draw
  37173. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37174. */
  37175. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37176. /**
  37177. * Draw a list of unindexed primitives
  37178. * @param fillMode defines the primitive to use
  37179. * @param verticesStart defines the index of first vertex to draw
  37180. * @param verticesCount defines the count of vertices to draw
  37181. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37182. */
  37183. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37184. private _drawMode;
  37185. /** @hidden */
  37186. protected _reportDrawCall(): void;
  37187. /** @hidden */
  37188. _releaseEffect(effect: Effect): void;
  37189. /** @hidden */
  37190. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37191. /**
  37192. * Create a new effect (used to store vertex/fragment shaders)
  37193. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37194. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37195. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37196. * @param samplers defines an array of string used to represent textures
  37197. * @param defines defines the string containing the defines to use to compile the shaders
  37198. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37199. * @param onCompiled defines a function to call when the effect creation is successful
  37200. * @param onError defines a function to call when the effect creation has failed
  37201. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37202. * @returns the new Effect
  37203. */
  37204. 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;
  37205. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37206. private _compileShader;
  37207. private _compileRawShader;
  37208. /** @hidden */
  37209. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37210. /**
  37211. * Directly creates a webGL program
  37212. * @param pipelineContext defines the pipeline context to attach to
  37213. * @param vertexCode defines the vertex shader code to use
  37214. * @param fragmentCode defines the fragment shader code to use
  37215. * @param context defines the webGL context to use (if not set, the current one will be used)
  37216. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37217. * @returns the new webGL program
  37218. */
  37219. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37220. /**
  37221. * Creates a webGL program
  37222. * @param pipelineContext defines the pipeline context to attach to
  37223. * @param vertexCode defines the vertex shader code to use
  37224. * @param fragmentCode defines the fragment shader code to use
  37225. * @param defines defines the string containing the defines to use to compile the shaders
  37226. * @param context defines the webGL context to use (if not set, the current one will be used)
  37227. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37228. * @returns the new webGL program
  37229. */
  37230. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37231. /**
  37232. * Creates a new pipeline context
  37233. * @returns the new pipeline
  37234. */
  37235. createPipelineContext(): IPipelineContext;
  37236. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37237. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37238. /** @hidden */
  37239. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37240. /** @hidden */
  37241. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37242. /** @hidden */
  37243. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37244. /**
  37245. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37246. * @param pipelineContext defines the pipeline context to use
  37247. * @param uniformsNames defines the list of uniform names
  37248. * @returns an array of webGL uniform locations
  37249. */
  37250. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37251. /**
  37252. * Gets the lsit of active attributes for a given webGL program
  37253. * @param pipelineContext defines the pipeline context to use
  37254. * @param attributesNames defines the list of attribute names to get
  37255. * @returns an array of indices indicating the offset of each attribute
  37256. */
  37257. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37258. /**
  37259. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37260. * @param effect defines the effect to activate
  37261. */
  37262. enableEffect(effect: Nullable<Effect>): void;
  37263. /**
  37264. * Set the value of an uniform to a number (int)
  37265. * @param uniform defines the webGL uniform location where to store the value
  37266. * @param value defines the int number to store
  37267. * @returns true if the value was set
  37268. */
  37269. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37270. /**
  37271. * Set the value of an uniform to an array of int32
  37272. * @param uniform defines the webGL uniform location where to store the value
  37273. * @param array defines the array of int32 to store
  37274. * @returns true if the value was set
  37275. */
  37276. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37277. /**
  37278. * Set the value of an uniform to an array of int32 (stored as vec2)
  37279. * @param uniform defines the webGL uniform location where to store the value
  37280. * @param array defines the array of int32 to store
  37281. * @returns true if the value was set
  37282. */
  37283. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37284. /**
  37285. * Set the value of an uniform to an array of int32 (stored as vec3)
  37286. * @param uniform defines the webGL uniform location where to store the value
  37287. * @param array defines the array of int32 to store
  37288. * @returns true if the value was set
  37289. */
  37290. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37291. /**
  37292. * Set the value of an uniform to an array of int32 (stored as vec4)
  37293. * @param uniform defines the webGL uniform location where to store the value
  37294. * @param array defines the array of int32 to store
  37295. * @returns true if the value was set
  37296. */
  37297. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37298. /**
  37299. * Set the value of an uniform to an array of number
  37300. * @param uniform defines the webGL uniform location where to store the value
  37301. * @param array defines the array of number to store
  37302. * @returns true if the value was set
  37303. */
  37304. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37305. /**
  37306. * Set the value of an uniform to an array of number (stored as vec2)
  37307. * @param uniform defines the webGL uniform location where to store the value
  37308. * @param array defines the array of number to store
  37309. * @returns true if the value was set
  37310. */
  37311. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37312. /**
  37313. * Set the value of an uniform to an array of number (stored as vec3)
  37314. * @param uniform defines the webGL uniform location where to store the value
  37315. * @param array defines the array of number to store
  37316. * @returns true if the value was set
  37317. */
  37318. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37319. /**
  37320. * Set the value of an uniform to an array of number (stored as vec4)
  37321. * @param uniform defines the webGL uniform location where to store the value
  37322. * @param array defines the array of number to store
  37323. * @returns true if the value was set
  37324. */
  37325. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37326. /**
  37327. * Set the value of an uniform to an array of float32 (stored as matrices)
  37328. * @param uniform defines the webGL uniform location where to store the value
  37329. * @param matrices defines the array of float32 to store
  37330. * @returns true if the value was set
  37331. */
  37332. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37333. /**
  37334. * Set the value of an uniform to a matrix (3x3)
  37335. * @param uniform defines the webGL uniform location where to store the value
  37336. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37337. * @returns true if the value was set
  37338. */
  37339. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37340. /**
  37341. * Set the value of an uniform to a matrix (2x2)
  37342. * @param uniform defines the webGL uniform location where to store the value
  37343. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37344. * @returns true if the value was set
  37345. */
  37346. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37347. /**
  37348. * Set the value of an uniform to a number (float)
  37349. * @param uniform defines the webGL uniform location where to store the value
  37350. * @param value defines the float number to store
  37351. * @returns true if the value was transfered
  37352. */
  37353. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37354. /**
  37355. * Set the value of an uniform to a vec2
  37356. * @param uniform defines the webGL uniform location where to store the value
  37357. * @param x defines the 1st component of the value
  37358. * @param y defines the 2nd component of the value
  37359. * @returns true if the value was set
  37360. */
  37361. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37362. /**
  37363. * Set the value of an uniform to a vec3
  37364. * @param uniform defines the webGL uniform location where to store the value
  37365. * @param x defines the 1st component of the value
  37366. * @param y defines the 2nd component of the value
  37367. * @param z defines the 3rd component of the value
  37368. * @returns true if the value was set
  37369. */
  37370. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37371. /**
  37372. * Set the value of an uniform to a vec4
  37373. * @param uniform defines the webGL uniform location where to store the value
  37374. * @param x defines the 1st component of the value
  37375. * @param y defines the 2nd component of the value
  37376. * @param z defines the 3rd component of the value
  37377. * @param w defines the 4th component of the value
  37378. * @returns true if the value was set
  37379. */
  37380. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37381. /**
  37382. * Apply all cached states (depth, culling, stencil and alpha)
  37383. */
  37384. applyStates(): void;
  37385. /**
  37386. * Enable or disable color writing
  37387. * @param enable defines the state to set
  37388. */
  37389. setColorWrite(enable: boolean): void;
  37390. /**
  37391. * Gets a boolean indicating if color writing is enabled
  37392. * @returns the current color writing state
  37393. */
  37394. getColorWrite(): boolean;
  37395. /**
  37396. * Gets the depth culling state manager
  37397. */
  37398. get depthCullingState(): DepthCullingState;
  37399. /**
  37400. * Gets the alpha state manager
  37401. */
  37402. get alphaState(): AlphaState;
  37403. /**
  37404. * Gets the stencil state manager
  37405. */
  37406. get stencilState(): StencilState;
  37407. /**
  37408. * Clears the list of texture accessible through engine.
  37409. * This can help preventing texture load conflict due to name collision.
  37410. */
  37411. clearInternalTexturesCache(): void;
  37412. /**
  37413. * Force the entire cache to be cleared
  37414. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37415. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37416. */
  37417. wipeCaches(bruteForce?: boolean): void;
  37418. /** @hidden */
  37419. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37420. min: number;
  37421. mag: number;
  37422. };
  37423. /** @hidden */
  37424. _createTexture(): WebGLTexture;
  37425. /**
  37426. * Usually called from Texture.ts.
  37427. * Passed information to create a WebGLTexture
  37428. * @param url defines a value which contains one of the following:
  37429. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37430. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37431. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37432. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37433. * @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)
  37434. * @param scene needed for loading to the correct scene
  37435. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37436. * @param onLoad optional callback to be called upon successful completion
  37437. * @param onError optional callback to be called upon failure
  37438. * @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
  37439. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37440. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37441. * @param forcedExtension defines the extension to use to pick the right loader
  37442. * @param mimeType defines an optional mime type
  37443. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37444. */
  37445. 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;
  37446. /**
  37447. * Loads an image as an HTMLImageElement.
  37448. * @param input url string, ArrayBuffer, or Blob to load
  37449. * @param onLoad callback called when the image successfully loads
  37450. * @param onError callback called when the image fails to load
  37451. * @param offlineProvider offline provider for caching
  37452. * @param mimeType optional mime type
  37453. * @returns the HTMLImageElement of the loaded image
  37454. * @hidden
  37455. */
  37456. 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>;
  37457. /**
  37458. * @hidden
  37459. */
  37460. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37461. private _unpackFlipYCached;
  37462. /**
  37463. * In case you are sharing the context with other applications, it might
  37464. * be interested to not cache the unpack flip y state to ensure a consistent
  37465. * value would be set.
  37466. */
  37467. enableUnpackFlipYCached: boolean;
  37468. /** @hidden */
  37469. _unpackFlipY(value: boolean): void;
  37470. /** @hidden */
  37471. _getUnpackAlignement(): number;
  37472. private _getTextureTarget;
  37473. /**
  37474. * Update the sampling mode of a given texture
  37475. * @param samplingMode defines the required sampling mode
  37476. * @param texture defines the texture to update
  37477. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37478. */
  37479. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37480. /**
  37481. * Update the sampling mode of a given texture
  37482. * @param texture defines the texture to update
  37483. * @param wrapU defines the texture wrap mode of the u coordinates
  37484. * @param wrapV defines the texture wrap mode of the v coordinates
  37485. * @param wrapR defines the texture wrap mode of the r coordinates
  37486. */
  37487. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37488. /** @hidden */
  37489. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37490. width: number;
  37491. height: number;
  37492. layers?: number;
  37493. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37494. /** @hidden */
  37495. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37496. /** @hidden */
  37497. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37498. /**
  37499. * Update a portion of an internal texture
  37500. * @param texture defines the texture to update
  37501. * @param imageData defines the data to store into the texture
  37502. * @param xOffset defines the x coordinates of the update rectangle
  37503. * @param yOffset defines the y coordinates of the update rectangle
  37504. * @param width defines the width of the update rectangle
  37505. * @param height defines the height of the update rectangle
  37506. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37507. * @param lod defines the lod level to update (0 by default)
  37508. */
  37509. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37510. /** @hidden */
  37511. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37512. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37513. private _prepareWebGLTexture;
  37514. /** @hidden */
  37515. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37516. private _getDepthStencilBuffer;
  37517. /** @hidden */
  37518. _releaseFramebufferObjects(texture: InternalTexture): void;
  37519. /** @hidden */
  37520. _releaseTexture(texture: InternalTexture): void;
  37521. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37522. protected _setProgram(program: WebGLProgram): void;
  37523. protected _boundUniforms: {
  37524. [key: number]: WebGLUniformLocation;
  37525. };
  37526. /**
  37527. * Binds an effect to the webGL context
  37528. * @param effect defines the effect to bind
  37529. */
  37530. bindSamplers(effect: Effect): void;
  37531. private _activateCurrentTexture;
  37532. /** @hidden */
  37533. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37534. /** @hidden */
  37535. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37536. /**
  37537. * Unbind all textures from the webGL context
  37538. */
  37539. unbindAllTextures(): void;
  37540. /**
  37541. * Sets a texture to the according uniform.
  37542. * @param channel The texture channel
  37543. * @param uniform The uniform to set
  37544. * @param texture The texture to apply
  37545. */
  37546. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37547. private _bindSamplerUniformToChannel;
  37548. private _getTextureWrapMode;
  37549. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37550. /**
  37551. * Sets an array of texture to the webGL context
  37552. * @param channel defines the channel where the texture array must be set
  37553. * @param uniform defines the associated uniform location
  37554. * @param textures defines the array of textures to bind
  37555. */
  37556. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37557. /** @hidden */
  37558. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37559. private _setTextureParameterFloat;
  37560. private _setTextureParameterInteger;
  37561. /**
  37562. * Unbind all vertex attributes from the webGL context
  37563. */
  37564. unbindAllAttributes(): void;
  37565. /**
  37566. * 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
  37567. */
  37568. releaseEffects(): void;
  37569. /**
  37570. * Dispose and release all associated resources
  37571. */
  37572. dispose(): void;
  37573. /**
  37574. * Attach a new callback raised when context lost event is fired
  37575. * @param callback defines the callback to call
  37576. */
  37577. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37578. /**
  37579. * Attach a new callback raised when context restored event is fired
  37580. * @param callback defines the callback to call
  37581. */
  37582. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37583. /**
  37584. * Get the current error code of the webGL context
  37585. * @returns the error code
  37586. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37587. */
  37588. getError(): number;
  37589. private _canRenderToFloatFramebuffer;
  37590. private _canRenderToHalfFloatFramebuffer;
  37591. private _canRenderToFramebuffer;
  37592. /** @hidden */
  37593. _getWebGLTextureType(type: number): number;
  37594. /** @hidden */
  37595. _getInternalFormat(format: number): number;
  37596. /** @hidden */
  37597. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37598. /** @hidden */
  37599. _getRGBAMultiSampleBufferFormat(type: number): number;
  37600. /** @hidden */
  37601. _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;
  37602. /**
  37603. * Loads a file from a url
  37604. * @param url url to load
  37605. * @param onSuccess callback called when the file successfully loads
  37606. * @param onProgress callback called while file is loading (if the server supports this mode)
  37607. * @param offlineProvider defines the offline provider for caching
  37608. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37609. * @param onError callback called when the file fails to load
  37610. * @returns a file request object
  37611. * @hidden
  37612. */
  37613. 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;
  37614. /**
  37615. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37616. * @param x defines the x coordinate of the rectangle where pixels must be read
  37617. * @param y defines the y coordinate of the rectangle where pixels must be read
  37618. * @param width defines the width of the rectangle where pixels must be read
  37619. * @param height defines the height of the rectangle where pixels must be read
  37620. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37621. * @returns a Uint8Array containing RGBA colors
  37622. */
  37623. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37624. private static _isSupported;
  37625. /**
  37626. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37627. * @returns true if the engine can be created
  37628. * @ignorenaming
  37629. */
  37630. static isSupported(): boolean;
  37631. /**
  37632. * Find the next highest power of two.
  37633. * @param x Number to start search from.
  37634. * @return Next highest power of two.
  37635. */
  37636. static CeilingPOT(x: number): number;
  37637. /**
  37638. * Find the next lowest power of two.
  37639. * @param x Number to start search from.
  37640. * @return Next lowest power of two.
  37641. */
  37642. static FloorPOT(x: number): number;
  37643. /**
  37644. * Find the nearest power of two.
  37645. * @param x Number to start search from.
  37646. * @return Next nearest power of two.
  37647. */
  37648. static NearestPOT(x: number): number;
  37649. /**
  37650. * Get the closest exponent of two
  37651. * @param value defines the value to approximate
  37652. * @param max defines the maximum value to return
  37653. * @param mode defines how to define the closest value
  37654. * @returns closest exponent of two of the given value
  37655. */
  37656. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37657. /**
  37658. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37659. * @param func - the function to be called
  37660. * @param requester - the object that will request the next frame. Falls back to window.
  37661. * @returns frame number
  37662. */
  37663. static QueueNewFrame(func: () => void, requester?: any): number;
  37664. /**
  37665. * Gets host document
  37666. * @returns the host document object
  37667. */
  37668. getHostDocument(): Nullable<Document>;
  37669. }
  37670. }
  37671. declare module "babylonjs/Maths/sphericalPolynomial" {
  37672. import { Vector3 } from "babylonjs/Maths/math.vector";
  37673. import { Color3 } from "babylonjs/Maths/math.color";
  37674. /**
  37675. * Class representing spherical harmonics coefficients to the 3rd degree
  37676. */
  37677. export class SphericalHarmonics {
  37678. /**
  37679. * Defines whether or not the harmonics have been prescaled for rendering.
  37680. */
  37681. preScaled: boolean;
  37682. /**
  37683. * The l0,0 coefficients of the spherical harmonics
  37684. */
  37685. l00: Vector3;
  37686. /**
  37687. * The l1,-1 coefficients of the spherical harmonics
  37688. */
  37689. l1_1: Vector3;
  37690. /**
  37691. * The l1,0 coefficients of the spherical harmonics
  37692. */
  37693. l10: Vector3;
  37694. /**
  37695. * The l1,1 coefficients of the spherical harmonics
  37696. */
  37697. l11: Vector3;
  37698. /**
  37699. * The l2,-2 coefficients of the spherical harmonics
  37700. */
  37701. l2_2: Vector3;
  37702. /**
  37703. * The l2,-1 coefficients of the spherical harmonics
  37704. */
  37705. l2_1: Vector3;
  37706. /**
  37707. * The l2,0 coefficients of the spherical harmonics
  37708. */
  37709. l20: Vector3;
  37710. /**
  37711. * The l2,1 coefficients of the spherical harmonics
  37712. */
  37713. l21: Vector3;
  37714. /**
  37715. * The l2,2 coefficients of the spherical harmonics
  37716. */
  37717. l22: Vector3;
  37718. /**
  37719. * Adds a light to the spherical harmonics
  37720. * @param direction the direction of the light
  37721. * @param color the color of the light
  37722. * @param deltaSolidAngle the delta solid angle of the light
  37723. */
  37724. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37725. /**
  37726. * Scales the spherical harmonics by the given amount
  37727. * @param scale the amount to scale
  37728. */
  37729. scaleInPlace(scale: number): void;
  37730. /**
  37731. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37732. *
  37733. * ```
  37734. * E_lm = A_l * L_lm
  37735. * ```
  37736. *
  37737. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37738. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37739. * the scaling factors are given in equation 9.
  37740. */
  37741. convertIncidentRadianceToIrradiance(): void;
  37742. /**
  37743. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37744. *
  37745. * ```
  37746. * L = (1/pi) * E * rho
  37747. * ```
  37748. *
  37749. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37750. */
  37751. convertIrradianceToLambertianRadiance(): void;
  37752. /**
  37753. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37754. * required operations at run time.
  37755. *
  37756. * This is simply done by scaling back the SH with Ylm constants parameter.
  37757. * The trigonometric part being applied by the shader at run time.
  37758. */
  37759. preScaleForRendering(): void;
  37760. /**
  37761. * Constructs a spherical harmonics from an array.
  37762. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37763. * @returns the spherical harmonics
  37764. */
  37765. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37766. /**
  37767. * Gets the spherical harmonics from polynomial
  37768. * @param polynomial the spherical polynomial
  37769. * @returns the spherical harmonics
  37770. */
  37771. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37772. }
  37773. /**
  37774. * Class representing spherical polynomial coefficients to the 3rd degree
  37775. */
  37776. export class SphericalPolynomial {
  37777. private _harmonics;
  37778. /**
  37779. * The spherical harmonics used to create the polynomials.
  37780. */
  37781. get preScaledHarmonics(): SphericalHarmonics;
  37782. /**
  37783. * The x coefficients of the spherical polynomial
  37784. */
  37785. x: Vector3;
  37786. /**
  37787. * The y coefficients of the spherical polynomial
  37788. */
  37789. y: Vector3;
  37790. /**
  37791. * The z coefficients of the spherical polynomial
  37792. */
  37793. z: Vector3;
  37794. /**
  37795. * The xx coefficients of the spherical polynomial
  37796. */
  37797. xx: Vector3;
  37798. /**
  37799. * The yy coefficients of the spherical polynomial
  37800. */
  37801. yy: Vector3;
  37802. /**
  37803. * The zz coefficients of the spherical polynomial
  37804. */
  37805. zz: Vector3;
  37806. /**
  37807. * The xy coefficients of the spherical polynomial
  37808. */
  37809. xy: Vector3;
  37810. /**
  37811. * The yz coefficients of the spherical polynomial
  37812. */
  37813. yz: Vector3;
  37814. /**
  37815. * The zx coefficients of the spherical polynomial
  37816. */
  37817. zx: Vector3;
  37818. /**
  37819. * Adds an ambient color to the spherical polynomial
  37820. * @param color the color to add
  37821. */
  37822. addAmbient(color: Color3): void;
  37823. /**
  37824. * Scales the spherical polynomial by the given amount
  37825. * @param scale the amount to scale
  37826. */
  37827. scaleInPlace(scale: number): void;
  37828. /**
  37829. * Gets the spherical polynomial from harmonics
  37830. * @param harmonics the spherical harmonics
  37831. * @returns the spherical polynomial
  37832. */
  37833. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37834. /**
  37835. * Constructs a spherical polynomial from an array.
  37836. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37837. * @returns the spherical polynomial
  37838. */
  37839. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37840. }
  37841. }
  37842. declare module "babylonjs/Materials/Textures/internalTexture" {
  37843. import { Observable } from "babylonjs/Misc/observable";
  37844. import { Nullable, int } from "babylonjs/types";
  37845. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37847. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37848. /**
  37849. * Defines the source of the internal texture
  37850. */
  37851. export enum InternalTextureSource {
  37852. /**
  37853. * The source of the texture data is unknown
  37854. */
  37855. Unknown = 0,
  37856. /**
  37857. * Texture data comes from an URL
  37858. */
  37859. Url = 1,
  37860. /**
  37861. * Texture data is only used for temporary storage
  37862. */
  37863. Temp = 2,
  37864. /**
  37865. * Texture data comes from raw data (ArrayBuffer)
  37866. */
  37867. Raw = 3,
  37868. /**
  37869. * Texture content is dynamic (video or dynamic texture)
  37870. */
  37871. Dynamic = 4,
  37872. /**
  37873. * Texture content is generated by rendering to it
  37874. */
  37875. RenderTarget = 5,
  37876. /**
  37877. * Texture content is part of a multi render target process
  37878. */
  37879. MultiRenderTarget = 6,
  37880. /**
  37881. * Texture data comes from a cube data file
  37882. */
  37883. Cube = 7,
  37884. /**
  37885. * Texture data comes from a raw cube data
  37886. */
  37887. CubeRaw = 8,
  37888. /**
  37889. * Texture data come from a prefiltered cube data file
  37890. */
  37891. CubePrefiltered = 9,
  37892. /**
  37893. * Texture content is raw 3D data
  37894. */
  37895. Raw3D = 10,
  37896. /**
  37897. * Texture content is raw 2D array data
  37898. */
  37899. Raw2DArray = 11,
  37900. /**
  37901. * Texture content is a depth texture
  37902. */
  37903. Depth = 12,
  37904. /**
  37905. * Texture data comes from a raw cube data encoded with RGBD
  37906. */
  37907. CubeRawRGBD = 13
  37908. }
  37909. /**
  37910. * Class used to store data associated with WebGL texture data for the engine
  37911. * This class should not be used directly
  37912. */
  37913. export class InternalTexture {
  37914. /** @hidden */
  37915. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  37916. /**
  37917. * Defines if the texture is ready
  37918. */
  37919. isReady: boolean;
  37920. /**
  37921. * Defines if the texture is a cube texture
  37922. */
  37923. isCube: boolean;
  37924. /**
  37925. * Defines if the texture contains 3D data
  37926. */
  37927. is3D: boolean;
  37928. /**
  37929. * Defines if the texture contains 2D array data
  37930. */
  37931. is2DArray: boolean;
  37932. /**
  37933. * Defines if the texture contains multiview data
  37934. */
  37935. isMultiview: boolean;
  37936. /**
  37937. * Gets the URL used to load this texture
  37938. */
  37939. url: string;
  37940. /**
  37941. * Gets the sampling mode of the texture
  37942. */
  37943. samplingMode: number;
  37944. /**
  37945. * Gets a boolean indicating if the texture needs mipmaps generation
  37946. */
  37947. generateMipMaps: boolean;
  37948. /**
  37949. * Gets the number of samples used by the texture (WebGL2+ only)
  37950. */
  37951. samples: number;
  37952. /**
  37953. * Gets the type of the texture (int, float...)
  37954. */
  37955. type: number;
  37956. /**
  37957. * Gets the format of the texture (RGB, RGBA...)
  37958. */
  37959. format: number;
  37960. /**
  37961. * Observable called when the texture is loaded
  37962. */
  37963. onLoadedObservable: Observable<InternalTexture>;
  37964. /**
  37965. * Gets the width of the texture
  37966. */
  37967. width: number;
  37968. /**
  37969. * Gets the height of the texture
  37970. */
  37971. height: number;
  37972. /**
  37973. * Gets the depth of the texture
  37974. */
  37975. depth: number;
  37976. /**
  37977. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  37978. */
  37979. baseWidth: number;
  37980. /**
  37981. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  37982. */
  37983. baseHeight: number;
  37984. /**
  37985. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  37986. */
  37987. baseDepth: number;
  37988. /**
  37989. * Gets a boolean indicating if the texture is inverted on Y axis
  37990. */
  37991. invertY: boolean;
  37992. /** @hidden */
  37993. _invertVScale: boolean;
  37994. /** @hidden */
  37995. _associatedChannel: number;
  37996. /** @hidden */
  37997. _source: InternalTextureSource;
  37998. /** @hidden */
  37999. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38000. /** @hidden */
  38001. _bufferView: Nullable<ArrayBufferView>;
  38002. /** @hidden */
  38003. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38004. /** @hidden */
  38005. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38006. /** @hidden */
  38007. _size: number;
  38008. /** @hidden */
  38009. _extension: string;
  38010. /** @hidden */
  38011. _files: Nullable<string[]>;
  38012. /** @hidden */
  38013. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38014. /** @hidden */
  38015. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38016. /** @hidden */
  38017. _framebuffer: Nullable<WebGLFramebuffer>;
  38018. /** @hidden */
  38019. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38020. /** @hidden */
  38021. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38022. /** @hidden */
  38023. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38024. /** @hidden */
  38025. _attachments: Nullable<number[]>;
  38026. /** @hidden */
  38027. _textureArray: Nullable<InternalTexture[]>;
  38028. /** @hidden */
  38029. _cachedCoordinatesMode: Nullable<number>;
  38030. /** @hidden */
  38031. _cachedWrapU: Nullable<number>;
  38032. /** @hidden */
  38033. _cachedWrapV: Nullable<number>;
  38034. /** @hidden */
  38035. _cachedWrapR: Nullable<number>;
  38036. /** @hidden */
  38037. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38038. /** @hidden */
  38039. _isDisabled: boolean;
  38040. /** @hidden */
  38041. _compression: Nullable<string>;
  38042. /** @hidden */
  38043. _generateStencilBuffer: boolean;
  38044. /** @hidden */
  38045. _generateDepthBuffer: boolean;
  38046. /** @hidden */
  38047. _comparisonFunction: number;
  38048. /** @hidden */
  38049. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38050. /** @hidden */
  38051. _lodGenerationScale: number;
  38052. /** @hidden */
  38053. _lodGenerationOffset: number;
  38054. /** @hidden */
  38055. _depthStencilTexture: Nullable<InternalTexture>;
  38056. /** @hidden */
  38057. _colorTextureArray: Nullable<WebGLTexture>;
  38058. /** @hidden */
  38059. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38060. /** @hidden */
  38061. _lodTextureHigh: Nullable<BaseTexture>;
  38062. /** @hidden */
  38063. _lodTextureMid: Nullable<BaseTexture>;
  38064. /** @hidden */
  38065. _lodTextureLow: Nullable<BaseTexture>;
  38066. /** @hidden */
  38067. _isRGBD: boolean;
  38068. /** @hidden */
  38069. _linearSpecularLOD: boolean;
  38070. /** @hidden */
  38071. _irradianceTexture: Nullable<BaseTexture>;
  38072. /** @hidden */
  38073. _webGLTexture: Nullable<WebGLTexture>;
  38074. /** @hidden */
  38075. _references: number;
  38076. /** @hidden */
  38077. _gammaSpace: Nullable<boolean>;
  38078. private _engine;
  38079. /**
  38080. * Gets the Engine the texture belongs to.
  38081. * @returns The babylon engine
  38082. */
  38083. getEngine(): ThinEngine;
  38084. /**
  38085. * Gets the data source type of the texture
  38086. */
  38087. get source(): InternalTextureSource;
  38088. /**
  38089. * Creates a new InternalTexture
  38090. * @param engine defines the engine to use
  38091. * @param source defines the type of data that will be used
  38092. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38093. */
  38094. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38095. /**
  38096. * Increments the number of references (ie. the number of Texture that point to it)
  38097. */
  38098. incrementReferences(): void;
  38099. /**
  38100. * Change the size of the texture (not the size of the content)
  38101. * @param width defines the new width
  38102. * @param height defines the new height
  38103. * @param depth defines the new depth (1 by default)
  38104. */
  38105. updateSize(width: int, height: int, depth?: int): void;
  38106. /** @hidden */
  38107. _rebuild(): void;
  38108. /** @hidden */
  38109. _swapAndDie(target: InternalTexture): void;
  38110. /**
  38111. * Dispose the current allocated resources
  38112. */
  38113. dispose(): void;
  38114. }
  38115. }
  38116. declare module "babylonjs/Audio/analyser" {
  38117. import { Scene } from "babylonjs/scene";
  38118. /**
  38119. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38120. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38121. */
  38122. export class Analyser {
  38123. /**
  38124. * Gets or sets the smoothing
  38125. * @ignorenaming
  38126. */
  38127. SMOOTHING: number;
  38128. /**
  38129. * Gets or sets the FFT table size
  38130. * @ignorenaming
  38131. */
  38132. FFT_SIZE: number;
  38133. /**
  38134. * Gets or sets the bar graph amplitude
  38135. * @ignorenaming
  38136. */
  38137. BARGRAPHAMPLITUDE: number;
  38138. /**
  38139. * Gets or sets the position of the debug canvas
  38140. * @ignorenaming
  38141. */
  38142. DEBUGCANVASPOS: {
  38143. x: number;
  38144. y: number;
  38145. };
  38146. /**
  38147. * Gets or sets the debug canvas size
  38148. * @ignorenaming
  38149. */
  38150. DEBUGCANVASSIZE: {
  38151. width: number;
  38152. height: number;
  38153. };
  38154. private _byteFreqs;
  38155. private _byteTime;
  38156. private _floatFreqs;
  38157. private _webAudioAnalyser;
  38158. private _debugCanvas;
  38159. private _debugCanvasContext;
  38160. private _scene;
  38161. private _registerFunc;
  38162. private _audioEngine;
  38163. /**
  38164. * Creates a new analyser
  38165. * @param scene defines hosting scene
  38166. */
  38167. constructor(scene: Scene);
  38168. /**
  38169. * Get the number of data values you will have to play with for the visualization
  38170. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38171. * @returns a number
  38172. */
  38173. getFrequencyBinCount(): number;
  38174. /**
  38175. * Gets the current frequency data as a byte array
  38176. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38177. * @returns a Uint8Array
  38178. */
  38179. getByteFrequencyData(): Uint8Array;
  38180. /**
  38181. * Gets the current waveform as a byte array
  38182. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38183. * @returns a Uint8Array
  38184. */
  38185. getByteTimeDomainData(): Uint8Array;
  38186. /**
  38187. * Gets the current frequency data as a float array
  38188. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38189. * @returns a Float32Array
  38190. */
  38191. getFloatFrequencyData(): Float32Array;
  38192. /**
  38193. * Renders the debug canvas
  38194. */
  38195. drawDebugCanvas(): void;
  38196. /**
  38197. * Stops rendering the debug canvas and removes it
  38198. */
  38199. stopDebugCanvas(): void;
  38200. /**
  38201. * Connects two audio nodes
  38202. * @param inputAudioNode defines first node to connect
  38203. * @param outputAudioNode defines second node to connect
  38204. */
  38205. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38206. /**
  38207. * Releases all associated resources
  38208. */
  38209. dispose(): void;
  38210. }
  38211. }
  38212. declare module "babylonjs/Audio/audioEngine" {
  38213. import { IDisposable } from "babylonjs/scene";
  38214. import { Analyser } from "babylonjs/Audio/analyser";
  38215. import { Nullable } from "babylonjs/types";
  38216. import { Observable } from "babylonjs/Misc/observable";
  38217. /**
  38218. * This represents an audio engine and it is responsible
  38219. * to play, synchronize and analyse sounds throughout the application.
  38220. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38221. */
  38222. export interface IAudioEngine extends IDisposable {
  38223. /**
  38224. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38225. */
  38226. readonly canUseWebAudio: boolean;
  38227. /**
  38228. * Gets the current AudioContext if available.
  38229. */
  38230. readonly audioContext: Nullable<AudioContext>;
  38231. /**
  38232. * The master gain node defines the global audio volume of your audio engine.
  38233. */
  38234. readonly masterGain: GainNode;
  38235. /**
  38236. * Gets whether or not mp3 are supported by your browser.
  38237. */
  38238. readonly isMP3supported: boolean;
  38239. /**
  38240. * Gets whether or not ogg are supported by your browser.
  38241. */
  38242. readonly isOGGsupported: boolean;
  38243. /**
  38244. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38245. * @ignoreNaming
  38246. */
  38247. WarnedWebAudioUnsupported: boolean;
  38248. /**
  38249. * Defines if the audio engine relies on a custom unlocked button.
  38250. * In this case, the embedded button will not be displayed.
  38251. */
  38252. useCustomUnlockedButton: boolean;
  38253. /**
  38254. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38255. */
  38256. readonly unlocked: boolean;
  38257. /**
  38258. * Event raised when audio has been unlocked on the browser.
  38259. */
  38260. onAudioUnlockedObservable: Observable<AudioEngine>;
  38261. /**
  38262. * Event raised when audio has been locked on the browser.
  38263. */
  38264. onAudioLockedObservable: Observable<AudioEngine>;
  38265. /**
  38266. * Flags the audio engine in Locked state.
  38267. * This happens due to new browser policies preventing audio to autoplay.
  38268. */
  38269. lock(): void;
  38270. /**
  38271. * Unlocks the audio engine once a user action has been done on the dom.
  38272. * This is helpful to resume play once browser policies have been satisfied.
  38273. */
  38274. unlock(): void;
  38275. /**
  38276. * Gets the global volume sets on the master gain.
  38277. * @returns the global volume if set or -1 otherwise
  38278. */
  38279. getGlobalVolume(): number;
  38280. /**
  38281. * Sets the global volume of your experience (sets on the master gain).
  38282. * @param newVolume Defines the new global volume of the application
  38283. */
  38284. setGlobalVolume(newVolume: number): void;
  38285. /**
  38286. * Connect the audio engine to an audio analyser allowing some amazing
  38287. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38289. * @param analyser The analyser to connect to the engine
  38290. */
  38291. connectToAnalyser(analyser: Analyser): void;
  38292. }
  38293. /**
  38294. * This represents the default audio engine used in babylon.
  38295. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38296. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38297. */
  38298. export class AudioEngine implements IAudioEngine {
  38299. private _audioContext;
  38300. private _audioContextInitialized;
  38301. private _muteButton;
  38302. private _hostElement;
  38303. /**
  38304. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38305. */
  38306. canUseWebAudio: boolean;
  38307. /**
  38308. * The master gain node defines the global audio volume of your audio engine.
  38309. */
  38310. masterGain: GainNode;
  38311. /**
  38312. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38313. * @ignoreNaming
  38314. */
  38315. WarnedWebAudioUnsupported: boolean;
  38316. /**
  38317. * Gets whether or not mp3 are supported by your browser.
  38318. */
  38319. isMP3supported: boolean;
  38320. /**
  38321. * Gets whether or not ogg are supported by your browser.
  38322. */
  38323. isOGGsupported: boolean;
  38324. /**
  38325. * Gets whether audio has been unlocked on the device.
  38326. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38327. * a user interaction has happened.
  38328. */
  38329. unlocked: boolean;
  38330. /**
  38331. * Defines if the audio engine relies on a custom unlocked button.
  38332. * In this case, the embedded button will not be displayed.
  38333. */
  38334. useCustomUnlockedButton: boolean;
  38335. /**
  38336. * Event raised when audio has been unlocked on the browser.
  38337. */
  38338. onAudioUnlockedObservable: Observable<AudioEngine>;
  38339. /**
  38340. * Event raised when audio has been locked on the browser.
  38341. */
  38342. onAudioLockedObservable: Observable<AudioEngine>;
  38343. /**
  38344. * Gets the current AudioContext if available.
  38345. */
  38346. get audioContext(): Nullable<AudioContext>;
  38347. private _connectedAnalyser;
  38348. /**
  38349. * Instantiates a new audio engine.
  38350. *
  38351. * There should be only one per page as some browsers restrict the number
  38352. * of audio contexts you can create.
  38353. * @param hostElement defines the host element where to display the mute icon if necessary
  38354. */
  38355. constructor(hostElement?: Nullable<HTMLElement>);
  38356. /**
  38357. * Flags the audio engine in Locked state.
  38358. * This happens due to new browser policies preventing audio to autoplay.
  38359. */
  38360. lock(): void;
  38361. /**
  38362. * Unlocks the audio engine once a user action has been done on the dom.
  38363. * This is helpful to resume play once browser policies have been satisfied.
  38364. */
  38365. unlock(): void;
  38366. private _resumeAudioContext;
  38367. private _initializeAudioContext;
  38368. private _tryToRun;
  38369. private _triggerRunningState;
  38370. private _triggerSuspendedState;
  38371. private _displayMuteButton;
  38372. private _moveButtonToTopLeft;
  38373. private _onResize;
  38374. private _hideMuteButton;
  38375. /**
  38376. * Destroy and release the resources associated with the audio ccontext.
  38377. */
  38378. dispose(): void;
  38379. /**
  38380. * Gets the global volume sets on the master gain.
  38381. * @returns the global volume if set or -1 otherwise
  38382. */
  38383. getGlobalVolume(): number;
  38384. /**
  38385. * Sets the global volume of your experience (sets on the master gain).
  38386. * @param newVolume Defines the new global volume of the application
  38387. */
  38388. setGlobalVolume(newVolume: number): void;
  38389. /**
  38390. * Connect the audio engine to an audio analyser allowing some amazing
  38391. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38392. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38393. * @param analyser The analyser to connect to the engine
  38394. */
  38395. connectToAnalyser(analyser: Analyser): void;
  38396. }
  38397. }
  38398. declare module "babylonjs/Loading/loadingScreen" {
  38399. /**
  38400. * Interface used to present a loading screen while loading a scene
  38401. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38402. */
  38403. export interface ILoadingScreen {
  38404. /**
  38405. * Function called to display the loading screen
  38406. */
  38407. displayLoadingUI: () => void;
  38408. /**
  38409. * Function called to hide the loading screen
  38410. */
  38411. hideLoadingUI: () => void;
  38412. /**
  38413. * Gets or sets the color to use for the background
  38414. */
  38415. loadingUIBackgroundColor: string;
  38416. /**
  38417. * Gets or sets the text to display while loading
  38418. */
  38419. loadingUIText: string;
  38420. }
  38421. /**
  38422. * Class used for the default loading screen
  38423. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38424. */
  38425. export class DefaultLoadingScreen implements ILoadingScreen {
  38426. private _renderingCanvas;
  38427. private _loadingText;
  38428. private _loadingDivBackgroundColor;
  38429. private _loadingDiv;
  38430. private _loadingTextDiv;
  38431. /** Gets or sets the logo url to use for the default loading screen */
  38432. static DefaultLogoUrl: string;
  38433. /** Gets or sets the spinner url to use for the default loading screen */
  38434. static DefaultSpinnerUrl: string;
  38435. /**
  38436. * Creates a new default loading screen
  38437. * @param _renderingCanvas defines the canvas used to render the scene
  38438. * @param _loadingText defines the default text to display
  38439. * @param _loadingDivBackgroundColor defines the default background color
  38440. */
  38441. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38442. /**
  38443. * Function called to display the loading screen
  38444. */
  38445. displayLoadingUI(): void;
  38446. /**
  38447. * Function called to hide the loading screen
  38448. */
  38449. hideLoadingUI(): void;
  38450. /**
  38451. * Gets or sets the text to display while loading
  38452. */
  38453. set loadingUIText(text: string);
  38454. get loadingUIText(): string;
  38455. /**
  38456. * Gets or sets the color to use for the background
  38457. */
  38458. get loadingUIBackgroundColor(): string;
  38459. set loadingUIBackgroundColor(color: string);
  38460. private _resizeLoadingUI;
  38461. }
  38462. }
  38463. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38464. /**
  38465. * Interface for any object that can request an animation frame
  38466. */
  38467. export interface ICustomAnimationFrameRequester {
  38468. /**
  38469. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38470. */
  38471. renderFunction?: Function;
  38472. /**
  38473. * Called to request the next frame to render to
  38474. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38475. */
  38476. requestAnimationFrame: Function;
  38477. /**
  38478. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38479. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38480. */
  38481. requestID?: number;
  38482. }
  38483. }
  38484. declare module "babylonjs/Misc/performanceMonitor" {
  38485. /**
  38486. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38487. */
  38488. export class PerformanceMonitor {
  38489. private _enabled;
  38490. private _rollingFrameTime;
  38491. private _lastFrameTimeMs;
  38492. /**
  38493. * constructor
  38494. * @param frameSampleSize The number of samples required to saturate the sliding window
  38495. */
  38496. constructor(frameSampleSize?: number);
  38497. /**
  38498. * Samples current frame
  38499. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38500. */
  38501. sampleFrame(timeMs?: number): void;
  38502. /**
  38503. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38504. */
  38505. get averageFrameTime(): number;
  38506. /**
  38507. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38508. */
  38509. get averageFrameTimeVariance(): number;
  38510. /**
  38511. * Returns the frame time of the most recent frame
  38512. */
  38513. get instantaneousFrameTime(): number;
  38514. /**
  38515. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38516. */
  38517. get averageFPS(): number;
  38518. /**
  38519. * Returns the average framerate in frames per second using the most recent frame time
  38520. */
  38521. get instantaneousFPS(): number;
  38522. /**
  38523. * Returns true if enough samples have been taken to completely fill the sliding window
  38524. */
  38525. get isSaturated(): boolean;
  38526. /**
  38527. * Enables contributions to the sliding window sample set
  38528. */
  38529. enable(): void;
  38530. /**
  38531. * Disables contributions to the sliding window sample set
  38532. * Samples will not be interpolated over the disabled period
  38533. */
  38534. disable(): void;
  38535. /**
  38536. * Returns true if sampling is enabled
  38537. */
  38538. get isEnabled(): boolean;
  38539. /**
  38540. * Resets performance monitor
  38541. */
  38542. reset(): void;
  38543. }
  38544. /**
  38545. * RollingAverage
  38546. *
  38547. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38548. */
  38549. export class RollingAverage {
  38550. /**
  38551. * Current average
  38552. */
  38553. average: number;
  38554. /**
  38555. * Current variance
  38556. */
  38557. variance: number;
  38558. protected _samples: Array<number>;
  38559. protected _sampleCount: number;
  38560. protected _pos: number;
  38561. protected _m2: number;
  38562. /**
  38563. * constructor
  38564. * @param length The number of samples required to saturate the sliding window
  38565. */
  38566. constructor(length: number);
  38567. /**
  38568. * Adds a sample to the sample set
  38569. * @param v The sample value
  38570. */
  38571. add(v: number): void;
  38572. /**
  38573. * Returns previously added values or null if outside of history or outside the sliding window domain
  38574. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38575. * @return Value previously recorded with add() or null if outside of range
  38576. */
  38577. history(i: number): number;
  38578. /**
  38579. * Returns true if enough samples have been taken to completely fill the sliding window
  38580. * @return true if sample-set saturated
  38581. */
  38582. isSaturated(): boolean;
  38583. /**
  38584. * Resets the rolling average (equivalent to 0 samples taken so far)
  38585. */
  38586. reset(): void;
  38587. /**
  38588. * Wraps a value around the sample range boundaries
  38589. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38590. * @return Wrapped position in sample range
  38591. */
  38592. protected _wrapPosition(i: number): number;
  38593. }
  38594. }
  38595. declare module "babylonjs/Misc/perfCounter" {
  38596. /**
  38597. * This class is used to track a performance counter which is number based.
  38598. * The user has access to many properties which give statistics of different nature.
  38599. *
  38600. * The implementer can track two kinds of Performance Counter: time and count.
  38601. * 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.
  38602. * 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.
  38603. */
  38604. export class PerfCounter {
  38605. /**
  38606. * Gets or sets a global boolean to turn on and off all the counters
  38607. */
  38608. static Enabled: boolean;
  38609. /**
  38610. * Returns the smallest value ever
  38611. */
  38612. get min(): number;
  38613. /**
  38614. * Returns the biggest value ever
  38615. */
  38616. get max(): number;
  38617. /**
  38618. * Returns the average value since the performance counter is running
  38619. */
  38620. get average(): number;
  38621. /**
  38622. * Returns the average value of the last second the counter was monitored
  38623. */
  38624. get lastSecAverage(): number;
  38625. /**
  38626. * Returns the current value
  38627. */
  38628. get current(): number;
  38629. /**
  38630. * Gets the accumulated total
  38631. */
  38632. get total(): number;
  38633. /**
  38634. * Gets the total value count
  38635. */
  38636. get count(): number;
  38637. /**
  38638. * Creates a new counter
  38639. */
  38640. constructor();
  38641. /**
  38642. * Call this method to start monitoring a new frame.
  38643. * 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.
  38644. */
  38645. fetchNewFrame(): void;
  38646. /**
  38647. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38648. * @param newCount the count value to add to the monitored count
  38649. * @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.
  38650. */
  38651. addCount(newCount: number, fetchResult: boolean): void;
  38652. /**
  38653. * Start monitoring this performance counter
  38654. */
  38655. beginMonitoring(): void;
  38656. /**
  38657. * Compute the time lapsed since the previous beginMonitoring() call.
  38658. * @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
  38659. */
  38660. endMonitoring(newFrame?: boolean): void;
  38661. private _fetchResult;
  38662. private _startMonitoringTime;
  38663. private _min;
  38664. private _max;
  38665. private _average;
  38666. private _current;
  38667. private _totalValueCount;
  38668. private _totalAccumulated;
  38669. private _lastSecAverage;
  38670. private _lastSecAccumulated;
  38671. private _lastSecTime;
  38672. private _lastSecValueCount;
  38673. }
  38674. }
  38675. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38676. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38677. import { Nullable } from "babylonjs/types";
  38678. module "babylonjs/Engines/thinEngine" {
  38679. interface ThinEngine {
  38680. /** @hidden */
  38681. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38682. }
  38683. }
  38684. }
  38685. declare module "babylonjs/Engines/engine" {
  38686. import { Observable } from "babylonjs/Misc/observable";
  38687. import { Nullable } from "babylonjs/types";
  38688. import { Scene } from "babylonjs/scene";
  38689. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38690. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38691. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38692. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38693. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38694. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38695. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38696. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38697. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38698. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38699. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38700. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38701. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38702. import "babylonjs/Engines/Extensions/engine.alpha";
  38703. import "babylonjs/Engines/Extensions/engine.readTexture";
  38704. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38705. import { Material } from "babylonjs/Materials/material";
  38706. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38707. /**
  38708. * Defines the interface used by display changed events
  38709. */
  38710. export interface IDisplayChangedEventArgs {
  38711. /** Gets the vrDisplay object (if any) */
  38712. vrDisplay: Nullable<any>;
  38713. /** Gets a boolean indicating if webVR is supported */
  38714. vrSupported: boolean;
  38715. }
  38716. /**
  38717. * Defines the interface used by objects containing a viewport (like a camera)
  38718. */
  38719. interface IViewportOwnerLike {
  38720. /**
  38721. * Gets or sets the viewport
  38722. */
  38723. viewport: IViewportLike;
  38724. }
  38725. /**
  38726. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38727. */
  38728. export class Engine extends ThinEngine {
  38729. /** Defines that alpha blending is disabled */
  38730. static readonly ALPHA_DISABLE: number;
  38731. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38732. static readonly ALPHA_ADD: number;
  38733. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38734. static readonly ALPHA_COMBINE: number;
  38735. /** Defines that alpha blending to DEST - SRC * DEST */
  38736. static readonly ALPHA_SUBTRACT: number;
  38737. /** Defines that alpha blending to SRC * DEST */
  38738. static readonly ALPHA_MULTIPLY: number;
  38739. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38740. static readonly ALPHA_MAXIMIZED: number;
  38741. /** Defines that alpha blending to SRC + DEST */
  38742. static readonly ALPHA_ONEONE: number;
  38743. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38744. static readonly ALPHA_PREMULTIPLIED: number;
  38745. /**
  38746. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38747. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38748. */
  38749. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38750. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38751. static readonly ALPHA_INTERPOLATE: number;
  38752. /**
  38753. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38754. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38755. */
  38756. static readonly ALPHA_SCREENMODE: number;
  38757. /** Defines that the ressource is not delayed*/
  38758. static readonly DELAYLOADSTATE_NONE: number;
  38759. /** Defines that the ressource was successfully delay loaded */
  38760. static readonly DELAYLOADSTATE_LOADED: number;
  38761. /** Defines that the ressource is currently delay loading */
  38762. static readonly DELAYLOADSTATE_LOADING: number;
  38763. /** Defines that the ressource is delayed and has not started loading */
  38764. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38765. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38766. static readonly NEVER: number;
  38767. /** 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 */
  38768. static readonly ALWAYS: number;
  38769. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38770. static readonly LESS: number;
  38771. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38772. static readonly EQUAL: number;
  38773. /** 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 */
  38774. static readonly LEQUAL: number;
  38775. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38776. static readonly GREATER: number;
  38777. /** 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 */
  38778. static readonly GEQUAL: number;
  38779. /** 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 */
  38780. static readonly NOTEQUAL: number;
  38781. /** Passed to stencilOperation to specify that stencil value must be kept */
  38782. static readonly KEEP: number;
  38783. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38784. static readonly REPLACE: number;
  38785. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38786. static readonly INCR: number;
  38787. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38788. static readonly DECR: number;
  38789. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38790. static readonly INVERT: number;
  38791. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38792. static readonly INCR_WRAP: number;
  38793. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38794. static readonly DECR_WRAP: number;
  38795. /** Texture is not repeating outside of 0..1 UVs */
  38796. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38797. /** Texture is repeating outside of 0..1 UVs */
  38798. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38799. /** Texture is repeating and mirrored */
  38800. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38801. /** ALPHA */
  38802. static readonly TEXTUREFORMAT_ALPHA: number;
  38803. /** LUMINANCE */
  38804. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38805. /** LUMINANCE_ALPHA */
  38806. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38807. /** RGB */
  38808. static readonly TEXTUREFORMAT_RGB: number;
  38809. /** RGBA */
  38810. static readonly TEXTUREFORMAT_RGBA: number;
  38811. /** RED */
  38812. static readonly TEXTUREFORMAT_RED: number;
  38813. /** RED (2nd reference) */
  38814. static readonly TEXTUREFORMAT_R: number;
  38815. /** RG */
  38816. static readonly TEXTUREFORMAT_RG: number;
  38817. /** RED_INTEGER */
  38818. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38819. /** RED_INTEGER (2nd reference) */
  38820. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38821. /** RG_INTEGER */
  38822. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38823. /** RGB_INTEGER */
  38824. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38825. /** RGBA_INTEGER */
  38826. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38827. /** UNSIGNED_BYTE */
  38828. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38829. /** UNSIGNED_BYTE (2nd reference) */
  38830. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38831. /** FLOAT */
  38832. static readonly TEXTURETYPE_FLOAT: number;
  38833. /** HALF_FLOAT */
  38834. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38835. /** BYTE */
  38836. static readonly TEXTURETYPE_BYTE: number;
  38837. /** SHORT */
  38838. static readonly TEXTURETYPE_SHORT: number;
  38839. /** UNSIGNED_SHORT */
  38840. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38841. /** INT */
  38842. static readonly TEXTURETYPE_INT: number;
  38843. /** UNSIGNED_INT */
  38844. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38845. /** UNSIGNED_SHORT_4_4_4_4 */
  38846. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38847. /** UNSIGNED_SHORT_5_5_5_1 */
  38848. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38849. /** UNSIGNED_SHORT_5_6_5 */
  38850. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38851. /** UNSIGNED_INT_2_10_10_10_REV */
  38852. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38853. /** UNSIGNED_INT_24_8 */
  38854. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38855. /** UNSIGNED_INT_10F_11F_11F_REV */
  38856. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38857. /** UNSIGNED_INT_5_9_9_9_REV */
  38858. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38859. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38860. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38861. /** nearest is mag = nearest and min = nearest and mip = linear */
  38862. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38863. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38864. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38865. /** Trilinear is mag = linear and min = linear and mip = linear */
  38866. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38867. /** nearest is mag = nearest and min = nearest and mip = linear */
  38868. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38869. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38870. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38871. /** Trilinear is mag = linear and min = linear and mip = linear */
  38872. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38873. /** mag = nearest and min = nearest and mip = nearest */
  38874. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  38875. /** mag = nearest and min = linear and mip = nearest */
  38876. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  38877. /** mag = nearest and min = linear and mip = linear */
  38878. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  38879. /** mag = nearest and min = linear and mip = none */
  38880. static readonly TEXTURE_NEAREST_LINEAR: number;
  38881. /** mag = nearest and min = nearest and mip = none */
  38882. static readonly TEXTURE_NEAREST_NEAREST: number;
  38883. /** mag = linear and min = nearest and mip = nearest */
  38884. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  38885. /** mag = linear and min = nearest and mip = linear */
  38886. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  38887. /** mag = linear and min = linear and mip = none */
  38888. static readonly TEXTURE_LINEAR_LINEAR: number;
  38889. /** mag = linear and min = nearest and mip = none */
  38890. static readonly TEXTURE_LINEAR_NEAREST: number;
  38891. /** Explicit coordinates mode */
  38892. static readonly TEXTURE_EXPLICIT_MODE: number;
  38893. /** Spherical coordinates mode */
  38894. static readonly TEXTURE_SPHERICAL_MODE: number;
  38895. /** Planar coordinates mode */
  38896. static readonly TEXTURE_PLANAR_MODE: number;
  38897. /** Cubic coordinates mode */
  38898. static readonly TEXTURE_CUBIC_MODE: number;
  38899. /** Projection coordinates mode */
  38900. static readonly TEXTURE_PROJECTION_MODE: number;
  38901. /** Skybox coordinates mode */
  38902. static readonly TEXTURE_SKYBOX_MODE: number;
  38903. /** Inverse Cubic coordinates mode */
  38904. static readonly TEXTURE_INVCUBIC_MODE: number;
  38905. /** Equirectangular coordinates mode */
  38906. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  38907. /** Equirectangular Fixed coordinates mode */
  38908. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  38909. /** Equirectangular Fixed Mirrored coordinates mode */
  38910. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  38911. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  38912. static readonly SCALEMODE_FLOOR: number;
  38913. /** Defines that texture rescaling will look for the nearest power of 2 size */
  38914. static readonly SCALEMODE_NEAREST: number;
  38915. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  38916. static readonly SCALEMODE_CEILING: number;
  38917. /**
  38918. * Returns the current npm package of the sdk
  38919. */
  38920. static get NpmPackage(): string;
  38921. /**
  38922. * Returns the current version of the framework
  38923. */
  38924. static get Version(): string;
  38925. /** Gets the list of created engines */
  38926. static get Instances(): Engine[];
  38927. /**
  38928. * Gets the latest created engine
  38929. */
  38930. static get LastCreatedEngine(): Nullable<Engine>;
  38931. /**
  38932. * Gets the latest created scene
  38933. */
  38934. static get LastCreatedScene(): Nullable<Scene>;
  38935. /**
  38936. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  38937. * @param flag defines which part of the materials must be marked as dirty
  38938. * @param predicate defines a predicate used to filter which materials should be affected
  38939. */
  38940. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38941. /**
  38942. * Method called to create the default loading screen.
  38943. * This can be overriden in your own app.
  38944. * @param canvas The rendering canvas element
  38945. * @returns The loading screen
  38946. */
  38947. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  38948. /**
  38949. * Method called to create the default rescale post process on each engine.
  38950. */
  38951. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  38952. /**
  38953. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  38954. **/
  38955. enableOfflineSupport: boolean;
  38956. /**
  38957. * 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)
  38958. **/
  38959. disableManifestCheck: boolean;
  38960. /**
  38961. * Gets the list of created scenes
  38962. */
  38963. scenes: Scene[];
  38964. /**
  38965. * Event raised when a new scene is created
  38966. */
  38967. onNewSceneAddedObservable: Observable<Scene>;
  38968. /**
  38969. * Gets the list of created postprocesses
  38970. */
  38971. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  38972. /**
  38973. * Gets a boolean indicating if the pointer is currently locked
  38974. */
  38975. isPointerLock: boolean;
  38976. /**
  38977. * Observable event triggered each time the rendering canvas is resized
  38978. */
  38979. onResizeObservable: Observable<Engine>;
  38980. /**
  38981. * Observable event triggered each time the canvas loses focus
  38982. */
  38983. onCanvasBlurObservable: Observable<Engine>;
  38984. /**
  38985. * Observable event triggered each time the canvas gains focus
  38986. */
  38987. onCanvasFocusObservable: Observable<Engine>;
  38988. /**
  38989. * Observable event triggered each time the canvas receives pointerout event
  38990. */
  38991. onCanvasPointerOutObservable: Observable<PointerEvent>;
  38992. /**
  38993. * Observable raised when the engine begins a new frame
  38994. */
  38995. onBeginFrameObservable: Observable<Engine>;
  38996. /**
  38997. * If set, will be used to request the next animation frame for the render loop
  38998. */
  38999. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39000. /**
  39001. * Observable raised when the engine ends the current frame
  39002. */
  39003. onEndFrameObservable: Observable<Engine>;
  39004. /**
  39005. * Observable raised when the engine is about to compile a shader
  39006. */
  39007. onBeforeShaderCompilationObservable: Observable<Engine>;
  39008. /**
  39009. * Observable raised when the engine has jsut compiled a shader
  39010. */
  39011. onAfterShaderCompilationObservable: Observable<Engine>;
  39012. /**
  39013. * Gets the audio engine
  39014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39015. * @ignorenaming
  39016. */
  39017. static audioEngine: IAudioEngine;
  39018. /**
  39019. * Default AudioEngine factory responsible of creating the Audio Engine.
  39020. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39021. */
  39022. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39023. /**
  39024. * Default offline support factory responsible of creating a tool used to store data locally.
  39025. * By default, this will create a Database object if the workload has been embedded.
  39026. */
  39027. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39028. private _loadingScreen;
  39029. private _pointerLockRequested;
  39030. private _rescalePostProcess;
  39031. private _deterministicLockstep;
  39032. private _lockstepMaxSteps;
  39033. private _timeStep;
  39034. protected get _supportsHardwareTextureRescaling(): boolean;
  39035. private _fps;
  39036. private _deltaTime;
  39037. /** @hidden */
  39038. _drawCalls: PerfCounter;
  39039. /** 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 */
  39040. canvasTabIndex: number;
  39041. /**
  39042. * Turn this value on if you want to pause FPS computation when in background
  39043. */
  39044. disablePerformanceMonitorInBackground: boolean;
  39045. private _performanceMonitor;
  39046. /**
  39047. * Gets the performance monitor attached to this engine
  39048. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39049. */
  39050. get performanceMonitor(): PerformanceMonitor;
  39051. private _onFocus;
  39052. private _onBlur;
  39053. private _onCanvasPointerOut;
  39054. private _onCanvasBlur;
  39055. private _onCanvasFocus;
  39056. private _onFullscreenChange;
  39057. private _onPointerLockChange;
  39058. /**
  39059. * Gets the HTML element used to attach event listeners
  39060. * @returns a HTML element
  39061. */
  39062. getInputElement(): Nullable<HTMLElement>;
  39063. /**
  39064. * Creates a new engine
  39065. * @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
  39066. * @param antialias defines enable antialiasing (default: false)
  39067. * @param options defines further options to be sent to the getContext() function
  39068. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39069. */
  39070. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39071. /**
  39072. * Gets current aspect ratio
  39073. * @param viewportOwner defines the camera to use to get the aspect ratio
  39074. * @param useScreen defines if screen size must be used (or the current render target if any)
  39075. * @returns a number defining the aspect ratio
  39076. */
  39077. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39078. /**
  39079. * Gets current screen aspect ratio
  39080. * @returns a number defining the aspect ratio
  39081. */
  39082. getScreenAspectRatio(): number;
  39083. /**
  39084. * Gets the client rect of the HTML canvas attached with the current webGL context
  39085. * @returns a client rectanglee
  39086. */
  39087. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39088. /**
  39089. * Gets the client rect of the HTML element used for events
  39090. * @returns a client rectanglee
  39091. */
  39092. getInputElementClientRect(): Nullable<ClientRect>;
  39093. /**
  39094. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39096. * @returns true if engine is in deterministic lock step mode
  39097. */
  39098. isDeterministicLockStep(): boolean;
  39099. /**
  39100. * Gets the max steps when engine is running in deterministic lock step
  39101. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39102. * @returns the max steps
  39103. */
  39104. getLockstepMaxSteps(): number;
  39105. /**
  39106. * Returns the time in ms between steps when using deterministic lock step.
  39107. * @returns time step in (ms)
  39108. */
  39109. getTimeStep(): number;
  39110. /**
  39111. * Force the mipmap generation for the given render target texture
  39112. * @param texture defines the render target texture to use
  39113. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39114. */
  39115. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39116. /** States */
  39117. /**
  39118. * Set various states to the webGL context
  39119. * @param culling defines backface culling state
  39120. * @param zOffset defines the value to apply to zOffset (0 by default)
  39121. * @param force defines if states must be applied even if cache is up to date
  39122. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39123. */
  39124. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39125. /**
  39126. * Set the z offset to apply to current rendering
  39127. * @param value defines the offset to apply
  39128. */
  39129. setZOffset(value: number): void;
  39130. /**
  39131. * Gets the current value of the zOffset
  39132. * @returns the current zOffset state
  39133. */
  39134. getZOffset(): number;
  39135. /**
  39136. * Enable or disable depth buffering
  39137. * @param enable defines the state to set
  39138. */
  39139. setDepthBuffer(enable: boolean): void;
  39140. /**
  39141. * Gets a boolean indicating if depth writing is enabled
  39142. * @returns the current depth writing state
  39143. */
  39144. getDepthWrite(): boolean;
  39145. /**
  39146. * Enable or disable depth writing
  39147. * @param enable defines the state to set
  39148. */
  39149. setDepthWrite(enable: boolean): void;
  39150. /**
  39151. * Gets a boolean indicating if stencil buffer is enabled
  39152. * @returns the current stencil buffer state
  39153. */
  39154. getStencilBuffer(): boolean;
  39155. /**
  39156. * Enable or disable the stencil buffer
  39157. * @param enable defines if the stencil buffer must be enabled or disabled
  39158. */
  39159. setStencilBuffer(enable: boolean): void;
  39160. /**
  39161. * Gets the current stencil mask
  39162. * @returns a number defining the new stencil mask to use
  39163. */
  39164. getStencilMask(): number;
  39165. /**
  39166. * Sets the current stencil mask
  39167. * @param mask defines the new stencil mask to use
  39168. */
  39169. setStencilMask(mask: number): void;
  39170. /**
  39171. * Gets the current stencil function
  39172. * @returns a number defining the stencil function to use
  39173. */
  39174. getStencilFunction(): number;
  39175. /**
  39176. * Gets the current stencil reference value
  39177. * @returns a number defining the stencil reference value to use
  39178. */
  39179. getStencilFunctionReference(): number;
  39180. /**
  39181. * Gets the current stencil mask
  39182. * @returns a number defining the stencil mask to use
  39183. */
  39184. getStencilFunctionMask(): number;
  39185. /**
  39186. * Sets the current stencil function
  39187. * @param stencilFunc defines the new stencil function to use
  39188. */
  39189. setStencilFunction(stencilFunc: number): void;
  39190. /**
  39191. * Sets the current stencil reference
  39192. * @param reference defines the new stencil reference to use
  39193. */
  39194. setStencilFunctionReference(reference: number): void;
  39195. /**
  39196. * Sets the current stencil mask
  39197. * @param mask defines the new stencil mask to use
  39198. */
  39199. setStencilFunctionMask(mask: number): void;
  39200. /**
  39201. * Gets the current stencil operation when stencil fails
  39202. * @returns a number defining stencil operation to use when stencil fails
  39203. */
  39204. getStencilOperationFail(): number;
  39205. /**
  39206. * Gets the current stencil operation when depth fails
  39207. * @returns a number defining stencil operation to use when depth fails
  39208. */
  39209. getStencilOperationDepthFail(): number;
  39210. /**
  39211. * Gets the current stencil operation when stencil passes
  39212. * @returns a number defining stencil operation to use when stencil passes
  39213. */
  39214. getStencilOperationPass(): number;
  39215. /**
  39216. * Sets the stencil operation to use when stencil fails
  39217. * @param operation defines the stencil operation to use when stencil fails
  39218. */
  39219. setStencilOperationFail(operation: number): void;
  39220. /**
  39221. * Sets the stencil operation to use when depth fails
  39222. * @param operation defines the stencil operation to use when depth fails
  39223. */
  39224. setStencilOperationDepthFail(operation: number): void;
  39225. /**
  39226. * Sets the stencil operation to use when stencil passes
  39227. * @param operation defines the stencil operation to use when stencil passes
  39228. */
  39229. setStencilOperationPass(operation: number): void;
  39230. /**
  39231. * Sets a boolean indicating if the dithering state is enabled or disabled
  39232. * @param value defines the dithering state
  39233. */
  39234. setDitheringState(value: boolean): void;
  39235. /**
  39236. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39237. * @param value defines the rasterizer state
  39238. */
  39239. setRasterizerState(value: boolean): void;
  39240. /**
  39241. * Gets the current depth function
  39242. * @returns a number defining the depth function
  39243. */
  39244. getDepthFunction(): Nullable<number>;
  39245. /**
  39246. * Sets the current depth function
  39247. * @param depthFunc defines the function to use
  39248. */
  39249. setDepthFunction(depthFunc: number): void;
  39250. /**
  39251. * Sets the current depth function to GREATER
  39252. */
  39253. setDepthFunctionToGreater(): void;
  39254. /**
  39255. * Sets the current depth function to GEQUAL
  39256. */
  39257. setDepthFunctionToGreaterOrEqual(): void;
  39258. /**
  39259. * Sets the current depth function to LESS
  39260. */
  39261. setDepthFunctionToLess(): void;
  39262. /**
  39263. * Sets the current depth function to LEQUAL
  39264. */
  39265. setDepthFunctionToLessOrEqual(): void;
  39266. private _cachedStencilBuffer;
  39267. private _cachedStencilFunction;
  39268. private _cachedStencilMask;
  39269. private _cachedStencilOperationPass;
  39270. private _cachedStencilOperationFail;
  39271. private _cachedStencilOperationDepthFail;
  39272. private _cachedStencilReference;
  39273. /**
  39274. * Caches the the state of the stencil buffer
  39275. */
  39276. cacheStencilState(): void;
  39277. /**
  39278. * Restores the state of the stencil buffer
  39279. */
  39280. restoreStencilState(): void;
  39281. /**
  39282. * Directly set the WebGL Viewport
  39283. * @param x defines the x coordinate of the viewport (in screen space)
  39284. * @param y defines the y coordinate of the viewport (in screen space)
  39285. * @param width defines the width of the viewport (in screen space)
  39286. * @param height defines the height of the viewport (in screen space)
  39287. * @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
  39288. */
  39289. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39290. /**
  39291. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39292. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39293. * @param y defines the y-coordinate of the corner of the clear rectangle
  39294. * @param width defines the width of the clear rectangle
  39295. * @param height defines the height of the clear rectangle
  39296. * @param clearColor defines the clear color
  39297. */
  39298. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39299. /**
  39300. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39301. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39302. * @param y defines the y-coordinate of the corner of the clear rectangle
  39303. * @param width defines the width of the clear rectangle
  39304. * @param height defines the height of the clear rectangle
  39305. */
  39306. enableScissor(x: number, y: number, width: number, height: number): void;
  39307. /**
  39308. * Disable previously set scissor test rectangle
  39309. */
  39310. disableScissor(): void;
  39311. protected _reportDrawCall(): void;
  39312. /**
  39313. * Initializes a webVR display and starts listening to display change events
  39314. * The onVRDisplayChangedObservable will be notified upon these changes
  39315. * @returns The onVRDisplayChangedObservable
  39316. */
  39317. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39318. /** @hidden */
  39319. _prepareVRComponent(): void;
  39320. /** @hidden */
  39321. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39322. /** @hidden */
  39323. _submitVRFrame(): void;
  39324. /**
  39325. * Call this function to leave webVR mode
  39326. * Will do nothing if webVR is not supported or if there is no webVR device
  39327. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39328. */
  39329. disableVR(): void;
  39330. /**
  39331. * Gets a boolean indicating that the system is in VR mode and is presenting
  39332. * @returns true if VR mode is engaged
  39333. */
  39334. isVRPresenting(): boolean;
  39335. /** @hidden */
  39336. _requestVRFrame(): void;
  39337. /** @hidden */
  39338. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39339. /**
  39340. * Gets the source code of the vertex shader associated with a specific webGL program
  39341. * @param program defines the program to use
  39342. * @returns a string containing the source code of the vertex shader associated with the program
  39343. */
  39344. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39345. /**
  39346. * Gets the source code of the fragment shader associated with a specific webGL program
  39347. * @param program defines the program to use
  39348. * @returns a string containing the source code of the fragment shader associated with the program
  39349. */
  39350. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39351. /**
  39352. * Sets a depth stencil texture from a render target to the according uniform.
  39353. * @param channel The texture channel
  39354. * @param uniform The uniform to set
  39355. * @param texture The render target texture containing the depth stencil texture to apply
  39356. */
  39357. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39358. /**
  39359. * Sets a texture to the webGL context from a postprocess
  39360. * @param channel defines the channel to use
  39361. * @param postProcess defines the source postprocess
  39362. */
  39363. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39364. /**
  39365. * Binds the output of the passed in post process to the texture channel specified
  39366. * @param channel The channel the texture should be bound to
  39367. * @param postProcess The post process which's output should be bound
  39368. */
  39369. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39370. protected _rebuildBuffers(): void;
  39371. /** @hidden */
  39372. _renderFrame(): void;
  39373. _renderLoop(): void;
  39374. /** @hidden */
  39375. _renderViews(): boolean;
  39376. /**
  39377. * Toggle full screen mode
  39378. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39379. */
  39380. switchFullscreen(requestPointerLock: boolean): void;
  39381. /**
  39382. * Enters full screen mode
  39383. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39384. */
  39385. enterFullscreen(requestPointerLock: boolean): void;
  39386. /**
  39387. * Exits full screen mode
  39388. */
  39389. exitFullscreen(): void;
  39390. /**
  39391. * Enters Pointerlock mode
  39392. */
  39393. enterPointerlock(): void;
  39394. /**
  39395. * Exits Pointerlock mode
  39396. */
  39397. exitPointerlock(): void;
  39398. /**
  39399. * Begin a new frame
  39400. */
  39401. beginFrame(): void;
  39402. /**
  39403. * Enf the current frame
  39404. */
  39405. endFrame(): void;
  39406. resize(): void;
  39407. /**
  39408. * Force a specific size of the canvas
  39409. * @param width defines the new canvas' width
  39410. * @param height defines the new canvas' height
  39411. * @returns true if the size was changed
  39412. */
  39413. setSize(width: number, height: number): boolean;
  39414. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39415. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39416. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39417. _releaseTexture(texture: InternalTexture): void;
  39418. /**
  39419. * @hidden
  39420. * Rescales a texture
  39421. * @param source input texutre
  39422. * @param destination destination texture
  39423. * @param scene scene to use to render the resize
  39424. * @param internalFormat format to use when resizing
  39425. * @param onComplete callback to be called when resize has completed
  39426. */
  39427. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39428. /**
  39429. * Gets the current framerate
  39430. * @returns a number representing the framerate
  39431. */
  39432. getFps(): number;
  39433. /**
  39434. * Gets the time spent between current and previous frame
  39435. * @returns a number representing the delta time in ms
  39436. */
  39437. getDeltaTime(): number;
  39438. private _measureFps;
  39439. /** @hidden */
  39440. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39441. /**
  39442. * Updates the sample count of a render target texture
  39443. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39444. * @param texture defines the texture to update
  39445. * @param samples defines the sample count to set
  39446. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39447. */
  39448. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39449. /**
  39450. * Updates a depth texture Comparison Mode and Function.
  39451. * If the comparison Function is equal to 0, the mode will be set to none.
  39452. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39453. * @param texture The texture to set the comparison function for
  39454. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39455. */
  39456. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39457. /**
  39458. * Creates a webGL buffer to use with instanciation
  39459. * @param capacity defines the size of the buffer
  39460. * @returns the webGL buffer
  39461. */
  39462. createInstancesBuffer(capacity: number): DataBuffer;
  39463. /**
  39464. * Delete a webGL buffer used with instanciation
  39465. * @param buffer defines the webGL buffer to delete
  39466. */
  39467. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39468. private _clientWaitAsync;
  39469. /** @hidden */
  39470. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39471. dispose(): void;
  39472. private _disableTouchAction;
  39473. /**
  39474. * Display the loading screen
  39475. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39476. */
  39477. displayLoadingUI(): void;
  39478. /**
  39479. * Hide the loading screen
  39480. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39481. */
  39482. hideLoadingUI(): void;
  39483. /**
  39484. * Gets the current loading screen object
  39485. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39486. */
  39487. get loadingScreen(): ILoadingScreen;
  39488. /**
  39489. * Sets the current loading screen object
  39490. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39491. */
  39492. set loadingScreen(loadingScreen: ILoadingScreen);
  39493. /**
  39494. * Sets the current loading screen text
  39495. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39496. */
  39497. set loadingUIText(text: string);
  39498. /**
  39499. * Sets the current loading screen background color
  39500. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39501. */
  39502. set loadingUIBackgroundColor(color: string);
  39503. /** Pointerlock and fullscreen */
  39504. /**
  39505. * Ask the browser to promote the current element to pointerlock mode
  39506. * @param element defines the DOM element to promote
  39507. */
  39508. static _RequestPointerlock(element: HTMLElement): void;
  39509. /**
  39510. * Asks the browser to exit pointerlock mode
  39511. */
  39512. static _ExitPointerlock(): void;
  39513. /**
  39514. * Ask the browser to promote the current element to fullscreen rendering mode
  39515. * @param element defines the DOM element to promote
  39516. */
  39517. static _RequestFullscreen(element: HTMLElement): void;
  39518. /**
  39519. * Asks the browser to exit fullscreen mode
  39520. */
  39521. static _ExitFullscreen(): void;
  39522. }
  39523. }
  39524. declare module "babylonjs/Engines/engineStore" {
  39525. import { Nullable } from "babylonjs/types";
  39526. import { Engine } from "babylonjs/Engines/engine";
  39527. import { Scene } from "babylonjs/scene";
  39528. /**
  39529. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39530. * during the life time of the application.
  39531. */
  39532. export class EngineStore {
  39533. /** Gets the list of created engines */
  39534. static Instances: import("babylonjs/Engines/engine").Engine[];
  39535. /** @hidden */
  39536. static _LastCreatedScene: Nullable<Scene>;
  39537. /**
  39538. * Gets the latest created engine
  39539. */
  39540. static get LastCreatedEngine(): Nullable<Engine>;
  39541. /**
  39542. * Gets the latest created scene
  39543. */
  39544. static get LastCreatedScene(): Nullable<Scene>;
  39545. /**
  39546. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39547. * @ignorenaming
  39548. */
  39549. static UseFallbackTexture: boolean;
  39550. /**
  39551. * Texture content used if a texture cannot loaded
  39552. * @ignorenaming
  39553. */
  39554. static FallbackTexture: string;
  39555. }
  39556. }
  39557. declare module "babylonjs/Misc/promise" {
  39558. /**
  39559. * Helper class that provides a small promise polyfill
  39560. */
  39561. export class PromisePolyfill {
  39562. /**
  39563. * Static function used to check if the polyfill is required
  39564. * If this is the case then the function will inject the polyfill to window.Promise
  39565. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39566. */
  39567. static Apply(force?: boolean): void;
  39568. }
  39569. }
  39570. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39571. /**
  39572. * Interface for screenshot methods with describe argument called `size` as object with options
  39573. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39574. */
  39575. export interface IScreenshotSize {
  39576. /**
  39577. * number in pixels for canvas height
  39578. */
  39579. height?: number;
  39580. /**
  39581. * multiplier allowing render at a higher or lower resolution
  39582. * If value is defined then height and width will be ignored and taken from camera
  39583. */
  39584. precision?: number;
  39585. /**
  39586. * number in pixels for canvas width
  39587. */
  39588. width?: number;
  39589. }
  39590. }
  39591. declare module "babylonjs/Misc/tools" {
  39592. import { Nullable, float } from "babylonjs/types";
  39593. import { DomManagement } from "babylonjs/Misc/domManagement";
  39594. import { WebRequest } from "babylonjs/Misc/webRequest";
  39595. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39596. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39597. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39598. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39599. import { Camera } from "babylonjs/Cameras/camera";
  39600. import { Engine } from "babylonjs/Engines/engine";
  39601. interface IColor4Like {
  39602. r: float;
  39603. g: float;
  39604. b: float;
  39605. a: float;
  39606. }
  39607. /**
  39608. * Class containing a set of static utilities functions
  39609. */
  39610. export class Tools {
  39611. /**
  39612. * Gets or sets the base URL to use to load assets
  39613. */
  39614. static get BaseUrl(): string;
  39615. static set BaseUrl(value: string);
  39616. /**
  39617. * Enable/Disable Custom HTTP Request Headers globally.
  39618. * default = false
  39619. * @see CustomRequestHeaders
  39620. */
  39621. static UseCustomRequestHeaders: boolean;
  39622. /**
  39623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39624. * i.e. when loading files, where the server/service expects an Authorization header
  39625. */
  39626. static CustomRequestHeaders: {
  39627. [key: string]: string;
  39628. };
  39629. /**
  39630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39631. */
  39632. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39633. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39634. /**
  39635. * Default behaviour for cors in the application.
  39636. * It can be a string if the expected behavior is identical in the entire app.
  39637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39638. */
  39639. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39640. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39641. /**
  39642. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39643. * @ignorenaming
  39644. */
  39645. static get UseFallbackTexture(): boolean;
  39646. static set UseFallbackTexture(value: boolean);
  39647. /**
  39648. * Use this object to register external classes like custom textures or material
  39649. * to allow the laoders to instantiate them
  39650. */
  39651. static get RegisteredExternalClasses(): {
  39652. [key: string]: Object;
  39653. };
  39654. static set RegisteredExternalClasses(classes: {
  39655. [key: string]: Object;
  39656. });
  39657. /**
  39658. * Texture content used if a texture cannot loaded
  39659. * @ignorenaming
  39660. */
  39661. static get fallbackTexture(): string;
  39662. static set fallbackTexture(value: string);
  39663. /**
  39664. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39665. * @param u defines the coordinate on X axis
  39666. * @param v defines the coordinate on Y axis
  39667. * @param width defines the width of the source data
  39668. * @param height defines the height of the source data
  39669. * @param pixels defines the source byte array
  39670. * @param color defines the output color
  39671. */
  39672. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39673. /**
  39674. * Interpolates between a and b via alpha
  39675. * @param a The lower value (returned when alpha = 0)
  39676. * @param b The upper value (returned when alpha = 1)
  39677. * @param alpha The interpolation-factor
  39678. * @return The mixed value
  39679. */
  39680. static Mix(a: number, b: number, alpha: number): number;
  39681. /**
  39682. * Tries to instantiate a new object from a given class name
  39683. * @param className defines the class name to instantiate
  39684. * @returns the new object or null if the system was not able to do the instantiation
  39685. */
  39686. static Instantiate(className: string): any;
  39687. /**
  39688. * Provides a slice function that will work even on IE
  39689. * @param data defines the array to slice
  39690. * @param start defines the start of the data (optional)
  39691. * @param end defines the end of the data (optional)
  39692. * @returns the new sliced array
  39693. */
  39694. static Slice<T>(data: T, start?: number, end?: number): T;
  39695. /**
  39696. * Polyfill for setImmediate
  39697. * @param action defines the action to execute after the current execution block
  39698. */
  39699. static SetImmediate(action: () => void): void;
  39700. /**
  39701. * Function indicating if a number is an exponent of 2
  39702. * @param value defines the value to test
  39703. * @returns true if the value is an exponent of 2
  39704. */
  39705. static IsExponentOfTwo(value: number): boolean;
  39706. private static _tmpFloatArray;
  39707. /**
  39708. * Returns the nearest 32-bit single precision float representation of a Number
  39709. * @param value A Number. If the parameter is of a different type, it will get converted
  39710. * to a number or to NaN if it cannot be converted
  39711. * @returns number
  39712. */
  39713. static FloatRound(value: number): number;
  39714. /**
  39715. * Extracts the filename from a path
  39716. * @param path defines the path to use
  39717. * @returns the filename
  39718. */
  39719. static GetFilename(path: string): string;
  39720. /**
  39721. * Extracts the "folder" part of a path (everything before the filename).
  39722. * @param uri The URI to extract the info from
  39723. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39724. * @returns The "folder" part of the path
  39725. */
  39726. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39727. /**
  39728. * Extracts text content from a DOM element hierarchy
  39729. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39730. */
  39731. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39732. /**
  39733. * Convert an angle in radians to degrees
  39734. * @param angle defines the angle to convert
  39735. * @returns the angle in degrees
  39736. */
  39737. static ToDegrees(angle: number): number;
  39738. /**
  39739. * Convert an angle in degrees to radians
  39740. * @param angle defines the angle to convert
  39741. * @returns the angle in radians
  39742. */
  39743. static ToRadians(angle: number): number;
  39744. /**
  39745. * Returns an array if obj is not an array
  39746. * @param obj defines the object to evaluate as an array
  39747. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39748. * @returns either obj directly if obj is an array or a new array containing obj
  39749. */
  39750. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39751. /**
  39752. * Gets the pointer prefix to use
  39753. * @param engine defines the engine we are finding the prefix for
  39754. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39755. */
  39756. static GetPointerPrefix(engine: Engine): string;
  39757. /**
  39758. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39759. * @param url define the url we are trying
  39760. * @param element define the dom element where to configure the cors policy
  39761. */
  39762. static SetCorsBehavior(url: string | string[], element: {
  39763. crossOrigin: string | null;
  39764. }): void;
  39765. /**
  39766. * Removes unwanted characters from an url
  39767. * @param url defines the url to clean
  39768. * @returns the cleaned url
  39769. */
  39770. static CleanUrl(url: string): string;
  39771. /**
  39772. * Gets or sets a function used to pre-process url before using them to load assets
  39773. */
  39774. static get PreprocessUrl(): (url: string) => string;
  39775. static set PreprocessUrl(processor: (url: string) => string);
  39776. /**
  39777. * Loads an image as an HTMLImageElement.
  39778. * @param input url string, ArrayBuffer, or Blob to load
  39779. * @param onLoad callback called when the image successfully loads
  39780. * @param onError callback called when the image fails to load
  39781. * @param offlineProvider offline provider for caching
  39782. * @param mimeType optional mime type
  39783. * @returns the HTMLImageElement of the loaded image
  39784. */
  39785. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39786. /**
  39787. * Loads a file from a url
  39788. * @param url url string, ArrayBuffer, or Blob to load
  39789. * @param onSuccess callback called when the file successfully loads
  39790. * @param onProgress callback called while file is loading (if the server supports this mode)
  39791. * @param offlineProvider defines the offline provider for caching
  39792. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39793. * @param onError callback called when the file fails to load
  39794. * @returns a file request object
  39795. */
  39796. 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;
  39797. /**
  39798. * Loads a file from a url
  39799. * @param url the file url to load
  39800. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39801. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39802. */
  39803. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39804. /**
  39805. * Load a script (identified by an url). When the url returns, the
  39806. * content of this file is added into a new script element, attached to the DOM (body element)
  39807. * @param scriptUrl defines the url of the script to laod
  39808. * @param onSuccess defines the callback called when the script is loaded
  39809. * @param onError defines the callback to call if an error occurs
  39810. * @param scriptId defines the id of the script element
  39811. */
  39812. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39813. /**
  39814. * Load an asynchronous script (identified by an url). When the url returns, the
  39815. * content of this file is added into a new script element, attached to the DOM (body element)
  39816. * @param scriptUrl defines the url of the script to laod
  39817. * @param scriptId defines the id of the script element
  39818. * @returns a promise request object
  39819. */
  39820. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39821. /**
  39822. * Loads a file from a blob
  39823. * @param fileToLoad defines the blob to use
  39824. * @param callback defines the callback to call when data is loaded
  39825. * @param progressCallback defines the callback to call during loading process
  39826. * @returns a file request object
  39827. */
  39828. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39829. /**
  39830. * Reads a file from a File object
  39831. * @param file defines the file to load
  39832. * @param onSuccess defines the callback to call when data is loaded
  39833. * @param onProgress defines the callback to call during loading process
  39834. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39835. * @param onError defines the callback to call when an error occurs
  39836. * @returns a file request object
  39837. */
  39838. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39839. /**
  39840. * Creates a data url from a given string content
  39841. * @param content defines the content to convert
  39842. * @returns the new data url link
  39843. */
  39844. static FileAsURL(content: string): string;
  39845. /**
  39846. * Format the given number to a specific decimal format
  39847. * @param value defines the number to format
  39848. * @param decimals defines the number of decimals to use
  39849. * @returns the formatted string
  39850. */
  39851. static Format(value: number, decimals?: number): string;
  39852. /**
  39853. * Tries to copy an object by duplicating every property
  39854. * @param source defines the source object
  39855. * @param destination defines the target object
  39856. * @param doNotCopyList defines a list of properties to avoid
  39857. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39858. */
  39859. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39860. /**
  39861. * Gets a boolean indicating if the given object has no own property
  39862. * @param obj defines the object to test
  39863. * @returns true if object has no own property
  39864. */
  39865. static IsEmpty(obj: any): boolean;
  39866. /**
  39867. * Function used to register events at window level
  39868. * @param windowElement defines the Window object to use
  39869. * @param events defines the events to register
  39870. */
  39871. static RegisterTopRootEvents(windowElement: Window, events: {
  39872. name: string;
  39873. handler: Nullable<(e: FocusEvent) => any>;
  39874. }[]): void;
  39875. /**
  39876. * Function used to unregister events from window level
  39877. * @param windowElement defines the Window object to use
  39878. * @param events defines the events to unregister
  39879. */
  39880. static UnregisterTopRootEvents(windowElement: Window, events: {
  39881. name: string;
  39882. handler: Nullable<(e: FocusEvent) => any>;
  39883. }[]): void;
  39884. /**
  39885. * @ignore
  39886. */
  39887. static _ScreenshotCanvas: HTMLCanvasElement;
  39888. /**
  39889. * Dumps the current bound framebuffer
  39890. * @param width defines the rendering width
  39891. * @param height defines the rendering height
  39892. * @param engine defines the hosting engine
  39893. * @param successCallback defines the callback triggered once the data are available
  39894. * @param mimeType defines the mime type of the result
  39895. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  39896. */
  39897. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39898. /**
  39899. * Converts the canvas data to blob.
  39900. * This acts as a polyfill for browsers not supporting the to blob function.
  39901. * @param canvas Defines the canvas to extract the data from
  39902. * @param successCallback Defines the callback triggered once the data are available
  39903. * @param mimeType Defines the mime type of the result
  39904. */
  39905. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  39906. /**
  39907. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  39908. * @param successCallback defines the callback triggered once the data are available
  39909. * @param mimeType defines the mime type of the result
  39910. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  39911. */
  39912. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  39913. /**
  39914. * Downloads a blob in the browser
  39915. * @param blob defines the blob to download
  39916. * @param fileName defines the name of the downloaded file
  39917. */
  39918. static Download(blob: Blob, fileName: string): void;
  39919. /**
  39920. * Captures a screenshot of the current rendering
  39921. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39922. * @param engine defines the rendering engine
  39923. * @param camera defines the source camera
  39924. * @param size This parameter can be set to a single number or to an object with the
  39925. * following (optional) properties: precision, width, height. If a single number is passed,
  39926. * it will be used for both width and height. If an object is passed, the screenshot size
  39927. * will be derived from the parameters. The precision property is a multiplier allowing
  39928. * rendering at a higher or lower resolution
  39929. * @param successCallback defines the callback receives a single parameter which contains the
  39930. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39931. * src parameter of an <img> to display it
  39932. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39933. * Check your browser for supported MIME types
  39934. */
  39935. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  39936. /**
  39937. * Captures a screenshot of the current rendering
  39938. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39939. * @param engine defines the rendering engine
  39940. * @param camera defines the source camera
  39941. * @param size This parameter can be set to a single number or to an object with the
  39942. * following (optional) properties: precision, width, height. If a single number is passed,
  39943. * it will be used for both width and height. If an object is passed, the screenshot size
  39944. * will be derived from the parameters. The precision property is a multiplier allowing
  39945. * rendering at a higher or lower resolution
  39946. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  39947. * Check your browser for supported MIME types
  39948. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39949. * to the src parameter of an <img> to display it
  39950. */
  39951. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  39952. /**
  39953. * Generates an image screenshot from the specified camera.
  39954. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39955. * @param engine The engine to use for rendering
  39956. * @param camera The camera to use for rendering
  39957. * @param size This parameter can be set to a single number or to an object with the
  39958. * following (optional) properties: precision, width, height. If a single number is passed,
  39959. * it will be used for both width and height. If an object is passed, the screenshot size
  39960. * will be derived from the parameters. The precision property is a multiplier allowing
  39961. * rendering at a higher or lower resolution
  39962. * @param successCallback The callback receives a single parameter which contains the
  39963. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  39964. * src parameter of an <img> to display it
  39965. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39966. * Check your browser for supported MIME types
  39967. * @param samples Texture samples (default: 1)
  39968. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39969. * @param fileName A name for for the downloaded file.
  39970. */
  39971. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  39972. /**
  39973. * Generates an image screenshot from the specified camera.
  39974. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  39975. * @param engine The engine to use for rendering
  39976. * @param camera The camera to use for rendering
  39977. * @param size This parameter can be set to a single number or to an object with the
  39978. * following (optional) properties: precision, width, height. If a single number is passed,
  39979. * it will be used for both width and height. If an object is passed, the screenshot size
  39980. * will be derived from the parameters. The precision property is a multiplier allowing
  39981. * rendering at a higher or lower resolution
  39982. * @param mimeType The MIME type of the screenshot image (default: image/png).
  39983. * Check your browser for supported MIME types
  39984. * @param samples Texture samples (default: 1)
  39985. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  39986. * @param fileName A name for for the downloaded file.
  39987. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  39988. * to the src parameter of an <img> to display it
  39989. */
  39990. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  39991. /**
  39992. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  39993. * Be aware Math.random() could cause collisions, but:
  39994. * "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"
  39995. * @returns a pseudo random id
  39996. */
  39997. static RandomId(): string;
  39998. /**
  39999. * Test if the given uri is a base64 string
  40000. * @param uri The uri to test
  40001. * @return True if the uri is a base64 string or false otherwise
  40002. */
  40003. static IsBase64(uri: string): boolean;
  40004. /**
  40005. * Decode the given base64 uri.
  40006. * @param uri The uri to decode
  40007. * @return The decoded base64 data.
  40008. */
  40009. static DecodeBase64(uri: string): ArrayBuffer;
  40010. /**
  40011. * Gets the absolute url.
  40012. * @param url the input url
  40013. * @return the absolute url
  40014. */
  40015. static GetAbsoluteUrl(url: string): string;
  40016. /**
  40017. * No log
  40018. */
  40019. static readonly NoneLogLevel: number;
  40020. /**
  40021. * Only message logs
  40022. */
  40023. static readonly MessageLogLevel: number;
  40024. /**
  40025. * Only warning logs
  40026. */
  40027. static readonly WarningLogLevel: number;
  40028. /**
  40029. * Only error logs
  40030. */
  40031. static readonly ErrorLogLevel: number;
  40032. /**
  40033. * All logs
  40034. */
  40035. static readonly AllLogLevel: number;
  40036. /**
  40037. * Gets a value indicating the number of loading errors
  40038. * @ignorenaming
  40039. */
  40040. static get errorsCount(): number;
  40041. /**
  40042. * Callback called when a new log is added
  40043. */
  40044. static OnNewCacheEntry: (entry: string) => void;
  40045. /**
  40046. * Log a message to the console
  40047. * @param message defines the message to log
  40048. */
  40049. static Log(message: string): void;
  40050. /**
  40051. * Write a warning message to the console
  40052. * @param message defines the message to log
  40053. */
  40054. static Warn(message: string): void;
  40055. /**
  40056. * Write an error message to the console
  40057. * @param message defines the message to log
  40058. */
  40059. static Error(message: string): void;
  40060. /**
  40061. * Gets current log cache (list of logs)
  40062. */
  40063. static get LogCache(): string;
  40064. /**
  40065. * Clears the log cache
  40066. */
  40067. static ClearLogCache(): void;
  40068. /**
  40069. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40070. */
  40071. static set LogLevels(level: number);
  40072. /**
  40073. * Checks if the window object exists
  40074. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40075. */
  40076. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40077. /**
  40078. * No performance log
  40079. */
  40080. static readonly PerformanceNoneLogLevel: number;
  40081. /**
  40082. * Use user marks to log performance
  40083. */
  40084. static readonly PerformanceUserMarkLogLevel: number;
  40085. /**
  40086. * Log performance to the console
  40087. */
  40088. static readonly PerformanceConsoleLogLevel: number;
  40089. private static _performance;
  40090. /**
  40091. * Sets the current performance log level
  40092. */
  40093. static set PerformanceLogLevel(level: number);
  40094. private static _StartPerformanceCounterDisabled;
  40095. private static _EndPerformanceCounterDisabled;
  40096. private static _StartUserMark;
  40097. private static _EndUserMark;
  40098. private static _StartPerformanceConsole;
  40099. private static _EndPerformanceConsole;
  40100. /**
  40101. * Starts a performance counter
  40102. */
  40103. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40104. /**
  40105. * Ends a specific performance coutner
  40106. */
  40107. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40108. /**
  40109. * Gets either window.performance.now() if supported or Date.now() else
  40110. */
  40111. static get Now(): number;
  40112. /**
  40113. * This method will return the name of the class used to create the instance of the given object.
  40114. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40115. * @param object the object to get the class name from
  40116. * @param isType defines if the object is actually a type
  40117. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40118. */
  40119. static GetClassName(object: any, isType?: boolean): string;
  40120. /**
  40121. * Gets the first element of an array satisfying a given predicate
  40122. * @param array defines the array to browse
  40123. * @param predicate defines the predicate to use
  40124. * @returns null if not found or the element
  40125. */
  40126. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40127. /**
  40128. * This method will return the name of the full name of the class, including its owning module (if any).
  40129. * 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).
  40130. * @param object the object to get the class name from
  40131. * @param isType defines if the object is actually a type
  40132. * @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.
  40133. * @ignorenaming
  40134. */
  40135. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40136. /**
  40137. * Returns a promise that resolves after the given amount of time.
  40138. * @param delay Number of milliseconds to delay
  40139. * @returns Promise that resolves after the given amount of time
  40140. */
  40141. static DelayAsync(delay: number): Promise<void>;
  40142. /**
  40143. * Utility function to detect if the current user agent is Safari
  40144. * @returns whether or not the current user agent is safari
  40145. */
  40146. static IsSafari(): boolean;
  40147. }
  40148. /**
  40149. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40150. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40151. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40152. * @param name The name of the class, case should be preserved
  40153. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40154. */
  40155. export function className(name: string, module?: string): (target: Object) => void;
  40156. /**
  40157. * An implementation of a loop for asynchronous functions.
  40158. */
  40159. export class AsyncLoop {
  40160. /**
  40161. * Defines the number of iterations for the loop
  40162. */
  40163. iterations: number;
  40164. /**
  40165. * Defines the current index of the loop.
  40166. */
  40167. index: number;
  40168. private _done;
  40169. private _fn;
  40170. private _successCallback;
  40171. /**
  40172. * Constructor.
  40173. * @param iterations the number of iterations.
  40174. * @param func the function to run each iteration
  40175. * @param successCallback the callback that will be called upon succesful execution
  40176. * @param offset starting offset.
  40177. */
  40178. constructor(
  40179. /**
  40180. * Defines the number of iterations for the loop
  40181. */
  40182. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40183. /**
  40184. * Execute the next iteration. Must be called after the last iteration was finished.
  40185. */
  40186. executeNext(): void;
  40187. /**
  40188. * Break the loop and run the success callback.
  40189. */
  40190. breakLoop(): void;
  40191. /**
  40192. * Create and run an async loop.
  40193. * @param iterations the number of iterations.
  40194. * @param fn the function to run each iteration
  40195. * @param successCallback the callback that will be called upon succesful execution
  40196. * @param offset starting offset.
  40197. * @returns the created async loop object
  40198. */
  40199. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40200. /**
  40201. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40202. * @param iterations total number of iterations
  40203. * @param syncedIterations number of synchronous iterations in each async iteration.
  40204. * @param fn the function to call each iteration.
  40205. * @param callback a success call back that will be called when iterating stops.
  40206. * @param breakFunction a break condition (optional)
  40207. * @param timeout timeout settings for the setTimeout function. default - 0.
  40208. * @returns the created async loop object
  40209. */
  40210. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40211. }
  40212. }
  40213. declare module "babylonjs/Misc/stringDictionary" {
  40214. import { Nullable } from "babylonjs/types";
  40215. /**
  40216. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40217. * The underlying implementation relies on an associative array to ensure the best performances.
  40218. * The value can be anything including 'null' but except 'undefined'
  40219. */
  40220. export class StringDictionary<T> {
  40221. /**
  40222. * This will clear this dictionary and copy the content from the 'source' one.
  40223. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40224. * @param source the dictionary to take the content from and copy to this dictionary
  40225. */
  40226. copyFrom(source: StringDictionary<T>): void;
  40227. /**
  40228. * Get a value based from its key
  40229. * @param key the given key to get the matching value from
  40230. * @return the value if found, otherwise undefined is returned
  40231. */
  40232. get(key: string): T | undefined;
  40233. /**
  40234. * Get a value from its key or add it if it doesn't exist.
  40235. * This method will ensure you that a given key/data will be present in the dictionary.
  40236. * @param key the given key to get the matching value from
  40237. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40238. * The factory will only be invoked if there's no data for the given key.
  40239. * @return the value corresponding to the key.
  40240. */
  40241. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40242. /**
  40243. * Get a value from its key if present in the dictionary otherwise add it
  40244. * @param key the key to get the value from
  40245. * @param val if there's no such key/value pair in the dictionary add it with this value
  40246. * @return the value corresponding to the key
  40247. */
  40248. getOrAdd(key: string, val: T): T;
  40249. /**
  40250. * Check if there's a given key in the dictionary
  40251. * @param key the key to check for
  40252. * @return true if the key is present, false otherwise
  40253. */
  40254. contains(key: string): boolean;
  40255. /**
  40256. * Add a new key and its corresponding value
  40257. * @param key the key to add
  40258. * @param value the value corresponding to the key
  40259. * @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
  40260. */
  40261. add(key: string, value: T): boolean;
  40262. /**
  40263. * Update a specific value associated to a key
  40264. * @param key defines the key to use
  40265. * @param value defines the value to store
  40266. * @returns true if the value was updated (or false if the key was not found)
  40267. */
  40268. set(key: string, value: T): boolean;
  40269. /**
  40270. * Get the element of the given key and remove it from the dictionary
  40271. * @param key defines the key to search
  40272. * @returns the value associated with the key or null if not found
  40273. */
  40274. getAndRemove(key: string): Nullable<T>;
  40275. /**
  40276. * Remove a key/value from the dictionary.
  40277. * @param key the key to remove
  40278. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40279. */
  40280. remove(key: string): boolean;
  40281. /**
  40282. * Clear the whole content of the dictionary
  40283. */
  40284. clear(): void;
  40285. /**
  40286. * Gets the current count
  40287. */
  40288. get count(): number;
  40289. /**
  40290. * Execute a callback on each key/val of the dictionary.
  40291. * Note that you can remove any element in this dictionary in the callback implementation
  40292. * @param callback the callback to execute on a given key/value pair
  40293. */
  40294. forEach(callback: (key: string, val: T) => void): void;
  40295. /**
  40296. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40297. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40298. * Note that you can remove any element in this dictionary in the callback implementation
  40299. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40300. * @returns the first item
  40301. */
  40302. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40303. private _count;
  40304. private _data;
  40305. }
  40306. }
  40307. declare module "babylonjs/Collisions/collisionCoordinator" {
  40308. import { Nullable } from "babylonjs/types";
  40309. import { Scene } from "babylonjs/scene";
  40310. import { Vector3 } from "babylonjs/Maths/math.vector";
  40311. import { Collider } from "babylonjs/Collisions/collider";
  40312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40313. /** @hidden */
  40314. export interface ICollisionCoordinator {
  40315. createCollider(): Collider;
  40316. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40317. init(scene: Scene): void;
  40318. }
  40319. /** @hidden */
  40320. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40321. private _scene;
  40322. private _scaledPosition;
  40323. private _scaledVelocity;
  40324. private _finalPosition;
  40325. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40326. createCollider(): Collider;
  40327. init(scene: Scene): void;
  40328. private _collideWithWorld;
  40329. }
  40330. }
  40331. declare module "babylonjs/Inputs/scene.inputManager" {
  40332. import { Nullable } from "babylonjs/types";
  40333. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40334. import { Vector2 } from "babylonjs/Maths/math.vector";
  40335. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40336. import { Scene } from "babylonjs/scene";
  40337. /**
  40338. * Class used to manage all inputs for the scene.
  40339. */
  40340. export class InputManager {
  40341. /** The distance in pixel that you have to move to prevent some events */
  40342. static DragMovementThreshold: number;
  40343. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40344. static LongPressDelay: number;
  40345. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40346. static DoubleClickDelay: number;
  40347. /** If you need to check double click without raising a single click at first click, enable this flag */
  40348. static ExclusiveDoubleClickMode: boolean;
  40349. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  40350. private _alreadyAttached;
  40351. private _wheelEventName;
  40352. private _onPointerMove;
  40353. private _onPointerDown;
  40354. private _onPointerUp;
  40355. private _initClickEvent;
  40356. private _initActionManager;
  40357. private _delayedSimpleClick;
  40358. private _delayedSimpleClickTimeout;
  40359. private _previousDelayedSimpleClickTimeout;
  40360. private _meshPickProceed;
  40361. private _previousButtonPressed;
  40362. private _currentPickResult;
  40363. private _previousPickResult;
  40364. private _totalPointersPressed;
  40365. private _doubleClickOccured;
  40366. private _pointerOverMesh;
  40367. private _pickedDownMesh;
  40368. private _pickedUpMesh;
  40369. private _pointerX;
  40370. private _pointerY;
  40371. private _unTranslatedPointerX;
  40372. private _unTranslatedPointerY;
  40373. private _startingPointerPosition;
  40374. private _previousStartingPointerPosition;
  40375. private _startingPointerTime;
  40376. private _previousStartingPointerTime;
  40377. private _pointerCaptures;
  40378. private _meshUnderPointerId;
  40379. private _onKeyDown;
  40380. private _onKeyUp;
  40381. private _onCanvasFocusObserver;
  40382. private _onCanvasBlurObserver;
  40383. private _scene;
  40384. /**
  40385. * Creates a new InputManager
  40386. * @param scene defines the hosting scene
  40387. */
  40388. constructor(scene: Scene);
  40389. /**
  40390. * Gets the mesh that is currently under the pointer
  40391. */
  40392. get meshUnderPointer(): Nullable<AbstractMesh>;
  40393. /**
  40394. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40395. * @param pointerId the pointer id to use
  40396. * @returns The mesh under this pointer id or null if not found
  40397. */
  40398. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40399. /**
  40400. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40401. */
  40402. get unTranslatedPointer(): Vector2;
  40403. /**
  40404. * Gets or sets the current on-screen X position of the pointer
  40405. */
  40406. get pointerX(): number;
  40407. set pointerX(value: number);
  40408. /**
  40409. * Gets or sets the current on-screen Y position of the pointer
  40410. */
  40411. get pointerY(): number;
  40412. set pointerY(value: number);
  40413. private _updatePointerPosition;
  40414. private _processPointerMove;
  40415. private _setRayOnPointerInfo;
  40416. private _checkPrePointerObservable;
  40417. /**
  40418. * Use this method to simulate a pointer move on a mesh
  40419. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40420. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40421. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40422. */
  40423. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40424. /**
  40425. * Use this method to simulate a pointer down on a mesh
  40426. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40427. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40428. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40429. */
  40430. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40431. private _processPointerDown;
  40432. /** @hidden */
  40433. _isPointerSwiping(): boolean;
  40434. /**
  40435. * Use this method to simulate a pointer up on a mesh
  40436. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40437. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40438. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40439. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40440. */
  40441. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40442. private _processPointerUp;
  40443. /**
  40444. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40445. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40446. * @returns true if the pointer was captured
  40447. */
  40448. isPointerCaptured(pointerId?: number): boolean;
  40449. /**
  40450. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40451. * @param attachUp defines if you want to attach events to pointerup
  40452. * @param attachDown defines if you want to attach events to pointerdown
  40453. * @param attachMove defines if you want to attach events to pointermove
  40454. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40455. */
  40456. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40457. /**
  40458. * Detaches all event handlers
  40459. */
  40460. detachControl(): void;
  40461. /**
  40462. * Force the value of meshUnderPointer
  40463. * @param mesh defines the mesh to use
  40464. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40465. */
  40466. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40467. /**
  40468. * Gets the mesh under the pointer
  40469. * @returns a Mesh or null if no mesh is under the pointer
  40470. */
  40471. getPointerOverMesh(): Nullable<AbstractMesh>;
  40472. }
  40473. }
  40474. declare module "babylonjs/Animations/animationGroup" {
  40475. import { Animatable } from "babylonjs/Animations/animatable";
  40476. import { Animation } from "babylonjs/Animations/animation";
  40477. import { Scene, IDisposable } from "babylonjs/scene";
  40478. import { Observable } from "babylonjs/Misc/observable";
  40479. import { Nullable } from "babylonjs/types";
  40480. import "babylonjs/Animations/animatable";
  40481. /**
  40482. * This class defines the direct association between an animation and a target
  40483. */
  40484. export class TargetedAnimation {
  40485. /**
  40486. * Animation to perform
  40487. */
  40488. animation: Animation;
  40489. /**
  40490. * Target to animate
  40491. */
  40492. target: any;
  40493. /**
  40494. * Returns the string "TargetedAnimation"
  40495. * @returns "TargetedAnimation"
  40496. */
  40497. getClassName(): string;
  40498. /**
  40499. * Serialize the object
  40500. * @returns the JSON object representing the current entity
  40501. */
  40502. serialize(): any;
  40503. }
  40504. /**
  40505. * Use this class to create coordinated animations on multiple targets
  40506. */
  40507. export class AnimationGroup implements IDisposable {
  40508. /** The name of the animation group */
  40509. name: string;
  40510. private _scene;
  40511. private _targetedAnimations;
  40512. private _animatables;
  40513. private _from;
  40514. private _to;
  40515. private _isStarted;
  40516. private _isPaused;
  40517. private _speedRatio;
  40518. private _loopAnimation;
  40519. private _isAdditive;
  40520. /**
  40521. * Gets or sets the unique id of the node
  40522. */
  40523. uniqueId: number;
  40524. /**
  40525. * This observable will notify when one animation have ended
  40526. */
  40527. onAnimationEndObservable: Observable<TargetedAnimation>;
  40528. /**
  40529. * Observer raised when one animation loops
  40530. */
  40531. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40532. /**
  40533. * Observer raised when all animations have looped
  40534. */
  40535. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40536. /**
  40537. * This observable will notify when all animations have ended.
  40538. */
  40539. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40540. /**
  40541. * This observable will notify when all animations have paused.
  40542. */
  40543. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40544. /**
  40545. * This observable will notify when all animations are playing.
  40546. */
  40547. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40548. /**
  40549. * Gets the first frame
  40550. */
  40551. get from(): number;
  40552. /**
  40553. * Gets the last frame
  40554. */
  40555. get to(): number;
  40556. /**
  40557. * Define if the animations are started
  40558. */
  40559. get isStarted(): boolean;
  40560. /**
  40561. * Gets a value indicating that the current group is playing
  40562. */
  40563. get isPlaying(): boolean;
  40564. /**
  40565. * Gets or sets the speed ratio to use for all animations
  40566. */
  40567. get speedRatio(): number;
  40568. /**
  40569. * Gets or sets the speed ratio to use for all animations
  40570. */
  40571. set speedRatio(value: number);
  40572. /**
  40573. * Gets or sets if all animations should loop or not
  40574. */
  40575. get loopAnimation(): boolean;
  40576. set loopAnimation(value: boolean);
  40577. /**
  40578. * Gets or sets if all animations should be evaluated additively
  40579. */
  40580. get isAdditive(): boolean;
  40581. set isAdditive(value: boolean);
  40582. /**
  40583. * Gets the targeted animations for this animation group
  40584. */
  40585. get targetedAnimations(): Array<TargetedAnimation>;
  40586. /**
  40587. * returning the list of animatables controlled by this animation group.
  40588. */
  40589. get animatables(): Array<Animatable>;
  40590. /**
  40591. * Gets the list of target animations
  40592. */
  40593. get children(): TargetedAnimation[];
  40594. /**
  40595. * Instantiates a new Animation Group.
  40596. * This helps managing several animations at once.
  40597. * @see https://doc.babylonjs.com/how_to/group
  40598. * @param name Defines the name of the group
  40599. * @param scene Defines the scene the group belongs to
  40600. */
  40601. constructor(
  40602. /** The name of the animation group */
  40603. name: string, scene?: Nullable<Scene>);
  40604. /**
  40605. * Add an animation (with its target) in the group
  40606. * @param animation defines the animation we want to add
  40607. * @param target defines the target of the animation
  40608. * @returns the TargetedAnimation object
  40609. */
  40610. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40611. /**
  40612. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40613. * It can add constant keys at begin or end
  40614. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40615. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40616. * @returns the animation group
  40617. */
  40618. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40619. private _animationLoopCount;
  40620. private _animationLoopFlags;
  40621. private _processLoop;
  40622. /**
  40623. * Start all animations on given targets
  40624. * @param loop defines if animations must loop
  40625. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40626. * @param from defines the from key (optional)
  40627. * @param to defines the to key (optional)
  40628. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40629. * @returns the current animation group
  40630. */
  40631. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40632. /**
  40633. * Pause all animations
  40634. * @returns the animation group
  40635. */
  40636. pause(): AnimationGroup;
  40637. /**
  40638. * Play all animations to initial state
  40639. * This function will start() the animations if they were not started or will restart() them if they were paused
  40640. * @param loop defines if animations must loop
  40641. * @returns the animation group
  40642. */
  40643. play(loop?: boolean): AnimationGroup;
  40644. /**
  40645. * Reset all animations to initial state
  40646. * @returns the animation group
  40647. */
  40648. reset(): AnimationGroup;
  40649. /**
  40650. * Restart animations from key 0
  40651. * @returns the animation group
  40652. */
  40653. restart(): AnimationGroup;
  40654. /**
  40655. * Stop all animations
  40656. * @returns the animation group
  40657. */
  40658. stop(): AnimationGroup;
  40659. /**
  40660. * Set animation weight for all animatables
  40661. * @param weight defines the weight to use
  40662. * @return the animationGroup
  40663. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40664. */
  40665. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40666. /**
  40667. * Synchronize and normalize all animatables with a source animatable
  40668. * @param root defines the root animatable to synchronize with
  40669. * @return the animationGroup
  40670. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40671. */
  40672. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40673. /**
  40674. * Goes to a specific frame in this animation group
  40675. * @param frame the frame number to go to
  40676. * @return the animationGroup
  40677. */
  40678. goToFrame(frame: number): AnimationGroup;
  40679. /**
  40680. * Dispose all associated resources
  40681. */
  40682. dispose(): void;
  40683. private _checkAnimationGroupEnded;
  40684. /**
  40685. * Clone the current animation group and returns a copy
  40686. * @param newName defines the name of the new group
  40687. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40688. * @returns the new aniamtion group
  40689. */
  40690. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40691. /**
  40692. * Serializes the animationGroup to an object
  40693. * @returns Serialized object
  40694. */
  40695. serialize(): any;
  40696. /**
  40697. * Returns a new AnimationGroup object parsed from the source provided.
  40698. * @param parsedAnimationGroup defines the source
  40699. * @param scene defines the scene that will receive the animationGroup
  40700. * @returns a new AnimationGroup
  40701. */
  40702. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40703. /**
  40704. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40705. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40706. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40707. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40708. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40709. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40710. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40711. */
  40712. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40713. /**
  40714. * Returns the string "AnimationGroup"
  40715. * @returns "AnimationGroup"
  40716. */
  40717. getClassName(): string;
  40718. /**
  40719. * Creates a detailled string about the object
  40720. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40721. * @returns a string representing the object
  40722. */
  40723. toString(fullDetails?: boolean): string;
  40724. }
  40725. }
  40726. declare module "babylonjs/scene" {
  40727. import { Nullable } from "babylonjs/types";
  40728. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40729. import { Observable } from "babylonjs/Misc/observable";
  40730. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40731. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40732. import { Geometry } from "babylonjs/Meshes/geometry";
  40733. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40734. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40736. import { Mesh } from "babylonjs/Meshes/mesh";
  40737. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40738. import { Bone } from "babylonjs/Bones/bone";
  40739. import { Skeleton } from "babylonjs/Bones/skeleton";
  40740. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40741. import { Camera } from "babylonjs/Cameras/camera";
  40742. import { AbstractScene } from "babylonjs/abstractScene";
  40743. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40745. import { Material } from "babylonjs/Materials/material";
  40746. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40747. import { Effect } from "babylonjs/Materials/effect";
  40748. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40749. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40750. import { Light } from "babylonjs/Lights/light";
  40751. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40752. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40753. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40754. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40755. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40756. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40757. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40758. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40759. import { Engine } from "babylonjs/Engines/engine";
  40760. import { Node } from "babylonjs/node";
  40761. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40762. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40763. import { WebRequest } from "babylonjs/Misc/webRequest";
  40764. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40765. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40766. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40767. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40768. import { Plane } from "babylonjs/Maths/math.plane";
  40769. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40770. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40771. import { Ray } from "babylonjs/Culling/ray";
  40772. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40773. import { Animation } from "babylonjs/Animations/animation";
  40774. import { Animatable } from "babylonjs/Animations/animatable";
  40775. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40776. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40777. import { Collider } from "babylonjs/Collisions/collider";
  40778. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40779. /**
  40780. * Define an interface for all classes that will hold resources
  40781. */
  40782. export interface IDisposable {
  40783. /**
  40784. * Releases all held resources
  40785. */
  40786. dispose(): void;
  40787. }
  40788. /** Interface defining initialization parameters for Scene class */
  40789. export interface SceneOptions {
  40790. /**
  40791. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40792. * It will improve performance when the number of geometries becomes important.
  40793. */
  40794. useGeometryUniqueIdsMap?: boolean;
  40795. /**
  40796. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40797. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40798. */
  40799. useMaterialMeshMap?: boolean;
  40800. /**
  40801. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40802. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40803. */
  40804. useClonedMeshMap?: boolean;
  40805. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40806. virtual?: boolean;
  40807. }
  40808. /**
  40809. * Represents a scene to be rendered by the engine.
  40810. * @see https://doc.babylonjs.com/features/scene
  40811. */
  40812. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40813. /** The fog is deactivated */
  40814. static readonly FOGMODE_NONE: number;
  40815. /** The fog density is following an exponential function */
  40816. static readonly FOGMODE_EXP: number;
  40817. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40818. static readonly FOGMODE_EXP2: number;
  40819. /** The fog density is following a linear function. */
  40820. static readonly FOGMODE_LINEAR: number;
  40821. /**
  40822. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40823. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40824. */
  40825. static MinDeltaTime: number;
  40826. /**
  40827. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40828. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40829. */
  40830. static MaxDeltaTime: number;
  40831. /**
  40832. * Factory used to create the default material.
  40833. * @param name The name of the material to create
  40834. * @param scene The scene to create the material for
  40835. * @returns The default material
  40836. */
  40837. static DefaultMaterialFactory(scene: Scene): Material;
  40838. /**
  40839. * Factory used to create the a collision coordinator.
  40840. * @returns The collision coordinator
  40841. */
  40842. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40843. /** @hidden */
  40844. _inputManager: InputManager;
  40845. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40846. cameraToUseForPointers: Nullable<Camera>;
  40847. /** @hidden */
  40848. readonly _isScene: boolean;
  40849. /** @hidden */
  40850. _blockEntityCollection: boolean;
  40851. /**
  40852. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40853. */
  40854. autoClear: boolean;
  40855. /**
  40856. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40857. */
  40858. autoClearDepthAndStencil: boolean;
  40859. /**
  40860. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40861. */
  40862. clearColor: Color4;
  40863. /**
  40864. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40865. */
  40866. ambientColor: Color3;
  40867. /**
  40868. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40869. * It should only be one of the following (if not the default embedded one):
  40870. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40871. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40872. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40873. * The material properties need to be setup according to the type of texture in use.
  40874. */
  40875. environmentBRDFTexture: BaseTexture;
  40876. /**
  40877. * Texture used in all pbr material as the reflection texture.
  40878. * As in the majority of the scene they are the same (exception for multi room and so on),
  40879. * this is easier to reference from here than from all the materials.
  40880. */
  40881. get environmentTexture(): Nullable<BaseTexture>;
  40882. /**
  40883. * Texture used in all pbr material as the reflection texture.
  40884. * As in the majority of the scene they are the same (exception for multi room and so on),
  40885. * this is easier to set here than in all the materials.
  40886. */
  40887. set environmentTexture(value: Nullable<BaseTexture>);
  40888. /** @hidden */
  40889. protected _environmentIntensity: number;
  40890. /**
  40891. * Intensity of the environment in all pbr material.
  40892. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40893. * As in the majority of the scene they are the same (exception for multi room and so on),
  40894. * this is easier to reference from here than from all the materials.
  40895. */
  40896. get environmentIntensity(): number;
  40897. /**
  40898. * Intensity of the environment in all pbr material.
  40899. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  40900. * As in the majority of the scene they are the same (exception for multi room and so on),
  40901. * this is easier to set here than in all the materials.
  40902. */
  40903. set environmentIntensity(value: number);
  40904. /** @hidden */
  40905. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40906. /**
  40907. * Default image processing configuration used either in the rendering
  40908. * Forward main pass or through the imageProcessingPostProcess if present.
  40909. * As in the majority of the scene they are the same (exception for multi camera),
  40910. * this is easier to reference from here than from all the materials and post process.
  40911. *
  40912. * No setter as we it is a shared configuration, you can set the values instead.
  40913. */
  40914. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  40915. private _forceWireframe;
  40916. /**
  40917. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  40918. */
  40919. set forceWireframe(value: boolean);
  40920. get forceWireframe(): boolean;
  40921. private _skipFrustumClipping;
  40922. /**
  40923. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  40924. */
  40925. set skipFrustumClipping(value: boolean);
  40926. get skipFrustumClipping(): boolean;
  40927. private _forcePointsCloud;
  40928. /**
  40929. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  40930. */
  40931. set forcePointsCloud(value: boolean);
  40932. get forcePointsCloud(): boolean;
  40933. /**
  40934. * Gets or sets the active clipplane 1
  40935. */
  40936. clipPlane: Nullable<Plane>;
  40937. /**
  40938. * Gets or sets the active clipplane 2
  40939. */
  40940. clipPlane2: Nullable<Plane>;
  40941. /**
  40942. * Gets or sets the active clipplane 3
  40943. */
  40944. clipPlane3: Nullable<Plane>;
  40945. /**
  40946. * Gets or sets the active clipplane 4
  40947. */
  40948. clipPlane4: Nullable<Plane>;
  40949. /**
  40950. * Gets or sets the active clipplane 5
  40951. */
  40952. clipPlane5: Nullable<Plane>;
  40953. /**
  40954. * Gets or sets the active clipplane 6
  40955. */
  40956. clipPlane6: Nullable<Plane>;
  40957. /**
  40958. * Gets or sets a boolean indicating if animations are enabled
  40959. */
  40960. animationsEnabled: boolean;
  40961. private _animationPropertiesOverride;
  40962. /**
  40963. * Gets or sets the animation properties override
  40964. */
  40965. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  40966. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  40967. /**
  40968. * Gets or sets a boolean indicating if a constant deltatime has to be used
  40969. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  40970. */
  40971. useConstantAnimationDeltaTime: boolean;
  40972. /**
  40973. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  40974. * Please note that it requires to run a ray cast through the scene on every frame
  40975. */
  40976. constantlyUpdateMeshUnderPointer: boolean;
  40977. /**
  40978. * Defines the HTML cursor to use when hovering over interactive elements
  40979. */
  40980. hoverCursor: string;
  40981. /**
  40982. * Defines the HTML default cursor to use (empty by default)
  40983. */
  40984. defaultCursor: string;
  40985. /**
  40986. * Defines whether cursors are handled by the scene.
  40987. */
  40988. doNotHandleCursors: boolean;
  40989. /**
  40990. * This is used to call preventDefault() on pointer down
  40991. * in order to block unwanted artifacts like system double clicks
  40992. */
  40993. preventDefaultOnPointerDown: boolean;
  40994. /**
  40995. * This is used to call preventDefault() on pointer up
  40996. * in order to block unwanted artifacts like system double clicks
  40997. */
  40998. preventDefaultOnPointerUp: boolean;
  40999. /**
  41000. * Gets or sets user defined metadata
  41001. */
  41002. metadata: any;
  41003. /**
  41004. * For internal use only. Please do not use.
  41005. */
  41006. reservedDataStore: any;
  41007. /**
  41008. * Gets the name of the plugin used to load this scene (null by default)
  41009. */
  41010. loadingPluginName: string;
  41011. /**
  41012. * Use this array to add regular expressions used to disable offline support for specific urls
  41013. */
  41014. disableOfflineSupportExceptionRules: RegExp[];
  41015. /**
  41016. * An event triggered when the scene is disposed.
  41017. */
  41018. onDisposeObservable: Observable<Scene>;
  41019. private _onDisposeObserver;
  41020. /** Sets a function to be executed when this scene is disposed. */
  41021. set onDispose(callback: () => void);
  41022. /**
  41023. * An event triggered before rendering the scene (right after animations and physics)
  41024. */
  41025. onBeforeRenderObservable: Observable<Scene>;
  41026. private _onBeforeRenderObserver;
  41027. /** Sets a function to be executed before rendering this scene */
  41028. set beforeRender(callback: Nullable<() => void>);
  41029. /**
  41030. * An event triggered after rendering the scene
  41031. */
  41032. onAfterRenderObservable: Observable<Scene>;
  41033. /**
  41034. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41035. */
  41036. onAfterRenderCameraObservable: Observable<Camera>;
  41037. private _onAfterRenderObserver;
  41038. /** Sets a function to be executed after rendering this scene */
  41039. set afterRender(callback: Nullable<() => void>);
  41040. /**
  41041. * An event triggered before animating the scene
  41042. */
  41043. onBeforeAnimationsObservable: Observable<Scene>;
  41044. /**
  41045. * An event triggered after animations processing
  41046. */
  41047. onAfterAnimationsObservable: Observable<Scene>;
  41048. /**
  41049. * An event triggered before draw calls are ready to be sent
  41050. */
  41051. onBeforeDrawPhaseObservable: Observable<Scene>;
  41052. /**
  41053. * An event triggered after draw calls have been sent
  41054. */
  41055. onAfterDrawPhaseObservable: Observable<Scene>;
  41056. /**
  41057. * An event triggered when the scene is ready
  41058. */
  41059. onReadyObservable: Observable<Scene>;
  41060. /**
  41061. * An event triggered before rendering a camera
  41062. */
  41063. onBeforeCameraRenderObservable: Observable<Camera>;
  41064. private _onBeforeCameraRenderObserver;
  41065. /** Sets a function to be executed before rendering a camera*/
  41066. set beforeCameraRender(callback: () => void);
  41067. /**
  41068. * An event triggered after rendering a camera
  41069. */
  41070. onAfterCameraRenderObservable: Observable<Camera>;
  41071. private _onAfterCameraRenderObserver;
  41072. /** Sets a function to be executed after rendering a camera*/
  41073. set afterCameraRender(callback: () => void);
  41074. /**
  41075. * An event triggered when active meshes evaluation is about to start
  41076. */
  41077. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41078. /**
  41079. * An event triggered when active meshes evaluation is done
  41080. */
  41081. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41082. /**
  41083. * An event triggered when particles rendering is about to start
  41084. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41085. */
  41086. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41087. /**
  41088. * An event triggered when particles rendering is done
  41089. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41090. */
  41091. onAfterParticlesRenderingObservable: Observable<Scene>;
  41092. /**
  41093. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41094. */
  41095. onDataLoadedObservable: Observable<Scene>;
  41096. /**
  41097. * An event triggered when a camera is created
  41098. */
  41099. onNewCameraAddedObservable: Observable<Camera>;
  41100. /**
  41101. * An event triggered when a camera is removed
  41102. */
  41103. onCameraRemovedObservable: Observable<Camera>;
  41104. /**
  41105. * An event triggered when a light is created
  41106. */
  41107. onNewLightAddedObservable: Observable<Light>;
  41108. /**
  41109. * An event triggered when a light is removed
  41110. */
  41111. onLightRemovedObservable: Observable<Light>;
  41112. /**
  41113. * An event triggered when a geometry is created
  41114. */
  41115. onNewGeometryAddedObservable: Observable<Geometry>;
  41116. /**
  41117. * An event triggered when a geometry is removed
  41118. */
  41119. onGeometryRemovedObservable: Observable<Geometry>;
  41120. /**
  41121. * An event triggered when a transform node is created
  41122. */
  41123. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41124. /**
  41125. * An event triggered when a transform node is removed
  41126. */
  41127. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41128. /**
  41129. * An event triggered when a mesh is created
  41130. */
  41131. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41132. /**
  41133. * An event triggered when a mesh is removed
  41134. */
  41135. onMeshRemovedObservable: Observable<AbstractMesh>;
  41136. /**
  41137. * An event triggered when a skeleton is created
  41138. */
  41139. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41140. /**
  41141. * An event triggered when a skeleton is removed
  41142. */
  41143. onSkeletonRemovedObservable: Observable<Skeleton>;
  41144. /**
  41145. * An event triggered when a material is created
  41146. */
  41147. onNewMaterialAddedObservable: Observable<Material>;
  41148. /**
  41149. * An event triggered when a material is removed
  41150. */
  41151. onMaterialRemovedObservable: Observable<Material>;
  41152. /**
  41153. * An event triggered when a texture is created
  41154. */
  41155. onNewTextureAddedObservable: Observable<BaseTexture>;
  41156. /**
  41157. * An event triggered when a texture is removed
  41158. */
  41159. onTextureRemovedObservable: Observable<BaseTexture>;
  41160. /**
  41161. * An event triggered when render targets are about to be rendered
  41162. * Can happen multiple times per frame.
  41163. */
  41164. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41165. /**
  41166. * An event triggered when render targets were rendered.
  41167. * Can happen multiple times per frame.
  41168. */
  41169. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41170. /**
  41171. * An event triggered before calculating deterministic simulation step
  41172. */
  41173. onBeforeStepObservable: Observable<Scene>;
  41174. /**
  41175. * An event triggered after calculating deterministic simulation step
  41176. */
  41177. onAfterStepObservable: Observable<Scene>;
  41178. /**
  41179. * An event triggered when the activeCamera property is updated
  41180. */
  41181. onActiveCameraChanged: Observable<Scene>;
  41182. /**
  41183. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41184. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41185. * 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)
  41186. */
  41187. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41188. /**
  41189. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41190. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41191. * 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)
  41192. */
  41193. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41194. /**
  41195. * This Observable will when a mesh has been imported into the scene.
  41196. */
  41197. onMeshImportedObservable: Observable<AbstractMesh>;
  41198. /**
  41199. * This Observable will when an animation file has been imported into the scene.
  41200. */
  41201. onAnimationFileImportedObservable: Observable<Scene>;
  41202. /**
  41203. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41204. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41205. */
  41206. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41207. /** @hidden */
  41208. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41209. /**
  41210. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41211. */
  41212. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41213. /**
  41214. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41215. */
  41216. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41217. /**
  41218. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41219. */
  41220. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41221. /** Callback called when a pointer move is detected */
  41222. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41223. /** Callback called when a pointer down is detected */
  41224. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41225. /** Callback called when a pointer up is detected */
  41226. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41227. /** Callback called when a pointer pick is detected */
  41228. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41229. /**
  41230. * 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).
  41231. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41232. */
  41233. onPrePointerObservable: Observable<PointerInfoPre>;
  41234. /**
  41235. * Observable event triggered each time an input event is received from the rendering canvas
  41236. */
  41237. onPointerObservable: Observable<PointerInfo>;
  41238. /**
  41239. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41240. */
  41241. get unTranslatedPointer(): Vector2;
  41242. /**
  41243. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41244. */
  41245. static get DragMovementThreshold(): number;
  41246. static set DragMovementThreshold(value: number);
  41247. /**
  41248. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41249. */
  41250. static get LongPressDelay(): number;
  41251. static set LongPressDelay(value: number);
  41252. /**
  41253. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41254. */
  41255. static get DoubleClickDelay(): number;
  41256. static set DoubleClickDelay(value: number);
  41257. /** If you need to check double click without raising a single click at first click, enable this flag */
  41258. static get ExclusiveDoubleClickMode(): boolean;
  41259. static set ExclusiveDoubleClickMode(value: boolean);
  41260. /** @hidden */
  41261. _mirroredCameraPosition: Nullable<Vector3>;
  41262. /**
  41263. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41264. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41265. */
  41266. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41267. /**
  41268. * Observable event triggered each time an keyboard event is received from the hosting window
  41269. */
  41270. onKeyboardObservable: Observable<KeyboardInfo>;
  41271. private _useRightHandedSystem;
  41272. /**
  41273. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41274. */
  41275. set useRightHandedSystem(value: boolean);
  41276. get useRightHandedSystem(): boolean;
  41277. private _timeAccumulator;
  41278. private _currentStepId;
  41279. private _currentInternalStep;
  41280. /**
  41281. * Sets the step Id used by deterministic lock step
  41282. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41283. * @param newStepId defines the step Id
  41284. */
  41285. setStepId(newStepId: number): void;
  41286. /**
  41287. * Gets the step Id used by deterministic lock step
  41288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41289. * @returns the step Id
  41290. */
  41291. getStepId(): number;
  41292. /**
  41293. * Gets the internal step used by deterministic lock step
  41294. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41295. * @returns the internal step
  41296. */
  41297. getInternalStep(): number;
  41298. private _fogEnabled;
  41299. /**
  41300. * Gets or sets a boolean indicating if fog is enabled on this scene
  41301. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41302. * (Default is true)
  41303. */
  41304. set fogEnabled(value: boolean);
  41305. get fogEnabled(): boolean;
  41306. private _fogMode;
  41307. /**
  41308. * Gets or sets the fog mode to use
  41309. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41310. * | mode | value |
  41311. * | --- | --- |
  41312. * | FOGMODE_NONE | 0 |
  41313. * | FOGMODE_EXP | 1 |
  41314. * | FOGMODE_EXP2 | 2 |
  41315. * | FOGMODE_LINEAR | 3 |
  41316. */
  41317. set fogMode(value: number);
  41318. get fogMode(): number;
  41319. /**
  41320. * Gets or sets the fog color to use
  41321. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41322. * (Default is Color3(0.2, 0.2, 0.3))
  41323. */
  41324. fogColor: Color3;
  41325. /**
  41326. * Gets or sets the fog density to use
  41327. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41328. * (Default is 0.1)
  41329. */
  41330. fogDensity: number;
  41331. /**
  41332. * Gets or sets the fog start distance to use
  41333. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41334. * (Default is 0)
  41335. */
  41336. fogStart: number;
  41337. /**
  41338. * Gets or sets the fog end distance to use
  41339. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41340. * (Default is 1000)
  41341. */
  41342. fogEnd: number;
  41343. /**
  41344. * Flag indicating that the frame buffer binding is handled by another component
  41345. */
  41346. prePass: boolean;
  41347. private _shadowsEnabled;
  41348. /**
  41349. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41350. */
  41351. set shadowsEnabled(value: boolean);
  41352. get shadowsEnabled(): boolean;
  41353. private _lightsEnabled;
  41354. /**
  41355. * Gets or sets a boolean indicating if lights are enabled on this scene
  41356. */
  41357. set lightsEnabled(value: boolean);
  41358. get lightsEnabled(): boolean;
  41359. /** All of the active cameras added to this scene. */
  41360. activeCameras: Camera[];
  41361. /** @hidden */
  41362. _activeCamera: Nullable<Camera>;
  41363. /** Gets or sets the current active camera */
  41364. get activeCamera(): Nullable<Camera>;
  41365. set activeCamera(value: Nullable<Camera>);
  41366. private _defaultMaterial;
  41367. /** The default material used on meshes when no material is affected */
  41368. get defaultMaterial(): Material;
  41369. /** The default material used on meshes when no material is affected */
  41370. set defaultMaterial(value: Material);
  41371. private _texturesEnabled;
  41372. /**
  41373. * Gets or sets a boolean indicating if textures are enabled on this scene
  41374. */
  41375. set texturesEnabled(value: boolean);
  41376. get texturesEnabled(): boolean;
  41377. /**
  41378. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41379. */
  41380. physicsEnabled: boolean;
  41381. /**
  41382. * Gets or sets a boolean indicating if particles are enabled on this scene
  41383. */
  41384. particlesEnabled: boolean;
  41385. /**
  41386. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41387. */
  41388. spritesEnabled: boolean;
  41389. private _skeletonsEnabled;
  41390. /**
  41391. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41392. */
  41393. set skeletonsEnabled(value: boolean);
  41394. get skeletonsEnabled(): boolean;
  41395. /**
  41396. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41397. */
  41398. lensFlaresEnabled: boolean;
  41399. /**
  41400. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41401. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41402. */
  41403. collisionsEnabled: boolean;
  41404. private _collisionCoordinator;
  41405. /** @hidden */
  41406. get collisionCoordinator(): ICollisionCoordinator;
  41407. /**
  41408. * Defines the gravity applied to this scene (used only for collisions)
  41409. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41410. */
  41411. gravity: Vector3;
  41412. /**
  41413. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41414. */
  41415. postProcessesEnabled: boolean;
  41416. /**
  41417. * Gets the current postprocess manager
  41418. */
  41419. postProcessManager: PostProcessManager;
  41420. /**
  41421. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41422. */
  41423. renderTargetsEnabled: boolean;
  41424. /**
  41425. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41426. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41427. */
  41428. dumpNextRenderTargets: boolean;
  41429. /**
  41430. * The list of user defined render targets added to the scene
  41431. */
  41432. customRenderTargets: RenderTargetTexture[];
  41433. /**
  41434. * Defines if texture loading must be delayed
  41435. * If true, textures will only be loaded when they need to be rendered
  41436. */
  41437. useDelayedTextureLoading: boolean;
  41438. /**
  41439. * Gets the list of meshes imported to the scene through SceneLoader
  41440. */
  41441. importedMeshesFiles: String[];
  41442. /**
  41443. * Gets or sets a boolean indicating if probes are enabled on this scene
  41444. */
  41445. probesEnabled: boolean;
  41446. /**
  41447. * Gets or sets the current offline provider to use to store scene data
  41448. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41449. */
  41450. offlineProvider: IOfflineProvider;
  41451. /**
  41452. * Gets or sets the action manager associated with the scene
  41453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41454. */
  41455. actionManager: AbstractActionManager;
  41456. private _meshesForIntersections;
  41457. /**
  41458. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41459. */
  41460. proceduralTexturesEnabled: boolean;
  41461. private _engine;
  41462. private _totalVertices;
  41463. /** @hidden */
  41464. _activeIndices: PerfCounter;
  41465. /** @hidden */
  41466. _activeParticles: PerfCounter;
  41467. /** @hidden */
  41468. _activeBones: PerfCounter;
  41469. private _animationRatio;
  41470. /** @hidden */
  41471. _animationTimeLast: number;
  41472. /** @hidden */
  41473. _animationTime: number;
  41474. /**
  41475. * Gets or sets a general scale for animation speed
  41476. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41477. */
  41478. animationTimeScale: number;
  41479. /** @hidden */
  41480. _cachedMaterial: Nullable<Material>;
  41481. /** @hidden */
  41482. _cachedEffect: Nullable<Effect>;
  41483. /** @hidden */
  41484. _cachedVisibility: Nullable<number>;
  41485. private _renderId;
  41486. private _frameId;
  41487. private _executeWhenReadyTimeoutId;
  41488. private _intermediateRendering;
  41489. private _viewUpdateFlag;
  41490. private _projectionUpdateFlag;
  41491. /** @hidden */
  41492. _toBeDisposed: Nullable<IDisposable>[];
  41493. private _activeRequests;
  41494. /** @hidden */
  41495. _pendingData: any[];
  41496. private _isDisposed;
  41497. /**
  41498. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41499. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41500. */
  41501. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41502. private _activeMeshes;
  41503. private _processedMaterials;
  41504. private _renderTargets;
  41505. /** @hidden */
  41506. _activeParticleSystems: SmartArray<IParticleSystem>;
  41507. private _activeSkeletons;
  41508. private _softwareSkinnedMeshes;
  41509. private _renderingManager;
  41510. /** @hidden */
  41511. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41512. private _transformMatrix;
  41513. private _sceneUbo;
  41514. /** @hidden */
  41515. _viewMatrix: Matrix;
  41516. private _projectionMatrix;
  41517. /** @hidden */
  41518. _forcedViewPosition: Nullable<Vector3>;
  41519. /** @hidden */
  41520. _frustumPlanes: Plane[];
  41521. /**
  41522. * Gets the list of frustum planes (built from the active camera)
  41523. */
  41524. get frustumPlanes(): Plane[];
  41525. /**
  41526. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41527. * This is useful if there are more lights that the maximum simulteanous authorized
  41528. */
  41529. requireLightSorting: boolean;
  41530. /** @hidden */
  41531. readonly useMaterialMeshMap: boolean;
  41532. /** @hidden */
  41533. readonly useClonedMeshMap: boolean;
  41534. private _externalData;
  41535. private _uid;
  41536. /**
  41537. * @hidden
  41538. * Backing store of defined scene components.
  41539. */
  41540. _components: ISceneComponent[];
  41541. /**
  41542. * @hidden
  41543. * Backing store of defined scene components.
  41544. */
  41545. _serializableComponents: ISceneSerializableComponent[];
  41546. /**
  41547. * List of components to register on the next registration step.
  41548. */
  41549. private _transientComponents;
  41550. /**
  41551. * Registers the transient components if needed.
  41552. */
  41553. private _registerTransientComponents;
  41554. /**
  41555. * @hidden
  41556. * Add a component to the scene.
  41557. * Note that the ccomponent could be registered on th next frame if this is called after
  41558. * the register component stage.
  41559. * @param component Defines the component to add to the scene
  41560. */
  41561. _addComponent(component: ISceneComponent): void;
  41562. /**
  41563. * @hidden
  41564. * Gets a component from the scene.
  41565. * @param name defines the name of the component to retrieve
  41566. * @returns the component or null if not present
  41567. */
  41568. _getComponent(name: string): Nullable<ISceneComponent>;
  41569. /**
  41570. * @hidden
  41571. * Defines the actions happening before camera updates.
  41572. */
  41573. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41574. /**
  41575. * @hidden
  41576. * Defines the actions happening before clear the canvas.
  41577. */
  41578. _beforeClearStage: Stage<SimpleStageAction>;
  41579. /**
  41580. * @hidden
  41581. * Defines the actions when collecting render targets for the frame.
  41582. */
  41583. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41584. /**
  41585. * @hidden
  41586. * Defines the actions happening for one camera in the frame.
  41587. */
  41588. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41589. /**
  41590. * @hidden
  41591. * Defines the actions happening during the per mesh ready checks.
  41592. */
  41593. _isReadyForMeshStage: Stage<MeshStageAction>;
  41594. /**
  41595. * @hidden
  41596. * Defines the actions happening before evaluate active mesh checks.
  41597. */
  41598. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41599. /**
  41600. * @hidden
  41601. * Defines the actions happening during the evaluate sub mesh checks.
  41602. */
  41603. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41604. /**
  41605. * @hidden
  41606. * Defines the actions happening during the active mesh stage.
  41607. */
  41608. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41609. /**
  41610. * @hidden
  41611. * Defines the actions happening during the per camera render target step.
  41612. */
  41613. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41614. /**
  41615. * @hidden
  41616. * Defines the actions happening just before the active camera is drawing.
  41617. */
  41618. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41619. /**
  41620. * @hidden
  41621. * Defines the actions happening just before a render target is drawing.
  41622. */
  41623. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41624. /**
  41625. * @hidden
  41626. * Defines the actions happening just before a rendering group is drawing.
  41627. */
  41628. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41629. /**
  41630. * @hidden
  41631. * Defines the actions happening just before a mesh is drawing.
  41632. */
  41633. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41634. /**
  41635. * @hidden
  41636. * Defines the actions happening just after a mesh has been drawn.
  41637. */
  41638. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41639. /**
  41640. * @hidden
  41641. * Defines the actions happening just after a rendering group has been drawn.
  41642. */
  41643. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41644. /**
  41645. * @hidden
  41646. * Defines the actions happening just after the active camera has been drawn.
  41647. */
  41648. _afterCameraDrawStage: Stage<CameraStageAction>;
  41649. /**
  41650. * @hidden
  41651. * Defines the actions happening just after a render target has been drawn.
  41652. */
  41653. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41654. /**
  41655. * @hidden
  41656. * Defines the actions happening just after rendering all cameras and computing intersections.
  41657. */
  41658. _afterRenderStage: Stage<SimpleStageAction>;
  41659. /**
  41660. * @hidden
  41661. * Defines the actions happening when a pointer move event happens.
  41662. */
  41663. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41664. /**
  41665. * @hidden
  41666. * Defines the actions happening when a pointer down event happens.
  41667. */
  41668. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41669. /**
  41670. * @hidden
  41671. * Defines the actions happening when a pointer up event happens.
  41672. */
  41673. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41674. /**
  41675. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41676. */
  41677. private geometriesByUniqueId;
  41678. /**
  41679. * Creates a new Scene
  41680. * @param engine defines the engine to use to render this scene
  41681. * @param options defines the scene options
  41682. */
  41683. constructor(engine: Engine, options?: SceneOptions);
  41684. /**
  41685. * Gets a string identifying the name of the class
  41686. * @returns "Scene" string
  41687. */
  41688. getClassName(): string;
  41689. private _defaultMeshCandidates;
  41690. /**
  41691. * @hidden
  41692. */
  41693. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41694. private _defaultSubMeshCandidates;
  41695. /**
  41696. * @hidden
  41697. */
  41698. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41699. /**
  41700. * Sets the default candidate providers for the scene.
  41701. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41702. * and getCollidingSubMeshCandidates to their default function
  41703. */
  41704. setDefaultCandidateProviders(): void;
  41705. /**
  41706. * Gets the mesh that is currently under the pointer
  41707. */
  41708. get meshUnderPointer(): Nullable<AbstractMesh>;
  41709. /**
  41710. * Gets or sets the current on-screen X position of the pointer
  41711. */
  41712. get pointerX(): number;
  41713. set pointerX(value: number);
  41714. /**
  41715. * Gets or sets the current on-screen Y position of the pointer
  41716. */
  41717. get pointerY(): number;
  41718. set pointerY(value: number);
  41719. /**
  41720. * Gets the cached material (ie. the latest rendered one)
  41721. * @returns the cached material
  41722. */
  41723. getCachedMaterial(): Nullable<Material>;
  41724. /**
  41725. * Gets the cached effect (ie. the latest rendered one)
  41726. * @returns the cached effect
  41727. */
  41728. getCachedEffect(): Nullable<Effect>;
  41729. /**
  41730. * Gets the cached visibility state (ie. the latest rendered one)
  41731. * @returns the cached visibility state
  41732. */
  41733. getCachedVisibility(): Nullable<number>;
  41734. /**
  41735. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41736. * @param material defines the current material
  41737. * @param effect defines the current effect
  41738. * @param visibility defines the current visibility state
  41739. * @returns true if one parameter is not cached
  41740. */
  41741. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41742. /**
  41743. * Gets the engine associated with the scene
  41744. * @returns an Engine
  41745. */
  41746. getEngine(): Engine;
  41747. /**
  41748. * Gets the total number of vertices rendered per frame
  41749. * @returns the total number of vertices rendered per frame
  41750. */
  41751. getTotalVertices(): number;
  41752. /**
  41753. * Gets the performance counter for total vertices
  41754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41755. */
  41756. get totalVerticesPerfCounter(): PerfCounter;
  41757. /**
  41758. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41759. * @returns the total number of active indices rendered per frame
  41760. */
  41761. getActiveIndices(): number;
  41762. /**
  41763. * Gets the performance counter for active indices
  41764. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41765. */
  41766. get totalActiveIndicesPerfCounter(): PerfCounter;
  41767. /**
  41768. * Gets the total number of active particles rendered per frame
  41769. * @returns the total number of active particles rendered per frame
  41770. */
  41771. getActiveParticles(): number;
  41772. /**
  41773. * Gets the performance counter for active particles
  41774. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41775. */
  41776. get activeParticlesPerfCounter(): PerfCounter;
  41777. /**
  41778. * Gets the total number of active bones rendered per frame
  41779. * @returns the total number of active bones rendered per frame
  41780. */
  41781. getActiveBones(): number;
  41782. /**
  41783. * Gets the performance counter for active bones
  41784. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41785. */
  41786. get activeBonesPerfCounter(): PerfCounter;
  41787. /**
  41788. * Gets the array of active meshes
  41789. * @returns an array of AbstractMesh
  41790. */
  41791. getActiveMeshes(): SmartArray<AbstractMesh>;
  41792. /**
  41793. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41794. * @returns a number
  41795. */
  41796. getAnimationRatio(): number;
  41797. /**
  41798. * Gets an unique Id for the current render phase
  41799. * @returns a number
  41800. */
  41801. getRenderId(): number;
  41802. /**
  41803. * Gets an unique Id for the current frame
  41804. * @returns a number
  41805. */
  41806. getFrameId(): number;
  41807. /** Call this function if you want to manually increment the render Id*/
  41808. incrementRenderId(): void;
  41809. private _createUbo;
  41810. /**
  41811. * Use this method to simulate a pointer move on a mesh
  41812. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41813. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41814. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41815. * @returns the current scene
  41816. */
  41817. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41818. /**
  41819. * Use this method to simulate a pointer down on a mesh
  41820. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41821. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41822. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41823. * @returns the current scene
  41824. */
  41825. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41826. /**
  41827. * Use this method to simulate a pointer up on a mesh
  41828. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41829. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41830. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41831. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41832. * @returns the current scene
  41833. */
  41834. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41835. /**
  41836. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41837. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41838. * @returns true if the pointer was captured
  41839. */
  41840. isPointerCaptured(pointerId?: number): boolean;
  41841. /**
  41842. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41843. * @param attachUp defines if you want to attach events to pointerup
  41844. * @param attachDown defines if you want to attach events to pointerdown
  41845. * @param attachMove defines if you want to attach events to pointermove
  41846. */
  41847. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41848. /** Detaches all event handlers*/
  41849. detachControl(): void;
  41850. /**
  41851. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41852. * Delay loaded resources are not taking in account
  41853. * @return true if all required resources are ready
  41854. */
  41855. isReady(): boolean;
  41856. /** Resets all cached information relative to material (including effect and visibility) */
  41857. resetCachedMaterial(): void;
  41858. /**
  41859. * Registers a function to be called before every frame render
  41860. * @param func defines the function to register
  41861. */
  41862. registerBeforeRender(func: () => void): void;
  41863. /**
  41864. * Unregisters a function called before every frame render
  41865. * @param func defines the function to unregister
  41866. */
  41867. unregisterBeforeRender(func: () => void): void;
  41868. /**
  41869. * Registers a function to be called after every frame render
  41870. * @param func defines the function to register
  41871. */
  41872. registerAfterRender(func: () => void): void;
  41873. /**
  41874. * Unregisters a function called after every frame render
  41875. * @param func defines the function to unregister
  41876. */
  41877. unregisterAfterRender(func: () => void): void;
  41878. private _executeOnceBeforeRender;
  41879. /**
  41880. * The provided function will run before render once and will be disposed afterwards.
  41881. * A timeout delay can be provided so that the function will be executed in N ms.
  41882. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  41883. * @param func The function to be executed.
  41884. * @param timeout optional delay in ms
  41885. */
  41886. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  41887. /** @hidden */
  41888. _addPendingData(data: any): void;
  41889. /** @hidden */
  41890. _removePendingData(data: any): void;
  41891. /**
  41892. * Returns the number of items waiting to be loaded
  41893. * @returns the number of items waiting to be loaded
  41894. */
  41895. getWaitingItemsCount(): number;
  41896. /**
  41897. * Returns a boolean indicating if the scene is still loading data
  41898. */
  41899. get isLoading(): boolean;
  41900. /**
  41901. * Registers a function to be executed when the scene is ready
  41902. * @param {Function} func - the function to be executed
  41903. */
  41904. executeWhenReady(func: () => void): void;
  41905. /**
  41906. * Returns a promise that resolves when the scene is ready
  41907. * @returns A promise that resolves when the scene is ready
  41908. */
  41909. whenReadyAsync(): Promise<void>;
  41910. /** @hidden */
  41911. _checkIsReady(): void;
  41912. /**
  41913. * Gets all animatable attached to the scene
  41914. */
  41915. get animatables(): Animatable[];
  41916. /**
  41917. * Resets the last animation time frame.
  41918. * Useful to override when animations start running when loading a scene for the first time.
  41919. */
  41920. resetLastAnimationTimeFrame(): void;
  41921. /**
  41922. * Gets the current view matrix
  41923. * @returns a Matrix
  41924. */
  41925. getViewMatrix(): Matrix;
  41926. /**
  41927. * Gets the current projection matrix
  41928. * @returns a Matrix
  41929. */
  41930. getProjectionMatrix(): Matrix;
  41931. /**
  41932. * Gets the current transform matrix
  41933. * @returns a Matrix made of View * Projection
  41934. */
  41935. getTransformMatrix(): Matrix;
  41936. /**
  41937. * Sets the current transform matrix
  41938. * @param viewL defines the View matrix to use
  41939. * @param projectionL defines the Projection matrix to use
  41940. * @param viewR defines the right View matrix to use (if provided)
  41941. * @param projectionR defines the right Projection matrix to use (if provided)
  41942. */
  41943. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  41944. /**
  41945. * Gets the uniform buffer used to store scene data
  41946. * @returns a UniformBuffer
  41947. */
  41948. getSceneUniformBuffer(): UniformBuffer;
  41949. /**
  41950. * Gets an unique (relatively to the current scene) Id
  41951. * @returns an unique number for the scene
  41952. */
  41953. getUniqueId(): number;
  41954. /**
  41955. * Add a mesh to the list of scene's meshes
  41956. * @param newMesh defines the mesh to add
  41957. * @param recursive if all child meshes should also be added to the scene
  41958. */
  41959. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  41960. /**
  41961. * Remove a mesh for the list of scene's meshes
  41962. * @param toRemove defines the mesh to remove
  41963. * @param recursive if all child meshes should also be removed from the scene
  41964. * @returns the index where the mesh was in the mesh list
  41965. */
  41966. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  41967. /**
  41968. * Add a transform node to the list of scene's transform nodes
  41969. * @param newTransformNode defines the transform node to add
  41970. */
  41971. addTransformNode(newTransformNode: TransformNode): void;
  41972. /**
  41973. * Remove a transform node for the list of scene's transform nodes
  41974. * @param toRemove defines the transform node to remove
  41975. * @returns the index where the transform node was in the transform node list
  41976. */
  41977. removeTransformNode(toRemove: TransformNode): number;
  41978. /**
  41979. * Remove a skeleton for the list of scene's skeletons
  41980. * @param toRemove defines the skeleton to remove
  41981. * @returns the index where the skeleton was in the skeleton list
  41982. */
  41983. removeSkeleton(toRemove: Skeleton): number;
  41984. /**
  41985. * Remove a morph target for the list of scene's morph targets
  41986. * @param toRemove defines the morph target to remove
  41987. * @returns the index where the morph target was in the morph target list
  41988. */
  41989. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  41990. /**
  41991. * Remove a light for the list of scene's lights
  41992. * @param toRemove defines the light to remove
  41993. * @returns the index where the light was in the light list
  41994. */
  41995. removeLight(toRemove: Light): number;
  41996. /**
  41997. * Remove a camera for the list of scene's cameras
  41998. * @param toRemove defines the camera to remove
  41999. * @returns the index where the camera was in the camera list
  42000. */
  42001. removeCamera(toRemove: Camera): number;
  42002. /**
  42003. * Remove a particle system for the list of scene's particle systems
  42004. * @param toRemove defines the particle system to remove
  42005. * @returns the index where the particle system was in the particle system list
  42006. */
  42007. removeParticleSystem(toRemove: IParticleSystem): number;
  42008. /**
  42009. * Remove a animation for the list of scene's animations
  42010. * @param toRemove defines the animation to remove
  42011. * @returns the index where the animation was in the animation list
  42012. */
  42013. removeAnimation(toRemove: Animation): number;
  42014. /**
  42015. * Will stop the animation of the given target
  42016. * @param target - the target
  42017. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42018. * @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)
  42019. */
  42020. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42021. /**
  42022. * Removes the given animation group from this scene.
  42023. * @param toRemove The animation group to remove
  42024. * @returns The index of the removed animation group
  42025. */
  42026. removeAnimationGroup(toRemove: AnimationGroup): number;
  42027. /**
  42028. * Removes the given multi-material from this scene.
  42029. * @param toRemove The multi-material to remove
  42030. * @returns The index of the removed multi-material
  42031. */
  42032. removeMultiMaterial(toRemove: MultiMaterial): number;
  42033. /**
  42034. * Removes the given material from this scene.
  42035. * @param toRemove The material to remove
  42036. * @returns The index of the removed material
  42037. */
  42038. removeMaterial(toRemove: Material): number;
  42039. /**
  42040. * Removes the given action manager from this scene.
  42041. * @param toRemove The action manager to remove
  42042. * @returns The index of the removed action manager
  42043. */
  42044. removeActionManager(toRemove: AbstractActionManager): number;
  42045. /**
  42046. * Removes the given texture from this scene.
  42047. * @param toRemove The texture to remove
  42048. * @returns The index of the removed texture
  42049. */
  42050. removeTexture(toRemove: BaseTexture): number;
  42051. /**
  42052. * Adds the given light to this scene
  42053. * @param newLight The light to add
  42054. */
  42055. addLight(newLight: Light): void;
  42056. /**
  42057. * Sorts the list list based on light priorities
  42058. */
  42059. sortLightsByPriority(): void;
  42060. /**
  42061. * Adds the given camera to this scene
  42062. * @param newCamera The camera to add
  42063. */
  42064. addCamera(newCamera: Camera): void;
  42065. /**
  42066. * Adds the given skeleton to this scene
  42067. * @param newSkeleton The skeleton to add
  42068. */
  42069. addSkeleton(newSkeleton: Skeleton): void;
  42070. /**
  42071. * Adds the given particle system to this scene
  42072. * @param newParticleSystem The particle system to add
  42073. */
  42074. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42075. /**
  42076. * Adds the given animation to this scene
  42077. * @param newAnimation The animation to add
  42078. */
  42079. addAnimation(newAnimation: Animation): void;
  42080. /**
  42081. * Adds the given animation group to this scene.
  42082. * @param newAnimationGroup The animation group to add
  42083. */
  42084. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42085. /**
  42086. * Adds the given multi-material to this scene
  42087. * @param newMultiMaterial The multi-material to add
  42088. */
  42089. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42090. /**
  42091. * Adds the given material to this scene
  42092. * @param newMaterial The material to add
  42093. */
  42094. addMaterial(newMaterial: Material): void;
  42095. /**
  42096. * Adds the given morph target to this scene
  42097. * @param newMorphTargetManager The morph target to add
  42098. */
  42099. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42100. /**
  42101. * Adds the given geometry to this scene
  42102. * @param newGeometry The geometry to add
  42103. */
  42104. addGeometry(newGeometry: Geometry): void;
  42105. /**
  42106. * Adds the given action manager to this scene
  42107. * @param newActionManager The action manager to add
  42108. */
  42109. addActionManager(newActionManager: AbstractActionManager): void;
  42110. /**
  42111. * Adds the given texture to this scene.
  42112. * @param newTexture The texture to add
  42113. */
  42114. addTexture(newTexture: BaseTexture): void;
  42115. /**
  42116. * Switch active camera
  42117. * @param newCamera defines the new active camera
  42118. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42119. */
  42120. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42121. /**
  42122. * sets the active camera of the scene using its ID
  42123. * @param id defines the camera's ID
  42124. * @return the new active camera or null if none found.
  42125. */
  42126. setActiveCameraByID(id: string): Nullable<Camera>;
  42127. /**
  42128. * sets the active camera of the scene using its name
  42129. * @param name defines the camera's name
  42130. * @returns the new active camera or null if none found.
  42131. */
  42132. setActiveCameraByName(name: string): Nullable<Camera>;
  42133. /**
  42134. * get an animation group using its name
  42135. * @param name defines the material's name
  42136. * @return the animation group or null if none found.
  42137. */
  42138. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42139. /**
  42140. * Get a material using its unique id
  42141. * @param uniqueId defines the material's unique id
  42142. * @return the material or null if none found.
  42143. */
  42144. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42145. /**
  42146. * get a material using its id
  42147. * @param id defines the material's ID
  42148. * @return the material or null if none found.
  42149. */
  42150. getMaterialByID(id: string): Nullable<Material>;
  42151. /**
  42152. * Gets a the last added material using a given id
  42153. * @param id defines the material's ID
  42154. * @return the last material with the given id or null if none found.
  42155. */
  42156. getLastMaterialByID(id: string): Nullable<Material>;
  42157. /**
  42158. * Gets a material using its name
  42159. * @param name defines the material's name
  42160. * @return the material or null if none found.
  42161. */
  42162. getMaterialByName(name: string): Nullable<Material>;
  42163. /**
  42164. * Get a texture using its unique id
  42165. * @param uniqueId defines the texture's unique id
  42166. * @return the texture or null if none found.
  42167. */
  42168. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42169. /**
  42170. * Gets a camera using its id
  42171. * @param id defines the id to look for
  42172. * @returns the camera or null if not found
  42173. */
  42174. getCameraByID(id: string): Nullable<Camera>;
  42175. /**
  42176. * Gets a camera using its unique id
  42177. * @param uniqueId defines the unique id to look for
  42178. * @returns the camera or null if not found
  42179. */
  42180. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42181. /**
  42182. * Gets a camera using its name
  42183. * @param name defines the camera's name
  42184. * @return the camera or null if none found.
  42185. */
  42186. getCameraByName(name: string): Nullable<Camera>;
  42187. /**
  42188. * Gets a bone using its id
  42189. * @param id defines the bone's id
  42190. * @return the bone or null if not found
  42191. */
  42192. getBoneByID(id: string): Nullable<Bone>;
  42193. /**
  42194. * Gets a bone using its id
  42195. * @param name defines the bone's name
  42196. * @return the bone or null if not found
  42197. */
  42198. getBoneByName(name: string): Nullable<Bone>;
  42199. /**
  42200. * Gets a light node using its name
  42201. * @param name defines the the light's name
  42202. * @return the light or null if none found.
  42203. */
  42204. getLightByName(name: string): Nullable<Light>;
  42205. /**
  42206. * Gets a light node using its id
  42207. * @param id defines the light's id
  42208. * @return the light or null if none found.
  42209. */
  42210. getLightByID(id: string): Nullable<Light>;
  42211. /**
  42212. * Gets a light node using its scene-generated unique ID
  42213. * @param uniqueId defines the light's unique id
  42214. * @return the light or null if none found.
  42215. */
  42216. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42217. /**
  42218. * Gets a particle system by id
  42219. * @param id defines the particle system id
  42220. * @return the corresponding system or null if none found
  42221. */
  42222. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42223. /**
  42224. * Gets a geometry using its ID
  42225. * @param id defines the geometry's id
  42226. * @return the geometry or null if none found.
  42227. */
  42228. getGeometryByID(id: string): Nullable<Geometry>;
  42229. private _getGeometryByUniqueID;
  42230. /**
  42231. * Add a new geometry to this scene
  42232. * @param geometry defines the geometry to be added to the scene.
  42233. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42234. * @return a boolean defining if the geometry was added or not
  42235. */
  42236. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42237. /**
  42238. * Removes an existing geometry
  42239. * @param geometry defines the geometry to be removed from the scene
  42240. * @return a boolean defining if the geometry was removed or not
  42241. */
  42242. removeGeometry(geometry: Geometry): boolean;
  42243. /**
  42244. * Gets the list of geometries attached to the scene
  42245. * @returns an array of Geometry
  42246. */
  42247. getGeometries(): Geometry[];
  42248. /**
  42249. * Gets the first added mesh found of a given ID
  42250. * @param id defines the id to search for
  42251. * @return the mesh found or null if not found at all
  42252. */
  42253. getMeshByID(id: string): Nullable<AbstractMesh>;
  42254. /**
  42255. * Gets a list of meshes using their id
  42256. * @param id defines the id to search for
  42257. * @returns a list of meshes
  42258. */
  42259. getMeshesByID(id: string): Array<AbstractMesh>;
  42260. /**
  42261. * Gets the first added transform node found of a given ID
  42262. * @param id defines the id to search for
  42263. * @return the found transform node or null if not found at all.
  42264. */
  42265. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42266. /**
  42267. * Gets a transform node with its auto-generated unique id
  42268. * @param uniqueId efines the unique id to search for
  42269. * @return the found transform node or null if not found at all.
  42270. */
  42271. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42272. /**
  42273. * Gets a list of transform nodes using their id
  42274. * @param id defines the id to search for
  42275. * @returns a list of transform nodes
  42276. */
  42277. getTransformNodesByID(id: string): Array<TransformNode>;
  42278. /**
  42279. * Gets a mesh with its auto-generated unique id
  42280. * @param uniqueId defines the unique id to search for
  42281. * @return the found mesh or null if not found at all.
  42282. */
  42283. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42284. /**
  42285. * Gets a the last added mesh using a given id
  42286. * @param id defines the id to search for
  42287. * @return the found mesh or null if not found at all.
  42288. */
  42289. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42290. /**
  42291. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42292. * @param id defines the id to search for
  42293. * @return the found node or null if not found at all
  42294. */
  42295. getLastEntryByID(id: string): Nullable<Node>;
  42296. /**
  42297. * Gets a node (Mesh, Camera, Light) using a given id
  42298. * @param id defines the id to search for
  42299. * @return the found node or null if not found at all
  42300. */
  42301. getNodeByID(id: string): Nullable<Node>;
  42302. /**
  42303. * Gets a node (Mesh, Camera, Light) using a given name
  42304. * @param name defines the name to search for
  42305. * @return the found node or null if not found at all.
  42306. */
  42307. getNodeByName(name: string): Nullable<Node>;
  42308. /**
  42309. * Gets a mesh using a given name
  42310. * @param name defines the name to search for
  42311. * @return the found mesh or null if not found at all.
  42312. */
  42313. getMeshByName(name: string): Nullable<AbstractMesh>;
  42314. /**
  42315. * Gets a transform node using a given name
  42316. * @param name defines the name to search for
  42317. * @return the found transform node or null if not found at all.
  42318. */
  42319. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42320. /**
  42321. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42322. * @param id defines the id to search for
  42323. * @return the found skeleton or null if not found at all.
  42324. */
  42325. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42326. /**
  42327. * Gets a skeleton using a given auto generated unique id
  42328. * @param uniqueId defines the unique id to search for
  42329. * @return the found skeleton or null if not found at all.
  42330. */
  42331. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42332. /**
  42333. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42334. * @param id defines the id to search for
  42335. * @return the found skeleton or null if not found at all.
  42336. */
  42337. getSkeletonById(id: string): Nullable<Skeleton>;
  42338. /**
  42339. * Gets a skeleton using a given name
  42340. * @param name defines the name to search for
  42341. * @return the found skeleton or null if not found at all.
  42342. */
  42343. getSkeletonByName(name: string): Nullable<Skeleton>;
  42344. /**
  42345. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42346. * @param id defines the id to search for
  42347. * @return the found morph target manager or null if not found at all.
  42348. */
  42349. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42350. /**
  42351. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42352. * @param id defines the id to search for
  42353. * @return the found morph target or null if not found at all.
  42354. */
  42355. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42356. /**
  42357. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42358. * @param name defines the name to search for
  42359. * @return the found morph target or null if not found at all.
  42360. */
  42361. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42362. /**
  42363. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42364. * @param name defines the name to search for
  42365. * @return the found post process or null if not found at all.
  42366. */
  42367. getPostProcessByName(name: string): Nullable<PostProcess>;
  42368. /**
  42369. * Gets a boolean indicating if the given mesh is active
  42370. * @param mesh defines the mesh to look for
  42371. * @returns true if the mesh is in the active list
  42372. */
  42373. isActiveMesh(mesh: AbstractMesh): boolean;
  42374. /**
  42375. * Return a unique id as a string which can serve as an identifier for the scene
  42376. */
  42377. get uid(): string;
  42378. /**
  42379. * Add an externaly attached data from its key.
  42380. * This method call will fail and return false, if such key already exists.
  42381. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42382. * @param key the unique key that identifies the data
  42383. * @param data the data object to associate to the key for this Engine instance
  42384. * @return true if no such key were already present and the data was added successfully, false otherwise
  42385. */
  42386. addExternalData<T>(key: string, data: T): boolean;
  42387. /**
  42388. * Get an externaly attached data from its key
  42389. * @param key the unique key that identifies the data
  42390. * @return the associated data, if present (can be null), or undefined if not present
  42391. */
  42392. getExternalData<T>(key: string): Nullable<T>;
  42393. /**
  42394. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42395. * @param key the unique key that identifies the data
  42396. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42397. * @return the associated data, can be null if the factory returned null.
  42398. */
  42399. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42400. /**
  42401. * Remove an externaly attached data from the Engine instance
  42402. * @param key the unique key that identifies the data
  42403. * @return true if the data was successfully removed, false if it doesn't exist
  42404. */
  42405. removeExternalData(key: string): boolean;
  42406. private _evaluateSubMesh;
  42407. /**
  42408. * Clear the processed materials smart array preventing retention point in material dispose.
  42409. */
  42410. freeProcessedMaterials(): void;
  42411. private _preventFreeActiveMeshesAndRenderingGroups;
  42412. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42413. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42414. * when disposing several meshes in a row or a hierarchy of meshes.
  42415. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42416. */
  42417. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42418. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42419. /**
  42420. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42421. */
  42422. freeActiveMeshes(): void;
  42423. /**
  42424. * Clear the info related to rendering groups preventing retention points during dispose.
  42425. */
  42426. freeRenderingGroups(): void;
  42427. /** @hidden */
  42428. _isInIntermediateRendering(): boolean;
  42429. /**
  42430. * Lambda returning the list of potentially active meshes.
  42431. */
  42432. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42433. /**
  42434. * Lambda returning the list of potentially active sub meshes.
  42435. */
  42436. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42437. /**
  42438. * Lambda returning the list of potentially intersecting sub meshes.
  42439. */
  42440. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42441. /**
  42442. * Lambda returning the list of potentially colliding sub meshes.
  42443. */
  42444. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42445. private _activeMeshesFrozen;
  42446. private _skipEvaluateActiveMeshesCompletely;
  42447. /**
  42448. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42449. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42450. * @returns the current scene
  42451. */
  42452. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42453. /**
  42454. * Use this function to restart evaluating active meshes on every frame
  42455. * @returns the current scene
  42456. */
  42457. unfreezeActiveMeshes(): Scene;
  42458. private _evaluateActiveMeshes;
  42459. private _activeMesh;
  42460. /**
  42461. * Update the transform matrix to update from the current active camera
  42462. * @param force defines a boolean used to force the update even if cache is up to date
  42463. */
  42464. updateTransformMatrix(force?: boolean): void;
  42465. private _bindFrameBuffer;
  42466. /** @hidden */
  42467. _allowPostProcessClearColor: boolean;
  42468. /** @hidden */
  42469. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42470. private _processSubCameras;
  42471. private _checkIntersections;
  42472. /** @hidden */
  42473. _advancePhysicsEngineStep(step: number): void;
  42474. /**
  42475. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42476. */
  42477. getDeterministicFrameTime: () => number;
  42478. /** @hidden */
  42479. _animate(): void;
  42480. /** Execute all animations (for a frame) */
  42481. animate(): void;
  42482. /**
  42483. * Render the scene
  42484. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42485. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42486. */
  42487. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42488. /**
  42489. * Freeze all materials
  42490. * A frozen material will not be updatable but should be faster to render
  42491. */
  42492. freezeMaterials(): void;
  42493. /**
  42494. * Unfreeze all materials
  42495. * A frozen material will not be updatable but should be faster to render
  42496. */
  42497. unfreezeMaterials(): void;
  42498. /**
  42499. * Releases all held ressources
  42500. */
  42501. dispose(): void;
  42502. /**
  42503. * Gets if the scene is already disposed
  42504. */
  42505. get isDisposed(): boolean;
  42506. /**
  42507. * Call this function to reduce memory footprint of the scene.
  42508. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42509. */
  42510. clearCachedVertexData(): void;
  42511. /**
  42512. * This function will remove the local cached buffer data from texture.
  42513. * It will save memory but will prevent the texture from being rebuilt
  42514. */
  42515. cleanCachedTextureBuffer(): void;
  42516. /**
  42517. * Get the world extend vectors with an optional filter
  42518. *
  42519. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42520. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42521. */
  42522. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42523. min: Vector3;
  42524. max: Vector3;
  42525. };
  42526. /**
  42527. * Creates a ray that can be used to pick in the scene
  42528. * @param x defines the x coordinate of the origin (on-screen)
  42529. * @param y defines the y coordinate of the origin (on-screen)
  42530. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42531. * @param camera defines the camera to use for the picking
  42532. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42533. * @returns a Ray
  42534. */
  42535. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42536. /**
  42537. * Creates a ray that can be used to pick in the scene
  42538. * @param x defines the x coordinate of the origin (on-screen)
  42539. * @param y defines the y coordinate of the origin (on-screen)
  42540. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42541. * @param result defines the ray where to store the picking ray
  42542. * @param camera defines the camera to use for the picking
  42543. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42544. * @returns the current scene
  42545. */
  42546. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42547. /**
  42548. * Creates a ray that can be used to pick in the scene
  42549. * @param x defines the x coordinate of the origin (on-screen)
  42550. * @param y defines the y coordinate of the origin (on-screen)
  42551. * @param camera defines the camera to use for the picking
  42552. * @returns a Ray
  42553. */
  42554. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42555. /**
  42556. * Creates a ray that can be used to pick in the scene
  42557. * @param x defines the x coordinate of the origin (on-screen)
  42558. * @param y defines the y coordinate of the origin (on-screen)
  42559. * @param result defines the ray where to store the picking ray
  42560. * @param camera defines the camera to use for the picking
  42561. * @returns the current scene
  42562. */
  42563. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42564. /** Launch a ray to try to pick a mesh in the scene
  42565. * @param x position on screen
  42566. * @param y position on screen
  42567. * @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
  42568. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42569. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42570. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42571. * @returns a PickingInfo
  42572. */
  42573. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42574. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42575. * @param x position on screen
  42576. * @param y position on screen
  42577. * @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
  42578. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42579. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42580. * @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)
  42581. */
  42582. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42583. /** Use the given ray to pick a mesh in the scene
  42584. * @param ray The ray to use to pick meshes
  42585. * @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
  42586. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42587. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42588. * @returns a PickingInfo
  42589. */
  42590. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42591. /**
  42592. * Launch a ray to try to pick a mesh in the scene
  42593. * @param x X position on screen
  42594. * @param y Y position on screen
  42595. * @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
  42596. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42597. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42598. * @returns an array of PickingInfo
  42599. */
  42600. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42601. /**
  42602. * Launch a ray to try to pick a mesh in the scene
  42603. * @param ray Ray to use
  42604. * @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
  42605. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42606. * @returns an array of PickingInfo
  42607. */
  42608. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42609. /**
  42610. * Force the value of meshUnderPointer
  42611. * @param mesh defines the mesh to use
  42612. * @param pointerId optional pointer id when using more than one pointer
  42613. */
  42614. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42615. /**
  42616. * Gets the mesh under the pointer
  42617. * @returns a Mesh or null if no mesh is under the pointer
  42618. */
  42619. getPointerOverMesh(): Nullable<AbstractMesh>;
  42620. /** @hidden */
  42621. _rebuildGeometries(): void;
  42622. /** @hidden */
  42623. _rebuildTextures(): void;
  42624. private _getByTags;
  42625. /**
  42626. * Get a list of meshes by tags
  42627. * @param tagsQuery defines the tags query to use
  42628. * @param forEach defines a predicate used to filter results
  42629. * @returns an array of Mesh
  42630. */
  42631. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42632. /**
  42633. * Get a list of cameras by tags
  42634. * @param tagsQuery defines the tags query to use
  42635. * @param forEach defines a predicate used to filter results
  42636. * @returns an array of Camera
  42637. */
  42638. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42639. /**
  42640. * Get a list of lights by tags
  42641. * @param tagsQuery defines the tags query to use
  42642. * @param forEach defines a predicate used to filter results
  42643. * @returns an array of Light
  42644. */
  42645. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42646. /**
  42647. * Get a list of materials by tags
  42648. * @param tagsQuery defines the tags query to use
  42649. * @param forEach defines a predicate used to filter results
  42650. * @returns an array of Material
  42651. */
  42652. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42653. /**
  42654. * Get a list of transform nodes by tags
  42655. * @param tagsQuery defines the tags query to use
  42656. * @param forEach defines a predicate used to filter results
  42657. * @returns an array of TransformNode
  42658. */
  42659. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42660. /**
  42661. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42662. * This allowed control for front to back rendering or reversly depending of the special needs.
  42663. *
  42664. * @param renderingGroupId The rendering group id corresponding to its index
  42665. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42666. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42667. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42668. */
  42669. 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;
  42670. /**
  42671. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42672. *
  42673. * @param renderingGroupId The rendering group id corresponding to its index
  42674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42675. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42676. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42677. */
  42678. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42679. /**
  42680. * Gets the current auto clear configuration for one rendering group of the rendering
  42681. * manager.
  42682. * @param index the rendering group index to get the information for
  42683. * @returns The auto clear setup for the requested rendering group
  42684. */
  42685. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42686. private _blockMaterialDirtyMechanism;
  42687. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42688. get blockMaterialDirtyMechanism(): boolean;
  42689. set blockMaterialDirtyMechanism(value: boolean);
  42690. /**
  42691. * Will flag all materials as dirty to trigger new shader compilation
  42692. * @param flag defines the flag used to specify which material part must be marked as dirty
  42693. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42694. */
  42695. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42696. /** @hidden */
  42697. _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;
  42698. /** @hidden */
  42699. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42700. /** @hidden */
  42701. _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;
  42702. /** @hidden */
  42703. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42704. /** @hidden */
  42705. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42706. /** @hidden */
  42707. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42708. }
  42709. }
  42710. declare module "babylonjs/assetContainer" {
  42711. import { AbstractScene } from "babylonjs/abstractScene";
  42712. import { Scene } from "babylonjs/scene";
  42713. import { Mesh } from "babylonjs/Meshes/mesh";
  42714. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42715. import { Skeleton } from "babylonjs/Bones/skeleton";
  42716. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42717. import { Animatable } from "babylonjs/Animations/animatable";
  42718. import { Nullable } from "babylonjs/types";
  42719. import { Node } from "babylonjs/node";
  42720. /**
  42721. * Set of assets to keep when moving a scene into an asset container.
  42722. */
  42723. export class KeepAssets extends AbstractScene {
  42724. }
  42725. /**
  42726. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42727. */
  42728. export class InstantiatedEntries {
  42729. /**
  42730. * List of new root nodes (eg. nodes with no parent)
  42731. */
  42732. rootNodes: TransformNode[];
  42733. /**
  42734. * List of new skeletons
  42735. */
  42736. skeletons: Skeleton[];
  42737. /**
  42738. * List of new animation groups
  42739. */
  42740. animationGroups: AnimationGroup[];
  42741. }
  42742. /**
  42743. * Container with a set of assets that can be added or removed from a scene.
  42744. */
  42745. export class AssetContainer extends AbstractScene {
  42746. private _wasAddedToScene;
  42747. /**
  42748. * The scene the AssetContainer belongs to.
  42749. */
  42750. scene: Scene;
  42751. /**
  42752. * Instantiates an AssetContainer.
  42753. * @param scene The scene the AssetContainer belongs to.
  42754. */
  42755. constructor(scene: Scene);
  42756. /**
  42757. * Instantiate or clone all meshes and add the new ones to the scene.
  42758. * Skeletons and animation groups will all be cloned
  42759. * @param nameFunction defines an optional function used to get new names for clones
  42760. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42761. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42762. */
  42763. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42764. /**
  42765. * Adds all the assets from the container to the scene.
  42766. */
  42767. addAllToScene(): void;
  42768. /**
  42769. * Removes all the assets in the container from the scene
  42770. */
  42771. removeAllFromScene(): void;
  42772. /**
  42773. * Disposes all the assets in the container
  42774. */
  42775. dispose(): void;
  42776. private _moveAssets;
  42777. /**
  42778. * Removes all the assets contained in the scene and adds them to the container.
  42779. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42780. */
  42781. moveAllFromScene(keepAssets?: KeepAssets): void;
  42782. /**
  42783. * 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.
  42784. * @returns the root mesh
  42785. */
  42786. createRootMesh(): Mesh;
  42787. /**
  42788. * Merge animations (direct and animation groups) from this asset container into a scene
  42789. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42790. * @param animatables set of animatables to retarget to a node from the scene
  42791. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42792. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42793. */
  42794. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42795. }
  42796. }
  42797. declare module "babylonjs/abstractScene" {
  42798. import { Scene } from "babylonjs/scene";
  42799. import { Nullable } from "babylonjs/types";
  42800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42801. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42802. import { Geometry } from "babylonjs/Meshes/geometry";
  42803. import { Skeleton } from "babylonjs/Bones/skeleton";
  42804. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42805. import { AssetContainer } from "babylonjs/assetContainer";
  42806. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42807. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42809. import { Material } from "babylonjs/Materials/material";
  42810. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42811. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42812. import { Camera } from "babylonjs/Cameras/camera";
  42813. import { Light } from "babylonjs/Lights/light";
  42814. import { Node } from "babylonjs/node";
  42815. import { Animation } from "babylonjs/Animations/animation";
  42816. /**
  42817. * Defines how the parser contract is defined.
  42818. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42819. */
  42820. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42821. /**
  42822. * Defines how the individual parser contract is defined.
  42823. * These parser can parse an individual asset
  42824. */
  42825. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42826. /**
  42827. * Base class of the scene acting as a container for the different elements composing a scene.
  42828. * This class is dynamically extended by the different components of the scene increasing
  42829. * flexibility and reducing coupling
  42830. */
  42831. export abstract class AbstractScene {
  42832. /**
  42833. * Stores the list of available parsers in the application.
  42834. */
  42835. private static _BabylonFileParsers;
  42836. /**
  42837. * Stores the list of available individual parsers in the application.
  42838. */
  42839. private static _IndividualBabylonFileParsers;
  42840. /**
  42841. * Adds a parser in the list of available ones
  42842. * @param name Defines the name of the parser
  42843. * @param parser Defines the parser to add
  42844. */
  42845. static AddParser(name: string, parser: BabylonFileParser): void;
  42846. /**
  42847. * Gets a general parser from the list of avaialble ones
  42848. * @param name Defines the name of the parser
  42849. * @returns the requested parser or null
  42850. */
  42851. static GetParser(name: string): Nullable<BabylonFileParser>;
  42852. /**
  42853. * Adds n individual parser in the list of available ones
  42854. * @param name Defines the name of the parser
  42855. * @param parser Defines the parser to add
  42856. */
  42857. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42858. /**
  42859. * Gets an individual parser from the list of avaialble ones
  42860. * @param name Defines the name of the parser
  42861. * @returns the requested parser or null
  42862. */
  42863. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42864. /**
  42865. * Parser json data and populate both a scene and its associated container object
  42866. * @param jsonData Defines the data to parse
  42867. * @param scene Defines the scene to parse the data for
  42868. * @param container Defines the container attached to the parsing sequence
  42869. * @param rootUrl Defines the root url of the data
  42870. */
  42871. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42872. /**
  42873. * Gets the list of root nodes (ie. nodes with no parent)
  42874. */
  42875. rootNodes: Node[];
  42876. /** All of the cameras added to this scene
  42877. * @see https://doc.babylonjs.com/babylon101/cameras
  42878. */
  42879. cameras: Camera[];
  42880. /**
  42881. * All of the lights added to this scene
  42882. * @see https://doc.babylonjs.com/babylon101/lights
  42883. */
  42884. lights: Light[];
  42885. /**
  42886. * All of the (abstract) meshes added to this scene
  42887. */
  42888. meshes: AbstractMesh[];
  42889. /**
  42890. * The list of skeletons added to the scene
  42891. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  42892. */
  42893. skeletons: Skeleton[];
  42894. /**
  42895. * All of the particle systems added to this scene
  42896. * @see https://doc.babylonjs.com/babylon101/particles
  42897. */
  42898. particleSystems: IParticleSystem[];
  42899. /**
  42900. * Gets a list of Animations associated with the scene
  42901. */
  42902. animations: Animation[];
  42903. /**
  42904. * All of the animation groups added to this scene
  42905. * @see https://doc.babylonjs.com/how_to/group
  42906. */
  42907. animationGroups: AnimationGroup[];
  42908. /**
  42909. * All of the multi-materials added to this scene
  42910. * @see https://doc.babylonjs.com/how_to/multi_materials
  42911. */
  42912. multiMaterials: MultiMaterial[];
  42913. /**
  42914. * All of the materials added to this scene
  42915. * In the context of a Scene, it is not supposed to be modified manually.
  42916. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  42917. * Note also that the order of the Material within the array is not significant and might change.
  42918. * @see https://doc.babylonjs.com/babylon101/materials
  42919. */
  42920. materials: Material[];
  42921. /**
  42922. * The list of morph target managers added to the scene
  42923. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  42924. */
  42925. morphTargetManagers: MorphTargetManager[];
  42926. /**
  42927. * The list of geometries used in the scene.
  42928. */
  42929. geometries: Geometry[];
  42930. /**
  42931. * All of the tranform nodes added to this scene
  42932. * In the context of a Scene, it is not supposed to be modified manually.
  42933. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  42934. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  42935. * @see https://doc.babylonjs.com/how_to/transformnode
  42936. */
  42937. transformNodes: TransformNode[];
  42938. /**
  42939. * ActionManagers available on the scene.
  42940. */
  42941. actionManagers: AbstractActionManager[];
  42942. /**
  42943. * Textures to keep.
  42944. */
  42945. textures: BaseTexture[];
  42946. /** @hidden */
  42947. protected _environmentTexture: Nullable<BaseTexture>;
  42948. /**
  42949. * Texture used in all pbr material as the reflection texture.
  42950. * As in the majority of the scene they are the same (exception for multi room and so on),
  42951. * this is easier to reference from here than from all the materials.
  42952. */
  42953. get environmentTexture(): Nullable<BaseTexture>;
  42954. set environmentTexture(value: Nullable<BaseTexture>);
  42955. /**
  42956. * The list of postprocesses added to the scene
  42957. */
  42958. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  42959. /**
  42960. * @returns all meshes, lights, cameras, transformNodes and bones
  42961. */
  42962. getNodes(): Array<Node>;
  42963. }
  42964. }
  42965. declare module "babylonjs/Audio/sound" {
  42966. import { Observable } from "babylonjs/Misc/observable";
  42967. import { Vector3 } from "babylonjs/Maths/math.vector";
  42968. import { Nullable } from "babylonjs/types";
  42969. import { Scene } from "babylonjs/scene";
  42970. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42971. /**
  42972. * Interface used to define options for Sound class
  42973. */
  42974. export interface ISoundOptions {
  42975. /**
  42976. * Does the sound autoplay once loaded.
  42977. */
  42978. autoplay?: boolean;
  42979. /**
  42980. * Does the sound loop after it finishes playing once.
  42981. */
  42982. loop?: boolean;
  42983. /**
  42984. * Sound's volume
  42985. */
  42986. volume?: number;
  42987. /**
  42988. * Is it a spatial sound?
  42989. */
  42990. spatialSound?: boolean;
  42991. /**
  42992. * Maximum distance to hear that sound
  42993. */
  42994. maxDistance?: number;
  42995. /**
  42996. * Uses user defined attenuation function
  42997. */
  42998. useCustomAttenuation?: boolean;
  42999. /**
  43000. * Define the roll off factor of spatial sounds.
  43001. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43002. */
  43003. rolloffFactor?: number;
  43004. /**
  43005. * Define the reference distance the sound should be heard perfectly.
  43006. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43007. */
  43008. refDistance?: number;
  43009. /**
  43010. * Define the distance attenuation model the sound will follow.
  43011. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43012. */
  43013. distanceModel?: string;
  43014. /**
  43015. * Defines the playback speed (1 by default)
  43016. */
  43017. playbackRate?: number;
  43018. /**
  43019. * Defines if the sound is from a streaming source
  43020. */
  43021. streaming?: boolean;
  43022. /**
  43023. * Defines an optional length (in seconds) inside the sound file
  43024. */
  43025. length?: number;
  43026. /**
  43027. * Defines an optional offset (in seconds) inside the sound file
  43028. */
  43029. offset?: number;
  43030. /**
  43031. * If true, URLs will not be required to state the audio file codec to use.
  43032. */
  43033. skipCodecCheck?: boolean;
  43034. }
  43035. /**
  43036. * Defines a sound that can be played in the application.
  43037. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43038. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43039. */
  43040. export class Sound {
  43041. /**
  43042. * The name of the sound in the scene.
  43043. */
  43044. name: string;
  43045. /**
  43046. * Does the sound autoplay once loaded.
  43047. */
  43048. autoplay: boolean;
  43049. /**
  43050. * Does the sound loop after it finishes playing once.
  43051. */
  43052. loop: boolean;
  43053. /**
  43054. * Does the sound use a custom attenuation curve to simulate the falloff
  43055. * happening when the source gets further away from the camera.
  43056. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43057. */
  43058. useCustomAttenuation: boolean;
  43059. /**
  43060. * The sound track id this sound belongs to.
  43061. */
  43062. soundTrackId: number;
  43063. /**
  43064. * Is this sound currently played.
  43065. */
  43066. isPlaying: boolean;
  43067. /**
  43068. * Is this sound currently paused.
  43069. */
  43070. isPaused: boolean;
  43071. /**
  43072. * Does this sound enables spatial sound.
  43073. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43074. */
  43075. spatialSound: boolean;
  43076. /**
  43077. * Define the reference distance the sound should be heard perfectly.
  43078. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43079. */
  43080. refDistance: number;
  43081. /**
  43082. * Define the roll off factor of spatial sounds.
  43083. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43084. */
  43085. rolloffFactor: number;
  43086. /**
  43087. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43088. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43089. */
  43090. maxDistance: number;
  43091. /**
  43092. * Define the distance attenuation model the sound will follow.
  43093. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43094. */
  43095. distanceModel: string;
  43096. /**
  43097. * @hidden
  43098. * Back Compat
  43099. **/
  43100. onended: () => any;
  43101. /**
  43102. * Gets or sets an object used to store user defined information for the sound.
  43103. */
  43104. metadata: any;
  43105. /**
  43106. * Observable event when the current playing sound finishes.
  43107. */
  43108. onEndedObservable: Observable<Sound>;
  43109. private _panningModel;
  43110. private _playbackRate;
  43111. private _streaming;
  43112. private _startTime;
  43113. private _startOffset;
  43114. private _position;
  43115. /** @hidden */
  43116. _positionInEmitterSpace: boolean;
  43117. private _localDirection;
  43118. private _volume;
  43119. private _isReadyToPlay;
  43120. private _isDirectional;
  43121. private _readyToPlayCallback;
  43122. private _audioBuffer;
  43123. private _soundSource;
  43124. private _streamingSource;
  43125. private _soundPanner;
  43126. private _soundGain;
  43127. private _inputAudioNode;
  43128. private _outputAudioNode;
  43129. private _coneInnerAngle;
  43130. private _coneOuterAngle;
  43131. private _coneOuterGain;
  43132. private _scene;
  43133. private _connectedTransformNode;
  43134. private _customAttenuationFunction;
  43135. private _registerFunc;
  43136. private _isOutputConnected;
  43137. private _htmlAudioElement;
  43138. private _urlType;
  43139. private _length?;
  43140. private _offset?;
  43141. /** @hidden */
  43142. static _SceneComponentInitialization: (scene: Scene) => void;
  43143. /**
  43144. * Create a sound and attach it to a scene
  43145. * @param name Name of your sound
  43146. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43147. * @param scene defines the scene the sound belongs to
  43148. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43149. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43150. */
  43151. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43152. /**
  43153. * Release the sound and its associated resources
  43154. */
  43155. dispose(): void;
  43156. /**
  43157. * Gets if the sounds is ready to be played or not.
  43158. * @returns true if ready, otherwise false
  43159. */
  43160. isReady(): boolean;
  43161. private _soundLoaded;
  43162. /**
  43163. * Sets the data of the sound from an audiobuffer
  43164. * @param audioBuffer The audioBuffer containing the data
  43165. */
  43166. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43167. /**
  43168. * Updates the current sounds options such as maxdistance, loop...
  43169. * @param options A JSON object containing values named as the object properties
  43170. */
  43171. updateOptions(options: ISoundOptions): void;
  43172. private _createSpatialParameters;
  43173. private _updateSpatialParameters;
  43174. /**
  43175. * Switch the panning model to HRTF:
  43176. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43177. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43178. */
  43179. switchPanningModelToHRTF(): void;
  43180. /**
  43181. * Switch the panning model to Equal Power:
  43182. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43183. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43184. */
  43185. switchPanningModelToEqualPower(): void;
  43186. private _switchPanningModel;
  43187. /**
  43188. * Connect this sound to a sound track audio node like gain...
  43189. * @param soundTrackAudioNode the sound track audio node to connect to
  43190. */
  43191. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43192. /**
  43193. * Transform this sound into a directional source
  43194. * @param coneInnerAngle Size of the inner cone in degree
  43195. * @param coneOuterAngle Size of the outer cone in degree
  43196. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43197. */
  43198. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43199. /**
  43200. * Gets or sets the inner angle for the directional cone.
  43201. */
  43202. get directionalConeInnerAngle(): number;
  43203. /**
  43204. * Gets or sets the inner angle for the directional cone.
  43205. */
  43206. set directionalConeInnerAngle(value: number);
  43207. /**
  43208. * Gets or sets the outer angle for the directional cone.
  43209. */
  43210. get directionalConeOuterAngle(): number;
  43211. /**
  43212. * Gets or sets the outer angle for the directional cone.
  43213. */
  43214. set directionalConeOuterAngle(value: number);
  43215. /**
  43216. * Sets the position of the emitter if spatial sound is enabled
  43217. * @param newPosition Defines the new posisiton
  43218. */
  43219. setPosition(newPosition: Vector3): void;
  43220. /**
  43221. * Sets the local direction of the emitter if spatial sound is enabled
  43222. * @param newLocalDirection Defines the new local direction
  43223. */
  43224. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43225. private _updateDirection;
  43226. /** @hidden */
  43227. updateDistanceFromListener(): void;
  43228. /**
  43229. * Sets a new custom attenuation function for the sound.
  43230. * @param callback Defines the function used for the attenuation
  43231. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43232. */
  43233. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43234. /**
  43235. * Play the sound
  43236. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43237. * @param offset (optional) Start the sound at a specific time in seconds
  43238. * @param length (optional) Sound duration (in seconds)
  43239. */
  43240. play(time?: number, offset?: number, length?: number): void;
  43241. private _onended;
  43242. /**
  43243. * Stop the sound
  43244. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43245. */
  43246. stop(time?: number): void;
  43247. /**
  43248. * Put the sound in pause
  43249. */
  43250. pause(): void;
  43251. /**
  43252. * Sets a dedicated volume for this sounds
  43253. * @param newVolume Define the new volume of the sound
  43254. * @param time Define time for gradual change to new volume
  43255. */
  43256. setVolume(newVolume: number, time?: number): void;
  43257. /**
  43258. * Set the sound play back rate
  43259. * @param newPlaybackRate Define the playback rate the sound should be played at
  43260. */
  43261. setPlaybackRate(newPlaybackRate: number): void;
  43262. /**
  43263. * Gets the volume of the sound.
  43264. * @returns the volume of the sound
  43265. */
  43266. getVolume(): number;
  43267. /**
  43268. * Attach the sound to a dedicated mesh
  43269. * @param transformNode The transform node to connect the sound with
  43270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43271. */
  43272. attachToMesh(transformNode: TransformNode): void;
  43273. /**
  43274. * Detach the sound from the previously attached mesh
  43275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43276. */
  43277. detachFromMesh(): void;
  43278. private _onRegisterAfterWorldMatrixUpdate;
  43279. /**
  43280. * Clone the current sound in the scene.
  43281. * @returns the new sound clone
  43282. */
  43283. clone(): Nullable<Sound>;
  43284. /**
  43285. * Gets the current underlying audio buffer containing the data
  43286. * @returns the audio buffer
  43287. */
  43288. getAudioBuffer(): Nullable<AudioBuffer>;
  43289. /**
  43290. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43291. * @returns the source node
  43292. */
  43293. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43294. /**
  43295. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43296. * @returns the gain node
  43297. */
  43298. getSoundGain(): Nullable<GainNode>;
  43299. /**
  43300. * Serializes the Sound in a JSON representation
  43301. * @returns the JSON representation of the sound
  43302. */
  43303. serialize(): any;
  43304. /**
  43305. * Parse a JSON representation of a sound to innstantiate in a given scene
  43306. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43307. * @param scene Define the scene the new parsed sound should be created in
  43308. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43309. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43310. * @returns the newly parsed sound
  43311. */
  43312. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43313. }
  43314. }
  43315. declare module "babylonjs/Actions/directAudioActions" {
  43316. import { Action } from "babylonjs/Actions/action";
  43317. import { Condition } from "babylonjs/Actions/condition";
  43318. import { Sound } from "babylonjs/Audio/sound";
  43319. /**
  43320. * This defines an action helpful to play a defined sound on a triggered action.
  43321. */
  43322. export class PlaySoundAction extends Action {
  43323. private _sound;
  43324. /**
  43325. * Instantiate the action
  43326. * @param triggerOptions defines the trigger options
  43327. * @param sound defines the sound to play
  43328. * @param condition defines the trigger related conditions
  43329. */
  43330. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43331. /** @hidden */
  43332. _prepare(): void;
  43333. /**
  43334. * Execute the action and play the sound.
  43335. */
  43336. execute(): void;
  43337. /**
  43338. * Serializes the actions and its related information.
  43339. * @param parent defines the object to serialize in
  43340. * @returns the serialized object
  43341. */
  43342. serialize(parent: any): any;
  43343. }
  43344. /**
  43345. * This defines an action helpful to stop a defined sound on a triggered action.
  43346. */
  43347. export class StopSoundAction extends Action {
  43348. private _sound;
  43349. /**
  43350. * Instantiate the action
  43351. * @param triggerOptions defines the trigger options
  43352. * @param sound defines the sound to stop
  43353. * @param condition defines the trigger related conditions
  43354. */
  43355. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43356. /** @hidden */
  43357. _prepare(): void;
  43358. /**
  43359. * Execute the action and stop the sound.
  43360. */
  43361. execute(): void;
  43362. /**
  43363. * Serializes the actions and its related information.
  43364. * @param parent defines the object to serialize in
  43365. * @returns the serialized object
  43366. */
  43367. serialize(parent: any): any;
  43368. }
  43369. }
  43370. declare module "babylonjs/Actions/interpolateValueAction" {
  43371. import { Action } from "babylonjs/Actions/action";
  43372. import { Condition } from "babylonjs/Actions/condition";
  43373. import { Observable } from "babylonjs/Misc/observable";
  43374. /**
  43375. * This defines an action responsible to change the value of a property
  43376. * by interpolating between its current value and the newly set one once triggered.
  43377. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43378. */
  43379. export class InterpolateValueAction extends Action {
  43380. /**
  43381. * Defines the path of the property where the value should be interpolated
  43382. */
  43383. propertyPath: string;
  43384. /**
  43385. * Defines the target value at the end of the interpolation.
  43386. */
  43387. value: any;
  43388. /**
  43389. * Defines the time it will take for the property to interpolate to the value.
  43390. */
  43391. duration: number;
  43392. /**
  43393. * Defines if the other scene animations should be stopped when the action has been triggered
  43394. */
  43395. stopOtherAnimations?: boolean;
  43396. /**
  43397. * Defines a callback raised once the interpolation animation has been done.
  43398. */
  43399. onInterpolationDone?: () => void;
  43400. /**
  43401. * Observable triggered once the interpolation animation has been done.
  43402. */
  43403. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43404. private _target;
  43405. private _effectiveTarget;
  43406. private _property;
  43407. /**
  43408. * Instantiate the action
  43409. * @param triggerOptions defines the trigger options
  43410. * @param target defines the object containing the value to interpolate
  43411. * @param propertyPath defines the path to the property in the target object
  43412. * @param value defines the target value at the end of the interpolation
  43413. * @param duration deines the time it will take for the property to interpolate to the value.
  43414. * @param condition defines the trigger related conditions
  43415. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43416. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43417. */
  43418. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43419. /** @hidden */
  43420. _prepare(): void;
  43421. /**
  43422. * Execute the action starts the value interpolation.
  43423. */
  43424. execute(): void;
  43425. /**
  43426. * Serializes the actions and its related information.
  43427. * @param parent defines the object to serialize in
  43428. * @returns the serialized object
  43429. */
  43430. serialize(parent: any): any;
  43431. }
  43432. }
  43433. declare module "babylonjs/Actions/index" {
  43434. export * from "babylonjs/Actions/abstractActionManager";
  43435. export * from "babylonjs/Actions/action";
  43436. export * from "babylonjs/Actions/actionEvent";
  43437. export * from "babylonjs/Actions/actionManager";
  43438. export * from "babylonjs/Actions/condition";
  43439. export * from "babylonjs/Actions/directActions";
  43440. export * from "babylonjs/Actions/directAudioActions";
  43441. export * from "babylonjs/Actions/interpolateValueAction";
  43442. }
  43443. declare module "babylonjs/Animations/index" {
  43444. export * from "babylonjs/Animations/animatable";
  43445. export * from "babylonjs/Animations/animation";
  43446. export * from "babylonjs/Animations/animationGroup";
  43447. export * from "babylonjs/Animations/animationPropertiesOverride";
  43448. export * from "babylonjs/Animations/easing";
  43449. export * from "babylonjs/Animations/runtimeAnimation";
  43450. export * from "babylonjs/Animations/animationEvent";
  43451. export * from "babylonjs/Animations/animationGroup";
  43452. export * from "babylonjs/Animations/animationKey";
  43453. export * from "babylonjs/Animations/animationRange";
  43454. export * from "babylonjs/Animations/animatable.interface";
  43455. }
  43456. declare module "babylonjs/Audio/soundTrack" {
  43457. import { Sound } from "babylonjs/Audio/sound";
  43458. import { Analyser } from "babylonjs/Audio/analyser";
  43459. import { Scene } from "babylonjs/scene";
  43460. /**
  43461. * Options allowed during the creation of a sound track.
  43462. */
  43463. export interface ISoundTrackOptions {
  43464. /**
  43465. * The volume the sound track should take during creation
  43466. */
  43467. volume?: number;
  43468. /**
  43469. * Define if the sound track is the main sound track of the scene
  43470. */
  43471. mainTrack?: boolean;
  43472. }
  43473. /**
  43474. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43475. * It will be also used in a future release to apply effects on a specific track.
  43476. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43477. */
  43478. export class SoundTrack {
  43479. /**
  43480. * The unique identifier of the sound track in the scene.
  43481. */
  43482. id: number;
  43483. /**
  43484. * The list of sounds included in the sound track.
  43485. */
  43486. soundCollection: Array<Sound>;
  43487. private _outputAudioNode;
  43488. private _scene;
  43489. private _connectedAnalyser;
  43490. private _options;
  43491. private _isInitialized;
  43492. /**
  43493. * Creates a new sound track.
  43494. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43495. * @param scene Define the scene the sound track belongs to
  43496. * @param options
  43497. */
  43498. constructor(scene: Scene, options?: ISoundTrackOptions);
  43499. private _initializeSoundTrackAudioGraph;
  43500. /**
  43501. * Release the sound track and its associated resources
  43502. */
  43503. dispose(): void;
  43504. /**
  43505. * Adds a sound to this sound track
  43506. * @param sound define the cound to add
  43507. * @ignoreNaming
  43508. */
  43509. AddSound(sound: Sound): void;
  43510. /**
  43511. * Removes a sound to this sound track
  43512. * @param sound define the cound to remove
  43513. * @ignoreNaming
  43514. */
  43515. RemoveSound(sound: Sound): void;
  43516. /**
  43517. * Set a global volume for the full sound track.
  43518. * @param newVolume Define the new volume of the sound track
  43519. */
  43520. setVolume(newVolume: number): void;
  43521. /**
  43522. * Switch the panning model to HRTF:
  43523. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43524. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43525. */
  43526. switchPanningModelToHRTF(): void;
  43527. /**
  43528. * Switch the panning model to Equal Power:
  43529. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43530. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43531. */
  43532. switchPanningModelToEqualPower(): void;
  43533. /**
  43534. * Connect the sound track to an audio analyser allowing some amazing
  43535. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43537. * @param analyser The analyser to connect to the engine
  43538. */
  43539. connectToAnalyser(analyser: Analyser): void;
  43540. }
  43541. }
  43542. declare module "babylonjs/Audio/audioSceneComponent" {
  43543. import { Sound } from "babylonjs/Audio/sound";
  43544. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43545. import { Nullable } from "babylonjs/types";
  43546. import { Vector3 } from "babylonjs/Maths/math.vector";
  43547. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43548. import { Scene } from "babylonjs/scene";
  43549. import { AbstractScene } from "babylonjs/abstractScene";
  43550. import "babylonjs/Audio/audioEngine";
  43551. module "babylonjs/abstractScene" {
  43552. interface AbstractScene {
  43553. /**
  43554. * The list of sounds used in the scene.
  43555. */
  43556. sounds: Nullable<Array<Sound>>;
  43557. }
  43558. }
  43559. module "babylonjs/scene" {
  43560. interface Scene {
  43561. /**
  43562. * @hidden
  43563. * Backing field
  43564. */
  43565. _mainSoundTrack: SoundTrack;
  43566. /**
  43567. * The main sound track played by the scene.
  43568. * It cotains your primary collection of sounds.
  43569. */
  43570. mainSoundTrack: SoundTrack;
  43571. /**
  43572. * The list of sound tracks added to the scene
  43573. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43574. */
  43575. soundTracks: Nullable<Array<SoundTrack>>;
  43576. /**
  43577. * Gets a sound using a given name
  43578. * @param name defines the name to search for
  43579. * @return the found sound or null if not found at all.
  43580. */
  43581. getSoundByName(name: string): Nullable<Sound>;
  43582. /**
  43583. * Gets or sets if audio support is enabled
  43584. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43585. */
  43586. audioEnabled: boolean;
  43587. /**
  43588. * Gets or sets if audio will be output to headphones
  43589. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43590. */
  43591. headphone: boolean;
  43592. /**
  43593. * Gets or sets custom audio listener position provider
  43594. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43595. */
  43596. audioListenerPositionProvider: Nullable<() => Vector3>;
  43597. /**
  43598. * Gets or sets a refresh rate when using 3D audio positioning
  43599. */
  43600. audioPositioningRefreshRate: number;
  43601. }
  43602. }
  43603. /**
  43604. * Defines the sound scene component responsible to manage any sounds
  43605. * in a given scene.
  43606. */
  43607. export class AudioSceneComponent implements ISceneSerializableComponent {
  43608. private static _CameraDirectionLH;
  43609. private static _CameraDirectionRH;
  43610. /**
  43611. * The component name helpfull to identify the component in the list of scene components.
  43612. */
  43613. readonly name: string;
  43614. /**
  43615. * The scene the component belongs to.
  43616. */
  43617. scene: Scene;
  43618. private _audioEnabled;
  43619. /**
  43620. * Gets whether audio is enabled or not.
  43621. * Please use related enable/disable method to switch state.
  43622. */
  43623. get audioEnabled(): boolean;
  43624. private _headphone;
  43625. /**
  43626. * Gets whether audio is outputing to headphone or not.
  43627. * Please use the according Switch methods to change output.
  43628. */
  43629. get headphone(): boolean;
  43630. /**
  43631. * Gets or sets a refresh rate when using 3D audio positioning
  43632. */
  43633. audioPositioningRefreshRate: number;
  43634. private _audioListenerPositionProvider;
  43635. /**
  43636. * Gets the current audio listener position provider
  43637. */
  43638. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43639. /**
  43640. * Sets a custom listener position for all sounds in the scene
  43641. * By default, this is the position of the first active camera
  43642. */
  43643. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43644. /**
  43645. * Creates a new instance of the component for the given scene
  43646. * @param scene Defines the scene to register the component in
  43647. */
  43648. constructor(scene: Scene);
  43649. /**
  43650. * Registers the component in a given scene
  43651. */
  43652. register(): void;
  43653. /**
  43654. * Rebuilds the elements related to this component in case of
  43655. * context lost for instance.
  43656. */
  43657. rebuild(): void;
  43658. /**
  43659. * Serializes the component data to the specified json object
  43660. * @param serializationObject The object to serialize to
  43661. */
  43662. serialize(serializationObject: any): void;
  43663. /**
  43664. * Adds all the elements from the container to the scene
  43665. * @param container the container holding the elements
  43666. */
  43667. addFromContainer(container: AbstractScene): void;
  43668. /**
  43669. * Removes all the elements in the container from the scene
  43670. * @param container contains the elements to remove
  43671. * @param dispose if the removed element should be disposed (default: false)
  43672. */
  43673. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43674. /**
  43675. * Disposes the component and the associated ressources.
  43676. */
  43677. dispose(): void;
  43678. /**
  43679. * Disables audio in the associated scene.
  43680. */
  43681. disableAudio(): void;
  43682. /**
  43683. * Enables audio in the associated scene.
  43684. */
  43685. enableAudio(): void;
  43686. /**
  43687. * Switch audio to headphone output.
  43688. */
  43689. switchAudioModeForHeadphones(): void;
  43690. /**
  43691. * Switch audio to normal speakers.
  43692. */
  43693. switchAudioModeForNormalSpeakers(): void;
  43694. private _cachedCameraDirection;
  43695. private _cachedCameraPosition;
  43696. private _lastCheck;
  43697. private _afterRender;
  43698. }
  43699. }
  43700. declare module "babylonjs/Audio/weightedsound" {
  43701. import { Sound } from "babylonjs/Audio/sound";
  43702. /**
  43703. * Wraps one or more Sound objects and selects one with random weight for playback.
  43704. */
  43705. export class WeightedSound {
  43706. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43707. loop: boolean;
  43708. private _coneInnerAngle;
  43709. private _coneOuterAngle;
  43710. private _volume;
  43711. /** A Sound is currently playing. */
  43712. isPlaying: boolean;
  43713. /** A Sound is currently paused. */
  43714. isPaused: boolean;
  43715. private _sounds;
  43716. private _weights;
  43717. private _currentIndex?;
  43718. /**
  43719. * Creates a new WeightedSound from the list of sounds given.
  43720. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43721. * @param sounds Array of Sounds that will be selected from.
  43722. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43723. */
  43724. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43725. /**
  43726. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43727. */
  43728. get directionalConeInnerAngle(): number;
  43729. /**
  43730. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43731. */
  43732. set directionalConeInnerAngle(value: number);
  43733. /**
  43734. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43735. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43736. */
  43737. get directionalConeOuterAngle(): number;
  43738. /**
  43739. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43740. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43741. */
  43742. set directionalConeOuterAngle(value: number);
  43743. /**
  43744. * Playback volume.
  43745. */
  43746. get volume(): number;
  43747. /**
  43748. * Playback volume.
  43749. */
  43750. set volume(value: number);
  43751. private _onended;
  43752. /**
  43753. * Suspend playback
  43754. */
  43755. pause(): void;
  43756. /**
  43757. * Stop playback
  43758. */
  43759. stop(): void;
  43760. /**
  43761. * Start playback.
  43762. * @param startOffset Position the clip head at a specific time in seconds.
  43763. */
  43764. play(startOffset?: number): void;
  43765. }
  43766. }
  43767. declare module "babylonjs/Audio/index" {
  43768. export * from "babylonjs/Audio/analyser";
  43769. export * from "babylonjs/Audio/audioEngine";
  43770. export * from "babylonjs/Audio/audioSceneComponent";
  43771. export * from "babylonjs/Audio/sound";
  43772. export * from "babylonjs/Audio/soundTrack";
  43773. export * from "babylonjs/Audio/weightedsound";
  43774. }
  43775. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43776. import { Behavior } from "babylonjs/Behaviors/behavior";
  43777. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43778. import { BackEase } from "babylonjs/Animations/easing";
  43779. /**
  43780. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43781. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43782. */
  43783. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43784. /**
  43785. * Gets the name of the behavior.
  43786. */
  43787. get name(): string;
  43788. /**
  43789. * The easing function used by animations
  43790. */
  43791. static EasingFunction: BackEase;
  43792. /**
  43793. * The easing mode used by animations
  43794. */
  43795. static EasingMode: number;
  43796. /**
  43797. * The duration of the animation, in milliseconds
  43798. */
  43799. transitionDuration: number;
  43800. /**
  43801. * Length of the distance animated by the transition when lower radius is reached
  43802. */
  43803. lowerRadiusTransitionRange: number;
  43804. /**
  43805. * Length of the distance animated by the transition when upper radius is reached
  43806. */
  43807. upperRadiusTransitionRange: number;
  43808. private _autoTransitionRange;
  43809. /**
  43810. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43811. */
  43812. get autoTransitionRange(): boolean;
  43813. /**
  43814. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43815. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43816. */
  43817. set autoTransitionRange(value: boolean);
  43818. private _attachedCamera;
  43819. private _onAfterCheckInputsObserver;
  43820. private _onMeshTargetChangedObserver;
  43821. /**
  43822. * Initializes the behavior.
  43823. */
  43824. init(): void;
  43825. /**
  43826. * Attaches the behavior to its arc rotate camera.
  43827. * @param camera Defines the camera to attach the behavior to
  43828. */
  43829. attach(camera: ArcRotateCamera): void;
  43830. /**
  43831. * Detaches the behavior from its current arc rotate camera.
  43832. */
  43833. detach(): void;
  43834. private _radiusIsAnimating;
  43835. private _radiusBounceTransition;
  43836. private _animatables;
  43837. private _cachedWheelPrecision;
  43838. /**
  43839. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43840. * @param radiusLimit The limit to check against.
  43841. * @return Bool to indicate if at limit.
  43842. */
  43843. private _isRadiusAtLimit;
  43844. /**
  43845. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43846. * @param radiusDelta The delta by which to animate to. Can be negative.
  43847. */
  43848. private _applyBoundRadiusAnimation;
  43849. /**
  43850. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43851. */
  43852. protected _clearAnimationLocks(): void;
  43853. /**
  43854. * Stops and removes all animations that have been applied to the camera
  43855. */
  43856. stopAllAnimations(): void;
  43857. }
  43858. }
  43859. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43860. import { Behavior } from "babylonjs/Behaviors/behavior";
  43861. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43862. import { ExponentialEase } from "babylonjs/Animations/easing";
  43863. import { Nullable } from "babylonjs/types";
  43864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43865. import { Vector3 } from "babylonjs/Maths/math.vector";
  43866. /**
  43867. * 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.
  43868. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43869. */
  43870. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43871. /**
  43872. * Gets the name of the behavior.
  43873. */
  43874. get name(): string;
  43875. private _mode;
  43876. private _radiusScale;
  43877. private _positionScale;
  43878. private _defaultElevation;
  43879. private _elevationReturnTime;
  43880. private _elevationReturnWaitTime;
  43881. private _zoomStopsAnimation;
  43882. private _framingTime;
  43883. /**
  43884. * The easing function used by animations
  43885. */
  43886. static EasingFunction: ExponentialEase;
  43887. /**
  43888. * The easing mode used by animations
  43889. */
  43890. static EasingMode: number;
  43891. /**
  43892. * Sets the current mode used by the behavior
  43893. */
  43894. set mode(mode: number);
  43895. /**
  43896. * Gets current mode used by the behavior.
  43897. */
  43898. get mode(): number;
  43899. /**
  43900. * Sets the scale applied to the radius (1 by default)
  43901. */
  43902. set radiusScale(radius: number);
  43903. /**
  43904. * Gets the scale applied to the radius
  43905. */
  43906. get radiusScale(): number;
  43907. /**
  43908. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43909. */
  43910. set positionScale(scale: number);
  43911. /**
  43912. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  43913. */
  43914. get positionScale(): number;
  43915. /**
  43916. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43917. * behaviour is triggered, in radians.
  43918. */
  43919. set defaultElevation(elevation: number);
  43920. /**
  43921. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  43922. * behaviour is triggered, in radians.
  43923. */
  43924. get defaultElevation(): number;
  43925. /**
  43926. * Sets the time (in milliseconds) taken to return to the default beta position.
  43927. * Negative value indicates camera should not return to default.
  43928. */
  43929. set elevationReturnTime(speed: number);
  43930. /**
  43931. * Gets the time (in milliseconds) taken to return to the default beta position.
  43932. * Negative value indicates camera should not return to default.
  43933. */
  43934. get elevationReturnTime(): number;
  43935. /**
  43936. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43937. */
  43938. set elevationReturnWaitTime(time: number);
  43939. /**
  43940. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  43941. */
  43942. get elevationReturnWaitTime(): number;
  43943. /**
  43944. * Sets the flag that indicates if user zooming should stop animation.
  43945. */
  43946. set zoomStopsAnimation(flag: boolean);
  43947. /**
  43948. * Gets the flag that indicates if user zooming should stop animation.
  43949. */
  43950. get zoomStopsAnimation(): boolean;
  43951. /**
  43952. * Sets the transition time when framing the mesh, in milliseconds
  43953. */
  43954. set framingTime(time: number);
  43955. /**
  43956. * Gets the transition time when framing the mesh, in milliseconds
  43957. */
  43958. get framingTime(): number;
  43959. /**
  43960. * Define if the behavior should automatically change the configured
  43961. * camera limits and sensibilities.
  43962. */
  43963. autoCorrectCameraLimitsAndSensibility: boolean;
  43964. private _onPrePointerObservableObserver;
  43965. private _onAfterCheckInputsObserver;
  43966. private _onMeshTargetChangedObserver;
  43967. private _attachedCamera;
  43968. private _isPointerDown;
  43969. private _lastInteractionTime;
  43970. /**
  43971. * Initializes the behavior.
  43972. */
  43973. init(): void;
  43974. /**
  43975. * Attaches the behavior to its arc rotate camera.
  43976. * @param camera Defines the camera to attach the behavior to
  43977. */
  43978. attach(camera: ArcRotateCamera): void;
  43979. /**
  43980. * Detaches the behavior from its current arc rotate camera.
  43981. */
  43982. detach(): void;
  43983. private _animatables;
  43984. private _betaIsAnimating;
  43985. private _betaTransition;
  43986. private _radiusTransition;
  43987. private _vectorTransition;
  43988. /**
  43989. * Targets the given mesh and updates zoom level accordingly.
  43990. * @param mesh The mesh to target.
  43991. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43992. * @param onAnimationEnd Callback triggered at the end of the framing animation
  43993. */
  43994. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  43995. /**
  43996. * Targets the given mesh with its children and updates zoom level accordingly.
  43997. * @param mesh The mesh to target.
  43998. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  43999. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44000. */
  44001. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44002. /**
  44003. * Targets the given meshes with their children and updates zoom level accordingly.
  44004. * @param meshes The mesh to target.
  44005. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44006. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44007. */
  44008. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44009. /**
  44010. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44011. * @param minimumWorld Determines the smaller position of the bounding box extend
  44012. * @param maximumWorld Determines the bigger position of the bounding box extend
  44013. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44014. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44015. */
  44016. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44017. /**
  44018. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44019. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44020. * frustum width.
  44021. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44022. * to fully enclose the mesh in the viewing frustum.
  44023. */
  44024. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44025. /**
  44026. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44027. * is automatically returned to its default position (expected to be above ground plane).
  44028. */
  44029. private _maintainCameraAboveGround;
  44030. /**
  44031. * Returns the frustum slope based on the canvas ratio and camera FOV
  44032. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44033. */
  44034. private _getFrustumSlope;
  44035. /**
  44036. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44037. */
  44038. private _clearAnimationLocks;
  44039. /**
  44040. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44041. */
  44042. private _applyUserInteraction;
  44043. /**
  44044. * Stops and removes all animations that have been applied to the camera
  44045. */
  44046. stopAllAnimations(): void;
  44047. /**
  44048. * Gets a value indicating if the user is moving the camera
  44049. */
  44050. get isUserIsMoving(): boolean;
  44051. /**
  44052. * The camera can move all the way towards the mesh.
  44053. */
  44054. static IgnoreBoundsSizeMode: number;
  44055. /**
  44056. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44057. */
  44058. static FitFrustumSidesMode: number;
  44059. }
  44060. }
  44061. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44062. import { Nullable } from "babylonjs/types";
  44063. import { Camera } from "babylonjs/Cameras/camera";
  44064. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44065. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44066. /**
  44067. * Base class for Camera Pointer Inputs.
  44068. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44069. * for example usage.
  44070. */
  44071. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44072. /**
  44073. * Defines the camera the input is attached to.
  44074. */
  44075. abstract camera: Camera;
  44076. /**
  44077. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44078. */
  44079. protected _altKey: boolean;
  44080. protected _ctrlKey: boolean;
  44081. protected _metaKey: boolean;
  44082. protected _shiftKey: boolean;
  44083. /**
  44084. * Which mouse buttons were pressed at time of last mouse event.
  44085. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44086. */
  44087. protected _buttonsPressed: number;
  44088. /**
  44089. * Defines the buttons associated with the input to handle camera move.
  44090. */
  44091. buttons: number[];
  44092. /**
  44093. * Attach the input controls to a specific dom element to get the input from.
  44094. * @param element Defines the element the controls should be listened from
  44095. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44096. */
  44097. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44098. /**
  44099. * Detach the current controls from the specified dom element.
  44100. * @param element Defines the element to stop listening the inputs from
  44101. */
  44102. detachControl(element: Nullable<HTMLElement>): void;
  44103. /**
  44104. * Gets the class name of the current input.
  44105. * @returns the class name
  44106. */
  44107. getClassName(): string;
  44108. /**
  44109. * Get the friendly name associated with the input class.
  44110. * @returns the input friendly name
  44111. */
  44112. getSimpleName(): string;
  44113. /**
  44114. * Called on pointer POINTERDOUBLETAP event.
  44115. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44116. */
  44117. protected onDoubleTap(type: string): void;
  44118. /**
  44119. * Called on pointer POINTERMOVE event if only a single touch is active.
  44120. * Override this method to provide functionality.
  44121. */
  44122. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44123. /**
  44124. * Called on pointer POINTERMOVE event if multiple touches are active.
  44125. * Override this method to provide functionality.
  44126. */
  44127. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44128. /**
  44129. * Called on JS contextmenu event.
  44130. * Override this method to provide functionality.
  44131. */
  44132. protected onContextMenu(evt: PointerEvent): void;
  44133. /**
  44134. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44135. * press.
  44136. * Override this method to provide functionality.
  44137. */
  44138. protected onButtonDown(evt: PointerEvent): void;
  44139. /**
  44140. * Called each time a new POINTERUP event occurs. Ie, for each button
  44141. * release.
  44142. * Override this method to provide functionality.
  44143. */
  44144. protected onButtonUp(evt: PointerEvent): void;
  44145. /**
  44146. * Called when window becomes inactive.
  44147. * Override this method to provide functionality.
  44148. */
  44149. protected onLostFocus(): void;
  44150. private _pointerInput;
  44151. private _observer;
  44152. private _onLostFocus;
  44153. private pointA;
  44154. private pointB;
  44155. }
  44156. }
  44157. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44158. import { Nullable } from "babylonjs/types";
  44159. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44160. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44161. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44162. /**
  44163. * Manage the pointers inputs to control an arc rotate camera.
  44164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44165. */
  44166. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44167. /**
  44168. * Defines the camera the input is attached to.
  44169. */
  44170. camera: ArcRotateCamera;
  44171. /**
  44172. * Gets the class name of the current input.
  44173. * @returns the class name
  44174. */
  44175. getClassName(): string;
  44176. /**
  44177. * Defines the buttons associated with the input to handle camera move.
  44178. */
  44179. buttons: number[];
  44180. /**
  44181. * Defines the pointer angular sensibility along the X axis or how fast is
  44182. * the camera rotating.
  44183. */
  44184. angularSensibilityX: number;
  44185. /**
  44186. * Defines the pointer angular sensibility along the Y axis or how fast is
  44187. * the camera rotating.
  44188. */
  44189. angularSensibilityY: number;
  44190. /**
  44191. * Defines the pointer pinch precision or how fast is the camera zooming.
  44192. */
  44193. pinchPrecision: number;
  44194. /**
  44195. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44196. * from 0.
  44197. * It defines the percentage of current camera.radius to use as delta when
  44198. * pinch zoom is used.
  44199. */
  44200. pinchDeltaPercentage: number;
  44201. /**
  44202. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44203. * that any object in the plane at the camera's target point will scale
  44204. * perfectly with finger motion.
  44205. * Overrides pinchDeltaPercentage and pinchPrecision.
  44206. */
  44207. useNaturalPinchZoom: boolean;
  44208. /**
  44209. * Defines the pointer panning sensibility or how fast is the camera moving.
  44210. */
  44211. panningSensibility: number;
  44212. /**
  44213. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44214. */
  44215. multiTouchPanning: boolean;
  44216. /**
  44217. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44218. * zoom (pinch) through multitouch.
  44219. */
  44220. multiTouchPanAndZoom: boolean;
  44221. /**
  44222. * Revers pinch action direction.
  44223. */
  44224. pinchInwards: boolean;
  44225. private _isPanClick;
  44226. private _twoFingerActivityCount;
  44227. private _isPinching;
  44228. /**
  44229. * Called on pointer POINTERMOVE event if only a single touch is active.
  44230. */
  44231. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44232. /**
  44233. * Called on pointer POINTERDOUBLETAP event.
  44234. */
  44235. protected onDoubleTap(type: string): void;
  44236. /**
  44237. * Called on pointer POINTERMOVE event if multiple touches are active.
  44238. */
  44239. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44240. /**
  44241. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44242. * press.
  44243. */
  44244. protected onButtonDown(evt: PointerEvent): void;
  44245. /**
  44246. * Called each time a new POINTERUP event occurs. Ie, for each button
  44247. * release.
  44248. */
  44249. protected onButtonUp(evt: PointerEvent): void;
  44250. /**
  44251. * Called when window becomes inactive.
  44252. */
  44253. protected onLostFocus(): void;
  44254. }
  44255. }
  44256. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44257. import { Nullable } from "babylonjs/types";
  44258. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44259. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44260. /**
  44261. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44262. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44263. */
  44264. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44265. /**
  44266. * Defines the camera the input is attached to.
  44267. */
  44268. camera: ArcRotateCamera;
  44269. /**
  44270. * Defines the list of key codes associated with the up action (increase alpha)
  44271. */
  44272. keysUp: number[];
  44273. /**
  44274. * Defines the list of key codes associated with the down action (decrease alpha)
  44275. */
  44276. keysDown: number[];
  44277. /**
  44278. * Defines the list of key codes associated with the left action (increase beta)
  44279. */
  44280. keysLeft: number[];
  44281. /**
  44282. * Defines the list of key codes associated with the right action (decrease beta)
  44283. */
  44284. keysRight: number[];
  44285. /**
  44286. * Defines the list of key codes associated with the reset action.
  44287. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44288. */
  44289. keysReset: number[];
  44290. /**
  44291. * Defines the panning sensibility of the inputs.
  44292. * (How fast is the camera panning)
  44293. */
  44294. panningSensibility: number;
  44295. /**
  44296. * Defines the zooming sensibility of the inputs.
  44297. * (How fast is the camera zooming)
  44298. */
  44299. zoomingSensibility: number;
  44300. /**
  44301. * Defines whether maintaining the alt key down switch the movement mode from
  44302. * orientation to zoom.
  44303. */
  44304. useAltToZoom: boolean;
  44305. /**
  44306. * Rotation speed of the camera
  44307. */
  44308. angularSpeed: number;
  44309. private _keys;
  44310. private _ctrlPressed;
  44311. private _altPressed;
  44312. private _onCanvasBlurObserver;
  44313. private _onKeyboardObserver;
  44314. private _engine;
  44315. private _scene;
  44316. /**
  44317. * Attach the input controls to a specific dom element to get the input from.
  44318. * @param element Defines the element the controls should be listened from
  44319. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44320. */
  44321. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44322. /**
  44323. * Detach the current controls from the specified dom element.
  44324. * @param element Defines the element to stop listening the inputs from
  44325. */
  44326. detachControl(element: Nullable<HTMLElement>): void;
  44327. /**
  44328. * Update the current camera state depending on the inputs that have been used this frame.
  44329. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44330. */
  44331. checkInputs(): void;
  44332. /**
  44333. * Gets the class name of the current intput.
  44334. * @returns the class name
  44335. */
  44336. getClassName(): string;
  44337. /**
  44338. * Get the friendly name associated with the input class.
  44339. * @returns the input friendly name
  44340. */
  44341. getSimpleName(): string;
  44342. }
  44343. }
  44344. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44345. import { Nullable } from "babylonjs/types";
  44346. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44347. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44348. /**
  44349. * Manage the mouse wheel inputs to control an arc rotate camera.
  44350. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44351. */
  44352. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44353. /**
  44354. * Defines the camera the input is attached to.
  44355. */
  44356. camera: ArcRotateCamera;
  44357. /**
  44358. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44359. */
  44360. wheelPrecision: number;
  44361. /**
  44362. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44363. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44364. */
  44365. wheelDeltaPercentage: number;
  44366. private _wheel;
  44367. private _observer;
  44368. private computeDeltaFromMouseWheelLegacyEvent;
  44369. /**
  44370. * Attach the input controls to a specific dom element to get the input from.
  44371. * @param element Defines the element the controls should be listened from
  44372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44373. */
  44374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44375. /**
  44376. * Detach the current controls from the specified dom element.
  44377. * @param element Defines the element to stop listening the inputs from
  44378. */
  44379. detachControl(element: Nullable<HTMLElement>): void;
  44380. /**
  44381. * Gets the class name of the current intput.
  44382. * @returns the class name
  44383. */
  44384. getClassName(): string;
  44385. /**
  44386. * Get the friendly name associated with the input class.
  44387. * @returns the input friendly name
  44388. */
  44389. getSimpleName(): string;
  44390. }
  44391. }
  44392. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44393. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44394. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44395. /**
  44396. * Default Inputs manager for the ArcRotateCamera.
  44397. * It groups all the default supported inputs for ease of use.
  44398. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44399. */
  44400. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44401. /**
  44402. * Instantiates a new ArcRotateCameraInputsManager.
  44403. * @param camera Defines the camera the inputs belong to
  44404. */
  44405. constructor(camera: ArcRotateCamera);
  44406. /**
  44407. * Add mouse wheel input support to the input manager.
  44408. * @returns the current input manager
  44409. */
  44410. addMouseWheel(): ArcRotateCameraInputsManager;
  44411. /**
  44412. * Add pointers input support to the input manager.
  44413. * @returns the current input manager
  44414. */
  44415. addPointers(): ArcRotateCameraInputsManager;
  44416. /**
  44417. * Add keyboard input support to the input manager.
  44418. * @returns the current input manager
  44419. */
  44420. addKeyboard(): ArcRotateCameraInputsManager;
  44421. }
  44422. }
  44423. declare module "babylonjs/Cameras/arcRotateCamera" {
  44424. import { Observable } from "babylonjs/Misc/observable";
  44425. import { Nullable } from "babylonjs/types";
  44426. import { Scene } from "babylonjs/scene";
  44427. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44429. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44430. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44431. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44432. import { Camera } from "babylonjs/Cameras/camera";
  44433. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44434. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44435. import { Collider } from "babylonjs/Collisions/collider";
  44436. /**
  44437. * This represents an orbital type of camera.
  44438. *
  44439. * 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.
  44440. * 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.
  44441. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44442. */
  44443. export class ArcRotateCamera extends TargetCamera {
  44444. /**
  44445. * Defines the rotation angle of the camera along the longitudinal axis.
  44446. */
  44447. alpha: number;
  44448. /**
  44449. * Defines the rotation angle of the camera along the latitudinal axis.
  44450. */
  44451. beta: number;
  44452. /**
  44453. * Defines the radius of the camera from it s target point.
  44454. */
  44455. radius: number;
  44456. protected _target: Vector3;
  44457. protected _targetHost: Nullable<AbstractMesh>;
  44458. /**
  44459. * Defines the target point of the camera.
  44460. * The camera looks towards it form the radius distance.
  44461. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44462. */
  44463. get target(): Vector3;
  44464. set target(value: Vector3);
  44465. /**
  44466. * Define the current local position of the camera in the scene
  44467. */
  44468. get position(): Vector3;
  44469. set position(newPosition: Vector3);
  44470. protected _upToYMatrix: Matrix;
  44471. protected _YToUpMatrix: Matrix;
  44472. /**
  44473. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44474. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44475. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44476. */
  44477. set upVector(vec: Vector3);
  44478. get upVector(): Vector3;
  44479. /**
  44480. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44481. */
  44482. setMatUp(): void;
  44483. /**
  44484. * Current inertia value on the longitudinal axis.
  44485. * The bigger this number the longer it will take for the camera to stop.
  44486. */
  44487. inertialAlphaOffset: number;
  44488. /**
  44489. * Current inertia value on the latitudinal axis.
  44490. * The bigger this number the longer it will take for the camera to stop.
  44491. */
  44492. inertialBetaOffset: number;
  44493. /**
  44494. * Current inertia value on the radius axis.
  44495. * The bigger this number the longer it will take for the camera to stop.
  44496. */
  44497. inertialRadiusOffset: number;
  44498. /**
  44499. * Minimum allowed angle on the longitudinal axis.
  44500. * This can help limiting how the Camera is able to move in the scene.
  44501. */
  44502. lowerAlphaLimit: Nullable<number>;
  44503. /**
  44504. * Maximum allowed angle on the longitudinal axis.
  44505. * This can help limiting how the Camera is able to move in the scene.
  44506. */
  44507. upperAlphaLimit: Nullable<number>;
  44508. /**
  44509. * Minimum allowed angle on the latitudinal axis.
  44510. * This can help limiting how the Camera is able to move in the scene.
  44511. */
  44512. lowerBetaLimit: number;
  44513. /**
  44514. * Maximum allowed angle on the latitudinal axis.
  44515. * This can help limiting how the Camera is able to move in the scene.
  44516. */
  44517. upperBetaLimit: number;
  44518. /**
  44519. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44520. * This can help limiting how the Camera is able to move in the scene.
  44521. */
  44522. lowerRadiusLimit: Nullable<number>;
  44523. /**
  44524. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44525. * This can help limiting how the Camera is able to move in the scene.
  44526. */
  44527. upperRadiusLimit: Nullable<number>;
  44528. /**
  44529. * Defines the current inertia value used during panning of the camera along the X axis.
  44530. */
  44531. inertialPanningX: number;
  44532. /**
  44533. * Defines the current inertia value used during panning of the camera along the Y axis.
  44534. */
  44535. inertialPanningY: number;
  44536. /**
  44537. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44538. * Basically if your fingers moves away from more than this distance you will be considered
  44539. * in pinch mode.
  44540. */
  44541. pinchToPanMaxDistance: number;
  44542. /**
  44543. * Defines the maximum distance the camera can pan.
  44544. * This could help keeping the cammera always in your scene.
  44545. */
  44546. panningDistanceLimit: Nullable<number>;
  44547. /**
  44548. * Defines the target of the camera before paning.
  44549. */
  44550. panningOriginTarget: Vector3;
  44551. /**
  44552. * Defines the value of the inertia used during panning.
  44553. * 0 would mean stop inertia and one would mean no decelleration at all.
  44554. */
  44555. panningInertia: number;
  44556. /**
  44557. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44558. */
  44559. get angularSensibilityX(): number;
  44560. set angularSensibilityX(value: number);
  44561. /**
  44562. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44563. */
  44564. get angularSensibilityY(): number;
  44565. set angularSensibilityY(value: number);
  44566. /**
  44567. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44568. */
  44569. get pinchPrecision(): number;
  44570. set pinchPrecision(value: number);
  44571. /**
  44572. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44573. * It will be used instead of pinchDeltaPrecision if different from 0.
  44574. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44575. */
  44576. get pinchDeltaPercentage(): number;
  44577. set pinchDeltaPercentage(value: number);
  44578. /**
  44579. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44580. * and pinch delta percentage.
  44581. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44582. * that any object in the plane at the camera's target point will scale
  44583. * perfectly with finger motion.
  44584. */
  44585. get useNaturalPinchZoom(): boolean;
  44586. set useNaturalPinchZoom(value: boolean);
  44587. /**
  44588. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44589. */
  44590. get panningSensibility(): number;
  44591. set panningSensibility(value: number);
  44592. /**
  44593. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44594. */
  44595. get keysUp(): number[];
  44596. set keysUp(value: number[]);
  44597. /**
  44598. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44599. */
  44600. get keysDown(): number[];
  44601. set keysDown(value: number[]);
  44602. /**
  44603. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44604. */
  44605. get keysLeft(): number[];
  44606. set keysLeft(value: number[]);
  44607. /**
  44608. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44609. */
  44610. get keysRight(): number[];
  44611. set keysRight(value: number[]);
  44612. /**
  44613. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44614. */
  44615. get wheelPrecision(): number;
  44616. set wheelPrecision(value: number);
  44617. /**
  44618. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44619. * It will be used instead of pinchDeltaPrecision if different from 0.
  44620. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44621. */
  44622. get wheelDeltaPercentage(): number;
  44623. set wheelDeltaPercentage(value: number);
  44624. /**
  44625. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44626. */
  44627. zoomOnFactor: number;
  44628. /**
  44629. * Defines a screen offset for the camera position.
  44630. */
  44631. targetScreenOffset: Vector2;
  44632. /**
  44633. * Allows the camera to be completely reversed.
  44634. * If false the camera can not arrive upside down.
  44635. */
  44636. allowUpsideDown: boolean;
  44637. /**
  44638. * Define if double tap/click is used to restore the previously saved state of the camera.
  44639. */
  44640. useInputToRestoreState: boolean;
  44641. /** @hidden */
  44642. _viewMatrix: Matrix;
  44643. /** @hidden */
  44644. _useCtrlForPanning: boolean;
  44645. /** @hidden */
  44646. _panningMouseButton: number;
  44647. /**
  44648. * Defines the input associated to the camera.
  44649. */
  44650. inputs: ArcRotateCameraInputsManager;
  44651. /** @hidden */
  44652. _reset: () => void;
  44653. /**
  44654. * Defines the allowed panning axis.
  44655. */
  44656. panningAxis: Vector3;
  44657. protected _localDirection: Vector3;
  44658. protected _transformedDirection: Vector3;
  44659. private _bouncingBehavior;
  44660. /**
  44661. * Gets the bouncing behavior of the camera if it has been enabled.
  44662. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44663. */
  44664. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44665. /**
  44666. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44667. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44668. */
  44669. get useBouncingBehavior(): boolean;
  44670. set useBouncingBehavior(value: boolean);
  44671. private _framingBehavior;
  44672. /**
  44673. * Gets the framing behavior of the camera if it has been enabled.
  44674. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44675. */
  44676. get framingBehavior(): Nullable<FramingBehavior>;
  44677. /**
  44678. * Defines if the framing behavior of the camera is enabled on the camera.
  44679. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44680. */
  44681. get useFramingBehavior(): boolean;
  44682. set useFramingBehavior(value: boolean);
  44683. private _autoRotationBehavior;
  44684. /**
  44685. * Gets the auto rotation behavior of the camera if it has been enabled.
  44686. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44687. */
  44688. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44689. /**
  44690. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44691. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44692. */
  44693. get useAutoRotationBehavior(): boolean;
  44694. set useAutoRotationBehavior(value: boolean);
  44695. /**
  44696. * Observable triggered when the mesh target has been changed on the camera.
  44697. */
  44698. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44699. /**
  44700. * Event raised when the camera is colliding with a mesh.
  44701. */
  44702. onCollide: (collidedMesh: AbstractMesh) => void;
  44703. /**
  44704. * Defines whether the camera should check collision with the objects oh the scene.
  44705. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44706. */
  44707. checkCollisions: boolean;
  44708. /**
  44709. * Defines the collision radius of the camera.
  44710. * This simulates a sphere around the camera.
  44711. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44712. */
  44713. collisionRadius: Vector3;
  44714. protected _collider: Collider;
  44715. protected _previousPosition: Vector3;
  44716. protected _collisionVelocity: Vector3;
  44717. protected _newPosition: Vector3;
  44718. protected _previousAlpha: number;
  44719. protected _previousBeta: number;
  44720. protected _previousRadius: number;
  44721. protected _collisionTriggered: boolean;
  44722. protected _targetBoundingCenter: Nullable<Vector3>;
  44723. private _computationVector;
  44724. /**
  44725. * Instantiates a new ArcRotateCamera in a given scene
  44726. * @param name Defines the name of the camera
  44727. * @param alpha Defines the camera rotation along the logitudinal axis
  44728. * @param beta Defines the camera rotation along the latitudinal axis
  44729. * @param radius Defines the camera distance from its target
  44730. * @param target Defines the camera target
  44731. * @param scene Defines the scene the camera belongs to
  44732. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44733. */
  44734. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44735. /** @hidden */
  44736. _initCache(): void;
  44737. /** @hidden */
  44738. _updateCache(ignoreParentClass?: boolean): void;
  44739. protected _getTargetPosition(): Vector3;
  44740. private _storedAlpha;
  44741. private _storedBeta;
  44742. private _storedRadius;
  44743. private _storedTarget;
  44744. private _storedTargetScreenOffset;
  44745. /**
  44746. * Stores the current state of the camera (alpha, beta, radius and target)
  44747. * @returns the camera itself
  44748. */
  44749. storeState(): Camera;
  44750. /**
  44751. * @hidden
  44752. * Restored camera state. You must call storeState() first
  44753. */
  44754. _restoreStateValues(): boolean;
  44755. /** @hidden */
  44756. _isSynchronizedViewMatrix(): boolean;
  44757. /**
  44758. * Attached controls to the current camera.
  44759. * @param element Defines the element the controls should be listened from
  44760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44761. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44762. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44763. */
  44764. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44765. /**
  44766. * Detach the current controls from the camera.
  44767. * The camera will stop reacting to inputs.
  44768. * @param element Defines the element to stop listening the inputs from
  44769. */
  44770. detachControl(element: HTMLElement): void;
  44771. /** @hidden */
  44772. _checkInputs(): void;
  44773. protected _checkLimits(): void;
  44774. /**
  44775. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44776. */
  44777. rebuildAnglesAndRadius(): void;
  44778. /**
  44779. * Use a position to define the current camera related information like alpha, beta and radius
  44780. * @param position Defines the position to set the camera at
  44781. */
  44782. setPosition(position: Vector3): void;
  44783. /**
  44784. * Defines the target the camera should look at.
  44785. * This will automatically adapt alpha beta and radius to fit within the new target.
  44786. * @param target Defines the new target as a Vector or a mesh
  44787. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44788. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44789. */
  44790. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44791. /** @hidden */
  44792. _getViewMatrix(): Matrix;
  44793. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44794. /**
  44795. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44796. * @param meshes Defines the mesh to zoom on
  44797. * @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)
  44798. */
  44799. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44800. /**
  44801. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44802. * The target will be changed but the radius
  44803. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44804. * @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)
  44805. */
  44806. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44807. min: Vector3;
  44808. max: Vector3;
  44809. distance: number;
  44810. }, doNotUpdateMaxZ?: boolean): void;
  44811. /**
  44812. * @override
  44813. * Override Camera.createRigCamera
  44814. */
  44815. createRigCamera(name: string, cameraIndex: number): Camera;
  44816. /**
  44817. * @hidden
  44818. * @override
  44819. * Override Camera._updateRigCameras
  44820. */
  44821. _updateRigCameras(): void;
  44822. /**
  44823. * Destroy the camera and release the current resources hold by it.
  44824. */
  44825. dispose(): void;
  44826. /**
  44827. * Gets the current object class name.
  44828. * @return the class name
  44829. */
  44830. getClassName(): string;
  44831. }
  44832. }
  44833. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44834. import { Behavior } from "babylonjs/Behaviors/behavior";
  44835. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44836. /**
  44837. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44838. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44839. */
  44840. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44841. /**
  44842. * Gets the name of the behavior.
  44843. */
  44844. get name(): string;
  44845. private _zoomStopsAnimation;
  44846. private _idleRotationSpeed;
  44847. private _idleRotationWaitTime;
  44848. private _idleRotationSpinupTime;
  44849. /**
  44850. * Sets the flag that indicates if user zooming should stop animation.
  44851. */
  44852. set zoomStopsAnimation(flag: boolean);
  44853. /**
  44854. * Gets the flag that indicates if user zooming should stop animation.
  44855. */
  44856. get zoomStopsAnimation(): boolean;
  44857. /**
  44858. * Sets the default speed at which the camera rotates around the model.
  44859. */
  44860. set idleRotationSpeed(speed: number);
  44861. /**
  44862. * Gets the default speed at which the camera rotates around the model.
  44863. */
  44864. get idleRotationSpeed(): number;
  44865. /**
  44866. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44867. */
  44868. set idleRotationWaitTime(time: number);
  44869. /**
  44870. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44871. */
  44872. get idleRotationWaitTime(): number;
  44873. /**
  44874. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44875. */
  44876. set idleRotationSpinupTime(time: number);
  44877. /**
  44878. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  44879. */
  44880. get idleRotationSpinupTime(): number;
  44881. /**
  44882. * Gets a value indicating if the camera is currently rotating because of this behavior
  44883. */
  44884. get rotationInProgress(): boolean;
  44885. private _onPrePointerObservableObserver;
  44886. private _onAfterCheckInputsObserver;
  44887. private _attachedCamera;
  44888. private _isPointerDown;
  44889. private _lastFrameTime;
  44890. private _lastInteractionTime;
  44891. private _cameraRotationSpeed;
  44892. /**
  44893. * Initializes the behavior.
  44894. */
  44895. init(): void;
  44896. /**
  44897. * Attaches the behavior to its arc rotate camera.
  44898. * @param camera Defines the camera to attach the behavior to
  44899. */
  44900. attach(camera: ArcRotateCamera): void;
  44901. /**
  44902. * Detaches the behavior from its current arc rotate camera.
  44903. */
  44904. detach(): void;
  44905. /**
  44906. * Returns true if user is scrolling.
  44907. * @return true if user is scrolling.
  44908. */
  44909. private _userIsZooming;
  44910. private _lastFrameRadius;
  44911. private _shouldAnimationStopForInteraction;
  44912. /**
  44913. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44914. */
  44915. private _applyUserInteraction;
  44916. private _userIsMoving;
  44917. }
  44918. }
  44919. declare module "babylonjs/Behaviors/Cameras/index" {
  44920. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44921. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44922. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  44923. }
  44924. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  44925. import { Mesh } from "babylonjs/Meshes/mesh";
  44926. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44927. import { Behavior } from "babylonjs/Behaviors/behavior";
  44928. /**
  44929. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  44930. */
  44931. export class AttachToBoxBehavior implements Behavior<Mesh> {
  44932. private ui;
  44933. /**
  44934. * The name of the behavior
  44935. */
  44936. name: string;
  44937. /**
  44938. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  44939. */
  44940. distanceAwayFromFace: number;
  44941. /**
  44942. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  44943. */
  44944. distanceAwayFromBottomOfFace: number;
  44945. private _faceVectors;
  44946. private _target;
  44947. private _scene;
  44948. private _onRenderObserver;
  44949. private _tmpMatrix;
  44950. private _tmpVector;
  44951. /**
  44952. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  44953. * @param ui The transform node that should be attched to the mesh
  44954. */
  44955. constructor(ui: TransformNode);
  44956. /**
  44957. * Initializes the behavior
  44958. */
  44959. init(): void;
  44960. private _closestFace;
  44961. private _zeroVector;
  44962. private _lookAtTmpMatrix;
  44963. private _lookAtToRef;
  44964. /**
  44965. * Attaches the AttachToBoxBehavior to the passed in mesh
  44966. * @param target The mesh that the specified node will be attached to
  44967. */
  44968. attach(target: Mesh): void;
  44969. /**
  44970. * Detaches the behavior from the mesh
  44971. */
  44972. detach(): void;
  44973. }
  44974. }
  44975. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  44976. import { Behavior } from "babylonjs/Behaviors/behavior";
  44977. import { Mesh } from "babylonjs/Meshes/mesh";
  44978. /**
  44979. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  44980. */
  44981. export class FadeInOutBehavior implements Behavior<Mesh> {
  44982. /**
  44983. * Time in milliseconds to delay before fading in (Default: 0)
  44984. */
  44985. delay: number;
  44986. /**
  44987. * Time in milliseconds for the mesh to fade in (Default: 300)
  44988. */
  44989. fadeInTime: number;
  44990. private _millisecondsPerFrame;
  44991. private _hovered;
  44992. private _hoverValue;
  44993. private _ownerNode;
  44994. /**
  44995. * Instatiates the FadeInOutBehavior
  44996. */
  44997. constructor();
  44998. /**
  44999. * The name of the behavior
  45000. */
  45001. get name(): string;
  45002. /**
  45003. * Initializes the behavior
  45004. */
  45005. init(): void;
  45006. /**
  45007. * Attaches the fade behavior on the passed in mesh
  45008. * @param ownerNode The mesh that will be faded in/out once attached
  45009. */
  45010. attach(ownerNode: Mesh): void;
  45011. /**
  45012. * Detaches the behavior from the mesh
  45013. */
  45014. detach(): void;
  45015. /**
  45016. * Triggers the mesh to begin fading in or out
  45017. * @param value if the object should fade in or out (true to fade in)
  45018. */
  45019. fadeIn(value: boolean): void;
  45020. private _update;
  45021. private _setAllVisibility;
  45022. }
  45023. }
  45024. declare module "babylonjs/Misc/pivotTools" {
  45025. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45026. /**
  45027. * Class containing a set of static utilities functions for managing Pivots
  45028. * @hidden
  45029. */
  45030. export class PivotTools {
  45031. private static _PivotCached;
  45032. private static _OldPivotPoint;
  45033. private static _PivotTranslation;
  45034. private static _PivotTmpVector;
  45035. private static _PivotPostMultiplyPivotMatrix;
  45036. /** @hidden */
  45037. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45038. /** @hidden */
  45039. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45040. }
  45041. }
  45042. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45043. import { Scene } from "babylonjs/scene";
  45044. import { Vector4 } from "babylonjs/Maths/math.vector";
  45045. import { Mesh } from "babylonjs/Meshes/mesh";
  45046. import { Nullable } from "babylonjs/types";
  45047. import { Plane } from "babylonjs/Maths/math.plane";
  45048. /**
  45049. * Class containing static functions to help procedurally build meshes
  45050. */
  45051. export class PlaneBuilder {
  45052. /**
  45053. * Creates a plane mesh
  45054. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45055. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45056. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45058. * * 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
  45059. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45060. * @param name defines the name of the mesh
  45061. * @param options defines the options used to create the mesh
  45062. * @param scene defines the hosting scene
  45063. * @returns the plane mesh
  45064. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45065. */
  45066. static CreatePlane(name: string, options: {
  45067. size?: number;
  45068. width?: number;
  45069. height?: number;
  45070. sideOrientation?: number;
  45071. frontUVs?: Vector4;
  45072. backUVs?: Vector4;
  45073. updatable?: boolean;
  45074. sourcePlane?: Plane;
  45075. }, scene?: Nullable<Scene>): Mesh;
  45076. }
  45077. }
  45078. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45079. import { Behavior } from "babylonjs/Behaviors/behavior";
  45080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45081. import { Observable } from "babylonjs/Misc/observable";
  45082. import { Vector3 } from "babylonjs/Maths/math.vector";
  45083. import { Ray } from "babylonjs/Culling/ray";
  45084. import "babylonjs/Meshes/Builders/planeBuilder";
  45085. /**
  45086. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45087. */
  45088. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45089. private static _AnyMouseID;
  45090. /**
  45091. * Abstract mesh the behavior is set on
  45092. */
  45093. attachedNode: AbstractMesh;
  45094. private _dragPlane;
  45095. private _scene;
  45096. private _pointerObserver;
  45097. private _beforeRenderObserver;
  45098. private static _planeScene;
  45099. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45100. /**
  45101. * 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)
  45102. */
  45103. maxDragAngle: number;
  45104. /**
  45105. * @hidden
  45106. */
  45107. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45108. /**
  45109. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45110. */
  45111. currentDraggingPointerID: number;
  45112. /**
  45113. * The last position where the pointer hit the drag plane in world space
  45114. */
  45115. lastDragPosition: Vector3;
  45116. /**
  45117. * If the behavior is currently in a dragging state
  45118. */
  45119. dragging: boolean;
  45120. /**
  45121. * 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)
  45122. */
  45123. dragDeltaRatio: number;
  45124. /**
  45125. * If the drag plane orientation should be updated during the dragging (Default: true)
  45126. */
  45127. updateDragPlane: boolean;
  45128. private _debugMode;
  45129. private _moving;
  45130. /**
  45131. * Fires each time the attached mesh is dragged with the pointer
  45132. * * delta between last drag position and current drag position in world space
  45133. * * dragDistance along the drag axis
  45134. * * dragPlaneNormal normal of the current drag plane used during the drag
  45135. * * dragPlanePoint in world space where the drag intersects the drag plane
  45136. */
  45137. onDragObservable: Observable<{
  45138. delta: Vector3;
  45139. dragPlanePoint: Vector3;
  45140. dragPlaneNormal: Vector3;
  45141. dragDistance: number;
  45142. pointerId: number;
  45143. }>;
  45144. /**
  45145. * Fires each time a drag begins (eg. mouse down on mesh)
  45146. */
  45147. onDragStartObservable: Observable<{
  45148. dragPlanePoint: Vector3;
  45149. pointerId: number;
  45150. }>;
  45151. /**
  45152. * Fires each time a drag ends (eg. mouse release after drag)
  45153. */
  45154. onDragEndObservable: Observable<{
  45155. dragPlanePoint: Vector3;
  45156. pointerId: number;
  45157. }>;
  45158. /**
  45159. * If the attached mesh should be moved when dragged
  45160. */
  45161. moveAttached: boolean;
  45162. /**
  45163. * If the drag behavior will react to drag events (Default: true)
  45164. */
  45165. enabled: boolean;
  45166. /**
  45167. * If pointer events should start and release the drag (Default: true)
  45168. */
  45169. startAndReleaseDragOnPointerEvents: boolean;
  45170. /**
  45171. * If camera controls should be detached during the drag
  45172. */
  45173. detachCameraControls: boolean;
  45174. /**
  45175. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45176. */
  45177. useObjectOrientationForDragging: boolean;
  45178. private _options;
  45179. /**
  45180. * Gets the options used by the behavior
  45181. */
  45182. get options(): {
  45183. dragAxis?: Vector3;
  45184. dragPlaneNormal?: Vector3;
  45185. };
  45186. /**
  45187. * Sets the options used by the behavior
  45188. */
  45189. set options(options: {
  45190. dragAxis?: Vector3;
  45191. dragPlaneNormal?: Vector3;
  45192. });
  45193. /**
  45194. * Creates a pointer drag behavior that can be attached to a mesh
  45195. * @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)
  45196. */
  45197. constructor(options?: {
  45198. dragAxis?: Vector3;
  45199. dragPlaneNormal?: Vector3;
  45200. });
  45201. /**
  45202. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45203. */
  45204. validateDrag: (targetPosition: Vector3) => boolean;
  45205. /**
  45206. * The name of the behavior
  45207. */
  45208. get name(): string;
  45209. /**
  45210. * Initializes the behavior
  45211. */
  45212. init(): void;
  45213. private _tmpVector;
  45214. private _alternatePickedPoint;
  45215. private _worldDragAxis;
  45216. private _targetPosition;
  45217. private _attachedElement;
  45218. /**
  45219. * Attaches the drag behavior the passed in mesh
  45220. * @param ownerNode The mesh that will be dragged around once attached
  45221. * @param predicate Predicate to use for pick filtering
  45222. */
  45223. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45224. /**
  45225. * Force relase the drag action by code.
  45226. */
  45227. releaseDrag(): void;
  45228. private _startDragRay;
  45229. private _lastPointerRay;
  45230. /**
  45231. * Simulates the start of a pointer drag event on the behavior
  45232. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45233. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45234. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45235. */
  45236. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45237. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45238. private _dragDelta;
  45239. protected _moveDrag(ray: Ray): void;
  45240. private _pickWithRayOnDragPlane;
  45241. private _pointA;
  45242. private _pointC;
  45243. private _localAxis;
  45244. private _lookAt;
  45245. private _updateDragPlanePosition;
  45246. /**
  45247. * Detaches the behavior from the mesh
  45248. */
  45249. detach(): void;
  45250. }
  45251. }
  45252. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45253. import { Mesh } from "babylonjs/Meshes/mesh";
  45254. import { Behavior } from "babylonjs/Behaviors/behavior";
  45255. /**
  45256. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45257. */
  45258. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45259. private _dragBehaviorA;
  45260. private _dragBehaviorB;
  45261. private _startDistance;
  45262. private _initialScale;
  45263. private _targetScale;
  45264. private _ownerNode;
  45265. private _sceneRenderObserver;
  45266. /**
  45267. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45268. */
  45269. constructor();
  45270. /**
  45271. * The name of the behavior
  45272. */
  45273. get name(): string;
  45274. /**
  45275. * Initializes the behavior
  45276. */
  45277. init(): void;
  45278. private _getCurrentDistance;
  45279. /**
  45280. * Attaches the scale behavior the passed in mesh
  45281. * @param ownerNode The mesh that will be scaled around once attached
  45282. */
  45283. attach(ownerNode: Mesh): void;
  45284. /**
  45285. * Detaches the behavior from the mesh
  45286. */
  45287. detach(): void;
  45288. }
  45289. }
  45290. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45291. import { Behavior } from "babylonjs/Behaviors/behavior";
  45292. import { Mesh } from "babylonjs/Meshes/mesh";
  45293. import { Observable } from "babylonjs/Misc/observable";
  45294. /**
  45295. * 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
  45296. */
  45297. export class SixDofDragBehavior implements Behavior<Mesh> {
  45298. private static _virtualScene;
  45299. private _ownerNode;
  45300. private _sceneRenderObserver;
  45301. private _scene;
  45302. private _targetPosition;
  45303. private _virtualOriginMesh;
  45304. private _virtualDragMesh;
  45305. private _pointerObserver;
  45306. private _moving;
  45307. private _startingOrientation;
  45308. private _attachedElement;
  45309. /**
  45310. * 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)
  45311. */
  45312. private zDragFactor;
  45313. /**
  45314. * If the object should rotate to face the drag origin
  45315. */
  45316. rotateDraggedObject: boolean;
  45317. /**
  45318. * If the behavior is currently in a dragging state
  45319. */
  45320. dragging: boolean;
  45321. /**
  45322. * 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)
  45323. */
  45324. dragDeltaRatio: number;
  45325. /**
  45326. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45327. */
  45328. currentDraggingPointerID: number;
  45329. /**
  45330. * If camera controls should be detached during the drag
  45331. */
  45332. detachCameraControls: boolean;
  45333. /**
  45334. * Fires each time a drag starts
  45335. */
  45336. onDragStartObservable: Observable<{}>;
  45337. /**
  45338. * Fires each time a drag ends (eg. mouse release after drag)
  45339. */
  45340. onDragEndObservable: Observable<{}>;
  45341. /**
  45342. * 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
  45343. */
  45344. constructor();
  45345. /**
  45346. * The name of the behavior
  45347. */
  45348. get name(): string;
  45349. /**
  45350. * Initializes the behavior
  45351. */
  45352. init(): void;
  45353. /**
  45354. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45355. */
  45356. private get _pointerCamera();
  45357. /**
  45358. * Attaches the scale behavior the passed in mesh
  45359. * @param ownerNode The mesh that will be scaled around once attached
  45360. */
  45361. attach(ownerNode: Mesh): void;
  45362. /**
  45363. * Detaches the behavior from the mesh
  45364. */
  45365. detach(): void;
  45366. }
  45367. }
  45368. declare module "babylonjs/Behaviors/Meshes/index" {
  45369. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45370. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45371. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45372. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45373. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45374. }
  45375. declare module "babylonjs/Behaviors/index" {
  45376. export * from "babylonjs/Behaviors/behavior";
  45377. export * from "babylonjs/Behaviors/Cameras/index";
  45378. export * from "babylonjs/Behaviors/Meshes/index";
  45379. }
  45380. declare module "babylonjs/Bones/boneIKController" {
  45381. import { Bone } from "babylonjs/Bones/bone";
  45382. import { Vector3 } from "babylonjs/Maths/math.vector";
  45383. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45384. import { Nullable } from "babylonjs/types";
  45385. /**
  45386. * Class used to apply inverse kinematics to bones
  45387. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45388. */
  45389. export class BoneIKController {
  45390. private static _tmpVecs;
  45391. private static _tmpQuat;
  45392. private static _tmpMats;
  45393. /**
  45394. * Gets or sets the target mesh
  45395. */
  45396. targetMesh: AbstractMesh;
  45397. /** Gets or sets the mesh used as pole */
  45398. poleTargetMesh: AbstractMesh;
  45399. /**
  45400. * Gets or sets the bone used as pole
  45401. */
  45402. poleTargetBone: Nullable<Bone>;
  45403. /**
  45404. * Gets or sets the target position
  45405. */
  45406. targetPosition: Vector3;
  45407. /**
  45408. * Gets or sets the pole target position
  45409. */
  45410. poleTargetPosition: Vector3;
  45411. /**
  45412. * Gets or sets the pole target local offset
  45413. */
  45414. poleTargetLocalOffset: Vector3;
  45415. /**
  45416. * Gets or sets the pole angle
  45417. */
  45418. poleAngle: number;
  45419. /**
  45420. * Gets or sets the mesh associated with the controller
  45421. */
  45422. mesh: AbstractMesh;
  45423. /**
  45424. * 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)
  45425. */
  45426. slerpAmount: number;
  45427. private _bone1Quat;
  45428. private _bone1Mat;
  45429. private _bone2Ang;
  45430. private _bone1;
  45431. private _bone2;
  45432. private _bone1Length;
  45433. private _bone2Length;
  45434. private _maxAngle;
  45435. private _maxReach;
  45436. private _rightHandedSystem;
  45437. private _bendAxis;
  45438. private _slerping;
  45439. private _adjustRoll;
  45440. /**
  45441. * Gets or sets maximum allowed angle
  45442. */
  45443. get maxAngle(): number;
  45444. set maxAngle(value: number);
  45445. /**
  45446. * Creates a new BoneIKController
  45447. * @param mesh defines the mesh to control
  45448. * @param bone defines the bone to control
  45449. * @param options defines options to set up the controller
  45450. */
  45451. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45452. targetMesh?: AbstractMesh;
  45453. poleTargetMesh?: AbstractMesh;
  45454. poleTargetBone?: Bone;
  45455. poleTargetLocalOffset?: Vector3;
  45456. poleAngle?: number;
  45457. bendAxis?: Vector3;
  45458. maxAngle?: number;
  45459. slerpAmount?: number;
  45460. });
  45461. private _setMaxAngle;
  45462. /**
  45463. * Force the controller to update the bones
  45464. */
  45465. update(): void;
  45466. }
  45467. }
  45468. declare module "babylonjs/Bones/boneLookController" {
  45469. import { Vector3 } from "babylonjs/Maths/math.vector";
  45470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45471. import { Bone } from "babylonjs/Bones/bone";
  45472. import { Space } from "babylonjs/Maths/math.axis";
  45473. /**
  45474. * Class used to make a bone look toward a point in space
  45475. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45476. */
  45477. export class BoneLookController {
  45478. private static _tmpVecs;
  45479. private static _tmpQuat;
  45480. private static _tmpMats;
  45481. /**
  45482. * The target Vector3 that the bone will look at
  45483. */
  45484. target: Vector3;
  45485. /**
  45486. * The mesh that the bone is attached to
  45487. */
  45488. mesh: AbstractMesh;
  45489. /**
  45490. * The bone that will be looking to the target
  45491. */
  45492. bone: Bone;
  45493. /**
  45494. * The up axis of the coordinate system that is used when the bone is rotated
  45495. */
  45496. upAxis: Vector3;
  45497. /**
  45498. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45499. */
  45500. upAxisSpace: Space;
  45501. /**
  45502. * Used to make an adjustment to the yaw of the bone
  45503. */
  45504. adjustYaw: number;
  45505. /**
  45506. * Used to make an adjustment to the pitch of the bone
  45507. */
  45508. adjustPitch: number;
  45509. /**
  45510. * Used to make an adjustment to the roll of the bone
  45511. */
  45512. adjustRoll: number;
  45513. /**
  45514. * 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)
  45515. */
  45516. slerpAmount: number;
  45517. private _minYaw;
  45518. private _maxYaw;
  45519. private _minPitch;
  45520. private _maxPitch;
  45521. private _minYawSin;
  45522. private _minYawCos;
  45523. private _maxYawSin;
  45524. private _maxYawCos;
  45525. private _midYawConstraint;
  45526. private _minPitchTan;
  45527. private _maxPitchTan;
  45528. private _boneQuat;
  45529. private _slerping;
  45530. private _transformYawPitch;
  45531. private _transformYawPitchInv;
  45532. private _firstFrameSkipped;
  45533. private _yawRange;
  45534. private _fowardAxis;
  45535. /**
  45536. * Gets or sets the minimum yaw angle that the bone can look to
  45537. */
  45538. get minYaw(): number;
  45539. set minYaw(value: number);
  45540. /**
  45541. * Gets or sets the maximum yaw angle that the bone can look to
  45542. */
  45543. get maxYaw(): number;
  45544. set maxYaw(value: number);
  45545. /**
  45546. * Gets or sets the minimum pitch angle that the bone can look to
  45547. */
  45548. get minPitch(): number;
  45549. set minPitch(value: number);
  45550. /**
  45551. * Gets or sets the maximum pitch angle that the bone can look to
  45552. */
  45553. get maxPitch(): number;
  45554. set maxPitch(value: number);
  45555. /**
  45556. * Create a BoneLookController
  45557. * @param mesh the mesh that the bone belongs to
  45558. * @param bone the bone that will be looking to the target
  45559. * @param target the target Vector3 to look at
  45560. * @param options optional settings:
  45561. * * maxYaw: the maximum angle the bone will yaw to
  45562. * * minYaw: the minimum angle the bone will yaw to
  45563. * * maxPitch: the maximum angle the bone will pitch to
  45564. * * minPitch: the minimum angle the bone will yaw to
  45565. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45566. * * upAxis: the up axis of the coordinate system
  45567. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45568. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45569. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45570. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45571. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45572. * * adjustRoll: used to make an adjustment to the roll of the bone
  45573. **/
  45574. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45575. maxYaw?: number;
  45576. minYaw?: number;
  45577. maxPitch?: number;
  45578. minPitch?: number;
  45579. slerpAmount?: number;
  45580. upAxis?: Vector3;
  45581. upAxisSpace?: Space;
  45582. yawAxis?: Vector3;
  45583. pitchAxis?: Vector3;
  45584. adjustYaw?: number;
  45585. adjustPitch?: number;
  45586. adjustRoll?: number;
  45587. });
  45588. /**
  45589. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45590. */
  45591. update(): void;
  45592. private _getAngleDiff;
  45593. private _getAngleBetween;
  45594. private _isAngleBetween;
  45595. }
  45596. }
  45597. declare module "babylonjs/Bones/index" {
  45598. export * from "babylonjs/Bones/bone";
  45599. export * from "babylonjs/Bones/boneIKController";
  45600. export * from "babylonjs/Bones/boneLookController";
  45601. export * from "babylonjs/Bones/skeleton";
  45602. }
  45603. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45604. import { Nullable } from "babylonjs/types";
  45605. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45606. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45607. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45608. /**
  45609. * Manage the gamepad inputs to control an arc rotate camera.
  45610. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45611. */
  45612. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45613. /**
  45614. * Defines the camera the input is attached to.
  45615. */
  45616. camera: ArcRotateCamera;
  45617. /**
  45618. * Defines the gamepad the input is gathering event from.
  45619. */
  45620. gamepad: Nullable<Gamepad>;
  45621. /**
  45622. * Defines the gamepad rotation sensiblity.
  45623. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45624. */
  45625. gamepadRotationSensibility: number;
  45626. /**
  45627. * Defines the gamepad move sensiblity.
  45628. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45629. */
  45630. gamepadMoveSensibility: number;
  45631. private _yAxisScale;
  45632. /**
  45633. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45634. */
  45635. get invertYAxis(): boolean;
  45636. set invertYAxis(value: boolean);
  45637. private _onGamepadConnectedObserver;
  45638. private _onGamepadDisconnectedObserver;
  45639. /**
  45640. * Attach the input controls to a specific dom element to get the input from.
  45641. * @param element Defines the element the controls should be listened from
  45642. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45643. */
  45644. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45645. /**
  45646. * Detach the current controls from the specified dom element.
  45647. * @param element Defines the element to stop listening the inputs from
  45648. */
  45649. detachControl(element: Nullable<HTMLElement>): void;
  45650. /**
  45651. * Update the current camera state depending on the inputs that have been used this frame.
  45652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45653. */
  45654. checkInputs(): void;
  45655. /**
  45656. * Gets the class name of the current intput.
  45657. * @returns the class name
  45658. */
  45659. getClassName(): string;
  45660. /**
  45661. * Get the friendly name associated with the input class.
  45662. * @returns the input friendly name
  45663. */
  45664. getSimpleName(): string;
  45665. }
  45666. }
  45667. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45668. import { Nullable } from "babylonjs/types";
  45669. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45670. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45671. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45672. interface ArcRotateCameraInputsManager {
  45673. /**
  45674. * Add orientation input support to the input manager.
  45675. * @returns the current input manager
  45676. */
  45677. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45678. }
  45679. }
  45680. /**
  45681. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45682. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45683. */
  45684. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45685. /**
  45686. * Defines the camera the input is attached to.
  45687. */
  45688. camera: ArcRotateCamera;
  45689. /**
  45690. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45691. */
  45692. alphaCorrection: number;
  45693. /**
  45694. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45695. */
  45696. gammaCorrection: number;
  45697. private _alpha;
  45698. private _gamma;
  45699. private _dirty;
  45700. private _deviceOrientationHandler;
  45701. /**
  45702. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45703. */
  45704. constructor();
  45705. /**
  45706. * Attach the input controls to a specific dom element to get the input from.
  45707. * @param element Defines the element the controls should be listened from
  45708. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45709. */
  45710. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45711. /** @hidden */
  45712. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45713. /**
  45714. * Update the current camera state depending on the inputs that have been used this frame.
  45715. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45716. */
  45717. checkInputs(): void;
  45718. /**
  45719. * Detach the current controls from the specified dom element.
  45720. * @param element Defines the element to stop listening the inputs from
  45721. */
  45722. detachControl(element: Nullable<HTMLElement>): void;
  45723. /**
  45724. * Gets the class name of the current intput.
  45725. * @returns the class name
  45726. */
  45727. getClassName(): string;
  45728. /**
  45729. * Get the friendly name associated with the input class.
  45730. * @returns the input friendly name
  45731. */
  45732. getSimpleName(): string;
  45733. }
  45734. }
  45735. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45736. import { Nullable } from "babylonjs/types";
  45737. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45738. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45739. /**
  45740. * Listen to mouse events to control the camera.
  45741. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45742. */
  45743. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45744. /**
  45745. * Defines the camera the input is attached to.
  45746. */
  45747. camera: FlyCamera;
  45748. /**
  45749. * Defines if touch is enabled. (Default is true.)
  45750. */
  45751. touchEnabled: boolean;
  45752. /**
  45753. * Defines the buttons associated with the input to handle camera rotation.
  45754. */
  45755. buttons: number[];
  45756. /**
  45757. * Assign buttons for Yaw control.
  45758. */
  45759. buttonsYaw: number[];
  45760. /**
  45761. * Assign buttons for Pitch control.
  45762. */
  45763. buttonsPitch: number[];
  45764. /**
  45765. * Assign buttons for Roll control.
  45766. */
  45767. buttonsRoll: number[];
  45768. /**
  45769. * Detect if any button is being pressed while mouse is moved.
  45770. * -1 = Mouse locked.
  45771. * 0 = Left button.
  45772. * 1 = Middle Button.
  45773. * 2 = Right Button.
  45774. */
  45775. activeButton: number;
  45776. /**
  45777. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45778. * Higher values reduce its sensitivity.
  45779. */
  45780. angularSensibility: number;
  45781. private _mousemoveCallback;
  45782. private _observer;
  45783. private _rollObserver;
  45784. private previousPosition;
  45785. private noPreventDefault;
  45786. private element;
  45787. /**
  45788. * Listen to mouse events to control the camera.
  45789. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45790. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45791. */
  45792. constructor(touchEnabled?: boolean);
  45793. /**
  45794. * Attach the mouse control to the HTML DOM element.
  45795. * @param element Defines the element that listens to the input events.
  45796. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45797. */
  45798. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45799. /**
  45800. * Detach the current controls from the specified dom element.
  45801. * @param element Defines the element to stop listening the inputs from
  45802. */
  45803. detachControl(element: Nullable<HTMLElement>): void;
  45804. /**
  45805. * Gets the class name of the current input.
  45806. * @returns the class name.
  45807. */
  45808. getClassName(): string;
  45809. /**
  45810. * Get the friendly name associated with the input class.
  45811. * @returns the input's friendly name.
  45812. */
  45813. getSimpleName(): string;
  45814. private _pointerInput;
  45815. private _onMouseMove;
  45816. /**
  45817. * Rotate camera by mouse offset.
  45818. */
  45819. private rotateCamera;
  45820. }
  45821. }
  45822. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45823. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45824. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45825. /**
  45826. * Default Inputs manager for the FlyCamera.
  45827. * It groups all the default supported inputs for ease of use.
  45828. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45829. */
  45830. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45831. /**
  45832. * Instantiates a new FlyCameraInputsManager.
  45833. * @param camera Defines the camera the inputs belong to.
  45834. */
  45835. constructor(camera: FlyCamera);
  45836. /**
  45837. * Add keyboard input support to the input manager.
  45838. * @returns the new FlyCameraKeyboardMoveInput().
  45839. */
  45840. addKeyboard(): FlyCameraInputsManager;
  45841. /**
  45842. * Add mouse input support to the input manager.
  45843. * @param touchEnabled Enable touch screen support.
  45844. * @returns the new FlyCameraMouseInput().
  45845. */
  45846. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45847. }
  45848. }
  45849. declare module "babylonjs/Cameras/flyCamera" {
  45850. import { Scene } from "babylonjs/scene";
  45851. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45853. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45854. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45855. /**
  45856. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45857. * such as in a 3D Space Shooter or a Flight Simulator.
  45858. */
  45859. export class FlyCamera extends TargetCamera {
  45860. /**
  45861. * Define the collision ellipsoid of the camera.
  45862. * This is helpful for simulating a camera body, like a player's body.
  45863. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45864. */
  45865. ellipsoid: Vector3;
  45866. /**
  45867. * Define an offset for the position of the ellipsoid around the camera.
  45868. * This can be helpful if the camera is attached away from the player's body center,
  45869. * such as at its head.
  45870. */
  45871. ellipsoidOffset: Vector3;
  45872. /**
  45873. * Enable or disable collisions of the camera with the rest of the scene objects.
  45874. */
  45875. checkCollisions: boolean;
  45876. /**
  45877. * Enable or disable gravity on the camera.
  45878. */
  45879. applyGravity: boolean;
  45880. /**
  45881. * Define the current direction the camera is moving to.
  45882. */
  45883. cameraDirection: Vector3;
  45884. /**
  45885. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  45886. * This overrides and empties cameraRotation.
  45887. */
  45888. rotationQuaternion: Quaternion;
  45889. /**
  45890. * Track Roll to maintain the wanted Rolling when looking around.
  45891. */
  45892. _trackRoll: number;
  45893. /**
  45894. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  45895. */
  45896. rollCorrect: number;
  45897. /**
  45898. * Mimic a banked turn, Rolling the camera when Yawing.
  45899. * It's recommended to use rollCorrect = 10 for faster banking correction.
  45900. */
  45901. bankedTurn: boolean;
  45902. /**
  45903. * Limit in radians for how much Roll banking will add. (Default: 90°)
  45904. */
  45905. bankedTurnLimit: number;
  45906. /**
  45907. * Value of 0 disables the banked Roll.
  45908. * Value of 1 is equal to the Yaw angle in radians.
  45909. */
  45910. bankedTurnMultiplier: number;
  45911. /**
  45912. * The inputs manager loads all the input sources, such as keyboard and mouse.
  45913. */
  45914. inputs: FlyCameraInputsManager;
  45915. /**
  45916. * Gets the input sensibility for mouse input.
  45917. * Higher values reduce sensitivity.
  45918. */
  45919. get angularSensibility(): number;
  45920. /**
  45921. * Sets the input sensibility for a mouse input.
  45922. * Higher values reduce sensitivity.
  45923. */
  45924. set angularSensibility(value: number);
  45925. /**
  45926. * Get the keys for camera movement forward.
  45927. */
  45928. get keysForward(): number[];
  45929. /**
  45930. * Set the keys for camera movement forward.
  45931. */
  45932. set keysForward(value: number[]);
  45933. /**
  45934. * Get the keys for camera movement backward.
  45935. */
  45936. get keysBackward(): number[];
  45937. set keysBackward(value: number[]);
  45938. /**
  45939. * Get the keys for camera movement up.
  45940. */
  45941. get keysUp(): number[];
  45942. /**
  45943. * Set the keys for camera movement up.
  45944. */
  45945. set keysUp(value: number[]);
  45946. /**
  45947. * Get the keys for camera movement down.
  45948. */
  45949. get keysDown(): number[];
  45950. /**
  45951. * Set the keys for camera movement down.
  45952. */
  45953. set keysDown(value: number[]);
  45954. /**
  45955. * Get the keys for camera movement left.
  45956. */
  45957. get keysLeft(): number[];
  45958. /**
  45959. * Set the keys for camera movement left.
  45960. */
  45961. set keysLeft(value: number[]);
  45962. /**
  45963. * Set the keys for camera movement right.
  45964. */
  45965. get keysRight(): number[];
  45966. /**
  45967. * Set the keys for camera movement right.
  45968. */
  45969. set keysRight(value: number[]);
  45970. /**
  45971. * Event raised when the camera collides with a mesh in the scene.
  45972. */
  45973. onCollide: (collidedMesh: AbstractMesh) => void;
  45974. private _collider;
  45975. private _needMoveForGravity;
  45976. private _oldPosition;
  45977. private _diffPosition;
  45978. private _newPosition;
  45979. /** @hidden */
  45980. _localDirection: Vector3;
  45981. /** @hidden */
  45982. _transformedDirection: Vector3;
  45983. /**
  45984. * Instantiates a FlyCamera.
  45985. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45986. * such as in a 3D Space Shooter or a Flight Simulator.
  45987. * @param name Define the name of the camera in the scene.
  45988. * @param position Define the starting position of the camera in the scene.
  45989. * @param scene Define the scene the camera belongs to.
  45990. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  45991. */
  45992. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  45993. /**
  45994. * Attach a control to the HTML DOM element.
  45995. * @param element Defines the element that listens to the input events.
  45996. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  45997. */
  45998. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45999. /**
  46000. * Detach a control from the HTML DOM element.
  46001. * The camera will stop reacting to that input.
  46002. * @param element Defines the element that listens to the input events.
  46003. */
  46004. detachControl(element: HTMLElement): void;
  46005. private _collisionMask;
  46006. /**
  46007. * Get the mask that the camera ignores in collision events.
  46008. */
  46009. get collisionMask(): number;
  46010. /**
  46011. * Set the mask that the camera ignores in collision events.
  46012. */
  46013. set collisionMask(mask: number);
  46014. /** @hidden */
  46015. _collideWithWorld(displacement: Vector3): void;
  46016. /** @hidden */
  46017. private _onCollisionPositionChange;
  46018. /** @hidden */
  46019. _checkInputs(): void;
  46020. /** @hidden */
  46021. _decideIfNeedsToMove(): boolean;
  46022. /** @hidden */
  46023. _updatePosition(): void;
  46024. /**
  46025. * Restore the Roll to its target value at the rate specified.
  46026. * @param rate - Higher means slower restoring.
  46027. * @hidden
  46028. */
  46029. restoreRoll(rate: number): void;
  46030. /**
  46031. * Destroy the camera and release the current resources held by it.
  46032. */
  46033. dispose(): void;
  46034. /**
  46035. * Get the current object class name.
  46036. * @returns the class name.
  46037. */
  46038. getClassName(): string;
  46039. }
  46040. }
  46041. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46042. import { Nullable } from "babylonjs/types";
  46043. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46044. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46045. /**
  46046. * Listen to keyboard events to control the camera.
  46047. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46048. */
  46049. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46050. /**
  46051. * Defines the camera the input is attached to.
  46052. */
  46053. camera: FlyCamera;
  46054. /**
  46055. * The list of keyboard keys used to control the forward move of the camera.
  46056. */
  46057. keysForward: number[];
  46058. /**
  46059. * The list of keyboard keys used to control the backward move of the camera.
  46060. */
  46061. keysBackward: number[];
  46062. /**
  46063. * The list of keyboard keys used to control the forward move of the camera.
  46064. */
  46065. keysUp: number[];
  46066. /**
  46067. * The list of keyboard keys used to control the backward move of the camera.
  46068. */
  46069. keysDown: number[];
  46070. /**
  46071. * The list of keyboard keys used to control the right strafe move of the camera.
  46072. */
  46073. keysRight: number[];
  46074. /**
  46075. * The list of keyboard keys used to control the left strafe move of the camera.
  46076. */
  46077. keysLeft: number[];
  46078. private _keys;
  46079. private _onCanvasBlurObserver;
  46080. private _onKeyboardObserver;
  46081. private _engine;
  46082. private _scene;
  46083. /**
  46084. * Attach the input controls to a specific dom element to get the input from.
  46085. * @param element Defines the element the controls should be listened from
  46086. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46087. */
  46088. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46089. /**
  46090. * Detach the current controls from the specified dom element.
  46091. * @param element Defines the element to stop listening the inputs from
  46092. */
  46093. detachControl(element: Nullable<HTMLElement>): void;
  46094. /**
  46095. * Gets the class name of the current intput.
  46096. * @returns the class name
  46097. */
  46098. getClassName(): string;
  46099. /** @hidden */
  46100. _onLostFocus(e: FocusEvent): void;
  46101. /**
  46102. * Get the friendly name associated with the input class.
  46103. * @returns the input friendly name
  46104. */
  46105. getSimpleName(): string;
  46106. /**
  46107. * Update the current camera state depending on the inputs that have been used this frame.
  46108. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46109. */
  46110. checkInputs(): void;
  46111. }
  46112. }
  46113. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46114. import { Nullable } from "babylonjs/types";
  46115. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46116. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46117. /**
  46118. * Manage the mouse wheel inputs to control a follow camera.
  46119. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46120. */
  46121. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46122. /**
  46123. * Defines the camera the input is attached to.
  46124. */
  46125. camera: FollowCamera;
  46126. /**
  46127. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46128. */
  46129. axisControlRadius: boolean;
  46130. /**
  46131. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46132. */
  46133. axisControlHeight: boolean;
  46134. /**
  46135. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46136. */
  46137. axisControlRotation: boolean;
  46138. /**
  46139. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46140. * relation to mouseWheel events.
  46141. */
  46142. wheelPrecision: number;
  46143. /**
  46144. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46145. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46146. */
  46147. wheelDeltaPercentage: number;
  46148. private _wheel;
  46149. private _observer;
  46150. /**
  46151. * Attach the input controls to a specific dom element to get the input from.
  46152. * @param element Defines the element the controls should be listened from
  46153. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46154. */
  46155. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46156. /**
  46157. * Detach the current controls from the specified dom element.
  46158. * @param element Defines the element to stop listening the inputs from
  46159. */
  46160. detachControl(element: Nullable<HTMLElement>): void;
  46161. /**
  46162. * Gets the class name of the current intput.
  46163. * @returns the class name
  46164. */
  46165. getClassName(): string;
  46166. /**
  46167. * Get the friendly name associated with the input class.
  46168. * @returns the input friendly name
  46169. */
  46170. getSimpleName(): string;
  46171. }
  46172. }
  46173. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46174. import { Nullable } from "babylonjs/types";
  46175. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46176. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46177. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46178. /**
  46179. * Manage the pointers inputs to control an follow camera.
  46180. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46181. */
  46182. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46183. /**
  46184. * Defines the camera the input is attached to.
  46185. */
  46186. camera: FollowCamera;
  46187. /**
  46188. * Gets the class name of the current input.
  46189. * @returns the class name
  46190. */
  46191. getClassName(): string;
  46192. /**
  46193. * Defines the pointer angular sensibility along the X axis or how fast is
  46194. * the camera rotating.
  46195. * A negative number will reverse the axis direction.
  46196. */
  46197. angularSensibilityX: number;
  46198. /**
  46199. * Defines the pointer angular sensibility along the Y axis or how fast is
  46200. * the camera rotating.
  46201. * A negative number will reverse the axis direction.
  46202. */
  46203. angularSensibilityY: number;
  46204. /**
  46205. * Defines the pointer pinch precision or how fast is the camera zooming.
  46206. * A negative number will reverse the axis direction.
  46207. */
  46208. pinchPrecision: number;
  46209. /**
  46210. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46211. * from 0.
  46212. * It defines the percentage of current camera.radius to use as delta when
  46213. * pinch zoom is used.
  46214. */
  46215. pinchDeltaPercentage: number;
  46216. /**
  46217. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46218. */
  46219. axisXControlRadius: boolean;
  46220. /**
  46221. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46222. */
  46223. axisXControlHeight: boolean;
  46224. /**
  46225. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46226. */
  46227. axisXControlRotation: boolean;
  46228. /**
  46229. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46230. */
  46231. axisYControlRadius: boolean;
  46232. /**
  46233. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46234. */
  46235. axisYControlHeight: boolean;
  46236. /**
  46237. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46238. */
  46239. axisYControlRotation: boolean;
  46240. /**
  46241. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46242. */
  46243. axisPinchControlRadius: boolean;
  46244. /**
  46245. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46246. */
  46247. axisPinchControlHeight: boolean;
  46248. /**
  46249. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46250. */
  46251. axisPinchControlRotation: boolean;
  46252. /**
  46253. * Log error messages if basic misconfiguration has occurred.
  46254. */
  46255. warningEnable: boolean;
  46256. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46257. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46258. private _warningCounter;
  46259. private _warning;
  46260. }
  46261. }
  46262. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46263. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46264. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46265. /**
  46266. * Default Inputs manager for the FollowCamera.
  46267. * It groups all the default supported inputs for ease of use.
  46268. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46269. */
  46270. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46271. /**
  46272. * Instantiates a new FollowCameraInputsManager.
  46273. * @param camera Defines the camera the inputs belong to
  46274. */
  46275. constructor(camera: FollowCamera);
  46276. /**
  46277. * Add keyboard input support to the input manager.
  46278. * @returns the current input manager
  46279. */
  46280. addKeyboard(): FollowCameraInputsManager;
  46281. /**
  46282. * Add mouse wheel input support to the input manager.
  46283. * @returns the current input manager
  46284. */
  46285. addMouseWheel(): FollowCameraInputsManager;
  46286. /**
  46287. * Add pointers input support to the input manager.
  46288. * @returns the current input manager
  46289. */
  46290. addPointers(): FollowCameraInputsManager;
  46291. /**
  46292. * Add orientation input support to the input manager.
  46293. * @returns the current input manager
  46294. */
  46295. addVRDeviceOrientation(): FollowCameraInputsManager;
  46296. }
  46297. }
  46298. declare module "babylonjs/Cameras/followCamera" {
  46299. import { Nullable } from "babylonjs/types";
  46300. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46301. import { Scene } from "babylonjs/scene";
  46302. import { Vector3 } from "babylonjs/Maths/math.vector";
  46303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46304. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46305. /**
  46306. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46307. * an arc rotate version arcFollowCamera are available.
  46308. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46309. */
  46310. export class FollowCamera extends TargetCamera {
  46311. /**
  46312. * Distance the follow camera should follow an object at
  46313. */
  46314. radius: number;
  46315. /**
  46316. * Minimum allowed distance of the camera to the axis of rotation
  46317. * (The camera can not get closer).
  46318. * This can help limiting how the Camera is able to move in the scene.
  46319. */
  46320. lowerRadiusLimit: Nullable<number>;
  46321. /**
  46322. * Maximum allowed distance of the camera to the axis of rotation
  46323. * (The camera can not get further).
  46324. * This can help limiting how the Camera is able to move in the scene.
  46325. */
  46326. upperRadiusLimit: Nullable<number>;
  46327. /**
  46328. * Define a rotation offset between the camera and the object it follows
  46329. */
  46330. rotationOffset: number;
  46331. /**
  46332. * Minimum allowed angle to camera position relative to target object.
  46333. * This can help limiting how the Camera is able to move in the scene.
  46334. */
  46335. lowerRotationOffsetLimit: Nullable<number>;
  46336. /**
  46337. * Maximum allowed angle to camera position relative to target object.
  46338. * This can help limiting how the Camera is able to move in the scene.
  46339. */
  46340. upperRotationOffsetLimit: Nullable<number>;
  46341. /**
  46342. * Define a height offset between the camera and the object it follows.
  46343. * It can help following an object from the top (like a car chaing a plane)
  46344. */
  46345. heightOffset: number;
  46346. /**
  46347. * Minimum allowed height of camera position relative to target object.
  46348. * This can help limiting how the Camera is able to move in the scene.
  46349. */
  46350. lowerHeightOffsetLimit: Nullable<number>;
  46351. /**
  46352. * Maximum allowed height of camera position relative to target object.
  46353. * This can help limiting how the Camera is able to move in the scene.
  46354. */
  46355. upperHeightOffsetLimit: Nullable<number>;
  46356. /**
  46357. * Define how fast the camera can accelerate to follow it s target.
  46358. */
  46359. cameraAcceleration: number;
  46360. /**
  46361. * Define the speed limit of the camera following an object.
  46362. */
  46363. maxCameraSpeed: number;
  46364. /**
  46365. * Define the target of the camera.
  46366. */
  46367. lockedTarget: Nullable<AbstractMesh>;
  46368. /**
  46369. * Defines the input associated with the camera.
  46370. */
  46371. inputs: FollowCameraInputsManager;
  46372. /**
  46373. * Instantiates the follow camera.
  46374. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46375. * @param name Define the name of the camera in the scene
  46376. * @param position Define the position of the camera
  46377. * @param scene Define the scene the camera belong to
  46378. * @param lockedTarget Define the target of the camera
  46379. */
  46380. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46381. private _follow;
  46382. /**
  46383. * Attached controls to the current camera.
  46384. * @param element Defines the element the controls should be listened from
  46385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46386. */
  46387. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46388. /**
  46389. * Detach the current controls from the camera.
  46390. * The camera will stop reacting to inputs.
  46391. * @param element Defines the element to stop listening the inputs from
  46392. */
  46393. detachControl(element: HTMLElement): void;
  46394. /** @hidden */
  46395. _checkInputs(): void;
  46396. private _checkLimits;
  46397. /**
  46398. * Gets the camera class name.
  46399. * @returns the class name
  46400. */
  46401. getClassName(): string;
  46402. }
  46403. /**
  46404. * Arc Rotate version of the follow camera.
  46405. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46406. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46407. */
  46408. export class ArcFollowCamera extends TargetCamera {
  46409. /** The longitudinal angle of the camera */
  46410. alpha: number;
  46411. /** The latitudinal angle of the camera */
  46412. beta: number;
  46413. /** The radius of the camera from its target */
  46414. radius: number;
  46415. private _cartesianCoordinates;
  46416. /** Define the camera target (the mesh it should follow) */
  46417. private _meshTarget;
  46418. /**
  46419. * Instantiates a new ArcFollowCamera
  46420. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46421. * @param name Define the name of the camera
  46422. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46423. * @param beta Define the rotation angle of the camera around the elevation axis
  46424. * @param radius Define the radius of the camera from its target point
  46425. * @param target Define the target of the camera
  46426. * @param scene Define the scene the camera belongs to
  46427. */
  46428. constructor(name: string,
  46429. /** The longitudinal angle of the camera */
  46430. alpha: number,
  46431. /** The latitudinal angle of the camera */
  46432. beta: number,
  46433. /** The radius of the camera from its target */
  46434. radius: number,
  46435. /** Define the camera target (the mesh it should follow) */
  46436. target: Nullable<AbstractMesh>, scene: Scene);
  46437. private _follow;
  46438. /** @hidden */
  46439. _checkInputs(): void;
  46440. /**
  46441. * Returns the class name of the object.
  46442. * It is mostly used internally for serialization purposes.
  46443. */
  46444. getClassName(): string;
  46445. }
  46446. }
  46447. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46448. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46449. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46450. import { Nullable } from "babylonjs/types";
  46451. /**
  46452. * Manage the keyboard inputs to control the movement of a follow camera.
  46453. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46454. */
  46455. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46456. /**
  46457. * Defines the camera the input is attached to.
  46458. */
  46459. camera: FollowCamera;
  46460. /**
  46461. * Defines the list of key codes associated with the up action (increase heightOffset)
  46462. */
  46463. keysHeightOffsetIncr: number[];
  46464. /**
  46465. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46466. */
  46467. keysHeightOffsetDecr: number[];
  46468. /**
  46469. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46470. */
  46471. keysHeightOffsetModifierAlt: boolean;
  46472. /**
  46473. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46474. */
  46475. keysHeightOffsetModifierCtrl: boolean;
  46476. /**
  46477. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46478. */
  46479. keysHeightOffsetModifierShift: boolean;
  46480. /**
  46481. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46482. */
  46483. keysRotationOffsetIncr: number[];
  46484. /**
  46485. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46486. */
  46487. keysRotationOffsetDecr: number[];
  46488. /**
  46489. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46490. */
  46491. keysRotationOffsetModifierAlt: boolean;
  46492. /**
  46493. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46494. */
  46495. keysRotationOffsetModifierCtrl: boolean;
  46496. /**
  46497. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46498. */
  46499. keysRotationOffsetModifierShift: boolean;
  46500. /**
  46501. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46502. */
  46503. keysRadiusIncr: number[];
  46504. /**
  46505. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46506. */
  46507. keysRadiusDecr: number[];
  46508. /**
  46509. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46510. */
  46511. keysRadiusModifierAlt: boolean;
  46512. /**
  46513. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46514. */
  46515. keysRadiusModifierCtrl: boolean;
  46516. /**
  46517. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46518. */
  46519. keysRadiusModifierShift: boolean;
  46520. /**
  46521. * Defines the rate of change of heightOffset.
  46522. */
  46523. heightSensibility: number;
  46524. /**
  46525. * Defines the rate of change of rotationOffset.
  46526. */
  46527. rotationSensibility: number;
  46528. /**
  46529. * Defines the rate of change of radius.
  46530. */
  46531. radiusSensibility: number;
  46532. private _keys;
  46533. private _ctrlPressed;
  46534. private _altPressed;
  46535. private _shiftPressed;
  46536. private _onCanvasBlurObserver;
  46537. private _onKeyboardObserver;
  46538. private _engine;
  46539. private _scene;
  46540. /**
  46541. * Attach the input controls to a specific dom element to get the input from.
  46542. * @param element Defines the element the controls should be listened from
  46543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46544. */
  46545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46546. /**
  46547. * Detach the current controls from the specified dom element.
  46548. * @param element Defines the element to stop listening the inputs from
  46549. */
  46550. detachControl(element: Nullable<HTMLElement>): void;
  46551. /**
  46552. * Update the current camera state depending on the inputs that have been used this frame.
  46553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46554. */
  46555. checkInputs(): void;
  46556. /**
  46557. * Gets the class name of the current input.
  46558. * @returns the class name
  46559. */
  46560. getClassName(): string;
  46561. /**
  46562. * Get the friendly name associated with the input class.
  46563. * @returns the input friendly name
  46564. */
  46565. getSimpleName(): string;
  46566. /**
  46567. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46568. * allow modification of the heightOffset value.
  46569. */
  46570. private _modifierHeightOffset;
  46571. /**
  46572. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46573. * allow modification of the rotationOffset value.
  46574. */
  46575. private _modifierRotationOffset;
  46576. /**
  46577. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46578. * allow modification of the radius value.
  46579. */
  46580. private _modifierRadius;
  46581. }
  46582. }
  46583. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46584. import { Nullable } from "babylonjs/types";
  46585. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46586. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46587. import { Observable } from "babylonjs/Misc/observable";
  46588. module "babylonjs/Cameras/freeCameraInputsManager" {
  46589. interface FreeCameraInputsManager {
  46590. /**
  46591. * @hidden
  46592. */
  46593. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46594. /**
  46595. * Add orientation input support to the input manager.
  46596. * @returns the current input manager
  46597. */
  46598. addDeviceOrientation(): FreeCameraInputsManager;
  46599. }
  46600. }
  46601. /**
  46602. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46603. * Screen rotation is taken into account.
  46604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46605. */
  46606. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46607. private _camera;
  46608. private _screenOrientationAngle;
  46609. private _constantTranform;
  46610. private _screenQuaternion;
  46611. private _alpha;
  46612. private _beta;
  46613. private _gamma;
  46614. /**
  46615. * Can be used to detect if a device orientation sensor is available on a device
  46616. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46617. * @returns a promise that will resolve on orientation change
  46618. */
  46619. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46620. /**
  46621. * @hidden
  46622. */
  46623. _onDeviceOrientationChangedObservable: Observable<void>;
  46624. /**
  46625. * Instantiates a new input
  46626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46627. */
  46628. constructor();
  46629. /**
  46630. * Define the camera controlled by the input.
  46631. */
  46632. get camera(): FreeCamera;
  46633. set camera(camera: FreeCamera);
  46634. /**
  46635. * Attach the input controls to a specific dom element to get the input from.
  46636. * @param element Defines the element the controls should be listened from
  46637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46638. */
  46639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46640. private _orientationChanged;
  46641. private _deviceOrientation;
  46642. /**
  46643. * Detach the current controls from the specified dom element.
  46644. * @param element Defines the element to stop listening the inputs from
  46645. */
  46646. detachControl(element: Nullable<HTMLElement>): void;
  46647. /**
  46648. * Update the current camera state depending on the inputs that have been used this frame.
  46649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46650. */
  46651. checkInputs(): void;
  46652. /**
  46653. * Gets the class name of the current intput.
  46654. * @returns the class name
  46655. */
  46656. getClassName(): string;
  46657. /**
  46658. * Get the friendly name associated with the input class.
  46659. * @returns the input friendly name
  46660. */
  46661. getSimpleName(): string;
  46662. }
  46663. }
  46664. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46665. import { Nullable } from "babylonjs/types";
  46666. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46667. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46668. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46669. /**
  46670. * Manage the gamepad inputs to control a free camera.
  46671. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46672. */
  46673. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46674. /**
  46675. * Define the camera the input is attached to.
  46676. */
  46677. camera: FreeCamera;
  46678. /**
  46679. * Define the Gamepad controlling the input
  46680. */
  46681. gamepad: Nullable<Gamepad>;
  46682. /**
  46683. * Defines the gamepad rotation sensiblity.
  46684. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46685. */
  46686. gamepadAngularSensibility: number;
  46687. /**
  46688. * Defines the gamepad move sensiblity.
  46689. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46690. */
  46691. gamepadMoveSensibility: number;
  46692. private _yAxisScale;
  46693. /**
  46694. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46695. */
  46696. get invertYAxis(): boolean;
  46697. set invertYAxis(value: boolean);
  46698. private _onGamepadConnectedObserver;
  46699. private _onGamepadDisconnectedObserver;
  46700. private _cameraTransform;
  46701. private _deltaTransform;
  46702. private _vector3;
  46703. private _vector2;
  46704. /**
  46705. * Attach the input controls to a specific dom element to get the input from.
  46706. * @param element Defines the element the controls should be listened from
  46707. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46708. */
  46709. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46710. /**
  46711. * Detach the current controls from the specified dom element.
  46712. * @param element Defines the element to stop listening the inputs from
  46713. */
  46714. detachControl(element: Nullable<HTMLElement>): void;
  46715. /**
  46716. * Update the current camera state depending on the inputs that have been used this frame.
  46717. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46718. */
  46719. checkInputs(): void;
  46720. /**
  46721. * Gets the class name of the current intput.
  46722. * @returns the class name
  46723. */
  46724. getClassName(): string;
  46725. /**
  46726. * Get the friendly name associated with the input class.
  46727. * @returns the input friendly name
  46728. */
  46729. getSimpleName(): string;
  46730. }
  46731. }
  46732. declare module "babylonjs/Misc/virtualJoystick" {
  46733. import { Nullable } from "babylonjs/types";
  46734. import { Vector3 } from "babylonjs/Maths/math.vector";
  46735. /**
  46736. * Defines the potential axis of a Joystick
  46737. */
  46738. export enum JoystickAxis {
  46739. /** X axis */
  46740. X = 0,
  46741. /** Y axis */
  46742. Y = 1,
  46743. /** Z axis */
  46744. Z = 2
  46745. }
  46746. /**
  46747. * Represents the different customization options available
  46748. * for VirtualJoystick
  46749. */
  46750. interface VirtualJoystickCustomizations {
  46751. /**
  46752. * Size of the joystick's puck
  46753. */
  46754. puckSize: number;
  46755. /**
  46756. * Size of the joystick's container
  46757. */
  46758. containerSize: number;
  46759. /**
  46760. * Color of the joystick && puck
  46761. */
  46762. color: string;
  46763. /**
  46764. * Image URL for the joystick's puck
  46765. */
  46766. puckImage?: string;
  46767. /**
  46768. * Image URL for the joystick's container
  46769. */
  46770. containerImage?: string;
  46771. /**
  46772. * Defines the unmoving position of the joystick container
  46773. */
  46774. position?: {
  46775. x: number;
  46776. y: number;
  46777. };
  46778. /**
  46779. * Defines whether or not the joystick container is always visible
  46780. */
  46781. alwaysVisible: boolean;
  46782. /**
  46783. * Defines whether or not to limit the movement of the puck to the joystick's container
  46784. */
  46785. limitToContainer: boolean;
  46786. }
  46787. /**
  46788. * Class used to define virtual joystick (used in touch mode)
  46789. */
  46790. export class VirtualJoystick {
  46791. /**
  46792. * Gets or sets a boolean indicating that left and right values must be inverted
  46793. */
  46794. reverseLeftRight: boolean;
  46795. /**
  46796. * Gets or sets a boolean indicating that up and down values must be inverted
  46797. */
  46798. reverseUpDown: boolean;
  46799. /**
  46800. * Gets the offset value for the position (ie. the change of the position value)
  46801. */
  46802. deltaPosition: Vector3;
  46803. /**
  46804. * Gets a boolean indicating if the virtual joystick was pressed
  46805. */
  46806. pressed: boolean;
  46807. /**
  46808. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46809. */
  46810. static Canvas: Nullable<HTMLCanvasElement>;
  46811. /**
  46812. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46813. */
  46814. limitToContainer: boolean;
  46815. private static _globalJoystickIndex;
  46816. private static _alwaysVisibleSticks;
  46817. private static vjCanvasContext;
  46818. private static vjCanvasWidth;
  46819. private static vjCanvasHeight;
  46820. private static halfWidth;
  46821. private static _GetDefaultOptions;
  46822. private _action;
  46823. private _axisTargetedByLeftAndRight;
  46824. private _axisTargetedByUpAndDown;
  46825. private _joystickSensibility;
  46826. private _inversedSensibility;
  46827. private _joystickPointerID;
  46828. private _joystickColor;
  46829. private _joystickPointerPos;
  46830. private _joystickPreviousPointerPos;
  46831. private _joystickPointerStartPos;
  46832. private _deltaJoystickVector;
  46833. private _leftJoystick;
  46834. private _touches;
  46835. private _joystickPosition;
  46836. private _alwaysVisible;
  46837. private _puckImage;
  46838. private _containerImage;
  46839. private _joystickPuckSize;
  46840. private _joystickContainerSize;
  46841. private _clearPuckSize;
  46842. private _clearContainerSize;
  46843. private _clearPuckSizeOffset;
  46844. private _clearContainerSizeOffset;
  46845. private _onPointerDownHandlerRef;
  46846. private _onPointerMoveHandlerRef;
  46847. private _onPointerUpHandlerRef;
  46848. private _onResize;
  46849. /**
  46850. * Creates a new virtual joystick
  46851. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46852. * @param customizations Defines the options we want to customize the VirtualJoystick
  46853. */
  46854. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46855. /**
  46856. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46857. * @param newJoystickSensibility defines the new sensibility
  46858. */
  46859. setJoystickSensibility(newJoystickSensibility: number): void;
  46860. private _onPointerDown;
  46861. private _onPointerMove;
  46862. private _onPointerUp;
  46863. /**
  46864. * Change the color of the virtual joystick
  46865. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46866. */
  46867. setJoystickColor(newColor: string): void;
  46868. /**
  46869. * Size of the joystick's container
  46870. */
  46871. set containerSize(newSize: number);
  46872. get containerSize(): number;
  46873. /**
  46874. * Size of the joystick's puck
  46875. */
  46876. set puckSize(newSize: number);
  46877. get puckSize(): number;
  46878. /**
  46879. * Clears the set position of the joystick
  46880. */
  46881. clearPosition(): void;
  46882. /**
  46883. * Defines whether or not the joystick container is always visible
  46884. */
  46885. set alwaysVisible(value: boolean);
  46886. get alwaysVisible(): boolean;
  46887. /**
  46888. * Sets the constant position of the Joystick container
  46889. * @param x X axis coordinate
  46890. * @param y Y axis coordinate
  46891. */
  46892. setPosition(x: number, y: number): void;
  46893. /**
  46894. * Defines a callback to call when the joystick is touched
  46895. * @param action defines the callback
  46896. */
  46897. setActionOnTouch(action: () => any): void;
  46898. /**
  46899. * Defines which axis you'd like to control for left & right
  46900. * @param axis defines the axis to use
  46901. */
  46902. setAxisForLeftRight(axis: JoystickAxis): void;
  46903. /**
  46904. * Defines which axis you'd like to control for up & down
  46905. * @param axis defines the axis to use
  46906. */
  46907. setAxisForUpDown(axis: JoystickAxis): void;
  46908. /**
  46909. * Clears the canvas from the previous puck / container draw
  46910. */
  46911. private _clearPreviousDraw;
  46912. /**
  46913. * Loads `urlPath` to be used for the container's image
  46914. * @param urlPath defines the urlPath of an image to use
  46915. */
  46916. setContainerImage(urlPath: string): void;
  46917. /**
  46918. * Loads `urlPath` to be used for the puck's image
  46919. * @param urlPath defines the urlPath of an image to use
  46920. */
  46921. setPuckImage(urlPath: string): void;
  46922. /**
  46923. * Draws the Virtual Joystick's container
  46924. */
  46925. private _drawContainer;
  46926. /**
  46927. * Draws the Virtual Joystick's puck
  46928. */
  46929. private _drawPuck;
  46930. private _drawVirtualJoystick;
  46931. /**
  46932. * Release internal HTML canvas
  46933. */
  46934. releaseCanvas(): void;
  46935. }
  46936. }
  46937. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  46938. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  46939. import { Nullable } from "babylonjs/types";
  46940. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46941. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46942. module "babylonjs/Cameras/freeCameraInputsManager" {
  46943. interface FreeCameraInputsManager {
  46944. /**
  46945. * Add virtual joystick input support to the input manager.
  46946. * @returns the current input manager
  46947. */
  46948. addVirtualJoystick(): FreeCameraInputsManager;
  46949. }
  46950. }
  46951. /**
  46952. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  46953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46954. */
  46955. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  46956. /**
  46957. * Defines the camera the input is attached to.
  46958. */
  46959. camera: FreeCamera;
  46960. private _leftjoystick;
  46961. private _rightjoystick;
  46962. /**
  46963. * Gets the left stick of the virtual joystick.
  46964. * @returns The virtual Joystick
  46965. */
  46966. getLeftJoystick(): VirtualJoystick;
  46967. /**
  46968. * Gets the right stick of the virtual joystick.
  46969. * @returns The virtual Joystick
  46970. */
  46971. getRightJoystick(): VirtualJoystick;
  46972. /**
  46973. * Update the current camera state depending on the inputs that have been used this frame.
  46974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46975. */
  46976. checkInputs(): void;
  46977. /**
  46978. * Attach the input controls to a specific dom element to get the input from.
  46979. * @param element Defines the element the controls should be listened from
  46980. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46981. */
  46982. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46983. /**
  46984. * Detach the current controls from the specified dom element.
  46985. * @param element Defines the element to stop listening the inputs from
  46986. */
  46987. detachControl(element: Nullable<HTMLElement>): void;
  46988. /**
  46989. * Gets the class name of the current intput.
  46990. * @returns the class name
  46991. */
  46992. getClassName(): string;
  46993. /**
  46994. * Get the friendly name associated with the input class.
  46995. * @returns the input friendly name
  46996. */
  46997. getSimpleName(): string;
  46998. }
  46999. }
  47000. declare module "babylonjs/Cameras/Inputs/index" {
  47001. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47002. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47003. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47004. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47005. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47006. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47007. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47008. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47009. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47010. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47011. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47012. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47013. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47014. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47015. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47016. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47017. }
  47018. declare module "babylonjs/Cameras/touchCamera" {
  47019. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47020. import { Scene } from "babylonjs/scene";
  47021. import { Vector3 } from "babylonjs/Maths/math.vector";
  47022. /**
  47023. * This represents a FPS type of camera controlled by touch.
  47024. * This is like a universal camera minus the Gamepad controls.
  47025. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47026. */
  47027. export class TouchCamera extends FreeCamera {
  47028. /**
  47029. * Defines the touch sensibility for rotation.
  47030. * The higher the faster.
  47031. */
  47032. get touchAngularSensibility(): number;
  47033. set touchAngularSensibility(value: number);
  47034. /**
  47035. * Defines the touch sensibility for move.
  47036. * The higher the faster.
  47037. */
  47038. get touchMoveSensibility(): number;
  47039. set touchMoveSensibility(value: number);
  47040. /**
  47041. * Instantiates a new touch camera.
  47042. * This represents a FPS type of camera controlled by touch.
  47043. * This is like a universal camera minus the Gamepad controls.
  47044. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47045. * @param name Define the name of the camera in the scene
  47046. * @param position Define the start position of the camera in the scene
  47047. * @param scene Define the scene the camera belongs to
  47048. */
  47049. constructor(name: string, position: Vector3, scene: Scene);
  47050. /**
  47051. * Gets the current object class name.
  47052. * @return the class name
  47053. */
  47054. getClassName(): string;
  47055. /** @hidden */
  47056. _setupInputs(): void;
  47057. }
  47058. }
  47059. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47060. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47061. import { Scene } from "babylonjs/scene";
  47062. import { Vector3 } from "babylonjs/Maths/math.vector";
  47063. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47064. import { Axis } from "babylonjs/Maths/math.axis";
  47065. /**
  47066. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47067. * being tilted forward or back and left or right.
  47068. */
  47069. export class DeviceOrientationCamera extends FreeCamera {
  47070. private _initialQuaternion;
  47071. private _quaternionCache;
  47072. private _tmpDragQuaternion;
  47073. private _disablePointerInputWhenUsingDeviceOrientation;
  47074. /**
  47075. * Creates a new device orientation camera
  47076. * @param name The name of the camera
  47077. * @param position The start position camera
  47078. * @param scene The scene the camera belongs to
  47079. */
  47080. constructor(name: string, position: Vector3, scene: Scene);
  47081. /**
  47082. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47083. */
  47084. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47085. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47086. private _dragFactor;
  47087. /**
  47088. * Enabled turning on the y axis when the orientation sensor is active
  47089. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47090. */
  47091. enableHorizontalDragging(dragFactor?: number): void;
  47092. /**
  47093. * Gets the current instance class name ("DeviceOrientationCamera").
  47094. * This helps avoiding instanceof at run time.
  47095. * @returns the class name
  47096. */
  47097. getClassName(): string;
  47098. /**
  47099. * @hidden
  47100. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47101. */
  47102. _checkInputs(): void;
  47103. /**
  47104. * Reset the camera to its default orientation on the specified axis only.
  47105. * @param axis The axis to reset
  47106. */
  47107. resetToCurrentRotation(axis?: Axis): void;
  47108. }
  47109. }
  47110. declare module "babylonjs/Gamepads/xboxGamepad" {
  47111. import { Observable } from "babylonjs/Misc/observable";
  47112. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47113. /**
  47114. * Defines supported buttons for XBox360 compatible gamepads
  47115. */
  47116. export enum Xbox360Button {
  47117. /** A */
  47118. A = 0,
  47119. /** B */
  47120. B = 1,
  47121. /** X */
  47122. X = 2,
  47123. /** Y */
  47124. Y = 3,
  47125. /** Left button */
  47126. LB = 4,
  47127. /** Right button */
  47128. RB = 5,
  47129. /** Back */
  47130. Back = 8,
  47131. /** Start */
  47132. Start = 9,
  47133. /** Left stick */
  47134. LeftStick = 10,
  47135. /** Right stick */
  47136. RightStick = 11
  47137. }
  47138. /** Defines values for XBox360 DPad */
  47139. export enum Xbox360Dpad {
  47140. /** Up */
  47141. Up = 12,
  47142. /** Down */
  47143. Down = 13,
  47144. /** Left */
  47145. Left = 14,
  47146. /** Right */
  47147. Right = 15
  47148. }
  47149. /**
  47150. * Defines a XBox360 gamepad
  47151. */
  47152. export class Xbox360Pad extends Gamepad {
  47153. private _leftTrigger;
  47154. private _rightTrigger;
  47155. private _onlefttriggerchanged;
  47156. private _onrighttriggerchanged;
  47157. private _onbuttondown;
  47158. private _onbuttonup;
  47159. private _ondpaddown;
  47160. private _ondpadup;
  47161. /** Observable raised when a button is pressed */
  47162. onButtonDownObservable: Observable<Xbox360Button>;
  47163. /** Observable raised when a button is released */
  47164. onButtonUpObservable: Observable<Xbox360Button>;
  47165. /** Observable raised when a pad is pressed */
  47166. onPadDownObservable: Observable<Xbox360Dpad>;
  47167. /** Observable raised when a pad is released */
  47168. onPadUpObservable: Observable<Xbox360Dpad>;
  47169. private _buttonA;
  47170. private _buttonB;
  47171. private _buttonX;
  47172. private _buttonY;
  47173. private _buttonBack;
  47174. private _buttonStart;
  47175. private _buttonLB;
  47176. private _buttonRB;
  47177. private _buttonLeftStick;
  47178. private _buttonRightStick;
  47179. private _dPadUp;
  47180. private _dPadDown;
  47181. private _dPadLeft;
  47182. private _dPadRight;
  47183. private _isXboxOnePad;
  47184. /**
  47185. * Creates a new XBox360 gamepad object
  47186. * @param id defines the id of this gamepad
  47187. * @param index defines its index
  47188. * @param gamepad defines the internal HTML gamepad object
  47189. * @param xboxOne defines if it is a XBox One gamepad
  47190. */
  47191. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47192. /**
  47193. * Defines the callback to call when left trigger is pressed
  47194. * @param callback defines the callback to use
  47195. */
  47196. onlefttriggerchanged(callback: (value: number) => void): void;
  47197. /**
  47198. * Defines the callback to call when right trigger is pressed
  47199. * @param callback defines the callback to use
  47200. */
  47201. onrighttriggerchanged(callback: (value: number) => void): void;
  47202. /**
  47203. * Gets the left trigger value
  47204. */
  47205. get leftTrigger(): number;
  47206. /**
  47207. * Sets the left trigger value
  47208. */
  47209. set leftTrigger(newValue: number);
  47210. /**
  47211. * Gets the right trigger value
  47212. */
  47213. get rightTrigger(): number;
  47214. /**
  47215. * Sets the right trigger value
  47216. */
  47217. set rightTrigger(newValue: number);
  47218. /**
  47219. * Defines the callback to call when a button is pressed
  47220. * @param callback defines the callback to use
  47221. */
  47222. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47223. /**
  47224. * Defines the callback to call when a button is released
  47225. * @param callback defines the callback to use
  47226. */
  47227. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47228. /**
  47229. * Defines the callback to call when a pad is pressed
  47230. * @param callback defines the callback to use
  47231. */
  47232. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47233. /**
  47234. * Defines the callback to call when a pad is released
  47235. * @param callback defines the callback to use
  47236. */
  47237. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47238. private _setButtonValue;
  47239. private _setDPadValue;
  47240. /**
  47241. * Gets the value of the `A` button
  47242. */
  47243. get buttonA(): number;
  47244. /**
  47245. * Sets the value of the `A` button
  47246. */
  47247. set buttonA(value: number);
  47248. /**
  47249. * Gets the value of the `B` button
  47250. */
  47251. get buttonB(): number;
  47252. /**
  47253. * Sets the value of the `B` button
  47254. */
  47255. set buttonB(value: number);
  47256. /**
  47257. * Gets the value of the `X` button
  47258. */
  47259. get buttonX(): number;
  47260. /**
  47261. * Sets the value of the `X` button
  47262. */
  47263. set buttonX(value: number);
  47264. /**
  47265. * Gets the value of the `Y` button
  47266. */
  47267. get buttonY(): number;
  47268. /**
  47269. * Sets the value of the `Y` button
  47270. */
  47271. set buttonY(value: number);
  47272. /**
  47273. * Gets the value of the `Start` button
  47274. */
  47275. get buttonStart(): number;
  47276. /**
  47277. * Sets the value of the `Start` button
  47278. */
  47279. set buttonStart(value: number);
  47280. /**
  47281. * Gets the value of the `Back` button
  47282. */
  47283. get buttonBack(): number;
  47284. /**
  47285. * Sets the value of the `Back` button
  47286. */
  47287. set buttonBack(value: number);
  47288. /**
  47289. * Gets the value of the `Left` button
  47290. */
  47291. get buttonLB(): number;
  47292. /**
  47293. * Sets the value of the `Left` button
  47294. */
  47295. set buttonLB(value: number);
  47296. /**
  47297. * Gets the value of the `Right` button
  47298. */
  47299. get buttonRB(): number;
  47300. /**
  47301. * Sets the value of the `Right` button
  47302. */
  47303. set buttonRB(value: number);
  47304. /**
  47305. * Gets the value of the Left joystick
  47306. */
  47307. get buttonLeftStick(): number;
  47308. /**
  47309. * Sets the value of the Left joystick
  47310. */
  47311. set buttonLeftStick(value: number);
  47312. /**
  47313. * Gets the value of the Right joystick
  47314. */
  47315. get buttonRightStick(): number;
  47316. /**
  47317. * Sets the value of the Right joystick
  47318. */
  47319. set buttonRightStick(value: number);
  47320. /**
  47321. * Gets the value of D-pad up
  47322. */
  47323. get dPadUp(): number;
  47324. /**
  47325. * Sets the value of D-pad up
  47326. */
  47327. set dPadUp(value: number);
  47328. /**
  47329. * Gets the value of D-pad down
  47330. */
  47331. get dPadDown(): number;
  47332. /**
  47333. * Sets the value of D-pad down
  47334. */
  47335. set dPadDown(value: number);
  47336. /**
  47337. * Gets the value of D-pad left
  47338. */
  47339. get dPadLeft(): number;
  47340. /**
  47341. * Sets the value of D-pad left
  47342. */
  47343. set dPadLeft(value: number);
  47344. /**
  47345. * Gets the value of D-pad right
  47346. */
  47347. get dPadRight(): number;
  47348. /**
  47349. * Sets the value of D-pad right
  47350. */
  47351. set dPadRight(value: number);
  47352. /**
  47353. * Force the gamepad to synchronize with device values
  47354. */
  47355. update(): void;
  47356. /**
  47357. * Disposes the gamepad
  47358. */
  47359. dispose(): void;
  47360. }
  47361. }
  47362. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47363. import { Observable } from "babylonjs/Misc/observable";
  47364. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47365. /**
  47366. * Defines supported buttons for DualShock compatible gamepads
  47367. */
  47368. export enum DualShockButton {
  47369. /** Cross */
  47370. Cross = 0,
  47371. /** Circle */
  47372. Circle = 1,
  47373. /** Square */
  47374. Square = 2,
  47375. /** Triangle */
  47376. Triangle = 3,
  47377. /** L1 */
  47378. L1 = 4,
  47379. /** R1 */
  47380. R1 = 5,
  47381. /** Share */
  47382. Share = 8,
  47383. /** Options */
  47384. Options = 9,
  47385. /** Left stick */
  47386. LeftStick = 10,
  47387. /** Right stick */
  47388. RightStick = 11
  47389. }
  47390. /** Defines values for DualShock DPad */
  47391. export enum DualShockDpad {
  47392. /** Up */
  47393. Up = 12,
  47394. /** Down */
  47395. Down = 13,
  47396. /** Left */
  47397. Left = 14,
  47398. /** Right */
  47399. Right = 15
  47400. }
  47401. /**
  47402. * Defines a DualShock gamepad
  47403. */
  47404. export class DualShockPad extends Gamepad {
  47405. private _leftTrigger;
  47406. private _rightTrigger;
  47407. private _onlefttriggerchanged;
  47408. private _onrighttriggerchanged;
  47409. private _onbuttondown;
  47410. private _onbuttonup;
  47411. private _ondpaddown;
  47412. private _ondpadup;
  47413. /** Observable raised when a button is pressed */
  47414. onButtonDownObservable: Observable<DualShockButton>;
  47415. /** Observable raised when a button is released */
  47416. onButtonUpObservable: Observable<DualShockButton>;
  47417. /** Observable raised when a pad is pressed */
  47418. onPadDownObservable: Observable<DualShockDpad>;
  47419. /** Observable raised when a pad is released */
  47420. onPadUpObservable: Observable<DualShockDpad>;
  47421. private _buttonCross;
  47422. private _buttonCircle;
  47423. private _buttonSquare;
  47424. private _buttonTriangle;
  47425. private _buttonShare;
  47426. private _buttonOptions;
  47427. private _buttonL1;
  47428. private _buttonR1;
  47429. private _buttonLeftStick;
  47430. private _buttonRightStick;
  47431. private _dPadUp;
  47432. private _dPadDown;
  47433. private _dPadLeft;
  47434. private _dPadRight;
  47435. /**
  47436. * Creates a new DualShock gamepad object
  47437. * @param id defines the id of this gamepad
  47438. * @param index defines its index
  47439. * @param gamepad defines the internal HTML gamepad object
  47440. */
  47441. constructor(id: string, index: number, gamepad: any);
  47442. /**
  47443. * Defines the callback to call when left trigger is pressed
  47444. * @param callback defines the callback to use
  47445. */
  47446. onlefttriggerchanged(callback: (value: number) => void): void;
  47447. /**
  47448. * Defines the callback to call when right trigger is pressed
  47449. * @param callback defines the callback to use
  47450. */
  47451. onrighttriggerchanged(callback: (value: number) => void): void;
  47452. /**
  47453. * Gets the left trigger value
  47454. */
  47455. get leftTrigger(): number;
  47456. /**
  47457. * Sets the left trigger value
  47458. */
  47459. set leftTrigger(newValue: number);
  47460. /**
  47461. * Gets the right trigger value
  47462. */
  47463. get rightTrigger(): number;
  47464. /**
  47465. * Sets the right trigger value
  47466. */
  47467. set rightTrigger(newValue: number);
  47468. /**
  47469. * Defines the callback to call when a button is pressed
  47470. * @param callback defines the callback to use
  47471. */
  47472. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47473. /**
  47474. * Defines the callback to call when a button is released
  47475. * @param callback defines the callback to use
  47476. */
  47477. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47478. /**
  47479. * Defines the callback to call when a pad is pressed
  47480. * @param callback defines the callback to use
  47481. */
  47482. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47483. /**
  47484. * Defines the callback to call when a pad is released
  47485. * @param callback defines the callback to use
  47486. */
  47487. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47488. private _setButtonValue;
  47489. private _setDPadValue;
  47490. /**
  47491. * Gets the value of the `Cross` button
  47492. */
  47493. get buttonCross(): number;
  47494. /**
  47495. * Sets the value of the `Cross` button
  47496. */
  47497. set buttonCross(value: number);
  47498. /**
  47499. * Gets the value of the `Circle` button
  47500. */
  47501. get buttonCircle(): number;
  47502. /**
  47503. * Sets the value of the `Circle` button
  47504. */
  47505. set buttonCircle(value: number);
  47506. /**
  47507. * Gets the value of the `Square` button
  47508. */
  47509. get buttonSquare(): number;
  47510. /**
  47511. * Sets the value of the `Square` button
  47512. */
  47513. set buttonSquare(value: number);
  47514. /**
  47515. * Gets the value of the `Triangle` button
  47516. */
  47517. get buttonTriangle(): number;
  47518. /**
  47519. * Sets the value of the `Triangle` button
  47520. */
  47521. set buttonTriangle(value: number);
  47522. /**
  47523. * Gets the value of the `Options` button
  47524. */
  47525. get buttonOptions(): number;
  47526. /**
  47527. * Sets the value of the `Options` button
  47528. */
  47529. set buttonOptions(value: number);
  47530. /**
  47531. * Gets the value of the `Share` button
  47532. */
  47533. get buttonShare(): number;
  47534. /**
  47535. * Sets the value of the `Share` button
  47536. */
  47537. set buttonShare(value: number);
  47538. /**
  47539. * Gets the value of the `L1` button
  47540. */
  47541. get buttonL1(): number;
  47542. /**
  47543. * Sets the value of the `L1` button
  47544. */
  47545. set buttonL1(value: number);
  47546. /**
  47547. * Gets the value of the `R1` button
  47548. */
  47549. get buttonR1(): number;
  47550. /**
  47551. * Sets the value of the `R1` button
  47552. */
  47553. set buttonR1(value: number);
  47554. /**
  47555. * Gets the value of the Left joystick
  47556. */
  47557. get buttonLeftStick(): number;
  47558. /**
  47559. * Sets the value of the Left joystick
  47560. */
  47561. set buttonLeftStick(value: number);
  47562. /**
  47563. * Gets the value of the Right joystick
  47564. */
  47565. get buttonRightStick(): number;
  47566. /**
  47567. * Sets the value of the Right joystick
  47568. */
  47569. set buttonRightStick(value: number);
  47570. /**
  47571. * Gets the value of D-pad up
  47572. */
  47573. get dPadUp(): number;
  47574. /**
  47575. * Sets the value of D-pad up
  47576. */
  47577. set dPadUp(value: number);
  47578. /**
  47579. * Gets the value of D-pad down
  47580. */
  47581. get dPadDown(): number;
  47582. /**
  47583. * Sets the value of D-pad down
  47584. */
  47585. set dPadDown(value: number);
  47586. /**
  47587. * Gets the value of D-pad left
  47588. */
  47589. get dPadLeft(): number;
  47590. /**
  47591. * Sets the value of D-pad left
  47592. */
  47593. set dPadLeft(value: number);
  47594. /**
  47595. * Gets the value of D-pad right
  47596. */
  47597. get dPadRight(): number;
  47598. /**
  47599. * Sets the value of D-pad right
  47600. */
  47601. set dPadRight(value: number);
  47602. /**
  47603. * Force the gamepad to synchronize with device values
  47604. */
  47605. update(): void;
  47606. /**
  47607. * Disposes the gamepad
  47608. */
  47609. dispose(): void;
  47610. }
  47611. }
  47612. declare module "babylonjs/Gamepads/gamepadManager" {
  47613. import { Observable } from "babylonjs/Misc/observable";
  47614. import { Nullable } from "babylonjs/types";
  47615. import { Scene } from "babylonjs/scene";
  47616. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47617. /**
  47618. * Manager for handling gamepads
  47619. */
  47620. export class GamepadManager {
  47621. private _scene?;
  47622. private _babylonGamepads;
  47623. private _oneGamepadConnected;
  47624. /** @hidden */
  47625. _isMonitoring: boolean;
  47626. private _gamepadEventSupported;
  47627. private _gamepadSupport?;
  47628. /**
  47629. * observable to be triggered when the gamepad controller has been connected
  47630. */
  47631. onGamepadConnectedObservable: Observable<Gamepad>;
  47632. /**
  47633. * observable to be triggered when the gamepad controller has been disconnected
  47634. */
  47635. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47636. private _onGamepadConnectedEvent;
  47637. private _onGamepadDisconnectedEvent;
  47638. /**
  47639. * Initializes the gamepad manager
  47640. * @param _scene BabylonJS scene
  47641. */
  47642. constructor(_scene?: Scene | undefined);
  47643. /**
  47644. * The gamepads in the game pad manager
  47645. */
  47646. get gamepads(): Gamepad[];
  47647. /**
  47648. * Get the gamepad controllers based on type
  47649. * @param type The type of gamepad controller
  47650. * @returns Nullable gamepad
  47651. */
  47652. getGamepadByType(type?: number): Nullable<Gamepad>;
  47653. /**
  47654. * Disposes the gamepad manager
  47655. */
  47656. dispose(): void;
  47657. private _addNewGamepad;
  47658. private _startMonitoringGamepads;
  47659. private _stopMonitoringGamepads;
  47660. /** @hidden */
  47661. _checkGamepadsStatus(): void;
  47662. private _updateGamepadObjects;
  47663. }
  47664. }
  47665. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47666. import { Nullable } from "babylonjs/types";
  47667. import { Scene } from "babylonjs/scene";
  47668. import { ISceneComponent } from "babylonjs/sceneComponent";
  47669. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47670. module "babylonjs/scene" {
  47671. interface Scene {
  47672. /** @hidden */
  47673. _gamepadManager: Nullable<GamepadManager>;
  47674. /**
  47675. * Gets the gamepad manager associated with the scene
  47676. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47677. */
  47678. gamepadManager: GamepadManager;
  47679. }
  47680. }
  47681. module "babylonjs/Cameras/freeCameraInputsManager" {
  47682. /**
  47683. * Interface representing a free camera inputs manager
  47684. */
  47685. interface FreeCameraInputsManager {
  47686. /**
  47687. * Adds gamepad input support to the FreeCameraInputsManager.
  47688. * @returns the FreeCameraInputsManager
  47689. */
  47690. addGamepad(): FreeCameraInputsManager;
  47691. }
  47692. }
  47693. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47694. /**
  47695. * Interface representing an arc rotate camera inputs manager
  47696. */
  47697. interface ArcRotateCameraInputsManager {
  47698. /**
  47699. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47700. * @returns the camera inputs manager
  47701. */
  47702. addGamepad(): ArcRotateCameraInputsManager;
  47703. }
  47704. }
  47705. /**
  47706. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47707. */
  47708. export class GamepadSystemSceneComponent implements ISceneComponent {
  47709. /**
  47710. * The component name helpfull to identify the component in the list of scene components.
  47711. */
  47712. readonly name: string;
  47713. /**
  47714. * The scene the component belongs to.
  47715. */
  47716. scene: Scene;
  47717. /**
  47718. * Creates a new instance of the component for the given scene
  47719. * @param scene Defines the scene to register the component in
  47720. */
  47721. constructor(scene: Scene);
  47722. /**
  47723. * Registers the component in a given scene
  47724. */
  47725. register(): void;
  47726. /**
  47727. * Rebuilds the elements related to this component in case of
  47728. * context lost for instance.
  47729. */
  47730. rebuild(): void;
  47731. /**
  47732. * Disposes the component and the associated ressources
  47733. */
  47734. dispose(): void;
  47735. private _beforeCameraUpdate;
  47736. }
  47737. }
  47738. declare module "babylonjs/Cameras/universalCamera" {
  47739. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47740. import { Scene } from "babylonjs/scene";
  47741. import { Vector3 } from "babylonjs/Maths/math.vector";
  47742. import "babylonjs/Gamepads/gamepadSceneComponent";
  47743. /**
  47744. * 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,
  47745. * which still works and will still be found in many Playgrounds.
  47746. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47747. */
  47748. export class UniversalCamera extends TouchCamera {
  47749. /**
  47750. * Defines the gamepad rotation sensiblity.
  47751. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47752. */
  47753. get gamepadAngularSensibility(): number;
  47754. set gamepadAngularSensibility(value: number);
  47755. /**
  47756. * Defines the gamepad move sensiblity.
  47757. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47758. */
  47759. get gamepadMoveSensibility(): number;
  47760. set gamepadMoveSensibility(value: number);
  47761. /**
  47762. * 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,
  47763. * which still works and will still be found in many Playgrounds.
  47764. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47765. * @param name Define the name of the camera in the scene
  47766. * @param position Define the start position of the camera in the scene
  47767. * @param scene Define the scene the camera belongs to
  47768. */
  47769. constructor(name: string, position: Vector3, scene: Scene);
  47770. /**
  47771. * Gets the current object class name.
  47772. * @return the class name
  47773. */
  47774. getClassName(): string;
  47775. }
  47776. }
  47777. declare module "babylonjs/Cameras/gamepadCamera" {
  47778. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47779. import { Scene } from "babylonjs/scene";
  47780. import { Vector3 } from "babylonjs/Maths/math.vector";
  47781. /**
  47782. * This represents a FPS type of camera. This is only here for back compat purpose.
  47783. * Please use the UniversalCamera instead as both are identical.
  47784. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47785. */
  47786. export class GamepadCamera extends UniversalCamera {
  47787. /**
  47788. * Instantiates a new Gamepad Camera
  47789. * This represents a FPS type of camera. This is only here for back compat purpose.
  47790. * Please use the UniversalCamera instead as both are identical.
  47791. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47792. * @param name Define the name of the camera in the scene
  47793. * @param position Define the start position of the camera in the scene
  47794. * @param scene Define the scene the camera belongs to
  47795. */
  47796. constructor(name: string, position: Vector3, scene: Scene);
  47797. /**
  47798. * Gets the current object class name.
  47799. * @return the class name
  47800. */
  47801. getClassName(): string;
  47802. }
  47803. }
  47804. declare module "babylonjs/Shaders/pass.fragment" {
  47805. /** @hidden */
  47806. export var passPixelShader: {
  47807. name: string;
  47808. shader: string;
  47809. };
  47810. }
  47811. declare module "babylonjs/Shaders/passCube.fragment" {
  47812. /** @hidden */
  47813. export var passCubePixelShader: {
  47814. name: string;
  47815. shader: string;
  47816. };
  47817. }
  47818. declare module "babylonjs/PostProcesses/passPostProcess" {
  47819. import { Nullable } from "babylonjs/types";
  47820. import { Camera } from "babylonjs/Cameras/camera";
  47821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47822. import { Engine } from "babylonjs/Engines/engine";
  47823. import "babylonjs/Shaders/pass.fragment";
  47824. import "babylonjs/Shaders/passCube.fragment";
  47825. import { Scene } from "babylonjs/scene";
  47826. /**
  47827. * PassPostProcess which produces an output the same as it's input
  47828. */
  47829. export class PassPostProcess extends PostProcess {
  47830. /**
  47831. * Gets a string identifying the name of the class
  47832. * @returns "PassPostProcess" string
  47833. */
  47834. getClassName(): string;
  47835. /**
  47836. * Creates the PassPostProcess
  47837. * @param name The name of the effect.
  47838. * @param options The required width/height ratio to downsize to before computing the render pass.
  47839. * @param camera The camera to apply the render pass to.
  47840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47841. * @param engine The engine which the post process will be applied. (default: current engine)
  47842. * @param reusable If the post process can be reused on the same frame. (default: false)
  47843. * @param textureType The type of texture to be used when performing the post processing.
  47844. * @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)
  47845. */
  47846. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47847. /** @hidden */
  47848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47849. }
  47850. /**
  47851. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47852. */
  47853. export class PassCubePostProcess extends PostProcess {
  47854. private _face;
  47855. /**
  47856. * Gets or sets the cube face to display.
  47857. * * 0 is +X
  47858. * * 1 is -X
  47859. * * 2 is +Y
  47860. * * 3 is -Y
  47861. * * 4 is +Z
  47862. * * 5 is -Z
  47863. */
  47864. get face(): number;
  47865. set face(value: number);
  47866. /**
  47867. * Gets a string identifying the name of the class
  47868. * @returns "PassCubePostProcess" string
  47869. */
  47870. getClassName(): string;
  47871. /**
  47872. * Creates the PassCubePostProcess
  47873. * @param name The name of the effect.
  47874. * @param options The required width/height ratio to downsize to before computing the render pass.
  47875. * @param camera The camera to apply the render pass to.
  47876. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47877. * @param engine The engine which the post process will be applied. (default: current engine)
  47878. * @param reusable If the post process can be reused on the same frame. (default: false)
  47879. * @param textureType The type of texture to be used when performing the post processing.
  47880. * @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)
  47881. */
  47882. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47883. /** @hidden */
  47884. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  47885. }
  47886. }
  47887. declare module "babylonjs/Shaders/anaglyph.fragment" {
  47888. /** @hidden */
  47889. export var anaglyphPixelShader: {
  47890. name: string;
  47891. shader: string;
  47892. };
  47893. }
  47894. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  47895. import { Engine } from "babylonjs/Engines/engine";
  47896. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47897. import { Camera } from "babylonjs/Cameras/camera";
  47898. import "babylonjs/Shaders/anaglyph.fragment";
  47899. /**
  47900. * Postprocess used to generate anaglyphic rendering
  47901. */
  47902. export class AnaglyphPostProcess extends PostProcess {
  47903. private _passedProcess;
  47904. /**
  47905. * Gets a string identifying the name of the class
  47906. * @returns "AnaglyphPostProcess" string
  47907. */
  47908. getClassName(): string;
  47909. /**
  47910. * Creates a new AnaglyphPostProcess
  47911. * @param name defines postprocess name
  47912. * @param options defines creation options or target ratio scale
  47913. * @param rigCameras defines cameras using this postprocess
  47914. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  47915. * @param engine defines hosting engine
  47916. * @param reusable defines if the postprocess will be reused multiple times per frame
  47917. */
  47918. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  47919. }
  47920. }
  47921. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  47922. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  47923. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector3 } from "babylonjs/Maths/math.vector";
  47926. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47927. /**
  47928. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  47929. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47930. */
  47931. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  47932. /**
  47933. * Creates a new AnaglyphArcRotateCamera
  47934. * @param name defines camera name
  47935. * @param alpha defines alpha angle (in radians)
  47936. * @param beta defines beta angle (in radians)
  47937. * @param radius defines radius
  47938. * @param target defines camera target
  47939. * @param interaxialDistance defines distance between each color axis
  47940. * @param scene defines the hosting scene
  47941. */
  47942. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  47943. /**
  47944. * Gets camera class name
  47945. * @returns AnaglyphArcRotateCamera
  47946. */
  47947. getClassName(): string;
  47948. }
  47949. }
  47950. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  47951. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47952. import { Scene } from "babylonjs/scene";
  47953. import { Vector3 } from "babylonjs/Maths/math.vector";
  47954. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47955. /**
  47956. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  47957. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47958. */
  47959. export class AnaglyphFreeCamera extends FreeCamera {
  47960. /**
  47961. * Creates a new AnaglyphFreeCamera
  47962. * @param name defines camera name
  47963. * @param position defines initial position
  47964. * @param interaxialDistance defines distance between each color axis
  47965. * @param scene defines the hosting scene
  47966. */
  47967. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47968. /**
  47969. * Gets camera class name
  47970. * @returns AnaglyphFreeCamera
  47971. */
  47972. getClassName(): string;
  47973. }
  47974. }
  47975. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  47976. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  47977. import { Scene } from "babylonjs/scene";
  47978. import { Vector3 } from "babylonjs/Maths/math.vector";
  47979. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47980. /**
  47981. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  47982. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  47983. */
  47984. export class AnaglyphGamepadCamera extends GamepadCamera {
  47985. /**
  47986. * Creates a new AnaglyphGamepadCamera
  47987. * @param name defines camera name
  47988. * @param position defines initial position
  47989. * @param interaxialDistance defines distance between each color axis
  47990. * @param scene defines the hosting scene
  47991. */
  47992. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  47993. /**
  47994. * Gets camera class name
  47995. * @returns AnaglyphGamepadCamera
  47996. */
  47997. getClassName(): string;
  47998. }
  47999. }
  48000. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48001. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48002. import { Scene } from "babylonjs/scene";
  48003. import { Vector3 } from "babylonjs/Maths/math.vector";
  48004. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48005. /**
  48006. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48007. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48008. */
  48009. export class AnaglyphUniversalCamera extends UniversalCamera {
  48010. /**
  48011. * Creates a new AnaglyphUniversalCamera
  48012. * @param name defines camera name
  48013. * @param position defines initial position
  48014. * @param interaxialDistance defines distance between each color axis
  48015. * @param scene defines the hosting scene
  48016. */
  48017. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48018. /**
  48019. * Gets camera class name
  48020. * @returns AnaglyphUniversalCamera
  48021. */
  48022. getClassName(): string;
  48023. }
  48024. }
  48025. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48026. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48027. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48028. import { Scene } from "babylonjs/scene";
  48029. import { Vector3 } from "babylonjs/Maths/math.vector";
  48030. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48031. /**
  48032. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48033. * @see https://doc.babylonjs.com/features/cameras
  48034. */
  48035. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48036. /**
  48037. * Creates a new StereoscopicArcRotateCamera
  48038. * @param name defines camera name
  48039. * @param alpha defines alpha angle (in radians)
  48040. * @param beta defines beta angle (in radians)
  48041. * @param radius defines radius
  48042. * @param target defines camera target
  48043. * @param interaxialDistance defines distance between each color axis
  48044. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48045. * @param scene defines the hosting scene
  48046. */
  48047. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48048. /**
  48049. * Gets camera class name
  48050. * @returns StereoscopicArcRotateCamera
  48051. */
  48052. getClassName(): string;
  48053. }
  48054. }
  48055. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48056. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48057. import { Scene } from "babylonjs/scene";
  48058. import { Vector3 } from "babylonjs/Maths/math.vector";
  48059. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48060. /**
  48061. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48062. * @see https://doc.babylonjs.com/features/cameras
  48063. */
  48064. export class StereoscopicFreeCamera extends FreeCamera {
  48065. /**
  48066. * Creates a new StereoscopicFreeCamera
  48067. * @param name defines camera name
  48068. * @param position defines initial position
  48069. * @param interaxialDistance defines distance between each color axis
  48070. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48071. * @param scene defines the hosting scene
  48072. */
  48073. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48074. /**
  48075. * Gets camera class name
  48076. * @returns StereoscopicFreeCamera
  48077. */
  48078. getClassName(): string;
  48079. }
  48080. }
  48081. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48082. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48083. import { Scene } from "babylonjs/scene";
  48084. import { Vector3 } from "babylonjs/Maths/math.vector";
  48085. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48086. /**
  48087. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48088. * @see https://doc.babylonjs.com/features/cameras
  48089. */
  48090. export class StereoscopicGamepadCamera extends GamepadCamera {
  48091. /**
  48092. * Creates a new StereoscopicGamepadCamera
  48093. * @param name defines camera name
  48094. * @param position defines initial position
  48095. * @param interaxialDistance defines distance between each color axis
  48096. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48097. * @param scene defines the hosting scene
  48098. */
  48099. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48100. /**
  48101. * Gets camera class name
  48102. * @returns StereoscopicGamepadCamera
  48103. */
  48104. getClassName(): string;
  48105. }
  48106. }
  48107. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48108. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48109. import { Scene } from "babylonjs/scene";
  48110. import { Vector3 } from "babylonjs/Maths/math.vector";
  48111. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48112. /**
  48113. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48114. * @see https://doc.babylonjs.com/features/cameras
  48115. */
  48116. export class StereoscopicUniversalCamera extends UniversalCamera {
  48117. /**
  48118. * Creates a new StereoscopicUniversalCamera
  48119. * @param name defines camera name
  48120. * @param position defines initial position
  48121. * @param interaxialDistance defines distance between each color axis
  48122. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48123. * @param scene defines the hosting scene
  48124. */
  48125. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48126. /**
  48127. * Gets camera class name
  48128. * @returns StereoscopicUniversalCamera
  48129. */
  48130. getClassName(): string;
  48131. }
  48132. }
  48133. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48134. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48135. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48136. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48137. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48138. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48139. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48140. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48141. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48142. }
  48143. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48144. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48145. import { Scene } from "babylonjs/scene";
  48146. import { Vector3 } from "babylonjs/Maths/math.vector";
  48147. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48148. /**
  48149. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48150. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48151. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48152. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48153. */
  48154. export class VirtualJoysticksCamera extends FreeCamera {
  48155. /**
  48156. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48157. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48158. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48159. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48160. * @param name Define the name of the camera in the scene
  48161. * @param position Define the start position of the camera in the scene
  48162. * @param scene Define the scene the camera belongs to
  48163. */
  48164. constructor(name: string, position: Vector3, scene: Scene);
  48165. /**
  48166. * Gets the current object class name.
  48167. * @return the class name
  48168. */
  48169. getClassName(): string;
  48170. }
  48171. }
  48172. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48173. import { Matrix } from "babylonjs/Maths/math.vector";
  48174. /**
  48175. * This represents all the required metrics to create a VR camera.
  48176. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48177. */
  48178. export class VRCameraMetrics {
  48179. /**
  48180. * Define the horizontal resolution off the screen.
  48181. */
  48182. hResolution: number;
  48183. /**
  48184. * Define the vertical resolution off the screen.
  48185. */
  48186. vResolution: number;
  48187. /**
  48188. * Define the horizontal screen size.
  48189. */
  48190. hScreenSize: number;
  48191. /**
  48192. * Define the vertical screen size.
  48193. */
  48194. vScreenSize: number;
  48195. /**
  48196. * Define the vertical screen center position.
  48197. */
  48198. vScreenCenter: number;
  48199. /**
  48200. * Define the distance of the eyes to the screen.
  48201. */
  48202. eyeToScreenDistance: number;
  48203. /**
  48204. * Define the distance between both lenses
  48205. */
  48206. lensSeparationDistance: number;
  48207. /**
  48208. * Define the distance between both viewer's eyes.
  48209. */
  48210. interpupillaryDistance: number;
  48211. /**
  48212. * Define the distortion factor of the VR postprocess.
  48213. * Please, touch with care.
  48214. */
  48215. distortionK: number[];
  48216. /**
  48217. * Define the chromatic aberration correction factors for the VR post process.
  48218. */
  48219. chromaAbCorrection: number[];
  48220. /**
  48221. * Define the scale factor of the post process.
  48222. * The smaller the better but the slower.
  48223. */
  48224. postProcessScaleFactor: number;
  48225. /**
  48226. * Define an offset for the lens center.
  48227. */
  48228. lensCenterOffset: number;
  48229. /**
  48230. * Define if the current vr camera should compensate the distortion of the lense or not.
  48231. */
  48232. compensateDistortion: boolean;
  48233. /**
  48234. * Defines if multiview should be enabled when rendering (Default: false)
  48235. */
  48236. multiviewEnabled: boolean;
  48237. /**
  48238. * Gets the rendering aspect ratio based on the provided resolutions.
  48239. */
  48240. get aspectRatio(): number;
  48241. /**
  48242. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48243. */
  48244. get aspectRatioFov(): number;
  48245. /**
  48246. * @hidden
  48247. */
  48248. get leftHMatrix(): Matrix;
  48249. /**
  48250. * @hidden
  48251. */
  48252. get rightHMatrix(): Matrix;
  48253. /**
  48254. * @hidden
  48255. */
  48256. get leftPreViewMatrix(): Matrix;
  48257. /**
  48258. * @hidden
  48259. */
  48260. get rightPreViewMatrix(): Matrix;
  48261. /**
  48262. * Get the default VRMetrics based on the most generic setup.
  48263. * @returns the default vr metrics
  48264. */
  48265. static GetDefault(): VRCameraMetrics;
  48266. }
  48267. }
  48268. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48269. /** @hidden */
  48270. export var vrDistortionCorrectionPixelShader: {
  48271. name: string;
  48272. shader: string;
  48273. };
  48274. }
  48275. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48276. import { Camera } from "babylonjs/Cameras/camera";
  48277. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48278. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48279. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48280. /**
  48281. * VRDistortionCorrectionPostProcess used for mobile VR
  48282. */
  48283. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48284. private _isRightEye;
  48285. private _distortionFactors;
  48286. private _postProcessScaleFactor;
  48287. private _lensCenterOffset;
  48288. private _scaleIn;
  48289. private _scaleFactor;
  48290. private _lensCenter;
  48291. /**
  48292. * Gets a string identifying the name of the class
  48293. * @returns "VRDistortionCorrectionPostProcess" string
  48294. */
  48295. getClassName(): string;
  48296. /**
  48297. * Initializes the VRDistortionCorrectionPostProcess
  48298. * @param name The name of the effect.
  48299. * @param camera The camera to apply the render pass to.
  48300. * @param isRightEye If this is for the right eye distortion
  48301. * @param vrMetrics All the required metrics for the VR camera
  48302. */
  48303. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48304. }
  48305. }
  48306. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48307. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48308. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48309. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48310. import { Scene } from "babylonjs/scene";
  48311. import { Vector3 } from "babylonjs/Maths/math.vector";
  48312. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48313. import "babylonjs/Cameras/RigModes/vrRigMode";
  48314. /**
  48315. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48316. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48317. */
  48318. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48319. /**
  48320. * Creates a new VRDeviceOrientationArcRotateCamera
  48321. * @param name defines camera name
  48322. * @param alpha defines the camera rotation along the logitudinal axis
  48323. * @param beta defines the camera rotation along the latitudinal axis
  48324. * @param radius defines the camera distance from its target
  48325. * @param target defines the camera target
  48326. * @param scene defines the scene the camera belongs to
  48327. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48328. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48329. */
  48330. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48331. /**
  48332. * Gets camera class name
  48333. * @returns VRDeviceOrientationArcRotateCamera
  48334. */
  48335. getClassName(): string;
  48336. }
  48337. }
  48338. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48339. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48340. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48341. import { Scene } from "babylonjs/scene";
  48342. import { Vector3 } from "babylonjs/Maths/math.vector";
  48343. import "babylonjs/Cameras/RigModes/vrRigMode";
  48344. /**
  48345. * Camera used to simulate VR rendering (based on FreeCamera)
  48346. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48347. */
  48348. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48349. /**
  48350. * Creates a new VRDeviceOrientationFreeCamera
  48351. * @param name defines camera name
  48352. * @param position defines the start position of the camera
  48353. * @param scene defines the scene the camera belongs to
  48354. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48355. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48356. */
  48357. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48358. /**
  48359. * Gets camera class name
  48360. * @returns VRDeviceOrientationFreeCamera
  48361. */
  48362. getClassName(): string;
  48363. }
  48364. }
  48365. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48366. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48367. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48368. import { Scene } from "babylonjs/scene";
  48369. import { Vector3 } from "babylonjs/Maths/math.vector";
  48370. import "babylonjs/Gamepads/gamepadSceneComponent";
  48371. /**
  48372. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48373. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48374. */
  48375. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48376. /**
  48377. * Creates a new VRDeviceOrientationGamepadCamera
  48378. * @param name defines camera name
  48379. * @param position defines the start position of the camera
  48380. * @param scene defines the scene the camera belongs to
  48381. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48382. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48383. */
  48384. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48385. /**
  48386. * Gets camera class name
  48387. * @returns VRDeviceOrientationGamepadCamera
  48388. */
  48389. getClassName(): string;
  48390. }
  48391. }
  48392. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48393. import { Scene } from "babylonjs/scene";
  48394. import { Texture } from "babylonjs/Materials/Textures/texture";
  48395. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48396. /**
  48397. * A class extending Texture allowing drawing on a texture
  48398. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48399. */
  48400. export class DynamicTexture extends Texture {
  48401. private _generateMipMaps;
  48402. private _canvas;
  48403. private _context;
  48404. /**
  48405. * Creates a DynamicTexture
  48406. * @param name defines the name of the texture
  48407. * @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
  48408. * @param scene defines the scene where you want the texture
  48409. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48410. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48411. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48412. */
  48413. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  48414. /**
  48415. * Get the current class name of the texture useful for serialization or dynamic coding.
  48416. * @returns "DynamicTexture"
  48417. */
  48418. getClassName(): string;
  48419. /**
  48420. * Gets the current state of canRescale
  48421. */
  48422. get canRescale(): boolean;
  48423. private _recreate;
  48424. /**
  48425. * Scales the texture
  48426. * @param ratio the scale factor to apply to both width and height
  48427. */
  48428. scale(ratio: number): void;
  48429. /**
  48430. * Resizes the texture
  48431. * @param width the new width
  48432. * @param height the new height
  48433. */
  48434. scaleTo(width: number, height: number): void;
  48435. /**
  48436. * Gets the context of the canvas used by the texture
  48437. * @returns the canvas context of the dynamic texture
  48438. */
  48439. getContext(): CanvasRenderingContext2D;
  48440. /**
  48441. * Clears the texture
  48442. */
  48443. clear(): void;
  48444. /**
  48445. * Updates the texture
  48446. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48447. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48448. */
  48449. update(invertY?: boolean, premulAlpha?: boolean): void;
  48450. /**
  48451. * Draws text onto the texture
  48452. * @param text defines the text to be drawn
  48453. * @param x defines the placement of the text from the left
  48454. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48455. * @param font defines the font to be used with font-style, font-size, font-name
  48456. * @param color defines the color used for the text
  48457. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48459. * @param update defines whether texture is immediately update (default is true)
  48460. */
  48461. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48462. /**
  48463. * Clones the texture
  48464. * @returns the clone of the texture.
  48465. */
  48466. clone(): DynamicTexture;
  48467. /**
  48468. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48469. * @returns a serialized dynamic texture object
  48470. */
  48471. serialize(): any;
  48472. private _IsCanvasElement;
  48473. /** @hidden */
  48474. _rebuild(): void;
  48475. }
  48476. }
  48477. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48478. import { Scene } from "babylonjs/scene";
  48479. import { Color3 } from "babylonjs/Maths/math.color";
  48480. import { Mesh } from "babylonjs/Meshes/mesh";
  48481. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48482. import { Nullable } from "babylonjs/types";
  48483. /**
  48484. * Class containing static functions to help procedurally build meshes
  48485. */
  48486. export class GroundBuilder {
  48487. /**
  48488. * Creates a ground mesh
  48489. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48490. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48492. * @param name defines the name of the mesh
  48493. * @param options defines the options used to create the mesh
  48494. * @param scene defines the hosting scene
  48495. * @returns the ground mesh
  48496. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48497. */
  48498. static CreateGround(name: string, options: {
  48499. width?: number;
  48500. height?: number;
  48501. subdivisions?: number;
  48502. subdivisionsX?: number;
  48503. subdivisionsY?: number;
  48504. updatable?: boolean;
  48505. }, scene: any): Mesh;
  48506. /**
  48507. * Creates a tiled ground mesh
  48508. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48509. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48510. * * 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
  48511. * * 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
  48512. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48513. * @param name defines the name of the mesh
  48514. * @param options defines the options used to create the mesh
  48515. * @param scene defines the hosting scene
  48516. * @returns the tiled ground mesh
  48517. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48518. */
  48519. static CreateTiledGround(name: string, options: {
  48520. xmin: number;
  48521. zmin: number;
  48522. xmax: number;
  48523. zmax: number;
  48524. subdivisions?: {
  48525. w: number;
  48526. h: number;
  48527. };
  48528. precision?: {
  48529. w: number;
  48530. h: number;
  48531. };
  48532. updatable?: boolean;
  48533. }, scene?: Nullable<Scene>): Mesh;
  48534. /**
  48535. * Creates a ground mesh from a height map
  48536. * * The parameter `url` sets the URL of the height map image resource.
  48537. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48538. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48539. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48540. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48541. * * 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.
  48542. * * 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).
  48543. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48545. * @param name defines the name of the mesh
  48546. * @param url defines the url to the height map
  48547. * @param options defines the options used to create the mesh
  48548. * @param scene defines the hosting scene
  48549. * @returns the ground mesh
  48550. * @see https://doc.babylonjs.com/babylon101/height_map
  48551. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48552. */
  48553. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48554. width?: number;
  48555. height?: number;
  48556. subdivisions?: number;
  48557. minHeight?: number;
  48558. maxHeight?: number;
  48559. colorFilter?: Color3;
  48560. alphaFilter?: number;
  48561. updatable?: boolean;
  48562. onReady?: (mesh: GroundMesh) => void;
  48563. }, scene?: Nullable<Scene>): GroundMesh;
  48564. }
  48565. }
  48566. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48567. import { Vector4 } from "babylonjs/Maths/math.vector";
  48568. import { Mesh } from "babylonjs/Meshes/mesh";
  48569. /**
  48570. * Class containing static functions to help procedurally build meshes
  48571. */
  48572. export class TorusBuilder {
  48573. /**
  48574. * Creates a torus mesh
  48575. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48576. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48577. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48578. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48579. * * 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
  48580. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48581. * @param name defines the name of the mesh
  48582. * @param options defines the options used to create the mesh
  48583. * @param scene defines the hosting scene
  48584. * @returns the torus mesh
  48585. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48586. */
  48587. static CreateTorus(name: string, options: {
  48588. diameter?: number;
  48589. thickness?: number;
  48590. tessellation?: number;
  48591. updatable?: boolean;
  48592. sideOrientation?: number;
  48593. frontUVs?: Vector4;
  48594. backUVs?: Vector4;
  48595. }, scene: any): Mesh;
  48596. }
  48597. }
  48598. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48599. import { Vector4 } from "babylonjs/Maths/math.vector";
  48600. import { Color4 } from "babylonjs/Maths/math.color";
  48601. import { Mesh } from "babylonjs/Meshes/mesh";
  48602. /**
  48603. * Class containing static functions to help procedurally build meshes
  48604. */
  48605. export class CylinderBuilder {
  48606. /**
  48607. * Creates a cylinder or a cone mesh
  48608. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48609. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48610. * * 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.
  48611. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48612. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48613. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48614. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48615. * * 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).
  48616. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48617. * * 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).
  48618. * * 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
  48619. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48620. * * 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
  48621. * * 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.
  48622. * * If `enclose` is false, a ring surface is one element.
  48623. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48624. * * 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
  48625. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48626. * * 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
  48627. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48628. * @param name defines the name of the mesh
  48629. * @param options defines the options used to create the mesh
  48630. * @param scene defines the hosting scene
  48631. * @returns the cylinder mesh
  48632. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48633. */
  48634. static CreateCylinder(name: string, options: {
  48635. height?: number;
  48636. diameterTop?: number;
  48637. diameterBottom?: number;
  48638. diameter?: number;
  48639. tessellation?: number;
  48640. subdivisions?: number;
  48641. arc?: number;
  48642. faceColors?: Color4[];
  48643. faceUV?: Vector4[];
  48644. updatable?: boolean;
  48645. hasRings?: boolean;
  48646. enclose?: boolean;
  48647. cap?: number;
  48648. sideOrientation?: number;
  48649. frontUVs?: Vector4;
  48650. backUVs?: Vector4;
  48651. }, scene: any): Mesh;
  48652. }
  48653. }
  48654. declare module "babylonjs/XR/webXRTypes" {
  48655. import { Nullable } from "babylonjs/types";
  48656. import { IDisposable } from "babylonjs/scene";
  48657. /**
  48658. * States of the webXR experience
  48659. */
  48660. export enum WebXRState {
  48661. /**
  48662. * Transitioning to being in XR mode
  48663. */
  48664. ENTERING_XR = 0,
  48665. /**
  48666. * Transitioning to non XR mode
  48667. */
  48668. EXITING_XR = 1,
  48669. /**
  48670. * In XR mode and presenting
  48671. */
  48672. IN_XR = 2,
  48673. /**
  48674. * Not entered XR mode
  48675. */
  48676. NOT_IN_XR = 3
  48677. }
  48678. /**
  48679. * Abstraction of the XR render target
  48680. */
  48681. export interface WebXRRenderTarget extends IDisposable {
  48682. /**
  48683. * xrpresent context of the canvas which can be used to display/mirror xr content
  48684. */
  48685. canvasContext: WebGLRenderingContext;
  48686. /**
  48687. * xr layer for the canvas
  48688. */
  48689. xrLayer: Nullable<XRWebGLLayer>;
  48690. /**
  48691. * Initializes the xr layer for the session
  48692. * @param xrSession xr session
  48693. * @returns a promise that will resolve once the XR Layer has been created
  48694. */
  48695. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48696. }
  48697. }
  48698. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48699. import { Nullable } from "babylonjs/types";
  48700. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48701. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48702. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48703. import { Observable } from "babylonjs/Misc/observable";
  48704. /**
  48705. * COnfiguration object for WebXR output canvas
  48706. */
  48707. export class WebXRManagedOutputCanvasOptions {
  48708. /**
  48709. * An optional canvas in case you wish to create it yourself and provide it here.
  48710. * If not provided, a new canvas will be created
  48711. */
  48712. canvasElement?: HTMLCanvasElement;
  48713. /**
  48714. * Options for this XR Layer output
  48715. */
  48716. canvasOptions?: XRWebGLLayerOptions;
  48717. /**
  48718. * CSS styling for a newly created canvas (if not provided)
  48719. */
  48720. newCanvasCssStyle?: string;
  48721. /**
  48722. * Get the default values of the configuration object
  48723. * @param engine defines the engine to use (can be null)
  48724. * @returns default values of this configuration object
  48725. */
  48726. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48727. }
  48728. /**
  48729. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48730. */
  48731. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48732. private _options;
  48733. private _canvas;
  48734. private _engine;
  48735. private _originalCanvasSize;
  48736. /**
  48737. * Rendering context of the canvas which can be used to display/mirror xr content
  48738. */
  48739. canvasContext: WebGLRenderingContext;
  48740. /**
  48741. * xr layer for the canvas
  48742. */
  48743. xrLayer: Nullable<XRWebGLLayer>;
  48744. /**
  48745. * Obseervers registered here will be triggered when the xr layer was initialized
  48746. */
  48747. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48748. /**
  48749. * Initializes the canvas to be added/removed upon entering/exiting xr
  48750. * @param _xrSessionManager The XR Session manager
  48751. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48752. */
  48753. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48754. /**
  48755. * Disposes of the object
  48756. */
  48757. dispose(): void;
  48758. /**
  48759. * Initializes the xr layer for the session
  48760. * @param xrSession xr session
  48761. * @returns a promise that will resolve once the XR Layer has been created
  48762. */
  48763. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48764. private _addCanvas;
  48765. private _removeCanvas;
  48766. private _setCanvasSize;
  48767. private _setManagedOutputCanvas;
  48768. }
  48769. }
  48770. declare module "babylonjs/XR/webXRSessionManager" {
  48771. import { Observable } from "babylonjs/Misc/observable";
  48772. import { Nullable } from "babylonjs/types";
  48773. import { IDisposable, Scene } from "babylonjs/scene";
  48774. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48775. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48776. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48777. /**
  48778. * Manages an XRSession to work with Babylon's engine
  48779. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48780. */
  48781. export class WebXRSessionManager implements IDisposable {
  48782. /** The scene which the session should be created for */
  48783. scene: Scene;
  48784. private _referenceSpace;
  48785. private _rttProvider;
  48786. private _sessionEnded;
  48787. private _xrNavigator;
  48788. private baseLayer;
  48789. /**
  48790. * The base reference space from which the session started. good if you want to reset your
  48791. * reference space
  48792. */
  48793. baseReferenceSpace: XRReferenceSpace;
  48794. /**
  48795. * Current XR frame
  48796. */
  48797. currentFrame: Nullable<XRFrame>;
  48798. /** WebXR timestamp updated every frame */
  48799. currentTimestamp: number;
  48800. /**
  48801. * Used just in case of a failure to initialize an immersive session.
  48802. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48803. */
  48804. defaultHeightCompensation: number;
  48805. /**
  48806. * Fires every time a new xrFrame arrives which can be used to update the camera
  48807. */
  48808. onXRFrameObservable: Observable<XRFrame>;
  48809. /**
  48810. * Fires when the reference space changed
  48811. */
  48812. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48813. /**
  48814. * Fires when the xr session is ended either by the device or manually done
  48815. */
  48816. onXRSessionEnded: Observable<any>;
  48817. /**
  48818. * Fires when the xr session is ended either by the device or manually done
  48819. */
  48820. onXRSessionInit: Observable<XRSession>;
  48821. /**
  48822. * Underlying xr session
  48823. */
  48824. session: XRSession;
  48825. /**
  48826. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48827. * or get the offset the player is currently at.
  48828. */
  48829. viewerReferenceSpace: XRReferenceSpace;
  48830. /**
  48831. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48832. * @param scene The scene which the session should be created for
  48833. */
  48834. constructor(
  48835. /** The scene which the session should be created for */
  48836. scene: Scene);
  48837. /**
  48838. * The current reference space used in this session. This reference space can constantly change!
  48839. * It is mainly used to offset the camera's position.
  48840. */
  48841. get referenceSpace(): XRReferenceSpace;
  48842. /**
  48843. * Set a new reference space and triggers the observable
  48844. */
  48845. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48846. /**
  48847. * Disposes of the session manager
  48848. */
  48849. dispose(): void;
  48850. /**
  48851. * Stops the xrSession and restores the render loop
  48852. * @returns Promise which resolves after it exits XR
  48853. */
  48854. exitXRAsync(): Promise<void>;
  48855. /**
  48856. * Gets the correct render target texture to be rendered this frame for this eye
  48857. * @param eye the eye for which to get the render target
  48858. * @returns the render target for the specified eye
  48859. */
  48860. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48861. /**
  48862. * Creates a WebXRRenderTarget object for the XR session
  48863. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48864. * @param options optional options to provide when creating a new render target
  48865. * @returns a WebXR render target to which the session can render
  48866. */
  48867. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48868. /**
  48869. * Initializes the manager
  48870. * After initialization enterXR can be called to start an XR session
  48871. * @returns Promise which resolves after it is initialized
  48872. */
  48873. initializeAsync(): Promise<void>;
  48874. /**
  48875. * Initializes an xr session
  48876. * @param xrSessionMode mode to initialize
  48877. * @param xrSessionInit defines optional and required values to pass to the session builder
  48878. * @returns a promise which will resolve once the session has been initialized
  48879. */
  48880. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  48881. /**
  48882. * Checks if a session would be supported for the creation options specified
  48883. * @param sessionMode session mode to check if supported eg. immersive-vr
  48884. * @returns A Promise that resolves to true if supported and false if not
  48885. */
  48886. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48887. /**
  48888. * Resets the reference space to the one started the session
  48889. */
  48890. resetReferenceSpace(): void;
  48891. /**
  48892. * Starts rendering to the xr layer
  48893. */
  48894. runXRRenderLoop(): void;
  48895. /**
  48896. * Sets the reference space on the xr session
  48897. * @param referenceSpaceType space to set
  48898. * @returns a promise that will resolve once the reference space has been set
  48899. */
  48900. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  48901. /**
  48902. * Updates the render state of the session
  48903. * @param state state to set
  48904. * @returns a promise that resolves once the render state has been updated
  48905. */
  48906. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  48907. /**
  48908. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  48909. * @param sessionMode defines the session to test
  48910. * @returns a promise with boolean as final value
  48911. */
  48912. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  48913. private _createRenderTargetTexture;
  48914. }
  48915. }
  48916. declare module "babylonjs/XR/webXRCamera" {
  48917. import { Vector3 } from "babylonjs/Maths/math.vector";
  48918. import { Scene } from "babylonjs/scene";
  48919. import { Camera } from "babylonjs/Cameras/camera";
  48920. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48921. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48922. import { Observable } from "babylonjs/Misc/observable";
  48923. /**
  48924. * WebXR Camera which holds the views for the xrSession
  48925. * @see https://doc.babylonjs.com/how_to/webxr_camera
  48926. */
  48927. export class WebXRCamera extends FreeCamera {
  48928. private _xrSessionManager;
  48929. private _firstFrame;
  48930. private _referenceQuaternion;
  48931. private _referencedPosition;
  48932. private _xrInvPositionCache;
  48933. private _xrInvQuaternionCache;
  48934. /**
  48935. * Observable raised before camera teleportation
  48936. */
  48937. onBeforeCameraTeleport: Observable<Vector3>;
  48938. /**
  48939. * Observable raised after camera teleportation
  48940. */
  48941. onAfterCameraTeleport: Observable<Vector3>;
  48942. /**
  48943. * Should position compensation execute on first frame.
  48944. * This is used when copying the position from a native (non XR) camera
  48945. */
  48946. compensateOnFirstFrame: boolean;
  48947. /**
  48948. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  48949. * @param name the name of the camera
  48950. * @param scene the scene to add the camera to
  48951. * @param _xrSessionManager a constructed xr session manager
  48952. */
  48953. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  48954. /**
  48955. * Return the user's height, unrelated to the current ground.
  48956. * This will be the y position of this camera, when ground level is 0.
  48957. */
  48958. get realWorldHeight(): number;
  48959. /** @hidden */
  48960. _updateForDualEyeDebugging(): void;
  48961. /**
  48962. * Sets this camera's transformation based on a non-vr camera
  48963. * @param otherCamera the non-vr camera to copy the transformation from
  48964. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  48965. */
  48966. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  48967. /**
  48968. * Gets the current instance class name ("WebXRCamera").
  48969. * @returns the class name
  48970. */
  48971. getClassName(): string;
  48972. private _rotate180;
  48973. private _updateFromXRSession;
  48974. private _updateNumberOfRigCameras;
  48975. private _updateReferenceSpace;
  48976. private _updateReferenceSpaceOffset;
  48977. }
  48978. }
  48979. declare module "babylonjs/XR/webXRFeaturesManager" {
  48980. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48981. import { IDisposable } from "babylonjs/scene";
  48982. /**
  48983. * Defining the interface required for a (webxr) feature
  48984. */
  48985. export interface IWebXRFeature extends IDisposable {
  48986. /**
  48987. * Is this feature attached
  48988. */
  48989. attached: boolean;
  48990. /**
  48991. * Should auto-attach be disabled?
  48992. */
  48993. disableAutoAttach: boolean;
  48994. /**
  48995. * Attach the feature to the session
  48996. * Will usually be called by the features manager
  48997. *
  48998. * @param force should attachment be forced (even when already attached)
  48999. * @returns true if successful.
  49000. */
  49001. attach(force?: boolean): boolean;
  49002. /**
  49003. * Detach the feature from the session
  49004. * Will usually be called by the features manager
  49005. *
  49006. * @returns true if successful.
  49007. */
  49008. detach(): boolean;
  49009. /**
  49010. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49011. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49012. *
  49013. * @returns whether or not the feature is compatible in this environment
  49014. */
  49015. isCompatible(): boolean;
  49016. /**
  49017. * Was this feature disposed;
  49018. */
  49019. isDisposed: boolean;
  49020. /**
  49021. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49022. */
  49023. xrNativeFeatureName?: string;
  49024. /**
  49025. * A list of (Babylon WebXR) features this feature depends on
  49026. */
  49027. dependsOn?: string[];
  49028. }
  49029. /**
  49030. * A list of the currently available features without referencing them
  49031. */
  49032. export class WebXRFeatureName {
  49033. /**
  49034. * The name of the anchor system feature
  49035. */
  49036. static readonly ANCHOR_SYSTEM: string;
  49037. /**
  49038. * The name of the background remover feature
  49039. */
  49040. static readonly BACKGROUND_REMOVER: string;
  49041. /**
  49042. * The name of the hit test feature
  49043. */
  49044. static readonly HIT_TEST: string;
  49045. /**
  49046. * physics impostors for xr controllers feature
  49047. */
  49048. static readonly PHYSICS_CONTROLLERS: string;
  49049. /**
  49050. * The name of the plane detection feature
  49051. */
  49052. static readonly PLANE_DETECTION: string;
  49053. /**
  49054. * The name of the pointer selection feature
  49055. */
  49056. static readonly POINTER_SELECTION: string;
  49057. /**
  49058. * The name of the teleportation feature
  49059. */
  49060. static readonly TELEPORTATION: string;
  49061. /**
  49062. * The name of the feature points feature.
  49063. */
  49064. static readonly FEATURE_POINTS: string;
  49065. /**
  49066. * The name of the hand tracking feature.
  49067. */
  49068. static readonly HAND_TRACKING: string;
  49069. }
  49070. /**
  49071. * Defining the constructor of a feature. Used to register the modules.
  49072. */
  49073. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49074. /**
  49075. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49076. * It is mainly used in AR sessions.
  49077. *
  49078. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49079. */
  49080. export class WebXRFeaturesManager implements IDisposable {
  49081. private _xrSessionManager;
  49082. private static readonly _AvailableFeatures;
  49083. private _features;
  49084. /**
  49085. * constructs a new features manages.
  49086. *
  49087. * @param _xrSessionManager an instance of WebXRSessionManager
  49088. */
  49089. constructor(_xrSessionManager: WebXRSessionManager);
  49090. /**
  49091. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49092. * Mainly used internally.
  49093. *
  49094. * @param featureName the name of the feature to register
  49095. * @param constructorFunction the function used to construct the module
  49096. * @param version the (babylon) version of the module
  49097. * @param stable is that a stable version of this module
  49098. */
  49099. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49100. /**
  49101. * Returns a constructor of a specific feature.
  49102. *
  49103. * @param featureName the name of the feature to construct
  49104. * @param version the version of the feature to load
  49105. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49106. * @param options optional options provided to the module.
  49107. * @returns a function that, when called, will return a new instance of this feature
  49108. */
  49109. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49110. /**
  49111. * Can be used to return the list of features currently registered
  49112. *
  49113. * @returns an Array of available features
  49114. */
  49115. static GetAvailableFeatures(): string[];
  49116. /**
  49117. * Gets the versions available for a specific feature
  49118. * @param featureName the name of the feature
  49119. * @returns an array with the available versions
  49120. */
  49121. static GetAvailableVersions(featureName: string): string[];
  49122. /**
  49123. * Return the latest unstable version of this feature
  49124. * @param featureName the name of the feature to search
  49125. * @returns the version number. if not found will return -1
  49126. */
  49127. static GetLatestVersionOfFeature(featureName: string): number;
  49128. /**
  49129. * Return the latest stable version of this feature
  49130. * @param featureName the name of the feature to search
  49131. * @returns the version number. if not found will return -1
  49132. */
  49133. static GetStableVersionOfFeature(featureName: string): number;
  49134. /**
  49135. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49136. * Can be used during a session to start a feature
  49137. * @param featureName the name of feature to attach
  49138. */
  49139. attachFeature(featureName: string): void;
  49140. /**
  49141. * Can be used inside a session or when the session ends to detach a specific feature
  49142. * @param featureName the name of the feature to detach
  49143. */
  49144. detachFeature(featureName: string): void;
  49145. /**
  49146. * Used to disable an already-enabled feature
  49147. * The feature will be disposed and will be recreated once enabled.
  49148. * @param featureName the feature to disable
  49149. * @returns true if disable was successful
  49150. */
  49151. disableFeature(featureName: string | {
  49152. Name: string;
  49153. }): boolean;
  49154. /**
  49155. * dispose this features manager
  49156. */
  49157. dispose(): void;
  49158. /**
  49159. * 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.
  49160. * 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.
  49161. *
  49162. * @param featureName the name of the feature to load or the class of the feature
  49163. * @param version optional version to load. if not provided the latest version will be enabled
  49164. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49165. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49166. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49167. * @returns a new constructed feature or throws an error if feature not found.
  49168. */
  49169. enableFeature(featureName: string | {
  49170. Name: string;
  49171. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49172. /**
  49173. * get the implementation of an enabled feature.
  49174. * @param featureName the name of the feature to load
  49175. * @returns the feature class, if found
  49176. */
  49177. getEnabledFeature(featureName: string): IWebXRFeature;
  49178. /**
  49179. * Get the list of enabled features
  49180. * @returns an array of enabled features
  49181. */
  49182. getEnabledFeatures(): string[];
  49183. /**
  49184. * This function will exten the session creation configuration object with enabled features.
  49185. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49186. * according to the defined "required" variable, provided during enableFeature call
  49187. * @param xrSessionInit the xr Session init object to extend
  49188. *
  49189. * @returns an extended XRSessionInit object
  49190. */
  49191. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49192. }
  49193. }
  49194. declare module "babylonjs/XR/webXRExperienceHelper" {
  49195. import { Observable } from "babylonjs/Misc/observable";
  49196. import { IDisposable, Scene } from "babylonjs/scene";
  49197. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49198. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49199. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49200. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49201. /**
  49202. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49203. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49204. */
  49205. export class WebXRExperienceHelper implements IDisposable {
  49206. private scene;
  49207. private _nonVRCamera;
  49208. private _originalSceneAutoClear;
  49209. private _supported;
  49210. /**
  49211. * Camera used to render xr content
  49212. */
  49213. camera: WebXRCamera;
  49214. /** A features manager for this xr session */
  49215. featuresManager: WebXRFeaturesManager;
  49216. /**
  49217. * Observers registered here will be triggered after the camera's initial transformation is set
  49218. * This can be used to set a different ground level or an extra rotation.
  49219. *
  49220. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49221. * to the position set after this observable is done executing.
  49222. */
  49223. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49224. /**
  49225. * Fires when the state of the experience helper has changed
  49226. */
  49227. onStateChangedObservable: Observable<WebXRState>;
  49228. /** Session manager used to keep track of xr session */
  49229. sessionManager: WebXRSessionManager;
  49230. /**
  49231. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49232. */
  49233. state: WebXRState;
  49234. /**
  49235. * Creates a WebXRExperienceHelper
  49236. * @param scene The scene the helper should be created in
  49237. */
  49238. private constructor();
  49239. /**
  49240. * Creates the experience helper
  49241. * @param scene the scene to attach the experience helper to
  49242. * @returns a promise for the experience helper
  49243. */
  49244. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49245. /**
  49246. * Disposes of the experience helper
  49247. */
  49248. dispose(): void;
  49249. /**
  49250. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49251. * @param sessionMode options for the XR session
  49252. * @param referenceSpaceType frame of reference of the XR session
  49253. * @param renderTarget the output canvas that will be used to enter XR mode
  49254. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49255. * @returns promise that resolves after xr mode has entered
  49256. */
  49257. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49258. /**
  49259. * Exits XR mode and returns the scene to its original state
  49260. * @returns promise that resolves after xr mode has exited
  49261. */
  49262. exitXRAsync(): Promise<void>;
  49263. private _nonXRToXRCamera;
  49264. private _setState;
  49265. }
  49266. }
  49267. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49268. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49269. import { Observable } from "babylonjs/Misc/observable";
  49270. import { IDisposable } from "babylonjs/scene";
  49271. /**
  49272. * X-Y values for axes in WebXR
  49273. */
  49274. export interface IWebXRMotionControllerAxesValue {
  49275. /**
  49276. * The value of the x axis
  49277. */
  49278. x: number;
  49279. /**
  49280. * The value of the y-axis
  49281. */
  49282. y: number;
  49283. }
  49284. /**
  49285. * changed / previous values for the values of this component
  49286. */
  49287. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49288. /**
  49289. * current (this frame) value
  49290. */
  49291. current: T;
  49292. /**
  49293. * previous (last change) value
  49294. */
  49295. previous: T;
  49296. }
  49297. /**
  49298. * Represents changes in the component between current frame and last values recorded
  49299. */
  49300. export interface IWebXRMotionControllerComponentChanges {
  49301. /**
  49302. * will be populated with previous and current values if axes changed
  49303. */
  49304. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49305. /**
  49306. * will be populated with previous and current values if pressed changed
  49307. */
  49308. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49309. /**
  49310. * will be populated with previous and current values if touched changed
  49311. */
  49312. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49313. /**
  49314. * will be populated with previous and current values if value changed
  49315. */
  49316. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49317. }
  49318. /**
  49319. * This class represents a single component (for example button or thumbstick) of a motion controller
  49320. */
  49321. export class WebXRControllerComponent implements IDisposable {
  49322. /**
  49323. * the id of this component
  49324. */
  49325. id: string;
  49326. /**
  49327. * the type of the component
  49328. */
  49329. type: MotionControllerComponentType;
  49330. private _buttonIndex;
  49331. private _axesIndices;
  49332. private _axes;
  49333. private _changes;
  49334. private _currentValue;
  49335. private _hasChanges;
  49336. private _pressed;
  49337. private _touched;
  49338. /**
  49339. * button component type
  49340. */
  49341. static BUTTON_TYPE: MotionControllerComponentType;
  49342. /**
  49343. * squeeze component type
  49344. */
  49345. static SQUEEZE_TYPE: MotionControllerComponentType;
  49346. /**
  49347. * Thumbstick component type
  49348. */
  49349. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49350. /**
  49351. * Touchpad component type
  49352. */
  49353. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49354. /**
  49355. * trigger component type
  49356. */
  49357. static TRIGGER_TYPE: MotionControllerComponentType;
  49358. /**
  49359. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49360. * the axes data changes
  49361. */
  49362. onAxisValueChangedObservable: Observable<{
  49363. x: number;
  49364. y: number;
  49365. }>;
  49366. /**
  49367. * Observers registered here will be triggered when the state of a button changes
  49368. * State change is either pressed / touched / value
  49369. */
  49370. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49371. /**
  49372. * Creates a new component for a motion controller.
  49373. * It is created by the motion controller itself
  49374. *
  49375. * @param id the id of this component
  49376. * @param type the type of the component
  49377. * @param _buttonIndex index in the buttons array of the gamepad
  49378. * @param _axesIndices indices of the values in the axes array of the gamepad
  49379. */
  49380. constructor(
  49381. /**
  49382. * the id of this component
  49383. */
  49384. id: string,
  49385. /**
  49386. * the type of the component
  49387. */
  49388. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49389. /**
  49390. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49391. */
  49392. get axes(): IWebXRMotionControllerAxesValue;
  49393. /**
  49394. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49395. */
  49396. get changes(): IWebXRMotionControllerComponentChanges;
  49397. /**
  49398. * Return whether or not the component changed the last frame
  49399. */
  49400. get hasChanges(): boolean;
  49401. /**
  49402. * is the button currently pressed
  49403. */
  49404. get pressed(): boolean;
  49405. /**
  49406. * is the button currently touched
  49407. */
  49408. get touched(): boolean;
  49409. /**
  49410. * Get the current value of this component
  49411. */
  49412. get value(): number;
  49413. /**
  49414. * Dispose this component
  49415. */
  49416. dispose(): void;
  49417. /**
  49418. * Are there axes correlating to this component
  49419. * @return true is axes data is available
  49420. */
  49421. isAxes(): boolean;
  49422. /**
  49423. * Is this component a button (hence - pressable)
  49424. * @returns true if can be pressed
  49425. */
  49426. isButton(): boolean;
  49427. /**
  49428. * update this component using the gamepad object it is in. Called on every frame
  49429. * @param nativeController the native gamepad controller object
  49430. */
  49431. update(nativeController: IMinimalMotionControllerObject): void;
  49432. }
  49433. }
  49434. declare module "babylonjs/Loading/sceneLoader" {
  49435. import { Observable } from "babylonjs/Misc/observable";
  49436. import { Nullable } from "babylonjs/types";
  49437. import { Scene } from "babylonjs/scene";
  49438. import { Engine } from "babylonjs/Engines/engine";
  49439. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49440. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49441. import { AssetContainer } from "babylonjs/assetContainer";
  49442. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49443. import { Skeleton } from "babylonjs/Bones/skeleton";
  49444. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49445. import { WebRequest } from "babylonjs/Misc/webRequest";
  49446. /**
  49447. * Interface used to represent data loading progression
  49448. */
  49449. export interface ISceneLoaderProgressEvent {
  49450. /**
  49451. * Defines if data length to load can be evaluated
  49452. */
  49453. readonly lengthComputable: boolean;
  49454. /**
  49455. * Defines the loaded data length
  49456. */
  49457. readonly loaded: number;
  49458. /**
  49459. * Defines the data length to load
  49460. */
  49461. readonly total: number;
  49462. }
  49463. /**
  49464. * Interface used by SceneLoader plugins to define supported file extensions
  49465. */
  49466. export interface ISceneLoaderPluginExtensions {
  49467. /**
  49468. * Defines the list of supported extensions
  49469. */
  49470. [extension: string]: {
  49471. isBinary: boolean;
  49472. };
  49473. }
  49474. /**
  49475. * Interface used by SceneLoader plugin factory
  49476. */
  49477. export interface ISceneLoaderPluginFactory {
  49478. /**
  49479. * Defines the name of the factory
  49480. */
  49481. name: string;
  49482. /**
  49483. * Function called to create a new plugin
  49484. * @return the new plugin
  49485. */
  49486. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49487. /**
  49488. * The callback that returns true if the data can be directly loaded.
  49489. * @param data string containing the file data
  49490. * @returns if the data can be loaded directly
  49491. */
  49492. canDirectLoad?(data: string): boolean;
  49493. }
  49494. /**
  49495. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49496. */
  49497. export interface ISceneLoaderPluginBase {
  49498. /**
  49499. * The friendly name of this plugin.
  49500. */
  49501. name: string;
  49502. /**
  49503. * The file extensions supported by this plugin.
  49504. */
  49505. extensions: string | ISceneLoaderPluginExtensions;
  49506. /**
  49507. * The callback called when loading from a url.
  49508. * @param scene scene loading this url
  49509. * @param url url to load
  49510. * @param onSuccess callback called when the file successfully loads
  49511. * @param onProgress callback called while file is loading (if the server supports this mode)
  49512. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49513. * @param onError callback called when the file fails to load
  49514. * @returns a file request object
  49515. */
  49516. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49517. /**
  49518. * The callback called when loading from a file object.
  49519. * @param scene scene loading this file
  49520. * @param file defines the file to load
  49521. * @param onSuccess defines the callback to call when data is loaded
  49522. * @param onProgress defines the callback to call during loading process
  49523. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49524. * @param onError defines the callback to call when an error occurs
  49525. * @returns a file request object
  49526. */
  49527. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49528. /**
  49529. * The callback that returns true if the data can be directly loaded.
  49530. * @param data string containing the file data
  49531. * @returns if the data can be loaded directly
  49532. */
  49533. canDirectLoad?(data: string): boolean;
  49534. /**
  49535. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49536. * @param scene scene loading this data
  49537. * @param data string containing the data
  49538. * @returns data to pass to the plugin
  49539. */
  49540. directLoad?(scene: Scene, data: string): any;
  49541. /**
  49542. * The callback that allows custom handling of the root url based on the response url.
  49543. * @param rootUrl the original root url
  49544. * @param responseURL the response url if available
  49545. * @returns the new root url
  49546. */
  49547. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49548. }
  49549. /**
  49550. * Interface used to define a SceneLoader plugin
  49551. */
  49552. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49553. /**
  49554. * Import meshes into a scene.
  49555. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49556. * @param scene The scene to import into
  49557. * @param data The data to import
  49558. * @param rootUrl The root url for scene and resources
  49559. * @param meshes The meshes array to import into
  49560. * @param particleSystems The particle systems array to import into
  49561. * @param skeletons The skeletons array to import into
  49562. * @param onError The callback when import fails
  49563. * @returns True if successful or false otherwise
  49564. */
  49565. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49566. /**
  49567. * Load into a scene.
  49568. * @param scene The scene to load into
  49569. * @param data The data to import
  49570. * @param rootUrl The root url for scene and resources
  49571. * @param onError The callback when import fails
  49572. * @returns True if successful or false otherwise
  49573. */
  49574. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49575. /**
  49576. * Load into an asset container.
  49577. * @param scene The scene to load into
  49578. * @param data The data to import
  49579. * @param rootUrl The root url for scene and resources
  49580. * @param onError The callback when import fails
  49581. * @returns The loaded asset container
  49582. */
  49583. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49584. }
  49585. /**
  49586. * Interface used to define an async SceneLoader plugin
  49587. */
  49588. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49589. /**
  49590. * Import meshes into a scene.
  49591. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49592. * @param scene The scene to import into
  49593. * @param data The data to import
  49594. * @param rootUrl The root url for scene and resources
  49595. * @param onProgress The callback when the load progresses
  49596. * @param fileName Defines the name of the file to load
  49597. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49598. */
  49599. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49600. meshes: AbstractMesh[];
  49601. particleSystems: IParticleSystem[];
  49602. skeletons: Skeleton[];
  49603. animationGroups: AnimationGroup[];
  49604. }>;
  49605. /**
  49606. * Load into a scene.
  49607. * @param scene The scene to load into
  49608. * @param data The data to import
  49609. * @param rootUrl The root url for scene and resources
  49610. * @param onProgress The callback when the load progresses
  49611. * @param fileName Defines the name of the file to load
  49612. * @returns Nothing
  49613. */
  49614. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49615. /**
  49616. * Load into an asset container.
  49617. * @param scene The scene to load into
  49618. * @param data The data to import
  49619. * @param rootUrl The root url for scene and resources
  49620. * @param onProgress The callback when the load progresses
  49621. * @param fileName Defines the name of the file to load
  49622. * @returns The loaded asset container
  49623. */
  49624. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49625. }
  49626. /**
  49627. * Mode that determines how to handle old animation groups before loading new ones.
  49628. */
  49629. export enum SceneLoaderAnimationGroupLoadingMode {
  49630. /**
  49631. * Reset all old animations to initial state then dispose them.
  49632. */
  49633. Clean = 0,
  49634. /**
  49635. * Stop all old animations.
  49636. */
  49637. Stop = 1,
  49638. /**
  49639. * Restart old animations from first frame.
  49640. */
  49641. Sync = 2,
  49642. /**
  49643. * Old animations remains untouched.
  49644. */
  49645. NoSync = 3
  49646. }
  49647. /**
  49648. * Defines a plugin registered by the SceneLoader
  49649. */
  49650. interface IRegisteredPlugin {
  49651. /**
  49652. * Defines the plugin to use
  49653. */
  49654. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49655. /**
  49656. * Defines if the plugin supports binary data
  49657. */
  49658. isBinary: boolean;
  49659. }
  49660. /**
  49661. * Class used to load scene from various file formats using registered plugins
  49662. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49663. */
  49664. export class SceneLoader {
  49665. /**
  49666. * No logging while loading
  49667. */
  49668. static readonly NO_LOGGING: number;
  49669. /**
  49670. * Minimal logging while loading
  49671. */
  49672. static readonly MINIMAL_LOGGING: number;
  49673. /**
  49674. * Summary logging while loading
  49675. */
  49676. static readonly SUMMARY_LOGGING: number;
  49677. /**
  49678. * Detailled logging while loading
  49679. */
  49680. static readonly DETAILED_LOGGING: number;
  49681. /**
  49682. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49683. */
  49684. static get ForceFullSceneLoadingForIncremental(): boolean;
  49685. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49686. /**
  49687. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49688. */
  49689. static get ShowLoadingScreen(): boolean;
  49690. static set ShowLoadingScreen(value: boolean);
  49691. /**
  49692. * Defines the current logging level (while loading the scene)
  49693. * @ignorenaming
  49694. */
  49695. static get loggingLevel(): number;
  49696. static set loggingLevel(value: number);
  49697. /**
  49698. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49699. */
  49700. static get CleanBoneMatrixWeights(): boolean;
  49701. static set CleanBoneMatrixWeights(value: boolean);
  49702. /**
  49703. * Event raised when a plugin is used to load a scene
  49704. */
  49705. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49706. private static _registeredPlugins;
  49707. private static _showingLoadingScreen;
  49708. /**
  49709. * Gets the default plugin (used to load Babylon files)
  49710. * @returns the .babylon plugin
  49711. */
  49712. static GetDefaultPlugin(): IRegisteredPlugin;
  49713. private static _GetPluginForExtension;
  49714. private static _GetPluginForDirectLoad;
  49715. private static _GetPluginForFilename;
  49716. private static _GetDirectLoad;
  49717. private static _LoadData;
  49718. private static _GetFileInfo;
  49719. /**
  49720. * Gets a plugin that can load the given extension
  49721. * @param extension defines the extension to load
  49722. * @returns a plugin or null if none works
  49723. */
  49724. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49725. /**
  49726. * Gets a boolean indicating that the given extension can be loaded
  49727. * @param extension defines the extension to load
  49728. * @returns true if the extension is supported
  49729. */
  49730. static IsPluginForExtensionAvailable(extension: string): boolean;
  49731. /**
  49732. * Adds a new plugin to the list of registered plugins
  49733. * @param plugin defines the plugin to add
  49734. */
  49735. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49736. /**
  49737. * Import meshes into a scene
  49738. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49739. * @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)
  49740. * @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)
  49741. * @param scene the instance of BABYLON.Scene to append to
  49742. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49743. * @param onProgress a callback with a progress event for each file being loaded
  49744. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49745. * @param pluginExtension the extension used to determine the plugin
  49746. * @returns The loaded plugin
  49747. */
  49748. 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>;
  49749. /**
  49750. * Import meshes into a scene
  49751. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49752. * @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)
  49753. * @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)
  49754. * @param scene the instance of BABYLON.Scene to append to
  49755. * @param onProgress a callback with a progress event for each file being loaded
  49756. * @param pluginExtension the extension used to determine the plugin
  49757. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49758. */
  49759. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49760. meshes: AbstractMesh[];
  49761. particleSystems: IParticleSystem[];
  49762. skeletons: Skeleton[];
  49763. animationGroups: AnimationGroup[];
  49764. }>;
  49765. /**
  49766. * Load a scene
  49767. * @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)
  49768. * @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)
  49769. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49770. * @param onSuccess a callback with the scene when import succeeds
  49771. * @param onProgress a callback with a progress event for each file being loaded
  49772. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49773. * @param pluginExtension the extension used to determine the plugin
  49774. * @returns The loaded plugin
  49775. */
  49776. 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>;
  49777. /**
  49778. * Load a scene
  49779. * @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)
  49780. * @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)
  49781. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49782. * @param onProgress a callback with a progress event for each file being loaded
  49783. * @param pluginExtension the extension used to determine the plugin
  49784. * @returns The loaded scene
  49785. */
  49786. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49787. /**
  49788. * Append a scene
  49789. * @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)
  49790. * @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)
  49791. * @param scene is the instance of BABYLON.Scene to append to
  49792. * @param onSuccess a callback with the scene when import succeeds
  49793. * @param onProgress a callback with a progress event for each file being loaded
  49794. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49795. * @param pluginExtension the extension used to determine the plugin
  49796. * @returns The loaded plugin
  49797. */
  49798. 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>;
  49799. /**
  49800. * Append a scene
  49801. * @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)
  49802. * @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)
  49803. * @param scene is the instance of BABYLON.Scene to append to
  49804. * @param onProgress a callback with a progress event for each file being loaded
  49805. * @param pluginExtension the extension used to determine the plugin
  49806. * @returns The given scene
  49807. */
  49808. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49809. /**
  49810. * Load a scene into an asset container
  49811. * @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)
  49812. * @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)
  49813. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49814. * @param onSuccess a callback with the scene when import succeeds
  49815. * @param onProgress a callback with a progress event for each file being loaded
  49816. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49817. * @param pluginExtension the extension used to determine the plugin
  49818. * @returns The loaded plugin
  49819. */
  49820. 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>;
  49821. /**
  49822. * Load a scene into an asset container
  49823. * @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)
  49824. * @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)
  49825. * @param scene is the instance of Scene to append to
  49826. * @param onProgress a callback with a progress event for each file being loaded
  49827. * @param pluginExtension the extension used to determine the plugin
  49828. * @returns The loaded asset container
  49829. */
  49830. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49831. /**
  49832. * Import animations from a file into a scene
  49833. * @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)
  49834. * @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)
  49835. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49836. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49837. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49838. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49839. * @param onSuccess a callback with the scene when import succeeds
  49840. * @param onProgress a callback with a progress event for each file being loaded
  49841. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49842. * @param pluginExtension the extension used to determine the plugin
  49843. */
  49844. 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;
  49845. /**
  49846. * Import animations from a file into a scene
  49847. * @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)
  49848. * @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)
  49849. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49850. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49851. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49852. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49853. * @param onSuccess a callback with the scene when import succeeds
  49854. * @param onProgress a callback with a progress event for each file being loaded
  49855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49856. * @param pluginExtension the extension used to determine the plugin
  49857. * @returns the updated scene with imported animations
  49858. */
  49859. 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>;
  49860. }
  49861. }
  49862. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49863. import { IDisposable, Scene } from "babylonjs/scene";
  49864. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49865. import { Observable } from "babylonjs/Misc/observable";
  49866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49867. import { Nullable } from "babylonjs/types";
  49868. /**
  49869. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49870. */
  49871. export type MotionControllerHandedness = "none" | "left" | "right";
  49872. /**
  49873. * The type of components available in motion controllers.
  49874. * This is not the name of the component.
  49875. */
  49876. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  49877. /**
  49878. * The state of a controller component
  49879. */
  49880. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  49881. /**
  49882. * The schema of motion controller layout.
  49883. * No object will be initialized using this interface
  49884. * This is used just to define the profile.
  49885. */
  49886. export interface IMotionControllerLayout {
  49887. /**
  49888. * Path to load the assets. Usually relative to the base path
  49889. */
  49890. assetPath: string;
  49891. /**
  49892. * Available components (unsorted)
  49893. */
  49894. components: {
  49895. /**
  49896. * A map of component Ids
  49897. */
  49898. [componentId: string]: {
  49899. /**
  49900. * The type of input the component outputs
  49901. */
  49902. type: MotionControllerComponentType;
  49903. /**
  49904. * The indices of this component in the gamepad object
  49905. */
  49906. gamepadIndices: {
  49907. /**
  49908. * Index of button
  49909. */
  49910. button?: number;
  49911. /**
  49912. * If available, index of x-axis
  49913. */
  49914. xAxis?: number;
  49915. /**
  49916. * If available, index of y-axis
  49917. */
  49918. yAxis?: number;
  49919. };
  49920. /**
  49921. * The mesh's root node name
  49922. */
  49923. rootNodeName: string;
  49924. /**
  49925. * Animation definitions for this model
  49926. */
  49927. visualResponses: {
  49928. [stateKey: string]: {
  49929. /**
  49930. * What property will be animated
  49931. */
  49932. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  49933. /**
  49934. * What states influence this visual response
  49935. */
  49936. states: MotionControllerComponentStateType[];
  49937. /**
  49938. * Type of animation - movement or visibility
  49939. */
  49940. valueNodeProperty: "transform" | "visibility";
  49941. /**
  49942. * Base node name to move. Its position will be calculated according to the min and max nodes
  49943. */
  49944. valueNodeName?: string;
  49945. /**
  49946. * Minimum movement node
  49947. */
  49948. minNodeName?: string;
  49949. /**
  49950. * Max movement node
  49951. */
  49952. maxNodeName?: string;
  49953. };
  49954. };
  49955. /**
  49956. * If touch enabled, what is the name of node to display user feedback
  49957. */
  49958. touchPointNodeName?: string;
  49959. };
  49960. };
  49961. /**
  49962. * Is it xr standard mapping or not
  49963. */
  49964. gamepadMapping: "" | "xr-standard";
  49965. /**
  49966. * Base root node of this entire model
  49967. */
  49968. rootNodeName: string;
  49969. /**
  49970. * Defines the main button component id
  49971. */
  49972. selectComponentId: string;
  49973. }
  49974. /**
  49975. * A definition for the layout map in the input profile
  49976. */
  49977. export interface IMotionControllerLayoutMap {
  49978. /**
  49979. * Layouts with handedness type as a key
  49980. */
  49981. [handedness: string]: IMotionControllerLayout;
  49982. }
  49983. /**
  49984. * The XR Input profile schema
  49985. * Profiles can be found here:
  49986. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  49987. */
  49988. export interface IMotionControllerProfile {
  49989. /**
  49990. * fallback profiles for this profileId
  49991. */
  49992. fallbackProfileIds: string[];
  49993. /**
  49994. * The layout map, with handedness as key
  49995. */
  49996. layouts: IMotionControllerLayoutMap;
  49997. /**
  49998. * The id of this profile
  49999. * correlates to the profile(s) in the xrInput.profiles array
  50000. */
  50001. profileId: string;
  50002. }
  50003. /**
  50004. * A helper-interface for the 3 meshes needed for controller button animation
  50005. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50006. */
  50007. export interface IMotionControllerButtonMeshMap {
  50008. /**
  50009. * the mesh that defines the pressed value mesh position.
  50010. * This is used to find the max-position of this button
  50011. */
  50012. pressedMesh: AbstractMesh;
  50013. /**
  50014. * the mesh that defines the unpressed value mesh position.
  50015. * This is used to find the min (or initial) position of this button
  50016. */
  50017. unpressedMesh: AbstractMesh;
  50018. /**
  50019. * The mesh that will be changed when value changes
  50020. */
  50021. valueMesh: AbstractMesh;
  50022. }
  50023. /**
  50024. * A helper-interface for the 3 meshes needed for controller axis animation.
  50025. * This will be expanded when touchpad animations are fully supported
  50026. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50027. */
  50028. export interface IMotionControllerMeshMap {
  50029. /**
  50030. * the mesh that defines the maximum value mesh position.
  50031. */
  50032. maxMesh?: AbstractMesh;
  50033. /**
  50034. * the mesh that defines the minimum value mesh position.
  50035. */
  50036. minMesh?: AbstractMesh;
  50037. /**
  50038. * The mesh that will be changed when axis value changes
  50039. */
  50040. valueMesh?: AbstractMesh;
  50041. }
  50042. /**
  50043. * The elements needed for change-detection of the gamepad objects in motion controllers
  50044. */
  50045. export interface IMinimalMotionControllerObject {
  50046. /**
  50047. * Available axes of this controller
  50048. */
  50049. axes: number[];
  50050. /**
  50051. * An array of available buttons
  50052. */
  50053. buttons: Array<{
  50054. /**
  50055. * Value of the button/trigger
  50056. */
  50057. value: number;
  50058. /**
  50059. * If the button/trigger is currently touched
  50060. */
  50061. touched: boolean;
  50062. /**
  50063. * If the button/trigger is currently pressed
  50064. */
  50065. pressed: boolean;
  50066. }>;
  50067. /**
  50068. * EXPERIMENTAL haptic support.
  50069. */
  50070. hapticActuators?: Array<{
  50071. pulse: (value: number, duration: number) => Promise<boolean>;
  50072. }>;
  50073. }
  50074. /**
  50075. * An Abstract Motion controller
  50076. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50077. * Each component has an observable to check for changes in value and state
  50078. */
  50079. export abstract class WebXRAbstractMotionController implements IDisposable {
  50080. protected scene: Scene;
  50081. protected layout: IMotionControllerLayout;
  50082. /**
  50083. * The gamepad object correlating to this controller
  50084. */
  50085. gamepadObject: IMinimalMotionControllerObject;
  50086. /**
  50087. * handedness (left/right/none) of this controller
  50088. */
  50089. handedness: MotionControllerHandedness;
  50090. private _initComponent;
  50091. private _modelReady;
  50092. /**
  50093. * A map of components (WebXRControllerComponent) in this motion controller
  50094. * Components have a ComponentType and can also have both button and axis definitions
  50095. */
  50096. readonly components: {
  50097. [id: string]: WebXRControllerComponent;
  50098. };
  50099. /**
  50100. * Disable the model's animation. Can be set at any time.
  50101. */
  50102. disableAnimation: boolean;
  50103. /**
  50104. * Observers registered here will be triggered when the model of this controller is done loading
  50105. */
  50106. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50107. /**
  50108. * The profile id of this motion controller
  50109. */
  50110. abstract profileId: string;
  50111. /**
  50112. * The root mesh of the model. It is null if the model was not yet initialized
  50113. */
  50114. rootMesh: Nullable<AbstractMesh>;
  50115. /**
  50116. * constructs a new abstract motion controller
  50117. * @param scene the scene to which the model of the controller will be added
  50118. * @param layout The profile layout to load
  50119. * @param gamepadObject The gamepad object correlating to this controller
  50120. * @param handedness handedness (left/right/none) of this controller
  50121. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50122. */
  50123. constructor(scene: Scene, layout: IMotionControllerLayout,
  50124. /**
  50125. * The gamepad object correlating to this controller
  50126. */
  50127. gamepadObject: IMinimalMotionControllerObject,
  50128. /**
  50129. * handedness (left/right/none) of this controller
  50130. */
  50131. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50132. /**
  50133. * Dispose this controller, the model mesh and all its components
  50134. */
  50135. dispose(): void;
  50136. /**
  50137. * Returns all components of specific type
  50138. * @param type the type to search for
  50139. * @return an array of components with this type
  50140. */
  50141. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50142. /**
  50143. * get a component based an its component id as defined in layout.components
  50144. * @param id the id of the component
  50145. * @returns the component correlates to the id or undefined if not found
  50146. */
  50147. getComponent(id: string): WebXRControllerComponent;
  50148. /**
  50149. * Get the list of components available in this motion controller
  50150. * @returns an array of strings correlating to available components
  50151. */
  50152. getComponentIds(): string[];
  50153. /**
  50154. * Get the first component of specific type
  50155. * @param type type of component to find
  50156. * @return a controller component or null if not found
  50157. */
  50158. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50159. /**
  50160. * Get the main (Select) component of this controller as defined in the layout
  50161. * @returns the main component of this controller
  50162. */
  50163. getMainComponent(): WebXRControllerComponent;
  50164. /**
  50165. * Loads the model correlating to this controller
  50166. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50167. * @returns A promise fulfilled with the result of the model loading
  50168. */
  50169. loadModel(): Promise<boolean>;
  50170. /**
  50171. * Update this model using the current XRFrame
  50172. * @param xrFrame the current xr frame to use and update the model
  50173. */
  50174. updateFromXRFrame(xrFrame: XRFrame): void;
  50175. /**
  50176. * Backwards compatibility due to a deeply-integrated typo
  50177. */
  50178. get handness(): XREye;
  50179. /**
  50180. * Pulse (vibrate) this controller
  50181. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50182. * Consecutive calls to this function will cancel the last pulse call
  50183. *
  50184. * @param value the strength of the pulse in 0.0...1.0 range
  50185. * @param duration Duration of the pulse in milliseconds
  50186. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50187. * @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
  50188. */
  50189. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50190. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50191. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50192. /**
  50193. * Moves the axis on the controller mesh based on its current state
  50194. * @param axis the index of the axis
  50195. * @param axisValue the value of the axis which determines the meshes new position
  50196. * @hidden
  50197. */
  50198. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50199. /**
  50200. * Update the model itself with the current frame data
  50201. * @param xrFrame the frame to use for updating the model mesh
  50202. */
  50203. protected updateModel(xrFrame: XRFrame): void;
  50204. /**
  50205. * Get the filename and path for this controller's model
  50206. * @returns a map of filename and path
  50207. */
  50208. protected abstract _getFilenameAndPath(): {
  50209. filename: string;
  50210. path: string;
  50211. };
  50212. /**
  50213. * This function is called before the mesh is loaded. It checks for loading constraints.
  50214. * For example, this function can check if the GLB loader is available
  50215. * If this function returns false, the generic controller will be loaded instead
  50216. * @returns Is the client ready to load the mesh
  50217. */
  50218. protected abstract _getModelLoadingConstraints(): boolean;
  50219. /**
  50220. * This function will be called after the model was successfully loaded and can be used
  50221. * for mesh transformations before it is available for the user
  50222. * @param meshes the loaded meshes
  50223. */
  50224. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50225. /**
  50226. * Set the root mesh for this controller. Important for the WebXR controller class
  50227. * @param meshes the loaded meshes
  50228. */
  50229. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50230. /**
  50231. * A function executed each frame that updates the mesh (if needed)
  50232. * @param xrFrame the current xrFrame
  50233. */
  50234. protected abstract _updateModel(xrFrame: XRFrame): void;
  50235. private _getGenericFilenameAndPath;
  50236. private _getGenericParentMesh;
  50237. }
  50238. }
  50239. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50240. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50242. import { Scene } from "babylonjs/scene";
  50243. /**
  50244. * A generic trigger-only motion controller for WebXR
  50245. */
  50246. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50247. /**
  50248. * Static version of the profile id of this controller
  50249. */
  50250. static ProfileId: string;
  50251. profileId: string;
  50252. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50253. protected _getFilenameAndPath(): {
  50254. filename: string;
  50255. path: string;
  50256. };
  50257. protected _getModelLoadingConstraints(): boolean;
  50258. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50259. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50260. protected _updateModel(): void;
  50261. }
  50262. }
  50263. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50264. import { Vector4 } from "babylonjs/Maths/math.vector";
  50265. import { Mesh } from "babylonjs/Meshes/mesh";
  50266. import { Scene } from "babylonjs/scene";
  50267. import { Nullable } from "babylonjs/types";
  50268. /**
  50269. * Class containing static functions to help procedurally build meshes
  50270. */
  50271. export class SphereBuilder {
  50272. /**
  50273. * Creates a sphere mesh
  50274. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50275. * * 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`)
  50276. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50277. * * 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
  50278. * * 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)
  50279. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50280. * * 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
  50281. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50282. * @param name defines the name of the mesh
  50283. * @param options defines the options used to create the mesh
  50284. * @param scene defines the hosting scene
  50285. * @returns the sphere mesh
  50286. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50287. */
  50288. static CreateSphere(name: string, options: {
  50289. segments?: number;
  50290. diameter?: number;
  50291. diameterX?: number;
  50292. diameterY?: number;
  50293. diameterZ?: number;
  50294. arc?: number;
  50295. slice?: number;
  50296. sideOrientation?: number;
  50297. frontUVs?: Vector4;
  50298. backUVs?: Vector4;
  50299. updatable?: boolean;
  50300. }, scene?: Nullable<Scene>): Mesh;
  50301. }
  50302. }
  50303. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50304. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50305. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50306. import { Scene } from "babylonjs/scene";
  50307. /**
  50308. * A profiled motion controller has its profile loaded from an online repository.
  50309. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50310. */
  50311. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50312. private _repositoryUrl;
  50313. private _buttonMeshMapping;
  50314. private _touchDots;
  50315. /**
  50316. * The profile ID of this controller. Will be populated when the controller initializes.
  50317. */
  50318. profileId: string;
  50319. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50320. dispose(): void;
  50321. protected _getFilenameAndPath(): {
  50322. filename: string;
  50323. path: string;
  50324. };
  50325. protected _getModelLoadingConstraints(): boolean;
  50326. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50327. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50328. protected _updateModel(_xrFrame: XRFrame): void;
  50329. }
  50330. }
  50331. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50332. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50333. import { Scene } from "babylonjs/scene";
  50334. /**
  50335. * A construction function type to create a new controller based on an xrInput object
  50336. */
  50337. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50338. /**
  50339. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50340. *
  50341. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50342. * it should be replaced with auto-loaded controllers.
  50343. *
  50344. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50345. */
  50346. export class WebXRMotionControllerManager {
  50347. private static _AvailableControllers;
  50348. private static _Fallbacks;
  50349. private static _ProfileLoadingPromises;
  50350. private static _ProfilesList;
  50351. /**
  50352. * The base URL of the online controller repository. Can be changed at any time.
  50353. */
  50354. static BaseRepositoryUrl: string;
  50355. /**
  50356. * Which repository gets priority - local or online
  50357. */
  50358. static PrioritizeOnlineRepository: boolean;
  50359. /**
  50360. * Use the online repository, or use only locally-defined controllers
  50361. */
  50362. static UseOnlineRepository: boolean;
  50363. /**
  50364. * Clear the cache used for profile loading and reload when requested again
  50365. */
  50366. static ClearProfilesCache(): void;
  50367. /**
  50368. * Register the default fallbacks.
  50369. * This function is called automatically when this file is imported.
  50370. */
  50371. static DefaultFallbacks(): void;
  50372. /**
  50373. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50374. * @param profileId the profile to which a fallback needs to be found
  50375. * @return an array with corresponding fallback profiles
  50376. */
  50377. static FindFallbackWithProfileId(profileId: string): string[];
  50378. /**
  50379. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50380. * The order of search:
  50381. *
  50382. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50383. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50384. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50385. * 4) return the generic trigger controller if none were found
  50386. *
  50387. * @param xrInput the xrInput to which a new controller is initialized
  50388. * @param scene the scene to which the model will be added
  50389. * @param forceProfile force a certain profile for this controller
  50390. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50391. */
  50392. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50393. /**
  50394. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50395. *
  50396. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50397. *
  50398. * @param type the profile type to register
  50399. * @param constructFunction the function to be called when loading this profile
  50400. */
  50401. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50402. /**
  50403. * Register a fallback to a specific profile.
  50404. * @param profileId the profileId that will receive the fallbacks
  50405. * @param fallbacks A list of fallback profiles
  50406. */
  50407. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50408. /**
  50409. * Will update the list of profiles available in the repository
  50410. * @return a promise that resolves to a map of profiles available online
  50411. */
  50412. static UpdateProfilesList(): Promise<{
  50413. [profile: string]: string;
  50414. }>;
  50415. private static _LoadProfileFromRepository;
  50416. private static _LoadProfilesFromAvailableControllers;
  50417. }
  50418. }
  50419. declare module "babylonjs/XR/webXRInputSource" {
  50420. import { Observable } from "babylonjs/Misc/observable";
  50421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50422. import { Ray } from "babylonjs/Culling/ray";
  50423. import { Scene } from "babylonjs/scene";
  50424. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50425. /**
  50426. * Configuration options for the WebXR controller creation
  50427. */
  50428. export interface IWebXRControllerOptions {
  50429. /**
  50430. * Should the controller mesh be animated when a user interacts with it
  50431. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50432. */
  50433. disableMotionControllerAnimation?: boolean;
  50434. /**
  50435. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50436. */
  50437. doNotLoadControllerMesh?: boolean;
  50438. /**
  50439. * Force a specific controller type for this controller.
  50440. * This can be used when creating your own profile or when testing different controllers
  50441. */
  50442. forceControllerProfile?: string;
  50443. /**
  50444. * Defines a rendering group ID for meshes that will be loaded.
  50445. * This is for the default controllers only.
  50446. */
  50447. renderingGroupId?: number;
  50448. }
  50449. /**
  50450. * Represents an XR controller
  50451. */
  50452. export class WebXRInputSource {
  50453. private _scene;
  50454. /** The underlying input source for the controller */
  50455. inputSource: XRInputSource;
  50456. private _options;
  50457. private _tmpVector;
  50458. private _uniqueId;
  50459. private _disposed;
  50460. /**
  50461. * 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
  50462. */
  50463. grip?: AbstractMesh;
  50464. /**
  50465. * If available, this is the gamepad object related to this controller.
  50466. * Using this object it is possible to get click events and trackpad changes of the
  50467. * webxr controller that is currently being used.
  50468. */
  50469. motionController?: WebXRAbstractMotionController;
  50470. /**
  50471. * Event that fires when the controller is removed/disposed.
  50472. * The object provided as event data is this controller, after associated assets were disposed.
  50473. * uniqueId is still available.
  50474. */
  50475. onDisposeObservable: Observable<WebXRInputSource>;
  50476. /**
  50477. * Will be triggered when the mesh associated with the motion controller is done loading.
  50478. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50479. * A shortened version of controller -> motion controller -> on mesh loaded.
  50480. */
  50481. onMeshLoadedObservable: Observable<AbstractMesh>;
  50482. /**
  50483. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50484. */
  50485. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50486. /**
  50487. * Pointer which can be used to select objects or attach a visible laser to
  50488. */
  50489. pointer: AbstractMesh;
  50490. /**
  50491. * Creates the input source object
  50492. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50493. * @param _scene the scene which the controller should be associated to
  50494. * @param inputSource the underlying input source for the controller
  50495. * @param _options options for this controller creation
  50496. */
  50497. constructor(_scene: Scene,
  50498. /** The underlying input source for the controller */
  50499. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50500. /**
  50501. * Get this controllers unique id
  50502. */
  50503. get uniqueId(): string;
  50504. /**
  50505. * Disposes of the object
  50506. */
  50507. dispose(): void;
  50508. /**
  50509. * Gets a world space ray coming from the pointer or grip
  50510. * @param result the resulting ray
  50511. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50512. */
  50513. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50514. /**
  50515. * Updates the controller pose based on the given XRFrame
  50516. * @param xrFrame xr frame to update the pose with
  50517. * @param referenceSpace reference space to use
  50518. */
  50519. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50520. }
  50521. }
  50522. declare module "babylonjs/XR/webXRInput" {
  50523. import { Observable } from "babylonjs/Misc/observable";
  50524. import { IDisposable } from "babylonjs/scene";
  50525. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50526. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50527. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50528. /**
  50529. * The schema for initialization options of the XR Input class
  50530. */
  50531. export interface IWebXRInputOptions {
  50532. /**
  50533. * If set to true no model will be automatically loaded
  50534. */
  50535. doNotLoadControllerMeshes?: boolean;
  50536. /**
  50537. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50538. * If not found, the xr input profile data will be used.
  50539. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50540. */
  50541. forceInputProfile?: string;
  50542. /**
  50543. * Do not send a request to the controller repository to load the profile.
  50544. *
  50545. * Instead, use the controllers available in babylon itself.
  50546. */
  50547. disableOnlineControllerRepository?: boolean;
  50548. /**
  50549. * A custom URL for the controllers repository
  50550. */
  50551. customControllersRepositoryURL?: string;
  50552. /**
  50553. * Should the controller model's components not move according to the user input
  50554. */
  50555. disableControllerAnimation?: boolean;
  50556. /**
  50557. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50558. */
  50559. controllerOptions?: IWebXRControllerOptions;
  50560. }
  50561. /**
  50562. * XR input used to track XR inputs such as controllers/rays
  50563. */
  50564. export class WebXRInput implements IDisposable {
  50565. /**
  50566. * the xr session manager for this session
  50567. */
  50568. xrSessionManager: WebXRSessionManager;
  50569. /**
  50570. * the WebXR camera for this session. Mainly used for teleportation
  50571. */
  50572. xrCamera: WebXRCamera;
  50573. private readonly options;
  50574. /**
  50575. * XR controllers being tracked
  50576. */
  50577. controllers: Array<WebXRInputSource>;
  50578. private _frameObserver;
  50579. private _sessionEndedObserver;
  50580. private _sessionInitObserver;
  50581. /**
  50582. * Event when a controller has been connected/added
  50583. */
  50584. onControllerAddedObservable: Observable<WebXRInputSource>;
  50585. /**
  50586. * Event when a controller has been removed/disconnected
  50587. */
  50588. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50589. /**
  50590. * Initializes the WebXRInput
  50591. * @param xrSessionManager the xr session manager for this session
  50592. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50593. * @param options = initialization options for this xr input
  50594. */
  50595. constructor(
  50596. /**
  50597. * the xr session manager for this session
  50598. */
  50599. xrSessionManager: WebXRSessionManager,
  50600. /**
  50601. * the WebXR camera for this session. Mainly used for teleportation
  50602. */
  50603. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50604. private _onInputSourcesChange;
  50605. private _addAndRemoveControllers;
  50606. /**
  50607. * Disposes of the object
  50608. */
  50609. dispose(): void;
  50610. }
  50611. }
  50612. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50613. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50614. import { Observable, EventState } from "babylonjs/Misc/observable";
  50615. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50616. /**
  50617. * This is the base class for all WebXR features.
  50618. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50619. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50620. */
  50621. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50622. protected _xrSessionManager: WebXRSessionManager;
  50623. private _attached;
  50624. private _removeOnDetach;
  50625. /**
  50626. * Is this feature disposed?
  50627. */
  50628. isDisposed: boolean;
  50629. /**
  50630. * Should auto-attach be disabled?
  50631. */
  50632. disableAutoAttach: boolean;
  50633. /**
  50634. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50635. */
  50636. xrNativeFeatureName: string;
  50637. /**
  50638. * Construct a new (abstract) WebXR feature
  50639. * @param _xrSessionManager the xr session manager for this feature
  50640. */
  50641. constructor(_xrSessionManager: WebXRSessionManager);
  50642. /**
  50643. * Is this feature attached
  50644. */
  50645. get attached(): boolean;
  50646. /**
  50647. * attach this feature
  50648. *
  50649. * @param force should attachment be forced (even when already attached)
  50650. * @returns true if successful, false is failed or already attached
  50651. */
  50652. attach(force?: boolean): boolean;
  50653. /**
  50654. * detach this feature.
  50655. *
  50656. * @returns true if successful, false if failed or already detached
  50657. */
  50658. detach(): boolean;
  50659. /**
  50660. * Dispose this feature and all of the resources attached
  50661. */
  50662. dispose(): void;
  50663. /**
  50664. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50665. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50666. *
  50667. * @returns whether or not the feature is compatible in this environment
  50668. */
  50669. isCompatible(): boolean;
  50670. /**
  50671. * This is used to register callbacks that will automatically be removed when detach is called.
  50672. * @param observable the observable to which the observer will be attached
  50673. * @param callback the callback to register
  50674. */
  50675. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50676. /**
  50677. * Code in this function will be executed on each xrFrame received from the browser.
  50678. * This function will not execute after the feature is detached.
  50679. * @param _xrFrame the current frame
  50680. */
  50681. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50682. }
  50683. }
  50684. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50685. import { IDisposable, Scene } from "babylonjs/scene";
  50686. import { Nullable } from "babylonjs/types";
  50687. import { Observable } from "babylonjs/Misc/observable";
  50688. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50689. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50690. import { Camera } from "babylonjs/Cameras/camera";
  50691. /**
  50692. * Renders a layer on top of an existing scene
  50693. */
  50694. export class UtilityLayerRenderer implements IDisposable {
  50695. /** the original scene that will be rendered on top of */
  50696. originalScene: Scene;
  50697. private _pointerCaptures;
  50698. private _lastPointerEvents;
  50699. private static _DefaultUtilityLayer;
  50700. private static _DefaultKeepDepthUtilityLayer;
  50701. private _sharedGizmoLight;
  50702. private _renderCamera;
  50703. /**
  50704. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50705. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50706. * @returns the camera that is used when rendering the utility layer
  50707. */
  50708. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50709. /**
  50710. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50711. * @param cam the camera that should be used when rendering the utility layer
  50712. */
  50713. setRenderCamera(cam: Nullable<Camera>): void;
  50714. /**
  50715. * @hidden
  50716. * Light which used by gizmos to get light shading
  50717. */
  50718. _getSharedGizmoLight(): HemisphericLight;
  50719. /**
  50720. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50721. */
  50722. pickUtilitySceneFirst: boolean;
  50723. /**
  50724. * 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)
  50725. */
  50726. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50727. /**
  50728. * 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)
  50729. */
  50730. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50731. /**
  50732. * The scene that is rendered on top of the original scene
  50733. */
  50734. utilityLayerScene: Scene;
  50735. /**
  50736. * If the utility layer should automatically be rendered on top of existing scene
  50737. */
  50738. shouldRender: boolean;
  50739. /**
  50740. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50741. */
  50742. onlyCheckPointerDownEvents: boolean;
  50743. /**
  50744. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50745. */
  50746. processAllEvents: boolean;
  50747. /**
  50748. * Observable raised when the pointer move from the utility layer scene to the main scene
  50749. */
  50750. onPointerOutObservable: Observable<number>;
  50751. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50752. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50753. private _afterRenderObserver;
  50754. private _sceneDisposeObserver;
  50755. private _originalPointerObserver;
  50756. /**
  50757. * Instantiates a UtilityLayerRenderer
  50758. * @param originalScene the original scene that will be rendered on top of
  50759. * @param handleEvents boolean indicating if the utility layer should handle events
  50760. */
  50761. constructor(
  50762. /** the original scene that will be rendered on top of */
  50763. originalScene: Scene, handleEvents?: boolean);
  50764. private _notifyObservers;
  50765. /**
  50766. * Renders the utility layers scene on top of the original scene
  50767. */
  50768. render(): void;
  50769. /**
  50770. * Disposes of the renderer
  50771. */
  50772. dispose(): void;
  50773. private _updateCamera;
  50774. }
  50775. }
  50776. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50777. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50778. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50779. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50780. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50781. import { Scene } from "babylonjs/scene";
  50782. import { Nullable } from "babylonjs/types";
  50783. import { Color3 } from "babylonjs/Maths/math.color";
  50784. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50785. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50786. /**
  50787. * Options interface for the pointer selection module
  50788. */
  50789. export interface IWebXRControllerPointerSelectionOptions {
  50790. /**
  50791. * if provided, this scene will be used to render meshes.
  50792. */
  50793. customUtilityLayerScene?: Scene;
  50794. /**
  50795. * 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)
  50796. * If not disabled, the last picked point will be used to execute a pointer up event
  50797. * If disabled, pointer up event will be triggered right after the pointer down event.
  50798. * Used in screen and gaze target ray mode only
  50799. */
  50800. disablePointerUpOnTouchOut: boolean;
  50801. /**
  50802. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50803. */
  50804. forceGazeMode: boolean;
  50805. /**
  50806. * 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
  50807. * to start a new countdown to the pointer down event.
  50808. * Defaults to 1.
  50809. */
  50810. gazeModePointerMovedFactor?: number;
  50811. /**
  50812. * Different button type to use instead of the main component
  50813. */
  50814. overrideButtonId?: string;
  50815. /**
  50816. * use this rendering group id for the meshes (optional)
  50817. */
  50818. renderingGroupId?: number;
  50819. /**
  50820. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50821. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50822. * 3000 means 3 seconds between pointing at something and selecting it
  50823. */
  50824. timeToSelect?: number;
  50825. /**
  50826. * Should meshes created here be added to a utility layer or the main scene
  50827. */
  50828. useUtilityLayer?: boolean;
  50829. /**
  50830. * Optional WebXR camera to be used for gaze selection
  50831. */
  50832. gazeCamera?: WebXRCamera;
  50833. /**
  50834. * the xr input to use with this pointer selection
  50835. */
  50836. xrInput: WebXRInput;
  50837. }
  50838. /**
  50839. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50840. */
  50841. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50842. private readonly _options;
  50843. private static _idCounter;
  50844. private _attachController;
  50845. private _controllers;
  50846. private _scene;
  50847. private _tmpVectorForPickCompare;
  50848. /**
  50849. * The module's name
  50850. */
  50851. static readonly Name: string;
  50852. /**
  50853. * The (Babylon) version of this module.
  50854. * This is an integer representing the implementation version.
  50855. * This number does not correspond to the WebXR specs version
  50856. */
  50857. static readonly Version: number;
  50858. /**
  50859. * Disable lighting on the laser pointer (so it will always be visible)
  50860. */
  50861. disablePointerLighting: boolean;
  50862. /**
  50863. * Disable lighting on the selection mesh (so it will always be visible)
  50864. */
  50865. disableSelectionMeshLighting: boolean;
  50866. /**
  50867. * Should the laser pointer be displayed
  50868. */
  50869. displayLaserPointer: boolean;
  50870. /**
  50871. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50872. */
  50873. displaySelectionMesh: boolean;
  50874. /**
  50875. * This color will be set to the laser pointer when selection is triggered
  50876. */
  50877. laserPointerPickedColor: Color3;
  50878. /**
  50879. * Default color of the laser pointer
  50880. */
  50881. laserPointerDefaultColor: Color3;
  50882. /**
  50883. * default color of the selection ring
  50884. */
  50885. selectionMeshDefaultColor: Color3;
  50886. /**
  50887. * This color will be applied to the selection ring when selection is triggered
  50888. */
  50889. selectionMeshPickedColor: Color3;
  50890. /**
  50891. * Optional filter to be used for ray selection. This predicate shares behavior with
  50892. * scene.pointerMovePredicate which takes priority if it is also assigned.
  50893. */
  50894. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  50895. /**
  50896. * constructs a new background remover module
  50897. * @param _xrSessionManager the session manager for this module
  50898. * @param _options read-only options to be used in this module
  50899. */
  50900. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  50901. /**
  50902. * attach this feature
  50903. * Will usually be called by the features manager
  50904. *
  50905. * @returns true if successful.
  50906. */
  50907. attach(): boolean;
  50908. /**
  50909. * detach this feature.
  50910. * Will usually be called by the features manager
  50911. *
  50912. * @returns true if successful.
  50913. */
  50914. detach(): boolean;
  50915. /**
  50916. * Will get the mesh under a specific pointer.
  50917. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  50918. * @param controllerId the controllerId to check
  50919. * @returns The mesh under pointer or null if no mesh is under the pointer
  50920. */
  50921. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  50922. /**
  50923. * Get the xr controller that correlates to the pointer id in the pointer event
  50924. *
  50925. * @param id the pointer id to search for
  50926. * @returns the controller that correlates to this id or null if not found
  50927. */
  50928. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  50929. protected _onXRFrame(_xrFrame: XRFrame): void;
  50930. private _attachGazeMode;
  50931. private _attachScreenRayMode;
  50932. private _attachTrackedPointerRayMode;
  50933. private _convertNormalToDirectionOfRay;
  50934. private _detachController;
  50935. private _generateNewMeshPair;
  50936. private _pickingMoved;
  50937. private _updatePointerDistance;
  50938. /** @hidden */
  50939. get lasterPointerDefaultColor(): Color3;
  50940. }
  50941. }
  50942. declare module "babylonjs/XR/webXREnterExitUI" {
  50943. import { Nullable } from "babylonjs/types";
  50944. import { Observable } from "babylonjs/Misc/observable";
  50945. import { IDisposable, Scene } from "babylonjs/scene";
  50946. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  50947. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  50948. /**
  50949. * Button which can be used to enter a different mode of XR
  50950. */
  50951. export class WebXREnterExitUIButton {
  50952. /** button element */
  50953. element: HTMLElement;
  50954. /** XR initialization options for the button */
  50955. sessionMode: XRSessionMode;
  50956. /** Reference space type */
  50957. referenceSpaceType: XRReferenceSpaceType;
  50958. /**
  50959. * Creates a WebXREnterExitUIButton
  50960. * @param element button element
  50961. * @param sessionMode XR initialization session mode
  50962. * @param referenceSpaceType the type of reference space to be used
  50963. */
  50964. constructor(
  50965. /** button element */
  50966. element: HTMLElement,
  50967. /** XR initialization options for the button */
  50968. sessionMode: XRSessionMode,
  50969. /** Reference space type */
  50970. referenceSpaceType: XRReferenceSpaceType);
  50971. /**
  50972. * Extendable function which can be used to update the button's visuals when the state changes
  50973. * @param activeButton the current active button in the UI
  50974. */
  50975. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  50976. }
  50977. /**
  50978. * Options to create the webXR UI
  50979. */
  50980. export class WebXREnterExitUIOptions {
  50981. /**
  50982. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  50983. */
  50984. customButtons?: Array<WebXREnterExitUIButton>;
  50985. /**
  50986. * A reference space type to use when creating the default button.
  50987. * Default is local-floor
  50988. */
  50989. referenceSpaceType?: XRReferenceSpaceType;
  50990. /**
  50991. * Context to enter xr with
  50992. */
  50993. renderTarget?: Nullable<WebXRRenderTarget>;
  50994. /**
  50995. * A session mode to use when creating the default button.
  50996. * Default is immersive-vr
  50997. */
  50998. sessionMode?: XRSessionMode;
  50999. /**
  51000. * A list of optional features to init the session with
  51001. */
  51002. optionalFeatures?: string[];
  51003. /**
  51004. * A list of optional features to init the session with
  51005. */
  51006. requiredFeatures?: string[];
  51007. }
  51008. /**
  51009. * UI to allow the user to enter/exit XR mode
  51010. */
  51011. export class WebXREnterExitUI implements IDisposable {
  51012. private scene;
  51013. /** version of the options passed to this UI */
  51014. options: WebXREnterExitUIOptions;
  51015. private _activeButton;
  51016. private _buttons;
  51017. /**
  51018. * The HTML Div Element to which buttons are added.
  51019. */
  51020. readonly overlay: HTMLDivElement;
  51021. /**
  51022. * Fired every time the active button is changed.
  51023. *
  51024. * When xr is entered via a button that launches xr that button will be the callback parameter
  51025. *
  51026. * When exiting xr the callback parameter will be null)
  51027. */
  51028. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51029. /**
  51030. *
  51031. * @param scene babylon scene object to use
  51032. * @param options (read-only) version of the options passed to this UI
  51033. */
  51034. private constructor();
  51035. /**
  51036. * Creates UI to allow the user to enter/exit XR mode
  51037. * @param scene the scene to add the ui to
  51038. * @param helper the xr experience helper to enter/exit xr with
  51039. * @param options options to configure the UI
  51040. * @returns the created ui
  51041. */
  51042. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51043. /**
  51044. * Disposes of the XR UI component
  51045. */
  51046. dispose(): void;
  51047. private _updateButtons;
  51048. }
  51049. }
  51050. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51051. import { Vector3 } from "babylonjs/Maths/math.vector";
  51052. import { Color4 } from "babylonjs/Maths/math.color";
  51053. import { Nullable } from "babylonjs/types";
  51054. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51055. import { Scene } from "babylonjs/scene";
  51056. /**
  51057. * Class containing static functions to help procedurally build meshes
  51058. */
  51059. export class LinesBuilder {
  51060. /**
  51061. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51062. * * 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
  51063. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51064. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51065. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51066. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51067. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51068. * * 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
  51069. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51071. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51072. * @param name defines the name of the new line system
  51073. * @param options defines the options used to create the line system
  51074. * @param scene defines the hosting scene
  51075. * @returns a new line system mesh
  51076. */
  51077. static CreateLineSystem(name: string, options: {
  51078. lines: Vector3[][];
  51079. updatable?: boolean;
  51080. instance?: Nullable<LinesMesh>;
  51081. colors?: Nullable<Color4[][]>;
  51082. useVertexAlpha?: boolean;
  51083. }, scene: Nullable<Scene>): LinesMesh;
  51084. /**
  51085. * Creates a line mesh
  51086. * 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
  51087. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51088. * * The parameter `points` is an array successive Vector3
  51089. * * 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
  51090. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51091. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51092. * * When updating an instance, remember that only point positions can change, not the number of points
  51093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51094. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51095. * @param name defines the name of the new line system
  51096. * @param options defines the options used to create the line system
  51097. * @param scene defines the hosting scene
  51098. * @returns a new line mesh
  51099. */
  51100. static CreateLines(name: string, options: {
  51101. points: Vector3[];
  51102. updatable?: boolean;
  51103. instance?: Nullable<LinesMesh>;
  51104. colors?: Color4[];
  51105. useVertexAlpha?: boolean;
  51106. }, scene?: Nullable<Scene>): LinesMesh;
  51107. /**
  51108. * Creates a dashed line mesh
  51109. * * 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
  51110. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51111. * * The parameter `points` is an array successive Vector3
  51112. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51113. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51114. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51115. * * 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
  51116. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51117. * * When updating an instance, remember that only point positions can change, not the number of points
  51118. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51119. * @param name defines the name of the mesh
  51120. * @param options defines the options used to create the mesh
  51121. * @param scene defines the hosting scene
  51122. * @returns the dashed line mesh
  51123. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51124. */
  51125. static CreateDashedLines(name: string, options: {
  51126. points: Vector3[];
  51127. dashSize?: number;
  51128. gapSize?: number;
  51129. dashNb?: number;
  51130. updatable?: boolean;
  51131. instance?: LinesMesh;
  51132. useVertexAlpha?: boolean;
  51133. }, scene?: Nullable<Scene>): LinesMesh;
  51134. }
  51135. }
  51136. declare module "babylonjs/Misc/timer" {
  51137. import { Observable, Observer } from "babylonjs/Misc/observable";
  51138. import { Nullable } from "babylonjs/types";
  51139. import { IDisposable } from "babylonjs/scene";
  51140. /**
  51141. * Construction options for a timer
  51142. */
  51143. export interface ITimerOptions<T> {
  51144. /**
  51145. * Time-to-end
  51146. */
  51147. timeout: number;
  51148. /**
  51149. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51150. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51151. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51152. */
  51153. contextObservable: Observable<T>;
  51154. /**
  51155. * Optional parameters when adding an observer to the observable
  51156. */
  51157. observableParameters?: {
  51158. mask?: number;
  51159. insertFirst?: boolean;
  51160. scope?: any;
  51161. };
  51162. /**
  51163. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51164. */
  51165. breakCondition?: (data?: ITimerData<T>) => boolean;
  51166. /**
  51167. * Will be triggered when the time condition has met
  51168. */
  51169. onEnded?: (data: ITimerData<any>) => void;
  51170. /**
  51171. * Will be triggered when the break condition has met (prematurely ended)
  51172. */
  51173. onAborted?: (data: ITimerData<any>) => void;
  51174. /**
  51175. * Optional function to execute on each tick (or count)
  51176. */
  51177. onTick?: (data: ITimerData<any>) => void;
  51178. }
  51179. /**
  51180. * An interface defining the data sent by the timer
  51181. */
  51182. export interface ITimerData<T> {
  51183. /**
  51184. * When did it start
  51185. */
  51186. startTime: number;
  51187. /**
  51188. * Time now
  51189. */
  51190. currentTime: number;
  51191. /**
  51192. * Time passed since started
  51193. */
  51194. deltaTime: number;
  51195. /**
  51196. * How much is completed, in [0.0...1.0].
  51197. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51198. */
  51199. completeRate: number;
  51200. /**
  51201. * What the registered observable sent in the last count
  51202. */
  51203. payload: T;
  51204. }
  51205. /**
  51206. * The current state of the timer
  51207. */
  51208. export enum TimerState {
  51209. /**
  51210. * Timer initialized, not yet started
  51211. */
  51212. INIT = 0,
  51213. /**
  51214. * Timer started and counting
  51215. */
  51216. STARTED = 1,
  51217. /**
  51218. * Timer ended (whether aborted or time reached)
  51219. */
  51220. ENDED = 2
  51221. }
  51222. /**
  51223. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51224. *
  51225. * @param options options with which to initialize this timer
  51226. */
  51227. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51228. /**
  51229. * An advanced implementation of a timer class
  51230. */
  51231. export class AdvancedTimer<T = any> implements IDisposable {
  51232. /**
  51233. * Will notify each time the timer calculates the remaining time
  51234. */
  51235. onEachCountObservable: Observable<ITimerData<T>>;
  51236. /**
  51237. * Will trigger when the timer was aborted due to the break condition
  51238. */
  51239. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51240. /**
  51241. * Will trigger when the timer ended successfully
  51242. */
  51243. onTimerEndedObservable: Observable<ITimerData<T>>;
  51244. /**
  51245. * Will trigger when the timer state has changed
  51246. */
  51247. onStateChangedObservable: Observable<TimerState>;
  51248. private _observer;
  51249. private _contextObservable;
  51250. private _observableParameters;
  51251. private _startTime;
  51252. private _timer;
  51253. private _state;
  51254. private _breakCondition;
  51255. private _timeToEnd;
  51256. private _breakOnNextTick;
  51257. /**
  51258. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51259. * @param options construction options for this advanced timer
  51260. */
  51261. constructor(options: ITimerOptions<T>);
  51262. /**
  51263. * set a breaking condition for this timer. Default is to never break during count
  51264. * @param predicate the new break condition. Returns true to break, false otherwise
  51265. */
  51266. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51267. /**
  51268. * Reset ALL associated observables in this advanced timer
  51269. */
  51270. clearObservables(): void;
  51271. /**
  51272. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51273. *
  51274. * @param timeToEnd how much time to measure until timer ended
  51275. */
  51276. start(timeToEnd?: number): void;
  51277. /**
  51278. * Will force a stop on the next tick.
  51279. */
  51280. stop(): void;
  51281. /**
  51282. * Dispose this timer, clearing all resources
  51283. */
  51284. dispose(): void;
  51285. private _setState;
  51286. private _tick;
  51287. private _stop;
  51288. }
  51289. }
  51290. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51291. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51292. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51293. import { Nullable } from "babylonjs/types";
  51294. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51295. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51296. import { Vector3 } from "babylonjs/Maths/math.vector";
  51297. import { Material } from "babylonjs/Materials/material";
  51298. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51299. import { Scene } from "babylonjs/scene";
  51300. /**
  51301. * The options container for the teleportation module
  51302. */
  51303. export interface IWebXRTeleportationOptions {
  51304. /**
  51305. * if provided, this scene will be used to render meshes.
  51306. */
  51307. customUtilityLayerScene?: Scene;
  51308. /**
  51309. * Values to configure the default target mesh
  51310. */
  51311. defaultTargetMeshOptions?: {
  51312. /**
  51313. * Fill color of the teleportation area
  51314. */
  51315. teleportationFillColor?: string;
  51316. /**
  51317. * Border color for the teleportation area
  51318. */
  51319. teleportationBorderColor?: string;
  51320. /**
  51321. * Disable the mesh's animation sequence
  51322. */
  51323. disableAnimation?: boolean;
  51324. /**
  51325. * Disable lighting on the material or the ring and arrow
  51326. */
  51327. disableLighting?: boolean;
  51328. /**
  51329. * Override the default material of the torus and arrow
  51330. */
  51331. torusArrowMaterial?: Material;
  51332. };
  51333. /**
  51334. * A list of meshes to use as floor meshes.
  51335. * Meshes can be added and removed after initializing the feature using the
  51336. * addFloorMesh and removeFloorMesh functions
  51337. * If empty, rotation will still work
  51338. */
  51339. floorMeshes?: AbstractMesh[];
  51340. /**
  51341. * use this rendering group id for the meshes (optional)
  51342. */
  51343. renderingGroupId?: number;
  51344. /**
  51345. * Should teleportation move only to snap points
  51346. */
  51347. snapPointsOnly?: boolean;
  51348. /**
  51349. * An array of points to which the teleportation will snap to.
  51350. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51351. */
  51352. snapPositions?: Vector3[];
  51353. /**
  51354. * How close should the teleportation ray be in order to snap to position.
  51355. * Default to 0.8 units (meters)
  51356. */
  51357. snapToPositionRadius?: number;
  51358. /**
  51359. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51360. * If you want to support rotation, make sure your mesh has a direction indicator.
  51361. *
  51362. * When left untouched, the default mesh will be initialized.
  51363. */
  51364. teleportationTargetMesh?: AbstractMesh;
  51365. /**
  51366. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51367. */
  51368. timeToTeleport?: number;
  51369. /**
  51370. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51371. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51372. */
  51373. useMainComponentOnly?: boolean;
  51374. /**
  51375. * Should meshes created here be added to a utility layer or the main scene
  51376. */
  51377. useUtilityLayer?: boolean;
  51378. /**
  51379. * Babylon XR Input class for controller
  51380. */
  51381. xrInput: WebXRInput;
  51382. /**
  51383. * Meshes that the teleportation ray cannot go through
  51384. */
  51385. pickBlockerMeshes?: AbstractMesh[];
  51386. }
  51387. /**
  51388. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51389. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51390. * the input of the attached controllers.
  51391. */
  51392. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51393. private _options;
  51394. private _controllers;
  51395. private _currentTeleportationControllerId;
  51396. private _floorMeshes;
  51397. private _quadraticBezierCurve;
  51398. private _selectionFeature;
  51399. private _snapToPositions;
  51400. private _snappedToPoint;
  51401. private _teleportationRingMaterial?;
  51402. private _tmpRay;
  51403. private _tmpVector;
  51404. private _tmpQuaternion;
  51405. /**
  51406. * The module's name
  51407. */
  51408. static readonly Name: string;
  51409. /**
  51410. * The (Babylon) version of this module.
  51411. * This is an integer representing the implementation version.
  51412. * This number does not correspond to the webxr specs version
  51413. */
  51414. static readonly Version: number;
  51415. /**
  51416. * Is movement backwards enabled
  51417. */
  51418. backwardsMovementEnabled: boolean;
  51419. /**
  51420. * Distance to travel when moving backwards
  51421. */
  51422. backwardsTeleportationDistance: number;
  51423. /**
  51424. * The distance from the user to the inspection point in the direction of the controller
  51425. * A higher number will allow the user to move further
  51426. * defaults to 5 (meters, in xr units)
  51427. */
  51428. parabolicCheckRadius: number;
  51429. /**
  51430. * Should the module support parabolic ray on top of direct ray
  51431. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51432. * Very helpful when moving between floors / different heights
  51433. */
  51434. parabolicRayEnabled: boolean;
  51435. /**
  51436. * How much rotation should be applied when rotating right and left
  51437. */
  51438. rotationAngle: number;
  51439. /**
  51440. * Is rotation enabled when moving forward?
  51441. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51442. */
  51443. rotationEnabled: boolean;
  51444. /**
  51445. * constructs a new anchor system
  51446. * @param _xrSessionManager an instance of WebXRSessionManager
  51447. * @param _options configuration object for this feature
  51448. */
  51449. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51450. /**
  51451. * Get the snapPointsOnly flag
  51452. */
  51453. get snapPointsOnly(): boolean;
  51454. /**
  51455. * Sets the snapPointsOnly flag
  51456. * @param snapToPoints should teleportation be exclusively to snap points
  51457. */
  51458. set snapPointsOnly(snapToPoints: boolean);
  51459. /**
  51460. * Add a new mesh to the floor meshes array
  51461. * @param mesh the mesh to use as floor mesh
  51462. */
  51463. addFloorMesh(mesh: AbstractMesh): void;
  51464. /**
  51465. * Add a new snap-to point to fix teleportation to this position
  51466. * @param newSnapPoint The new Snap-To point
  51467. */
  51468. addSnapPoint(newSnapPoint: Vector3): void;
  51469. attach(): boolean;
  51470. detach(): boolean;
  51471. dispose(): void;
  51472. /**
  51473. * Remove a mesh from the floor meshes array
  51474. * @param mesh the mesh to remove
  51475. */
  51476. removeFloorMesh(mesh: AbstractMesh): void;
  51477. /**
  51478. * Remove a mesh from the floor meshes array using its name
  51479. * @param name the mesh name to remove
  51480. */
  51481. removeFloorMeshByName(name: string): void;
  51482. /**
  51483. * 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
  51484. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51485. * @returns was the point found and removed or not
  51486. */
  51487. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51488. /**
  51489. * This function sets a selection feature that will be disabled when
  51490. * the forward ray is shown and will be reattached when hidden.
  51491. * This is used to remove the selection rays when moving.
  51492. * @param selectionFeature the feature to disable when forward movement is enabled
  51493. */
  51494. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51495. protected _onXRFrame(_xrFrame: XRFrame): void;
  51496. private _attachController;
  51497. private _createDefaultTargetMesh;
  51498. private _detachController;
  51499. private _findClosestSnapPointWithRadius;
  51500. private _setTargetMeshPosition;
  51501. private _setTargetMeshVisibility;
  51502. private _showParabolicPath;
  51503. private _teleportForward;
  51504. }
  51505. }
  51506. declare module "babylonjs/XR/webXRDefaultExperience" {
  51507. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51508. import { Scene } from "babylonjs/scene";
  51509. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51510. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51511. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51512. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51513. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51514. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51515. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51516. /**
  51517. * Options for the default xr helper
  51518. */
  51519. export class WebXRDefaultExperienceOptions {
  51520. /**
  51521. * Enable or disable default UI to enter XR
  51522. */
  51523. disableDefaultUI?: boolean;
  51524. /**
  51525. * Should teleportation not initialize. defaults to false.
  51526. */
  51527. disableTeleportation?: boolean;
  51528. /**
  51529. * Floor meshes that will be used for teleport
  51530. */
  51531. floorMeshes?: Array<AbstractMesh>;
  51532. /**
  51533. * If set to true, the first frame will not be used to reset position
  51534. * The first frame is mainly used when copying transformation from the old camera
  51535. * Mainly used in AR
  51536. */
  51537. ignoreNativeCameraTransformation?: boolean;
  51538. /**
  51539. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51540. */
  51541. inputOptions?: IWebXRInputOptions;
  51542. /**
  51543. * optional configuration for the output canvas
  51544. */
  51545. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51546. /**
  51547. * optional UI options. This can be used among other to change session mode and reference space type
  51548. */
  51549. uiOptions?: WebXREnterExitUIOptions;
  51550. /**
  51551. * When loading teleportation and pointer select, use stable versions instead of latest.
  51552. */
  51553. useStablePlugins?: boolean;
  51554. /**
  51555. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51556. */
  51557. renderingGroupId?: number;
  51558. /**
  51559. * A list of optional features to init the session with
  51560. * If set to true, all features we support will be added
  51561. */
  51562. optionalFeatures?: boolean | string[];
  51563. }
  51564. /**
  51565. * Default experience which provides a similar setup to the previous webVRExperience
  51566. */
  51567. export class WebXRDefaultExperience {
  51568. /**
  51569. * Base experience
  51570. */
  51571. baseExperience: WebXRExperienceHelper;
  51572. /**
  51573. * Enables ui for entering/exiting xr
  51574. */
  51575. enterExitUI: WebXREnterExitUI;
  51576. /**
  51577. * Input experience extension
  51578. */
  51579. input: WebXRInput;
  51580. /**
  51581. * Enables laser pointer and selection
  51582. */
  51583. pointerSelection: WebXRControllerPointerSelection;
  51584. /**
  51585. * Default target xr should render to
  51586. */
  51587. renderTarget: WebXRRenderTarget;
  51588. /**
  51589. * Enables teleportation
  51590. */
  51591. teleportation: WebXRMotionControllerTeleportation;
  51592. private constructor();
  51593. /**
  51594. * Creates the default xr experience
  51595. * @param scene scene
  51596. * @param options options for basic configuration
  51597. * @returns resulting WebXRDefaultExperience
  51598. */
  51599. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51600. /**
  51601. * DIsposes of the experience helper
  51602. */
  51603. dispose(): void;
  51604. }
  51605. }
  51606. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51607. import { Observable } from "babylonjs/Misc/observable";
  51608. import { Nullable } from "babylonjs/types";
  51609. import { Camera } from "babylonjs/Cameras/camera";
  51610. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51611. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51612. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51613. import { Scene } from "babylonjs/scene";
  51614. import { Vector3 } from "babylonjs/Maths/math.vector";
  51615. import { Color3 } from "babylonjs/Maths/math.color";
  51616. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51618. import { Mesh } from "babylonjs/Meshes/mesh";
  51619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51620. import { EasingFunction } from "babylonjs/Animations/easing";
  51621. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51622. import "babylonjs/Meshes/Builders/groundBuilder";
  51623. import "babylonjs/Meshes/Builders/torusBuilder";
  51624. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51625. import "babylonjs/Gamepads/gamepadSceneComponent";
  51626. import "babylonjs/Animations/animatable";
  51627. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51628. /**
  51629. * Options to modify the vr teleportation behavior.
  51630. */
  51631. export interface VRTeleportationOptions {
  51632. /**
  51633. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51634. */
  51635. floorMeshName?: string;
  51636. /**
  51637. * A list of meshes to be used as the teleportation floor. (default: empty)
  51638. */
  51639. floorMeshes?: Mesh[];
  51640. /**
  51641. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51642. */
  51643. teleportationMode?: number;
  51644. /**
  51645. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51646. */
  51647. teleportationTime?: number;
  51648. /**
  51649. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51650. */
  51651. teleportationSpeed?: number;
  51652. /**
  51653. * The easing function used in the animation or null for Linear. (default CircleEase)
  51654. */
  51655. easingFunction?: EasingFunction;
  51656. }
  51657. /**
  51658. * Options to modify the vr experience helper's behavior.
  51659. */
  51660. export interface VRExperienceHelperOptions extends WebVROptions {
  51661. /**
  51662. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51663. */
  51664. createDeviceOrientationCamera?: boolean;
  51665. /**
  51666. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51667. */
  51668. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51669. /**
  51670. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51671. */
  51672. laserToggle?: boolean;
  51673. /**
  51674. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51675. */
  51676. floorMeshes?: Mesh[];
  51677. /**
  51678. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51679. */
  51680. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51681. /**
  51682. * Defines if WebXR should be used instead of WebVR (if available)
  51683. */
  51684. useXR?: boolean;
  51685. }
  51686. /**
  51687. * Event containing information after VR has been entered
  51688. */
  51689. export class OnAfterEnteringVRObservableEvent {
  51690. /**
  51691. * If entering vr was successful
  51692. */
  51693. success: boolean;
  51694. }
  51695. /**
  51696. * Helps to quickly add VR support to an existing scene.
  51697. * See https://doc.babylonjs.com/how_to/webvr_helper
  51698. */
  51699. export class VRExperienceHelper {
  51700. /** Options to modify the vr experience helper's behavior. */
  51701. webVROptions: VRExperienceHelperOptions;
  51702. private _scene;
  51703. private _position;
  51704. private _btnVR;
  51705. private _btnVRDisplayed;
  51706. private _webVRsupported;
  51707. private _webVRready;
  51708. private _webVRrequesting;
  51709. private _webVRpresenting;
  51710. private _hasEnteredVR;
  51711. private _fullscreenVRpresenting;
  51712. private _inputElement;
  51713. private _webVRCamera;
  51714. private _vrDeviceOrientationCamera;
  51715. private _deviceOrientationCamera;
  51716. private _existingCamera;
  51717. private _onKeyDown;
  51718. private _onVrDisplayPresentChange;
  51719. private _onVRDisplayChanged;
  51720. private _onVRRequestPresentStart;
  51721. private _onVRRequestPresentComplete;
  51722. /**
  51723. * 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)
  51724. */
  51725. enableGazeEvenWhenNoPointerLock: boolean;
  51726. /**
  51727. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51728. */
  51729. exitVROnDoubleTap: boolean;
  51730. /**
  51731. * Observable raised right before entering VR.
  51732. */
  51733. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51734. /**
  51735. * Observable raised when entering VR has completed.
  51736. */
  51737. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51738. /**
  51739. * Observable raised when exiting VR.
  51740. */
  51741. onExitingVRObservable: Observable<VRExperienceHelper>;
  51742. /**
  51743. * Observable raised when controller mesh is loaded.
  51744. */
  51745. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51746. /** Return this.onEnteringVRObservable
  51747. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51748. */
  51749. get onEnteringVR(): Observable<VRExperienceHelper>;
  51750. /** Return this.onExitingVRObservable
  51751. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51752. */
  51753. get onExitingVR(): Observable<VRExperienceHelper>;
  51754. /** Return this.onControllerMeshLoadedObservable
  51755. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51756. */
  51757. get onControllerMeshLoaded(): Observable<WebVRController>;
  51758. private _rayLength;
  51759. private _useCustomVRButton;
  51760. private _teleportationRequested;
  51761. private _teleportActive;
  51762. private _floorMeshName;
  51763. private _floorMeshesCollection;
  51764. private _teleportationMode;
  51765. private _teleportationTime;
  51766. private _teleportationSpeed;
  51767. private _teleportationEasing;
  51768. private _rotationAllowed;
  51769. private _teleportBackwardsVector;
  51770. private _teleportationTarget;
  51771. private _isDefaultTeleportationTarget;
  51772. private _postProcessMove;
  51773. private _teleportationFillColor;
  51774. private _teleportationBorderColor;
  51775. private _rotationAngle;
  51776. private _haloCenter;
  51777. private _cameraGazer;
  51778. private _padSensibilityUp;
  51779. private _padSensibilityDown;
  51780. private _leftController;
  51781. private _rightController;
  51782. private _gazeColor;
  51783. private _laserColor;
  51784. private _pickedLaserColor;
  51785. private _pickedGazeColor;
  51786. /**
  51787. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51788. */
  51789. onNewMeshSelected: Observable<AbstractMesh>;
  51790. /**
  51791. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51792. * This observable will provide the mesh and the controller used to select the mesh
  51793. */
  51794. onMeshSelectedWithController: Observable<{
  51795. mesh: AbstractMesh;
  51796. controller: WebVRController;
  51797. }>;
  51798. /**
  51799. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51800. */
  51801. onNewMeshPicked: Observable<PickingInfo>;
  51802. private _circleEase;
  51803. /**
  51804. * Observable raised before camera teleportation
  51805. */
  51806. onBeforeCameraTeleport: Observable<Vector3>;
  51807. /**
  51808. * Observable raised after camera teleportation
  51809. */
  51810. onAfterCameraTeleport: Observable<Vector3>;
  51811. /**
  51812. * Observable raised when current selected mesh gets unselected
  51813. */
  51814. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51815. private _raySelectionPredicate;
  51816. /**
  51817. * To be optionaly changed by user to define custom ray selection
  51818. */
  51819. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51820. /**
  51821. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51822. */
  51823. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51824. /**
  51825. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51826. */
  51827. teleportationEnabled: boolean;
  51828. private _defaultHeight;
  51829. private _teleportationInitialized;
  51830. private _interactionsEnabled;
  51831. private _interactionsRequested;
  51832. private _displayGaze;
  51833. private _displayLaserPointer;
  51834. /**
  51835. * The mesh used to display where the user is going to teleport.
  51836. */
  51837. get teleportationTarget(): Mesh;
  51838. /**
  51839. * Sets the mesh to be used to display where the user is going to teleport.
  51840. */
  51841. set teleportationTarget(value: Mesh);
  51842. /**
  51843. * 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
  51844. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51845. * See https://doc.babylonjs.com/resources/baking_transformations
  51846. */
  51847. get gazeTrackerMesh(): Mesh;
  51848. set gazeTrackerMesh(value: Mesh);
  51849. /**
  51850. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51851. */
  51852. updateGazeTrackerScale: boolean;
  51853. /**
  51854. * If the gaze trackers color should be updated when selecting meshes
  51855. */
  51856. updateGazeTrackerColor: boolean;
  51857. /**
  51858. * If the controller laser color should be updated when selecting meshes
  51859. */
  51860. updateControllerLaserColor: boolean;
  51861. /**
  51862. * The gaze tracking mesh corresponding to the left controller
  51863. */
  51864. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51865. /**
  51866. * The gaze tracking mesh corresponding to the right controller
  51867. */
  51868. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51869. /**
  51870. * If the ray of the gaze should be displayed.
  51871. */
  51872. get displayGaze(): boolean;
  51873. /**
  51874. * Sets if the ray of the gaze should be displayed.
  51875. */
  51876. set displayGaze(value: boolean);
  51877. /**
  51878. * If the ray of the LaserPointer should be displayed.
  51879. */
  51880. get displayLaserPointer(): boolean;
  51881. /**
  51882. * Sets if the ray of the LaserPointer should be displayed.
  51883. */
  51884. set displayLaserPointer(value: boolean);
  51885. /**
  51886. * The deviceOrientationCamera used as the camera when not in VR.
  51887. */
  51888. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  51889. /**
  51890. * Based on the current WebVR support, returns the current VR camera used.
  51891. */
  51892. get currentVRCamera(): Nullable<Camera>;
  51893. /**
  51894. * The webVRCamera which is used when in VR.
  51895. */
  51896. get webVRCamera(): WebVRFreeCamera;
  51897. /**
  51898. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  51899. */
  51900. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  51901. /**
  51902. * The html button that is used to trigger entering into VR.
  51903. */
  51904. get vrButton(): Nullable<HTMLButtonElement>;
  51905. private get _teleportationRequestInitiated();
  51906. /**
  51907. * Defines whether or not Pointer lock should be requested when switching to
  51908. * full screen.
  51909. */
  51910. requestPointerLockOnFullScreen: boolean;
  51911. /**
  51912. * If asking to force XR, this will be populated with the default xr experience
  51913. */
  51914. xr: WebXRDefaultExperience;
  51915. /**
  51916. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  51917. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  51918. */
  51919. xrTestDone: boolean;
  51920. /**
  51921. * Instantiates a VRExperienceHelper.
  51922. * Helps to quickly add VR support to an existing scene.
  51923. * @param scene The scene the VRExperienceHelper belongs to.
  51924. * @param webVROptions Options to modify the vr experience helper's behavior.
  51925. */
  51926. constructor(scene: Scene,
  51927. /** Options to modify the vr experience helper's behavior. */
  51928. webVROptions?: VRExperienceHelperOptions);
  51929. private completeVRInit;
  51930. private _onDefaultMeshLoaded;
  51931. private _onResize;
  51932. private _onFullscreenChange;
  51933. /**
  51934. * Gets a value indicating if we are currently in VR mode.
  51935. */
  51936. get isInVRMode(): boolean;
  51937. private onVrDisplayPresentChange;
  51938. private onVRDisplayChanged;
  51939. private moveButtonToBottomRight;
  51940. private displayVRButton;
  51941. private updateButtonVisibility;
  51942. private _cachedAngularSensibility;
  51943. /**
  51944. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  51945. * Otherwise, will use the fullscreen API.
  51946. */
  51947. enterVR(): void;
  51948. /**
  51949. * Attempt to exit VR, or fullscreen.
  51950. */
  51951. exitVR(): void;
  51952. /**
  51953. * The position of the vr experience helper.
  51954. */
  51955. get position(): Vector3;
  51956. /**
  51957. * Sets the position of the vr experience helper.
  51958. */
  51959. set position(value: Vector3);
  51960. /**
  51961. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  51962. */
  51963. enableInteractions(): void;
  51964. private get _noControllerIsActive();
  51965. private beforeRender;
  51966. private _isTeleportationFloor;
  51967. /**
  51968. * Adds a floor mesh to be used for teleportation.
  51969. * @param floorMesh the mesh to be used for teleportation.
  51970. */
  51971. addFloorMesh(floorMesh: Mesh): void;
  51972. /**
  51973. * Removes a floor mesh from being used for teleportation.
  51974. * @param floorMesh the mesh to be removed.
  51975. */
  51976. removeFloorMesh(floorMesh: Mesh): void;
  51977. /**
  51978. * Enables interactions and teleportation using the VR controllers and gaze.
  51979. * @param vrTeleportationOptions options to modify teleportation behavior.
  51980. */
  51981. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  51982. private _onNewGamepadConnected;
  51983. private _tryEnableInteractionOnController;
  51984. private _onNewGamepadDisconnected;
  51985. private _enableInteractionOnController;
  51986. private _checkTeleportWithRay;
  51987. private _checkRotate;
  51988. private _checkTeleportBackwards;
  51989. private _enableTeleportationOnController;
  51990. private _createTeleportationCircles;
  51991. private _displayTeleportationTarget;
  51992. private _hideTeleportationTarget;
  51993. private _rotateCamera;
  51994. private _moveTeleportationSelectorTo;
  51995. private _workingVector;
  51996. private _workingQuaternion;
  51997. private _workingMatrix;
  51998. /**
  51999. * Time Constant Teleportation Mode
  52000. */
  52001. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52002. /**
  52003. * Speed Constant Teleportation Mode
  52004. */
  52005. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52006. /**
  52007. * Teleports the users feet to the desired location
  52008. * @param location The location where the user's feet should be placed
  52009. */
  52010. teleportCamera(location: Vector3): void;
  52011. private _convertNormalToDirectionOfRay;
  52012. private _castRayAndSelectObject;
  52013. private _notifySelectedMeshUnselected;
  52014. /**
  52015. * Permanently set new colors for the laser pointer
  52016. * @param color the new laser color
  52017. * @param pickedColor the new laser color when picked mesh detected
  52018. */
  52019. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52020. /**
  52021. * Set lighting enabled / disabled on the laser pointer of both controllers
  52022. * @param enabled should the lighting be enabled on the laser pointer
  52023. */
  52024. setLaserLightingState(enabled?: boolean): void;
  52025. /**
  52026. * Permanently set new colors for the gaze pointer
  52027. * @param color the new gaze color
  52028. * @param pickedColor the new gaze color when picked mesh detected
  52029. */
  52030. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52031. /**
  52032. * Sets the color of the laser ray from the vr controllers.
  52033. * @param color new color for the ray.
  52034. */
  52035. changeLaserColor(color: Color3): void;
  52036. /**
  52037. * Sets the color of the ray from the vr headsets gaze.
  52038. * @param color new color for the ray.
  52039. */
  52040. changeGazeColor(color: Color3): void;
  52041. /**
  52042. * Exits VR and disposes of the vr experience helper
  52043. */
  52044. dispose(): void;
  52045. /**
  52046. * Gets the name of the VRExperienceHelper class
  52047. * @returns "VRExperienceHelper"
  52048. */
  52049. getClassName(): string;
  52050. }
  52051. }
  52052. declare module "babylonjs/Cameras/VR/index" {
  52053. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52054. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52055. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52056. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52057. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52058. export * from "babylonjs/Cameras/VR/webVRCamera";
  52059. }
  52060. declare module "babylonjs/Cameras/RigModes/index" {
  52061. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52062. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52063. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52064. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52065. }
  52066. declare module "babylonjs/Cameras/index" {
  52067. export * from "babylonjs/Cameras/Inputs/index";
  52068. export * from "babylonjs/Cameras/cameraInputsManager";
  52069. export * from "babylonjs/Cameras/camera";
  52070. export * from "babylonjs/Cameras/targetCamera";
  52071. export * from "babylonjs/Cameras/freeCamera";
  52072. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52073. export * from "babylonjs/Cameras/touchCamera";
  52074. export * from "babylonjs/Cameras/arcRotateCamera";
  52075. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52076. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52077. export * from "babylonjs/Cameras/flyCamera";
  52078. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52079. export * from "babylonjs/Cameras/followCamera";
  52080. export * from "babylonjs/Cameras/followCameraInputsManager";
  52081. export * from "babylonjs/Cameras/gamepadCamera";
  52082. export * from "babylonjs/Cameras/Stereoscopic/index";
  52083. export * from "babylonjs/Cameras/universalCamera";
  52084. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52085. export * from "babylonjs/Cameras/VR/index";
  52086. export * from "babylonjs/Cameras/RigModes/index";
  52087. }
  52088. declare module "babylonjs/Collisions/index" {
  52089. export * from "babylonjs/Collisions/collider";
  52090. export * from "babylonjs/Collisions/collisionCoordinator";
  52091. export * from "babylonjs/Collisions/pickingInfo";
  52092. export * from "babylonjs/Collisions/intersectionInfo";
  52093. export * from "babylonjs/Collisions/meshCollisionData";
  52094. }
  52095. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52096. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52097. import { Vector3 } from "babylonjs/Maths/math.vector";
  52098. import { Ray } from "babylonjs/Culling/ray";
  52099. import { Plane } from "babylonjs/Maths/math.plane";
  52100. /**
  52101. * Contains an array of blocks representing the octree
  52102. */
  52103. export interface IOctreeContainer<T> {
  52104. /**
  52105. * Blocks within the octree
  52106. */
  52107. blocks: Array<OctreeBlock<T>>;
  52108. }
  52109. /**
  52110. * Class used to store a cell in an octree
  52111. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52112. */
  52113. export class OctreeBlock<T> {
  52114. /**
  52115. * Gets the content of the current block
  52116. */
  52117. entries: T[];
  52118. /**
  52119. * Gets the list of block children
  52120. */
  52121. blocks: Array<OctreeBlock<T>>;
  52122. private _depth;
  52123. private _maxDepth;
  52124. private _capacity;
  52125. private _minPoint;
  52126. private _maxPoint;
  52127. private _boundingVectors;
  52128. private _creationFunc;
  52129. /**
  52130. * Creates a new block
  52131. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52132. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52133. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52134. * @param depth defines the current depth of this block in the octree
  52135. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52136. * @param creationFunc defines a callback to call when an element is added to the block
  52137. */
  52138. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52139. /**
  52140. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52141. */
  52142. get capacity(): number;
  52143. /**
  52144. * Gets the minimum vector (in world space) of the block's bounding box
  52145. */
  52146. get minPoint(): Vector3;
  52147. /**
  52148. * Gets the maximum vector (in world space) of the block's bounding box
  52149. */
  52150. get maxPoint(): Vector3;
  52151. /**
  52152. * Add a new element to this block
  52153. * @param entry defines the element to add
  52154. */
  52155. addEntry(entry: T): void;
  52156. /**
  52157. * Remove an element from this block
  52158. * @param entry defines the element to remove
  52159. */
  52160. removeEntry(entry: T): void;
  52161. /**
  52162. * Add an array of elements to this block
  52163. * @param entries defines the array of elements to add
  52164. */
  52165. addEntries(entries: T[]): void;
  52166. /**
  52167. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52168. * @param frustumPlanes defines the frustum planes to test
  52169. * @param selection defines the array to store current content if selection is positive
  52170. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52171. */
  52172. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52173. /**
  52174. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52175. * @param sphereCenter defines the bounding sphere center
  52176. * @param sphereRadius defines the bounding sphere radius
  52177. * @param selection defines the array to store current content if selection is positive
  52178. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52179. */
  52180. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52181. /**
  52182. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52183. * @param ray defines the ray to test with
  52184. * @param selection defines the array to store current content if selection is positive
  52185. */
  52186. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52187. /**
  52188. * Subdivide the content into child blocks (this block will then be empty)
  52189. */
  52190. createInnerBlocks(): void;
  52191. /**
  52192. * @hidden
  52193. */
  52194. 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;
  52195. }
  52196. }
  52197. declare module "babylonjs/Culling/Octrees/octree" {
  52198. import { SmartArray } from "babylonjs/Misc/smartArray";
  52199. import { Vector3 } from "babylonjs/Maths/math.vector";
  52200. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52201. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52202. import { Ray } from "babylonjs/Culling/ray";
  52203. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52204. import { Plane } from "babylonjs/Maths/math.plane";
  52205. /**
  52206. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52207. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52208. */
  52209. export class Octree<T> {
  52210. /** 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.) */
  52211. maxDepth: number;
  52212. /**
  52213. * Blocks within the octree containing objects
  52214. */
  52215. blocks: Array<OctreeBlock<T>>;
  52216. /**
  52217. * Content stored in the octree
  52218. */
  52219. dynamicContent: T[];
  52220. private _maxBlockCapacity;
  52221. private _selectionContent;
  52222. private _creationFunc;
  52223. /**
  52224. * Creates a octree
  52225. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52226. * @param creationFunc function to be used to instatiate the octree
  52227. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52228. * @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.)
  52229. */
  52230. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52231. /** 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.) */
  52232. maxDepth?: number);
  52233. /**
  52234. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52235. * @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);
  52236. * @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);
  52237. * @param entries meshes to be added to the octree blocks
  52238. */
  52239. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52240. /**
  52241. * Adds a mesh to the octree
  52242. * @param entry Mesh to add to the octree
  52243. */
  52244. addMesh(entry: T): void;
  52245. /**
  52246. * Remove an element from the octree
  52247. * @param entry defines the element to remove
  52248. */
  52249. removeMesh(entry: T): void;
  52250. /**
  52251. * Selects an array of meshes within the frustum
  52252. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52253. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52254. * @returns array of meshes within the frustum
  52255. */
  52256. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52257. /**
  52258. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52259. * @param sphereCenter defines the bounding sphere center
  52260. * @param sphereRadius defines the bounding sphere radius
  52261. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52262. * @returns an array of objects that intersect the sphere
  52263. */
  52264. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52265. /**
  52266. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52267. * @param ray defines the ray to test with
  52268. * @returns array of intersected objects
  52269. */
  52270. intersectsRay(ray: Ray): SmartArray<T>;
  52271. /**
  52272. * Adds a mesh into the octree block if it intersects the block
  52273. */
  52274. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52275. /**
  52276. * Adds a submesh into the octree block if it intersects the block
  52277. */
  52278. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52279. }
  52280. }
  52281. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52282. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52283. import { Scene } from "babylonjs/scene";
  52284. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52285. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52286. import { Ray } from "babylonjs/Culling/ray";
  52287. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52288. import { Collider } from "babylonjs/Collisions/collider";
  52289. module "babylonjs/scene" {
  52290. interface Scene {
  52291. /**
  52292. * @hidden
  52293. * Backing Filed
  52294. */
  52295. _selectionOctree: Octree<AbstractMesh>;
  52296. /**
  52297. * Gets the octree used to boost mesh selection (picking)
  52298. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52299. */
  52300. selectionOctree: Octree<AbstractMesh>;
  52301. /**
  52302. * Creates or updates the octree used to boost selection (picking)
  52303. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52304. * @param maxCapacity defines the maximum capacity per leaf
  52305. * @param maxDepth defines the maximum depth of the octree
  52306. * @returns an octree of AbstractMesh
  52307. */
  52308. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52309. }
  52310. }
  52311. module "babylonjs/Meshes/abstractMesh" {
  52312. interface AbstractMesh {
  52313. /**
  52314. * @hidden
  52315. * Backing Field
  52316. */
  52317. _submeshesOctree: Octree<SubMesh>;
  52318. /**
  52319. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52320. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52321. * @param maxCapacity defines the maximum size of each block (64 by default)
  52322. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52323. * @returns the new octree
  52324. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52325. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52326. */
  52327. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52328. }
  52329. }
  52330. /**
  52331. * Defines the octree scene component responsible to manage any octrees
  52332. * in a given scene.
  52333. */
  52334. export class OctreeSceneComponent {
  52335. /**
  52336. * The component name help to identify the component in the list of scene components.
  52337. */
  52338. readonly name: string;
  52339. /**
  52340. * The scene the component belongs to.
  52341. */
  52342. scene: Scene;
  52343. /**
  52344. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52345. */
  52346. readonly checksIsEnabled: boolean;
  52347. /**
  52348. * Creates a new instance of the component for the given scene
  52349. * @param scene Defines the scene to register the component in
  52350. */
  52351. constructor(scene: Scene);
  52352. /**
  52353. * Registers the component in a given scene
  52354. */
  52355. register(): void;
  52356. /**
  52357. * Return the list of active meshes
  52358. * @returns the list of active meshes
  52359. */
  52360. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52361. /**
  52362. * Return the list of active sub meshes
  52363. * @param mesh The mesh to get the candidates sub meshes from
  52364. * @returns the list of active sub meshes
  52365. */
  52366. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52367. private _tempRay;
  52368. /**
  52369. * Return the list of sub meshes intersecting with a given local ray
  52370. * @param mesh defines the mesh to find the submesh for
  52371. * @param localRay defines the ray in local space
  52372. * @returns the list of intersecting sub meshes
  52373. */
  52374. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52375. /**
  52376. * Return the list of sub meshes colliding with a collider
  52377. * @param mesh defines the mesh to find the submesh for
  52378. * @param collider defines the collider to evaluate the collision against
  52379. * @returns the list of colliding sub meshes
  52380. */
  52381. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52382. /**
  52383. * Rebuilds the elements related to this component in case of
  52384. * context lost for instance.
  52385. */
  52386. rebuild(): void;
  52387. /**
  52388. * Disposes the component and the associated ressources.
  52389. */
  52390. dispose(): void;
  52391. }
  52392. }
  52393. declare module "babylonjs/Culling/Octrees/index" {
  52394. export * from "babylonjs/Culling/Octrees/octree";
  52395. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52396. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52397. }
  52398. declare module "babylonjs/Culling/index" {
  52399. export * from "babylonjs/Culling/boundingBox";
  52400. export * from "babylonjs/Culling/boundingInfo";
  52401. export * from "babylonjs/Culling/boundingSphere";
  52402. export * from "babylonjs/Culling/Octrees/index";
  52403. export * from "babylonjs/Culling/ray";
  52404. }
  52405. declare module "babylonjs/Gizmos/gizmo" {
  52406. import { Nullable } from "babylonjs/types";
  52407. import { IDisposable } from "babylonjs/scene";
  52408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52409. import { Mesh } from "babylonjs/Meshes/mesh";
  52410. import { Node } from "babylonjs/node";
  52411. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52412. /**
  52413. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52414. */
  52415. export class Gizmo implements IDisposable {
  52416. /** The utility layer the gizmo will be added to */
  52417. gizmoLayer: UtilityLayerRenderer;
  52418. /**
  52419. * The root mesh of the gizmo
  52420. */
  52421. _rootMesh: Mesh;
  52422. private _attachedMesh;
  52423. private _attachedNode;
  52424. /**
  52425. * Ratio for the scale of the gizmo (Default: 1)
  52426. */
  52427. protected _scaleRatio: number;
  52428. /**
  52429. * Ratio for the scale of the gizmo (Default: 1)
  52430. */
  52431. set scaleRatio(value: number);
  52432. get scaleRatio(): number;
  52433. /**
  52434. * If a custom mesh has been set (Default: false)
  52435. */
  52436. protected _customMeshSet: boolean;
  52437. /**
  52438. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52439. * * When set, interactions will be enabled
  52440. */
  52441. get attachedMesh(): Nullable<AbstractMesh>;
  52442. set attachedMesh(value: Nullable<AbstractMesh>);
  52443. /**
  52444. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52445. * * When set, interactions will be enabled
  52446. */
  52447. get attachedNode(): Nullable<Node>;
  52448. set attachedNode(value: Nullable<Node>);
  52449. /**
  52450. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52451. * @param mesh The mesh to replace the default mesh of the gizmo
  52452. */
  52453. setCustomMesh(mesh: Mesh): void;
  52454. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52455. /**
  52456. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52457. */
  52458. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52459. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52460. /**
  52461. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52462. */
  52463. updateGizmoPositionToMatchAttachedMesh: boolean;
  52464. /**
  52465. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52466. */
  52467. updateScale: boolean;
  52468. protected _interactionsEnabled: boolean;
  52469. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52470. private _beforeRenderObserver;
  52471. private _tempQuaternion;
  52472. private _tempVector;
  52473. private _tempVector2;
  52474. private _tempMatrix1;
  52475. private _tempMatrix2;
  52476. private _rightHandtoLeftHandMatrix;
  52477. /**
  52478. * Creates a gizmo
  52479. * @param gizmoLayer The utility layer the gizmo will be added to
  52480. */
  52481. constructor(
  52482. /** The utility layer the gizmo will be added to */
  52483. gizmoLayer?: UtilityLayerRenderer);
  52484. /**
  52485. * Updates the gizmo to match the attached mesh's position/rotation
  52486. */
  52487. protected _update(): void;
  52488. /**
  52489. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52490. * @param value Node, TransformNode or mesh
  52491. */
  52492. protected _matrixChanged(): void;
  52493. /**
  52494. * Disposes of the gizmo
  52495. */
  52496. dispose(): void;
  52497. }
  52498. }
  52499. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52500. import { Observable } from "babylonjs/Misc/observable";
  52501. import { Nullable } from "babylonjs/types";
  52502. import { Vector3 } from "babylonjs/Maths/math.vector";
  52503. import { Color3 } from "babylonjs/Maths/math.color";
  52504. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52505. import { Node } from "babylonjs/node";
  52506. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52507. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52508. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52509. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52510. import { Scene } from "babylonjs/scene";
  52511. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52512. /**
  52513. * Single plane drag gizmo
  52514. */
  52515. export class PlaneDragGizmo extends Gizmo {
  52516. /**
  52517. * Drag behavior responsible for the gizmos dragging interactions
  52518. */
  52519. dragBehavior: PointerDragBehavior;
  52520. private _pointerObserver;
  52521. /**
  52522. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52523. */
  52524. snapDistance: number;
  52525. /**
  52526. * Event that fires each time the gizmo snaps to a new location.
  52527. * * snapDistance is the the change in distance
  52528. */
  52529. onSnapObservable: Observable<{
  52530. snapDistance: number;
  52531. }>;
  52532. private _plane;
  52533. private _coloredMaterial;
  52534. private _hoverMaterial;
  52535. private _isEnabled;
  52536. private _parent;
  52537. /** @hidden */
  52538. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52539. /** @hidden */
  52540. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52541. /**
  52542. * Creates a PlaneDragGizmo
  52543. * @param gizmoLayer The utility layer the gizmo will be added to
  52544. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52545. * @param color The color of the gizmo
  52546. */
  52547. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52548. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52549. /**
  52550. * If the gizmo is enabled
  52551. */
  52552. set isEnabled(value: boolean);
  52553. get isEnabled(): boolean;
  52554. /**
  52555. * Disposes of the gizmo
  52556. */
  52557. dispose(): void;
  52558. }
  52559. }
  52560. declare module "babylonjs/Gizmos/positionGizmo" {
  52561. import { Observable } from "babylonjs/Misc/observable";
  52562. import { Nullable } from "babylonjs/types";
  52563. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52564. import { Node } from "babylonjs/node";
  52565. import { Mesh } from "babylonjs/Meshes/mesh";
  52566. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52567. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52568. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52569. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52570. /**
  52571. * Gizmo that enables dragging a mesh along 3 axis
  52572. */
  52573. export class PositionGizmo extends Gizmo {
  52574. /**
  52575. * Internal gizmo used for interactions on the x axis
  52576. */
  52577. xGizmo: AxisDragGizmo;
  52578. /**
  52579. * Internal gizmo used for interactions on the y axis
  52580. */
  52581. yGizmo: AxisDragGizmo;
  52582. /**
  52583. * Internal gizmo used for interactions on the z axis
  52584. */
  52585. zGizmo: AxisDragGizmo;
  52586. /**
  52587. * Internal gizmo used for interactions on the yz plane
  52588. */
  52589. xPlaneGizmo: PlaneDragGizmo;
  52590. /**
  52591. * Internal gizmo used for interactions on the xz plane
  52592. */
  52593. yPlaneGizmo: PlaneDragGizmo;
  52594. /**
  52595. * Internal gizmo used for interactions on the xy plane
  52596. */
  52597. zPlaneGizmo: PlaneDragGizmo;
  52598. /**
  52599. * private variables
  52600. */
  52601. private _meshAttached;
  52602. private _nodeAttached;
  52603. private _snapDistance;
  52604. /** Fires an event when any of it's sub gizmos are dragged */
  52605. onDragStartObservable: Observable<unknown>;
  52606. /** Fires an event when any of it's sub gizmos are released from dragging */
  52607. onDragEndObservable: Observable<unknown>;
  52608. /**
  52609. * If set to true, planar drag is enabled
  52610. */
  52611. private _planarGizmoEnabled;
  52612. get attachedMesh(): Nullable<AbstractMesh>;
  52613. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52614. get attachedNode(): Nullable<Node>;
  52615. set attachedNode(node: Nullable<Node>);
  52616. /**
  52617. * Creates a PositionGizmo
  52618. * @param gizmoLayer The utility layer the gizmo will be added to
  52619. @param thickness display gizmo axis thickness
  52620. */
  52621. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52622. /**
  52623. * If the planar drag gizmo is enabled
  52624. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52625. */
  52626. set planarGizmoEnabled(value: boolean);
  52627. get planarGizmoEnabled(): boolean;
  52628. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52629. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52630. /**
  52631. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52632. */
  52633. set snapDistance(value: number);
  52634. get snapDistance(): number;
  52635. /**
  52636. * Ratio for the scale of the gizmo (Default: 1)
  52637. */
  52638. set scaleRatio(value: number);
  52639. get scaleRatio(): number;
  52640. /**
  52641. * Disposes of the gizmo
  52642. */
  52643. dispose(): void;
  52644. /**
  52645. * CustomMeshes are not supported by this gizmo
  52646. * @param mesh The mesh to replace the default mesh of the gizmo
  52647. */
  52648. setCustomMesh(mesh: Mesh): void;
  52649. }
  52650. }
  52651. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52652. import { Observable } from "babylonjs/Misc/observable";
  52653. import { Nullable } from "babylonjs/types";
  52654. import { Vector3 } from "babylonjs/Maths/math.vector";
  52655. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52656. import { Node } from "babylonjs/node";
  52657. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52658. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52659. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52660. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52661. import { Scene } from "babylonjs/scene";
  52662. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52663. import { Color3 } from "babylonjs/Maths/math.color";
  52664. /**
  52665. * Single axis drag gizmo
  52666. */
  52667. export class AxisDragGizmo extends Gizmo {
  52668. /**
  52669. * Drag behavior responsible for the gizmos dragging interactions
  52670. */
  52671. dragBehavior: PointerDragBehavior;
  52672. private _pointerObserver;
  52673. /**
  52674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52675. */
  52676. snapDistance: number;
  52677. /**
  52678. * Event that fires each time the gizmo snaps to a new location.
  52679. * * snapDistance is the the change in distance
  52680. */
  52681. onSnapObservable: Observable<{
  52682. snapDistance: number;
  52683. }>;
  52684. private _isEnabled;
  52685. private _parent;
  52686. private _arrow;
  52687. private _coloredMaterial;
  52688. private _hoverMaterial;
  52689. /** @hidden */
  52690. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52691. /** @hidden */
  52692. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52693. /**
  52694. * Creates an AxisDragGizmo
  52695. * @param gizmoLayer The utility layer the gizmo will be added to
  52696. * @param dragAxis The axis which the gizmo will be able to drag on
  52697. * @param color The color of the gizmo
  52698. * @param thickness display gizmo axis thickness
  52699. */
  52700. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52701. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52702. /**
  52703. * If the gizmo is enabled
  52704. */
  52705. set isEnabled(value: boolean);
  52706. get isEnabled(): boolean;
  52707. /**
  52708. * Disposes of the gizmo
  52709. */
  52710. dispose(): void;
  52711. }
  52712. }
  52713. declare module "babylonjs/Debug/axesViewer" {
  52714. import { Vector3 } from "babylonjs/Maths/math.vector";
  52715. import { Nullable } from "babylonjs/types";
  52716. import { Scene } from "babylonjs/scene";
  52717. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52718. /**
  52719. * The Axes viewer will show 3 axes in a specific point in space
  52720. */
  52721. export class AxesViewer {
  52722. private _xAxis;
  52723. private _yAxis;
  52724. private _zAxis;
  52725. private _scaleLinesFactor;
  52726. private _instanced;
  52727. /**
  52728. * Gets the hosting scene
  52729. */
  52730. scene: Nullable<Scene>;
  52731. /**
  52732. * Gets or sets a number used to scale line length
  52733. */
  52734. scaleLines: number;
  52735. /** Gets the node hierarchy used to render x-axis */
  52736. get xAxis(): TransformNode;
  52737. /** Gets the node hierarchy used to render y-axis */
  52738. get yAxis(): TransformNode;
  52739. /** Gets the node hierarchy used to render z-axis */
  52740. get zAxis(): TransformNode;
  52741. /**
  52742. * Creates a new AxesViewer
  52743. * @param scene defines the hosting scene
  52744. * @param scaleLines defines a number used to scale line length (1 by default)
  52745. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52746. * @param xAxis defines the node hierarchy used to render the x-axis
  52747. * @param yAxis defines the node hierarchy used to render the y-axis
  52748. * @param zAxis defines the node hierarchy used to render the z-axis
  52749. */
  52750. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52751. /**
  52752. * Force the viewer to update
  52753. * @param position defines the position of the viewer
  52754. * @param xaxis defines the x axis of the viewer
  52755. * @param yaxis defines the y axis of the viewer
  52756. * @param zaxis defines the z axis of the viewer
  52757. */
  52758. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52759. /**
  52760. * Creates an instance of this axes viewer.
  52761. * @returns a new axes viewer with instanced meshes
  52762. */
  52763. createInstance(): AxesViewer;
  52764. /** Releases resources */
  52765. dispose(): void;
  52766. private static _SetRenderingGroupId;
  52767. }
  52768. }
  52769. declare module "babylonjs/Debug/boneAxesViewer" {
  52770. import { Nullable } from "babylonjs/types";
  52771. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52772. import { Vector3 } from "babylonjs/Maths/math.vector";
  52773. import { Mesh } from "babylonjs/Meshes/mesh";
  52774. import { Bone } from "babylonjs/Bones/bone";
  52775. import { Scene } from "babylonjs/scene";
  52776. /**
  52777. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52778. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52779. */
  52780. export class BoneAxesViewer extends AxesViewer {
  52781. /**
  52782. * Gets or sets the target mesh where to display the axes viewer
  52783. */
  52784. mesh: Nullable<Mesh>;
  52785. /**
  52786. * Gets or sets the target bone where to display the axes viewer
  52787. */
  52788. bone: Nullable<Bone>;
  52789. /** Gets current position */
  52790. pos: Vector3;
  52791. /** Gets direction of X axis */
  52792. xaxis: Vector3;
  52793. /** Gets direction of Y axis */
  52794. yaxis: Vector3;
  52795. /** Gets direction of Z axis */
  52796. zaxis: Vector3;
  52797. /**
  52798. * Creates a new BoneAxesViewer
  52799. * @param scene defines the hosting scene
  52800. * @param bone defines the target bone
  52801. * @param mesh defines the target mesh
  52802. * @param scaleLines defines a scaling factor for line length (1 by default)
  52803. */
  52804. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52805. /**
  52806. * Force the viewer to update
  52807. */
  52808. update(): void;
  52809. /** Releases resources */
  52810. dispose(): void;
  52811. }
  52812. }
  52813. declare module "babylonjs/Debug/debugLayer" {
  52814. import { Scene } from "babylonjs/scene";
  52815. /**
  52816. * Interface used to define scene explorer extensibility option
  52817. */
  52818. export interface IExplorerExtensibilityOption {
  52819. /**
  52820. * Define the option label
  52821. */
  52822. label: string;
  52823. /**
  52824. * Defines the action to execute on click
  52825. */
  52826. action: (entity: any) => void;
  52827. }
  52828. /**
  52829. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52830. */
  52831. export interface IExplorerExtensibilityGroup {
  52832. /**
  52833. * Defines a predicate to test if a given type mut be extended
  52834. */
  52835. predicate: (entity: any) => boolean;
  52836. /**
  52837. * Gets the list of options added to a type
  52838. */
  52839. entries: IExplorerExtensibilityOption[];
  52840. }
  52841. /**
  52842. * Interface used to define the options to use to create the Inspector
  52843. */
  52844. export interface IInspectorOptions {
  52845. /**
  52846. * Display in overlay mode (default: false)
  52847. */
  52848. overlay?: boolean;
  52849. /**
  52850. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52851. */
  52852. globalRoot?: HTMLElement;
  52853. /**
  52854. * Display the Scene explorer
  52855. */
  52856. showExplorer?: boolean;
  52857. /**
  52858. * Display the property inspector
  52859. */
  52860. showInspector?: boolean;
  52861. /**
  52862. * Display in embed mode (both panes on the right)
  52863. */
  52864. embedMode?: boolean;
  52865. /**
  52866. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  52867. */
  52868. handleResize?: boolean;
  52869. /**
  52870. * Allow the panes to popup (default: true)
  52871. */
  52872. enablePopup?: boolean;
  52873. /**
  52874. * Allow the panes to be closed by users (default: true)
  52875. */
  52876. enableClose?: boolean;
  52877. /**
  52878. * Optional list of extensibility entries
  52879. */
  52880. explorerExtensibility?: IExplorerExtensibilityGroup[];
  52881. /**
  52882. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  52883. */
  52884. inspectorURL?: string;
  52885. /**
  52886. * Optional initial tab (default to DebugLayerTab.Properties)
  52887. */
  52888. initialTab?: DebugLayerTab;
  52889. }
  52890. module "babylonjs/scene" {
  52891. interface Scene {
  52892. /**
  52893. * @hidden
  52894. * Backing field
  52895. */
  52896. _debugLayer: DebugLayer;
  52897. /**
  52898. * Gets the debug layer (aka Inspector) associated with the scene
  52899. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52900. */
  52901. debugLayer: DebugLayer;
  52902. }
  52903. }
  52904. /**
  52905. * Enum of inspector action tab
  52906. */
  52907. export enum DebugLayerTab {
  52908. /**
  52909. * Properties tag (default)
  52910. */
  52911. Properties = 0,
  52912. /**
  52913. * Debug tab
  52914. */
  52915. Debug = 1,
  52916. /**
  52917. * Statistics tab
  52918. */
  52919. Statistics = 2,
  52920. /**
  52921. * Tools tab
  52922. */
  52923. Tools = 3,
  52924. /**
  52925. * Settings tab
  52926. */
  52927. Settings = 4
  52928. }
  52929. /**
  52930. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52931. * what is happening in your scene
  52932. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52933. */
  52934. export class DebugLayer {
  52935. /**
  52936. * Define the url to get the inspector script from.
  52937. * By default it uses the babylonjs CDN.
  52938. * @ignoreNaming
  52939. */
  52940. static InspectorURL: string;
  52941. private _scene;
  52942. private BJSINSPECTOR;
  52943. private _onPropertyChangedObservable?;
  52944. /**
  52945. * Observable triggered when a property is changed through the inspector.
  52946. */
  52947. get onPropertyChangedObservable(): any;
  52948. /**
  52949. * Instantiates a new debug layer.
  52950. * The debug layer (aka Inspector) is the go to tool in order to better understand
  52951. * what is happening in your scene
  52952. * @see https://doc.babylonjs.com/features/playground_debuglayer
  52953. * @param scene Defines the scene to inspect
  52954. */
  52955. constructor(scene: Scene);
  52956. /** Creates the inspector window. */
  52957. private _createInspector;
  52958. /**
  52959. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  52960. * @param entity defines the entity to select
  52961. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  52962. */
  52963. select(entity: any, lineContainerTitles?: string | string[]): void;
  52964. /** Get the inspector from bundle or global */
  52965. private _getGlobalInspector;
  52966. /**
  52967. * Get if the inspector is visible or not.
  52968. * @returns true if visible otherwise, false
  52969. */
  52970. isVisible(): boolean;
  52971. /**
  52972. * Hide the inspector and close its window.
  52973. */
  52974. hide(): void;
  52975. /**
  52976. * Update the scene in the inspector
  52977. */
  52978. setAsActiveScene(): void;
  52979. /**
  52980. * Launch the debugLayer.
  52981. * @param config Define the configuration of the inspector
  52982. * @return a promise fulfilled when the debug layer is visible
  52983. */
  52984. show(config?: IInspectorOptions): Promise<DebugLayer>;
  52985. }
  52986. }
  52987. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  52988. import { Nullable } from "babylonjs/types";
  52989. import { Scene } from "babylonjs/scene";
  52990. import { Vector4 } from "babylonjs/Maths/math.vector";
  52991. import { Color4 } from "babylonjs/Maths/math.color";
  52992. import { Mesh } from "babylonjs/Meshes/mesh";
  52993. /**
  52994. * Class containing static functions to help procedurally build meshes
  52995. */
  52996. export class BoxBuilder {
  52997. /**
  52998. * Creates a box mesh
  52999. * * The parameter `size` sets the size (float) of each box side (default 1)
  53000. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53001. * * 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)
  53002. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53003. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53004. * * 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
  53005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53006. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53007. * @param name defines the name of the mesh
  53008. * @param options defines the options used to create the mesh
  53009. * @param scene defines the hosting scene
  53010. * @returns the box mesh
  53011. */
  53012. static CreateBox(name: string, options: {
  53013. size?: number;
  53014. width?: number;
  53015. height?: number;
  53016. depth?: number;
  53017. faceUV?: Vector4[];
  53018. faceColors?: Color4[];
  53019. sideOrientation?: number;
  53020. frontUVs?: Vector4;
  53021. backUVs?: Vector4;
  53022. wrap?: boolean;
  53023. topBaseAt?: number;
  53024. bottomBaseAt?: number;
  53025. updatable?: boolean;
  53026. }, scene?: Nullable<Scene>): Mesh;
  53027. }
  53028. }
  53029. declare module "babylonjs/Debug/physicsViewer" {
  53030. import { Nullable } from "babylonjs/types";
  53031. import { Scene } from "babylonjs/scene";
  53032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53033. import { Mesh } from "babylonjs/Meshes/mesh";
  53034. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53035. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53036. /**
  53037. * Used to show the physics impostor around the specific mesh
  53038. */
  53039. export class PhysicsViewer {
  53040. /** @hidden */
  53041. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53042. /** @hidden */
  53043. protected _meshes: Array<Nullable<AbstractMesh>>;
  53044. /** @hidden */
  53045. protected _scene: Nullable<Scene>;
  53046. /** @hidden */
  53047. protected _numMeshes: number;
  53048. /** @hidden */
  53049. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53050. private _renderFunction;
  53051. private _utilityLayer;
  53052. private _debugBoxMesh;
  53053. private _debugSphereMesh;
  53054. private _debugCylinderMesh;
  53055. private _debugMaterial;
  53056. private _debugMeshMeshes;
  53057. /**
  53058. * Creates a new PhysicsViewer
  53059. * @param scene defines the hosting scene
  53060. */
  53061. constructor(scene: Scene);
  53062. /** @hidden */
  53063. protected _updateDebugMeshes(): void;
  53064. /**
  53065. * Renders a specified physic impostor
  53066. * @param impostor defines the impostor to render
  53067. * @param targetMesh defines the mesh represented by the impostor
  53068. * @returns the new debug mesh used to render the impostor
  53069. */
  53070. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53071. /**
  53072. * Hides a specified physic impostor
  53073. * @param impostor defines the impostor to hide
  53074. */
  53075. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53076. private _getDebugMaterial;
  53077. private _getDebugBoxMesh;
  53078. private _getDebugSphereMesh;
  53079. private _getDebugCylinderMesh;
  53080. private _getDebugMeshMesh;
  53081. private _getDebugMesh;
  53082. /** Releases all resources */
  53083. dispose(): void;
  53084. }
  53085. }
  53086. declare module "babylonjs/Debug/rayHelper" {
  53087. import { Nullable } from "babylonjs/types";
  53088. import { Ray } from "babylonjs/Culling/ray";
  53089. import { Vector3 } from "babylonjs/Maths/math.vector";
  53090. import { Color3 } from "babylonjs/Maths/math.color";
  53091. import { Scene } from "babylonjs/scene";
  53092. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53093. import "babylonjs/Meshes/Builders/linesBuilder";
  53094. /**
  53095. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53096. * in order to better appreciate the issue one might have.
  53097. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53098. */
  53099. export class RayHelper {
  53100. /**
  53101. * Defines the ray we are currently tryin to visualize.
  53102. */
  53103. ray: Nullable<Ray>;
  53104. private _renderPoints;
  53105. private _renderLine;
  53106. private _renderFunction;
  53107. private _scene;
  53108. private _onAfterRenderObserver;
  53109. private _onAfterStepObserver;
  53110. private _attachedToMesh;
  53111. private _meshSpaceDirection;
  53112. private _meshSpaceOrigin;
  53113. /**
  53114. * Helper function to create a colored helper in a scene in one line.
  53115. * @param ray Defines the ray we are currently tryin to visualize
  53116. * @param scene Defines the scene the ray is used in
  53117. * @param color Defines the color we want to see the ray in
  53118. * @returns The newly created ray helper.
  53119. */
  53120. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53121. /**
  53122. * Instantiate a new ray helper.
  53123. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53124. * in order to better appreciate the issue one might have.
  53125. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53126. * @param ray Defines the ray we are currently tryin to visualize
  53127. */
  53128. constructor(ray: Ray);
  53129. /**
  53130. * Shows the ray we are willing to debug.
  53131. * @param scene Defines the scene the ray needs to be rendered in
  53132. * @param color Defines the color the ray needs to be rendered in
  53133. */
  53134. show(scene: Scene, color?: Color3): void;
  53135. /**
  53136. * Hides the ray we are debugging.
  53137. */
  53138. hide(): void;
  53139. private _render;
  53140. /**
  53141. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53142. * @param mesh Defines the mesh we want the helper attached to
  53143. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53144. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53145. * @param length Defines the length of the ray
  53146. */
  53147. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53148. /**
  53149. * Detach the ray helper from the mesh it has previously been attached to.
  53150. */
  53151. detachFromMesh(): void;
  53152. private _updateToMesh;
  53153. /**
  53154. * Dispose the helper and release its associated resources.
  53155. */
  53156. dispose(): void;
  53157. }
  53158. }
  53159. declare module "babylonjs/Debug/ISkeletonViewer" {
  53160. import { Skeleton } from "babylonjs/Bones/skeleton";
  53161. import { Color3 } from "babylonjs/Maths/math.color";
  53162. /**
  53163. * Defines the options associated with the creation of a SkeletonViewer.
  53164. */
  53165. export interface ISkeletonViewerOptions {
  53166. /** Should the system pause animations before building the Viewer? */
  53167. pauseAnimations: boolean;
  53168. /** Should the system return the skeleton to rest before building? */
  53169. returnToRest: boolean;
  53170. /** public Display Mode of the Viewer */
  53171. displayMode: number;
  53172. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53173. displayOptions: ISkeletonViewerDisplayOptions;
  53174. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53175. computeBonesUsingShaders: boolean;
  53176. /** Flag ignore non weighted bones */
  53177. useAllBones: boolean;
  53178. }
  53179. /**
  53180. * Defines how to display the various bone meshes for the viewer.
  53181. */
  53182. export interface ISkeletonViewerDisplayOptions {
  53183. /** How far down to start tapering the bone spurs */
  53184. midStep?: number;
  53185. /** How big is the midStep? */
  53186. midStepFactor?: number;
  53187. /** Base for the Sphere Size */
  53188. sphereBaseSize?: number;
  53189. /** The ratio of the sphere to the longest bone in units */
  53190. sphereScaleUnit?: number;
  53191. /** Ratio for the Sphere Size */
  53192. sphereFactor?: number;
  53193. /** Whether to show local axes or not */
  53194. showLocalAxes?: boolean;
  53195. /** Length of each local axis */
  53196. localAxesSize?: number;
  53197. }
  53198. /**
  53199. * Defines the constructor options for the BoneWeight Shader.
  53200. */
  53201. export interface IBoneWeightShaderOptions {
  53202. /** Skeleton to Map */
  53203. skeleton: Skeleton;
  53204. /** Colors for Uninfluenced bones */
  53205. colorBase?: Color3;
  53206. /** Colors for 0.0-0.25 Weight bones */
  53207. colorZero?: Color3;
  53208. /** Color for 0.25-0.5 Weight Influence */
  53209. colorQuarter?: Color3;
  53210. /** Color for 0.5-0.75 Weight Influence */
  53211. colorHalf?: Color3;
  53212. /** Color for 0.75-1 Weight Influence */
  53213. colorFull?: Color3;
  53214. /** Color for Zero Weight Influence */
  53215. targetBoneIndex?: number;
  53216. }
  53217. /**
  53218. * Simple structure of the gradient steps for the Color Map.
  53219. */
  53220. export interface ISkeletonMapShaderColorMapKnot {
  53221. /** Color of the Knot */
  53222. color: Color3;
  53223. /** Location of the Knot */
  53224. location: number;
  53225. }
  53226. /**
  53227. * Defines the constructor options for the SkeletonMap Shader.
  53228. */
  53229. export interface ISkeletonMapShaderOptions {
  53230. /** Skeleton to Map */
  53231. skeleton: Skeleton;
  53232. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53233. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53234. }
  53235. }
  53236. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53237. import { Nullable } from "babylonjs/types";
  53238. import { Scene } from "babylonjs/scene";
  53239. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53240. import { Color4 } from "babylonjs/Maths/math.color";
  53241. import { Mesh } from "babylonjs/Meshes/mesh";
  53242. /**
  53243. * Class containing static functions to help procedurally build meshes
  53244. */
  53245. export class RibbonBuilder {
  53246. /**
  53247. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53248. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53249. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53250. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53251. * * 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
  53252. * * 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
  53253. * * 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
  53254. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53255. * * 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
  53256. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53257. * * 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
  53258. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53259. * * 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
  53260. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53262. * @param name defines the name of the mesh
  53263. * @param options defines the options used to create the mesh
  53264. * @param scene defines the hosting scene
  53265. * @returns the ribbon mesh
  53266. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53267. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53268. */
  53269. static CreateRibbon(name: string, options: {
  53270. pathArray: Vector3[][];
  53271. closeArray?: boolean;
  53272. closePath?: boolean;
  53273. offset?: number;
  53274. updatable?: boolean;
  53275. sideOrientation?: number;
  53276. frontUVs?: Vector4;
  53277. backUVs?: Vector4;
  53278. instance?: Mesh;
  53279. invertUV?: boolean;
  53280. uvs?: Vector2[];
  53281. colors?: Color4[];
  53282. }, scene?: Nullable<Scene>): Mesh;
  53283. }
  53284. }
  53285. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53286. import { Nullable } from "babylonjs/types";
  53287. import { Scene } from "babylonjs/scene";
  53288. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53289. import { Mesh } from "babylonjs/Meshes/mesh";
  53290. /**
  53291. * Class containing static functions to help procedurally build meshes
  53292. */
  53293. export class ShapeBuilder {
  53294. /**
  53295. * 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.
  53296. * * 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.
  53297. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53298. * * 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.
  53299. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53300. * * 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
  53301. * * 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
  53302. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53304. * * 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
  53305. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53307. * @param name defines the name of the mesh
  53308. * @param options defines the options used to create the mesh
  53309. * @param scene defines the hosting scene
  53310. * @returns the extruded shape mesh
  53311. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53313. */
  53314. static ExtrudeShape(name: string, options: {
  53315. shape: Vector3[];
  53316. path: Vector3[];
  53317. scale?: number;
  53318. rotation?: number;
  53319. cap?: number;
  53320. updatable?: boolean;
  53321. sideOrientation?: number;
  53322. frontUVs?: Vector4;
  53323. backUVs?: Vector4;
  53324. instance?: Mesh;
  53325. invertUV?: boolean;
  53326. }, scene?: Nullable<Scene>): Mesh;
  53327. /**
  53328. * Creates an custom extruded shape mesh.
  53329. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53330. * * 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.
  53331. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53332. * * 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
  53333. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53334. * * 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
  53335. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53336. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53337. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53338. * * 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
  53339. * * 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
  53340. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53342. * * 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
  53343. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53344. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53345. * @param name defines the name of the mesh
  53346. * @param options defines the options used to create the mesh
  53347. * @param scene defines the hosting scene
  53348. * @returns the custom extruded shape mesh
  53349. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53350. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53351. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53352. */
  53353. static ExtrudeShapeCustom(name: string, options: {
  53354. shape: Vector3[];
  53355. path: Vector3[];
  53356. scaleFunction?: any;
  53357. rotationFunction?: any;
  53358. ribbonCloseArray?: boolean;
  53359. ribbonClosePath?: boolean;
  53360. cap?: number;
  53361. updatable?: boolean;
  53362. sideOrientation?: number;
  53363. frontUVs?: Vector4;
  53364. backUVs?: Vector4;
  53365. instance?: Mesh;
  53366. invertUV?: boolean;
  53367. }, scene?: Nullable<Scene>): Mesh;
  53368. private static _ExtrudeShapeGeneric;
  53369. }
  53370. }
  53371. declare module "babylonjs/Debug/skeletonViewer" {
  53372. import { Color3 } from "babylonjs/Maths/math.color";
  53373. import { Scene } from "babylonjs/scene";
  53374. import { Nullable } from "babylonjs/types";
  53375. import { Skeleton } from "babylonjs/Bones/skeleton";
  53376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53377. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53379. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53380. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53381. /**
  53382. * Class used to render a debug view of a given skeleton
  53383. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53384. */
  53385. export class SkeletonViewer {
  53386. /** defines the skeleton to render */
  53387. skeleton: Skeleton;
  53388. /** defines the mesh attached to the skeleton */
  53389. mesh: AbstractMesh;
  53390. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53391. autoUpdateBonesMatrices: boolean;
  53392. /** defines the rendering group id to use with the viewer */
  53393. renderingGroupId: number;
  53394. /** is the options for the viewer */
  53395. options: Partial<ISkeletonViewerOptions>;
  53396. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53397. static readonly DISPLAY_LINES: number;
  53398. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53399. static readonly DISPLAY_SPHERES: number;
  53400. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53401. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53402. /** public static method to create a BoneWeight Shader
  53403. * @param options The constructor options
  53404. * @param scene The scene that the shader is scoped to
  53405. * @returns The created ShaderMaterial
  53406. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53407. */
  53408. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53409. /** public static method to create a BoneWeight Shader
  53410. * @param options The constructor options
  53411. * @param scene The scene that the shader is scoped to
  53412. * @returns The created ShaderMaterial
  53413. */
  53414. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53415. /** private static method to create a BoneWeight Shader
  53416. * @param size The size of the buffer to create (usually the bone count)
  53417. * @param colorMap The gradient data to generate
  53418. * @param scene The scene that the shader is scoped to
  53419. * @returns an Array of floats from the color gradient values
  53420. */
  53421. private static _CreateBoneMapColorBuffer;
  53422. /** If SkeletonViewer scene scope. */
  53423. private _scene;
  53424. /** Gets or sets the color used to render the skeleton */
  53425. color: Color3;
  53426. /** Array of the points of the skeleton fo the line view. */
  53427. private _debugLines;
  53428. /** The SkeletonViewers Mesh. */
  53429. private _debugMesh;
  53430. /** The local axes Meshes. */
  53431. private _localAxes;
  53432. /** If SkeletonViewer is enabled. */
  53433. private _isEnabled;
  53434. /** If SkeletonViewer is ready. */
  53435. private _ready;
  53436. /** SkeletonViewer render observable. */
  53437. private _obs;
  53438. /** The Utility Layer to render the gizmos in. */
  53439. private _utilityLayer;
  53440. private _boneIndices;
  53441. /** Gets the Scene. */
  53442. get scene(): Scene;
  53443. /** Gets the utilityLayer. */
  53444. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53445. /** Checks Ready Status. */
  53446. get isReady(): Boolean;
  53447. /** Sets Ready Status. */
  53448. set ready(value: boolean);
  53449. /** Gets the debugMesh */
  53450. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53451. /** Sets the debugMesh */
  53452. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53453. /** Gets the displayMode */
  53454. get displayMode(): number;
  53455. /** Sets the displayMode */
  53456. set displayMode(value: number);
  53457. /**
  53458. * Creates a new SkeletonViewer
  53459. * @param skeleton defines the skeleton to render
  53460. * @param mesh defines the mesh attached to the skeleton
  53461. * @param scene defines the hosting scene
  53462. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53463. * @param renderingGroupId defines the rendering group id to use with the viewer
  53464. * @param options All of the extra constructor options for the SkeletonViewer
  53465. */
  53466. constructor(
  53467. /** defines the skeleton to render */
  53468. skeleton: Skeleton,
  53469. /** defines the mesh attached to the skeleton */
  53470. mesh: AbstractMesh,
  53471. /** The Scene scope*/
  53472. scene: Scene,
  53473. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53474. autoUpdateBonesMatrices?: boolean,
  53475. /** defines the rendering group id to use with the viewer */
  53476. renderingGroupId?: number,
  53477. /** is the options for the viewer */
  53478. options?: Partial<ISkeletonViewerOptions>);
  53479. /** The Dynamic bindings for the update functions */
  53480. private _bindObs;
  53481. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53482. update(): void;
  53483. /** Gets or sets a boolean indicating if the viewer is enabled */
  53484. set isEnabled(value: boolean);
  53485. get isEnabled(): boolean;
  53486. private _getBonePosition;
  53487. private _getLinesForBonesWithLength;
  53488. private _getLinesForBonesNoLength;
  53489. /** function to revert the mesh and scene back to the initial state. */
  53490. private _revert;
  53491. private getAbsoluteRestPose;
  53492. /** function to build and bind sphere joint points and spur bone representations. */
  53493. private _buildSpheresAndSpurs;
  53494. private _buildLocalAxes;
  53495. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53496. private _displayLinesUpdate;
  53497. /** Changes the displayMode of the skeleton viewer
  53498. * @param mode The displayMode numerical value
  53499. */
  53500. changeDisplayMode(mode: number): void;
  53501. /** Sets a display option of the skeleton viewer
  53502. *
  53503. * | Option | Type | Default | Description |
  53504. * | --------------- | ------- | ------- | ----------- |
  53505. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53506. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53507. *
  53508. * @param option String of the option name
  53509. * @param value The numerical option value
  53510. */
  53511. changeDisplayOptions(option: string, value: number): void;
  53512. /** Release associated resources */
  53513. dispose(): void;
  53514. }
  53515. }
  53516. declare module "babylonjs/Debug/index" {
  53517. export * from "babylonjs/Debug/axesViewer";
  53518. export * from "babylonjs/Debug/boneAxesViewer";
  53519. export * from "babylonjs/Debug/debugLayer";
  53520. export * from "babylonjs/Debug/physicsViewer";
  53521. export * from "babylonjs/Debug/rayHelper";
  53522. export * from "babylonjs/Debug/skeletonViewer";
  53523. export * from "babylonjs/Debug/ISkeletonViewer";
  53524. }
  53525. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53526. /**
  53527. * Enum for Device Types
  53528. */
  53529. export enum DeviceType {
  53530. /** Generic */
  53531. Generic = 0,
  53532. /** Keyboard */
  53533. Keyboard = 1,
  53534. /** Mouse */
  53535. Mouse = 2,
  53536. /** Touch Pointers */
  53537. Touch = 3,
  53538. /** PS4 Dual Shock */
  53539. DualShock = 4,
  53540. /** Xbox */
  53541. Xbox = 5,
  53542. /** Switch Controller */
  53543. Switch = 6
  53544. }
  53545. /**
  53546. * Enum for All Pointers (Touch/Mouse)
  53547. */
  53548. export enum PointerInput {
  53549. /** Horizontal Axis */
  53550. Horizontal = 0,
  53551. /** Vertical Axis */
  53552. Vertical = 1,
  53553. /** Left Click or Touch */
  53554. LeftClick = 2,
  53555. /** Middle Click */
  53556. MiddleClick = 3,
  53557. /** Right Click */
  53558. RightClick = 4,
  53559. /** Browser Back */
  53560. BrowserBack = 5,
  53561. /** Browser Forward */
  53562. BrowserForward = 6
  53563. }
  53564. /**
  53565. * Enum for Dual Shock Gamepad
  53566. */
  53567. export enum DualShockInput {
  53568. /** Cross */
  53569. Cross = 0,
  53570. /** Circle */
  53571. Circle = 1,
  53572. /** Square */
  53573. Square = 2,
  53574. /** Triangle */
  53575. Triangle = 3,
  53576. /** L1 */
  53577. L1 = 4,
  53578. /** R1 */
  53579. R1 = 5,
  53580. /** L2 */
  53581. L2 = 6,
  53582. /** R2 */
  53583. R2 = 7,
  53584. /** Share */
  53585. Share = 8,
  53586. /** Options */
  53587. Options = 9,
  53588. /** L3 */
  53589. L3 = 10,
  53590. /** R3 */
  53591. R3 = 11,
  53592. /** DPadUp */
  53593. DPadUp = 12,
  53594. /** DPadDown */
  53595. DPadDown = 13,
  53596. /** DPadLeft */
  53597. DPadLeft = 14,
  53598. /** DRight */
  53599. DPadRight = 15,
  53600. /** Home */
  53601. Home = 16,
  53602. /** TouchPad */
  53603. TouchPad = 17,
  53604. /** LStickXAxis */
  53605. LStickXAxis = 18,
  53606. /** LStickYAxis */
  53607. LStickYAxis = 19,
  53608. /** RStickXAxis */
  53609. RStickXAxis = 20,
  53610. /** RStickYAxis */
  53611. RStickYAxis = 21
  53612. }
  53613. /**
  53614. * Enum for Xbox Gamepad
  53615. */
  53616. export enum XboxInput {
  53617. /** A */
  53618. A = 0,
  53619. /** B */
  53620. B = 1,
  53621. /** X */
  53622. X = 2,
  53623. /** Y */
  53624. Y = 3,
  53625. /** LB */
  53626. LB = 4,
  53627. /** RB */
  53628. RB = 5,
  53629. /** LT */
  53630. LT = 6,
  53631. /** RT */
  53632. RT = 7,
  53633. /** Back */
  53634. Back = 8,
  53635. /** Start */
  53636. Start = 9,
  53637. /** LS */
  53638. LS = 10,
  53639. /** RS */
  53640. RS = 11,
  53641. /** DPadUp */
  53642. DPadUp = 12,
  53643. /** DPadDown */
  53644. DPadDown = 13,
  53645. /** DPadLeft */
  53646. DPadLeft = 14,
  53647. /** DRight */
  53648. DPadRight = 15,
  53649. /** Home */
  53650. Home = 16,
  53651. /** LStickXAxis */
  53652. LStickXAxis = 17,
  53653. /** LStickYAxis */
  53654. LStickYAxis = 18,
  53655. /** RStickXAxis */
  53656. RStickXAxis = 19,
  53657. /** RStickYAxis */
  53658. RStickYAxis = 20
  53659. }
  53660. /**
  53661. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53662. */
  53663. export enum SwitchInput {
  53664. /** B */
  53665. B = 0,
  53666. /** A */
  53667. A = 1,
  53668. /** Y */
  53669. Y = 2,
  53670. /** X */
  53671. X = 3,
  53672. /** L */
  53673. L = 4,
  53674. /** R */
  53675. R = 5,
  53676. /** ZL */
  53677. ZL = 6,
  53678. /** ZR */
  53679. ZR = 7,
  53680. /** Minus */
  53681. Minus = 8,
  53682. /** Plus */
  53683. Plus = 9,
  53684. /** LS */
  53685. LS = 10,
  53686. /** RS */
  53687. RS = 11,
  53688. /** DPadUp */
  53689. DPadUp = 12,
  53690. /** DPadDown */
  53691. DPadDown = 13,
  53692. /** DPadLeft */
  53693. DPadLeft = 14,
  53694. /** DRight */
  53695. DPadRight = 15,
  53696. /** Home */
  53697. Home = 16,
  53698. /** Capture */
  53699. Capture = 17,
  53700. /** LStickXAxis */
  53701. LStickXAxis = 18,
  53702. /** LStickYAxis */
  53703. LStickYAxis = 19,
  53704. /** RStickXAxis */
  53705. RStickXAxis = 20,
  53706. /** RStickYAxis */
  53707. RStickYAxis = 21
  53708. }
  53709. }
  53710. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53711. import { Engine } from "babylonjs/Engines/engine";
  53712. import { IDisposable } from "babylonjs/scene";
  53713. import { Nullable } from "babylonjs/types";
  53714. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53715. /**
  53716. * This class will take all inputs from Keyboard, Pointer, and
  53717. * any Gamepads and provide a polling system that all devices
  53718. * will use. This class assumes that there will only be one
  53719. * pointer device and one keyboard.
  53720. */
  53721. export class DeviceInputSystem implements IDisposable {
  53722. /**
  53723. * Callback to be triggered when a device is connected
  53724. */
  53725. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53726. /**
  53727. * Callback to be triggered when a device is disconnected
  53728. */
  53729. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53730. /**
  53731. * Callback to be triggered when event driven input is updated
  53732. */
  53733. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53734. private _inputs;
  53735. private _gamepads;
  53736. private _keyboardActive;
  53737. private _pointerActive;
  53738. private _elementToAttachTo;
  53739. private _keyboardDownEvent;
  53740. private _keyboardUpEvent;
  53741. private _pointerMoveEvent;
  53742. private _pointerDownEvent;
  53743. private _pointerUpEvent;
  53744. private _gamepadConnectedEvent;
  53745. private _gamepadDisconnectedEvent;
  53746. private static _MAX_KEYCODES;
  53747. private static _MAX_POINTER_INPUTS;
  53748. private constructor();
  53749. /**
  53750. * Creates a new DeviceInputSystem instance
  53751. * @param engine Engine to pull input element from
  53752. * @returns The new instance
  53753. */
  53754. static Create(engine: Engine): DeviceInputSystem;
  53755. /**
  53756. * Checks for current device input value, given an id and input index
  53757. * @param deviceName Id of connected device
  53758. * @param inputIndex Index of device input
  53759. * @returns Current value of input
  53760. */
  53761. /**
  53762. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53763. * @param deviceType Enum specifiying device type
  53764. * @param deviceSlot "Slot" or index that device is referenced in
  53765. * @param inputIndex Id of input to be checked
  53766. * @returns Current value of input
  53767. */
  53768. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53769. /**
  53770. * Dispose of all the eventlisteners
  53771. */
  53772. dispose(): void;
  53773. /**
  53774. * Add device and inputs to device array
  53775. * @param deviceType Enum specifiying device type
  53776. * @param deviceSlot "Slot" or index that device is referenced in
  53777. * @param numberOfInputs Number of input entries to create for given device
  53778. */
  53779. private _registerDevice;
  53780. /**
  53781. * Given a specific device name, remove that device from the device map
  53782. * @param deviceType Enum specifiying device type
  53783. * @param deviceSlot "Slot" or index that device is referenced in
  53784. */
  53785. private _unregisterDevice;
  53786. /**
  53787. * Handle all actions that come from keyboard interaction
  53788. */
  53789. private _handleKeyActions;
  53790. /**
  53791. * Handle all actions that come from pointer interaction
  53792. */
  53793. private _handlePointerActions;
  53794. /**
  53795. * Handle all actions that come from gamepad interaction
  53796. */
  53797. private _handleGamepadActions;
  53798. /**
  53799. * Update all non-event based devices with each frame
  53800. * @param deviceType Enum specifiying device type
  53801. * @param deviceSlot "Slot" or index that device is referenced in
  53802. * @param inputIndex Id of input to be checked
  53803. */
  53804. private _updateDevice;
  53805. /**
  53806. * Gets DeviceType from the device name
  53807. * @param deviceName Name of Device from DeviceInputSystem
  53808. * @returns DeviceType enum value
  53809. */
  53810. private _getGamepadDeviceType;
  53811. }
  53812. }
  53813. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53814. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53815. /**
  53816. * Type to handle enforcement of inputs
  53817. */
  53818. 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;
  53819. }
  53820. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53821. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53822. import { Engine } from "babylonjs/Engines/engine";
  53823. import { IDisposable } from "babylonjs/scene";
  53824. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53825. import { Nullable } from "babylonjs/types";
  53826. import { Observable } from "babylonjs/Misc/observable";
  53827. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53828. /**
  53829. * Class that handles all input for a specific device
  53830. */
  53831. export class DeviceSource<T extends DeviceType> {
  53832. /** Type of device */
  53833. readonly deviceType: DeviceType;
  53834. /** "Slot" or index that device is referenced in */
  53835. readonly deviceSlot: number;
  53836. /**
  53837. * Observable to handle device input changes per device
  53838. */
  53839. readonly onInputChangedObservable: Observable<{
  53840. inputIndex: DeviceInput<T>;
  53841. previousState: Nullable<number>;
  53842. currentState: Nullable<number>;
  53843. }>;
  53844. private readonly _deviceInputSystem;
  53845. /**
  53846. * Default Constructor
  53847. * @param deviceInputSystem Reference to DeviceInputSystem
  53848. * @param deviceType Type of device
  53849. * @param deviceSlot "Slot" or index that device is referenced in
  53850. */
  53851. constructor(deviceInputSystem: DeviceInputSystem,
  53852. /** Type of device */
  53853. deviceType: DeviceType,
  53854. /** "Slot" or index that device is referenced in */
  53855. deviceSlot?: number);
  53856. /**
  53857. * Get input for specific input
  53858. * @param inputIndex index of specific input on device
  53859. * @returns Input value from DeviceInputSystem
  53860. */
  53861. getInput(inputIndex: DeviceInput<T>): number;
  53862. }
  53863. /**
  53864. * Class to keep track of devices
  53865. */
  53866. export class DeviceSourceManager implements IDisposable {
  53867. /**
  53868. * Observable to be triggered when before a device is connected
  53869. */
  53870. readonly onBeforeDeviceConnectedObservable: Observable<{
  53871. deviceType: DeviceType;
  53872. deviceSlot: number;
  53873. }>;
  53874. /**
  53875. * Observable to be triggered when before a device is disconnected
  53876. */
  53877. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  53878. deviceType: DeviceType;
  53879. deviceSlot: number;
  53880. }>;
  53881. /**
  53882. * Observable to be triggered when after a device is connected
  53883. */
  53884. readonly onAfterDeviceConnectedObservable: Observable<{
  53885. deviceType: DeviceType;
  53886. deviceSlot: number;
  53887. }>;
  53888. /**
  53889. * Observable to be triggered when after a device is disconnected
  53890. */
  53891. readonly onAfterDeviceDisconnectedObservable: Observable<{
  53892. deviceType: DeviceType;
  53893. deviceSlot: number;
  53894. }>;
  53895. private readonly _devices;
  53896. private readonly _firstDevice;
  53897. private readonly _deviceInputSystem;
  53898. /**
  53899. * Default Constructor
  53900. * @param engine engine to pull input element from
  53901. */
  53902. constructor(engine: Engine);
  53903. /**
  53904. * Gets a DeviceSource, given a type and slot
  53905. * @param deviceType Enum specifying device type
  53906. * @param deviceSlot "Slot" or index that device is referenced in
  53907. * @returns DeviceSource object
  53908. */
  53909. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  53910. /**
  53911. * Gets an array of DeviceSource objects for a given device type
  53912. * @param deviceType Enum specifying device type
  53913. * @returns Array of DeviceSource objects
  53914. */
  53915. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  53916. /**
  53917. * Dispose of DeviceInputSystem and other parts
  53918. */
  53919. dispose(): void;
  53920. /**
  53921. * Function to add device name to device list
  53922. * @param deviceType Enum specifying device type
  53923. * @param deviceSlot "Slot" or index that device is referenced in
  53924. */
  53925. private _addDevice;
  53926. /**
  53927. * Function to remove device name to device list
  53928. * @param deviceType Enum specifying device type
  53929. * @param deviceSlot "Slot" or index that device is referenced in
  53930. */
  53931. private _removeDevice;
  53932. /**
  53933. * Updates array storing first connected device of each type
  53934. * @param type Type of Device
  53935. */
  53936. private _updateFirstDevices;
  53937. }
  53938. }
  53939. declare module "babylonjs/DeviceInput/index" {
  53940. export * from "babylonjs/DeviceInput/deviceInputSystem";
  53941. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53942. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53943. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53944. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  53945. }
  53946. declare module "babylonjs/Engines/nullEngine" {
  53947. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  53948. import { Engine } from "babylonjs/Engines/engine";
  53949. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  53950. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  53951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  53952. import { Effect } from "babylonjs/Materials/effect";
  53953. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  53954. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  53955. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  53956. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  53957. /**
  53958. * Options to create the null engine
  53959. */
  53960. export class NullEngineOptions {
  53961. /**
  53962. * Render width (Default: 512)
  53963. */
  53964. renderWidth: number;
  53965. /**
  53966. * Render height (Default: 256)
  53967. */
  53968. renderHeight: number;
  53969. /**
  53970. * Texture size (Default: 512)
  53971. */
  53972. textureSize: number;
  53973. /**
  53974. * If delta time between frames should be constant
  53975. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53976. */
  53977. deterministicLockstep: boolean;
  53978. /**
  53979. * Maximum about of steps between frames (Default: 4)
  53980. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53981. */
  53982. lockstepMaxSteps: number;
  53983. /**
  53984. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  53985. */
  53986. useHighPrecisionMatrix?: boolean;
  53987. }
  53988. /**
  53989. * The null engine class provides support for headless version of babylon.js.
  53990. * This can be used in server side scenario or for testing purposes
  53991. */
  53992. export class NullEngine extends Engine {
  53993. private _options;
  53994. /**
  53995. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  53996. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  53997. * @returns true if engine is in deterministic lock step mode
  53998. */
  53999. isDeterministicLockStep(): boolean;
  54000. /**
  54001. * Gets the max steps when engine is running in deterministic lock step
  54002. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54003. * @returns the max steps
  54004. */
  54005. getLockstepMaxSteps(): number;
  54006. /**
  54007. * Gets the current hardware scaling level.
  54008. * By default the hardware scaling level is computed from the window device ratio.
  54009. * 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.
  54010. * @returns a number indicating the current hardware scaling level
  54011. */
  54012. getHardwareScalingLevel(): number;
  54013. constructor(options?: NullEngineOptions);
  54014. /**
  54015. * Creates a vertex buffer
  54016. * @param vertices the data for the vertex buffer
  54017. * @returns the new WebGL static buffer
  54018. */
  54019. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54020. /**
  54021. * Creates a new index buffer
  54022. * @param indices defines the content of the index buffer
  54023. * @param updatable defines if the index buffer must be updatable
  54024. * @returns a new webGL buffer
  54025. */
  54026. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54027. /**
  54028. * Clear the current render buffer or the current render target (if any is set up)
  54029. * @param color defines the color to use
  54030. * @param backBuffer defines if the back buffer must be cleared
  54031. * @param depth defines if the depth buffer must be cleared
  54032. * @param stencil defines if the stencil buffer must be cleared
  54033. */
  54034. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54035. /**
  54036. * Gets the current render width
  54037. * @param useScreen defines if screen size must be used (or the current render target if any)
  54038. * @returns a number defining the current render width
  54039. */
  54040. getRenderWidth(useScreen?: boolean): number;
  54041. /**
  54042. * Gets the current render height
  54043. * @param useScreen defines if screen size must be used (or the current render target if any)
  54044. * @returns a number defining the current render height
  54045. */
  54046. getRenderHeight(useScreen?: boolean): number;
  54047. /**
  54048. * Set the WebGL's viewport
  54049. * @param viewport defines the viewport element to be used
  54050. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54051. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54052. */
  54053. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54054. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54055. /**
  54056. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54057. * @param pipelineContext defines the pipeline context to use
  54058. * @param uniformsNames defines the list of uniform names
  54059. * @returns an array of webGL uniform locations
  54060. */
  54061. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54062. /**
  54063. * Gets the lsit of active attributes for a given webGL program
  54064. * @param pipelineContext defines the pipeline context to use
  54065. * @param attributesNames defines the list of attribute names to get
  54066. * @returns an array of indices indicating the offset of each attribute
  54067. */
  54068. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54069. /**
  54070. * Binds an effect to the webGL context
  54071. * @param effect defines the effect to bind
  54072. */
  54073. bindSamplers(effect: Effect): void;
  54074. /**
  54075. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54076. * @param effect defines the effect to activate
  54077. */
  54078. enableEffect(effect: Effect): void;
  54079. /**
  54080. * Set various states to the webGL context
  54081. * @param culling defines backface culling state
  54082. * @param zOffset defines the value to apply to zOffset (0 by default)
  54083. * @param force defines if states must be applied even if cache is up to date
  54084. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54085. */
  54086. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54087. /**
  54088. * Set the value of an uniform to an array of int32
  54089. * @param uniform defines the webGL uniform location where to store the value
  54090. * @param array defines the array of int32 to store
  54091. * @returns true if value was set
  54092. */
  54093. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54094. /**
  54095. * Set the value of an uniform to an array of int32 (stored as vec2)
  54096. * @param uniform defines the webGL uniform location where to store the value
  54097. * @param array defines the array of int32 to store
  54098. * @returns true if value was set
  54099. */
  54100. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54101. /**
  54102. * Set the value of an uniform to an array of int32 (stored as vec3)
  54103. * @param uniform defines the webGL uniform location where to store the value
  54104. * @param array defines the array of int32 to store
  54105. * @returns true if value was set
  54106. */
  54107. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54108. /**
  54109. * Set the value of an uniform to an array of int32 (stored as vec4)
  54110. * @param uniform defines the webGL uniform location where to store the value
  54111. * @param array defines the array of int32 to store
  54112. * @returns true if value was set
  54113. */
  54114. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54115. /**
  54116. * Set the value of an uniform to an array of float32
  54117. * @param uniform defines the webGL uniform location where to store the value
  54118. * @param array defines the array of float32 to store
  54119. * @returns true if value was set
  54120. */
  54121. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54122. /**
  54123. * Set the value of an uniform to an array of float32 (stored as vec2)
  54124. * @param uniform defines the webGL uniform location where to store the value
  54125. * @param array defines the array of float32 to store
  54126. * @returns true if value was set
  54127. */
  54128. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54129. /**
  54130. * Set the value of an uniform to an array of float32 (stored as vec3)
  54131. * @param uniform defines the webGL uniform location where to store the value
  54132. * @param array defines the array of float32 to store
  54133. * @returns true if value was set
  54134. */
  54135. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54136. /**
  54137. * Set the value of an uniform to an array of float32 (stored as vec4)
  54138. * @param uniform defines the webGL uniform location where to store the value
  54139. * @param array defines the array of float32 to store
  54140. * @returns true if value was set
  54141. */
  54142. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54143. /**
  54144. * Set the value of an uniform to an array of number
  54145. * @param uniform defines the webGL uniform location where to store the value
  54146. * @param array defines the array of number to store
  54147. * @returns true if value was set
  54148. */
  54149. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54150. /**
  54151. * Set the value of an uniform to an array of number (stored as vec2)
  54152. * @param uniform defines the webGL uniform location where to store the value
  54153. * @param array defines the array of number to store
  54154. * @returns true if value was set
  54155. */
  54156. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54157. /**
  54158. * Set the value of an uniform to an array of number (stored as vec3)
  54159. * @param uniform defines the webGL uniform location where to store the value
  54160. * @param array defines the array of number to store
  54161. * @returns true if value was set
  54162. */
  54163. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54164. /**
  54165. * Set the value of an uniform to an array of number (stored as vec4)
  54166. * @param uniform defines the webGL uniform location where to store the value
  54167. * @param array defines the array of number to store
  54168. * @returns true if value was set
  54169. */
  54170. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54171. /**
  54172. * Set the value of an uniform to an array of float32 (stored as matrices)
  54173. * @param uniform defines the webGL uniform location where to store the value
  54174. * @param matrices defines the array of float32 to store
  54175. * @returns true if value was set
  54176. */
  54177. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54178. /**
  54179. * Set the value of an uniform to a matrix (3x3)
  54180. * @param uniform defines the webGL uniform location where to store the value
  54181. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54182. * @returns true if value was set
  54183. */
  54184. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54185. /**
  54186. * Set the value of an uniform to a matrix (2x2)
  54187. * @param uniform defines the webGL uniform location where to store the value
  54188. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54189. * @returns true if value was set
  54190. */
  54191. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54192. /**
  54193. * Set the value of an uniform to a number (float)
  54194. * @param uniform defines the webGL uniform location where to store the value
  54195. * @param value defines the float number to store
  54196. * @returns true if value was set
  54197. */
  54198. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54199. /**
  54200. * Set the value of an uniform to a vec2
  54201. * @param uniform defines the webGL uniform location where to store the value
  54202. * @param x defines the 1st component of the value
  54203. * @param y defines the 2nd component of the value
  54204. * @returns true if value was set
  54205. */
  54206. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54207. /**
  54208. * Set the value of an uniform to a vec3
  54209. * @param uniform defines the webGL uniform location where to store the value
  54210. * @param x defines the 1st component of the value
  54211. * @param y defines the 2nd component of the value
  54212. * @param z defines the 3rd component of the value
  54213. * @returns true if value was set
  54214. */
  54215. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54216. /**
  54217. * Set the value of an uniform to a boolean
  54218. * @param uniform defines the webGL uniform location where to store the value
  54219. * @param bool defines the boolean to store
  54220. * @returns true if value was set
  54221. */
  54222. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54223. /**
  54224. * Set the value of an uniform to a vec4
  54225. * @param uniform defines the webGL uniform location where to store the value
  54226. * @param x defines the 1st component of the value
  54227. * @param y defines the 2nd component of the value
  54228. * @param z defines the 3rd component of the value
  54229. * @param w defines the 4th component of the value
  54230. * @returns true if value was set
  54231. */
  54232. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54233. /**
  54234. * Sets the current alpha mode
  54235. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54236. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54237. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54238. */
  54239. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54240. /**
  54241. * Bind webGl buffers directly to the webGL context
  54242. * @param vertexBuffers defines the vertex buffer to bind
  54243. * @param indexBuffer defines the index buffer to bind
  54244. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54245. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54246. * @param effect defines the effect associated with the vertex buffer
  54247. */
  54248. bindBuffers(vertexBuffers: {
  54249. [key: string]: VertexBuffer;
  54250. }, indexBuffer: DataBuffer, effect: Effect): void;
  54251. /**
  54252. * Force the entire cache to be cleared
  54253. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54254. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54255. */
  54256. wipeCaches(bruteForce?: boolean): void;
  54257. /**
  54258. * Send a draw order
  54259. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54260. * @param indexStart defines the starting index
  54261. * @param indexCount defines the number of index to draw
  54262. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54263. */
  54264. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54265. /**
  54266. * Draw a list of indexed primitives
  54267. * @param fillMode defines the primitive to use
  54268. * @param indexStart defines the starting index
  54269. * @param indexCount defines the number of index to draw
  54270. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54271. */
  54272. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54273. /**
  54274. * Draw a list of unindexed primitives
  54275. * @param fillMode defines the primitive to use
  54276. * @param verticesStart defines the index of first vertex to draw
  54277. * @param verticesCount defines the count of vertices to draw
  54278. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54279. */
  54280. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54281. /** @hidden */
  54282. _createTexture(): WebGLTexture;
  54283. /** @hidden */
  54284. _releaseTexture(texture: InternalTexture): void;
  54285. /**
  54286. * Usually called from Texture.ts.
  54287. * Passed information to create a WebGLTexture
  54288. * @param urlArg defines a value which contains one of the following:
  54289. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54290. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54291. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54292. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54293. * @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)
  54294. * @param scene needed for loading to the correct scene
  54295. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54296. * @param onLoad optional callback to be called upon successful completion
  54297. * @param onError optional callback to be called upon failure
  54298. * @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
  54299. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54300. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54301. * @param forcedExtension defines the extension to use to pick the right loader
  54302. * @param mimeType defines an optional mime type
  54303. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54304. */
  54305. 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;
  54306. /**
  54307. * Creates a new render target texture
  54308. * @param size defines the size of the texture
  54309. * @param options defines the options used to create the texture
  54310. * @returns a new render target texture stored in an InternalTexture
  54311. */
  54312. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54313. /**
  54314. * Update the sampling mode of a given texture
  54315. * @param samplingMode defines the required sampling mode
  54316. * @param texture defines the texture to update
  54317. */
  54318. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54319. /**
  54320. * Binds the frame buffer to the specified texture.
  54321. * @param texture The texture to render to or null for the default canvas
  54322. * @param faceIndex The face of the texture to render to in case of cube texture
  54323. * @param requiredWidth The width of the target to render to
  54324. * @param requiredHeight The height of the target to render to
  54325. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54326. * @param lodLevel defines le lod level to bind to the frame buffer
  54327. */
  54328. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54329. /**
  54330. * Unbind the current render target texture from the webGL context
  54331. * @param texture defines the render target texture to unbind
  54332. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54333. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54334. */
  54335. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54336. /**
  54337. * Creates a dynamic vertex buffer
  54338. * @param vertices the data for the dynamic vertex buffer
  54339. * @returns the new WebGL dynamic buffer
  54340. */
  54341. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54342. /**
  54343. * Update the content of a dynamic texture
  54344. * @param texture defines the texture to update
  54345. * @param canvas defines the canvas containing the source
  54346. * @param invertY defines if data must be stored with Y axis inverted
  54347. * @param premulAlpha defines if alpha is stored as premultiplied
  54348. * @param format defines the format of the data
  54349. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54350. */
  54351. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54352. /**
  54353. * Gets a boolean indicating if all created effects are ready
  54354. * @returns true if all effects are ready
  54355. */
  54356. areAllEffectsReady(): boolean;
  54357. /**
  54358. * @hidden
  54359. * Get the current error code of the webGL context
  54360. * @returns the error code
  54361. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54362. */
  54363. getError(): number;
  54364. /** @hidden */
  54365. _getUnpackAlignement(): number;
  54366. /** @hidden */
  54367. _unpackFlipY(value: boolean): void;
  54368. /**
  54369. * Update a dynamic index buffer
  54370. * @param indexBuffer defines the target index buffer
  54371. * @param indices defines the data to update
  54372. * @param offset defines the offset in the target index buffer where update should start
  54373. */
  54374. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54375. /**
  54376. * Updates a dynamic vertex buffer.
  54377. * @param vertexBuffer the vertex buffer to update
  54378. * @param vertices the data used to update the vertex buffer
  54379. * @param byteOffset the byte offset of the data (optional)
  54380. * @param byteLength the byte length of the data (optional)
  54381. */
  54382. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54383. /** @hidden */
  54384. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54385. /** @hidden */
  54386. _bindTexture(channel: number, texture: InternalTexture): void;
  54387. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54388. /**
  54389. * 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
  54390. */
  54391. releaseEffects(): void;
  54392. displayLoadingUI(): void;
  54393. hideLoadingUI(): void;
  54394. /** @hidden */
  54395. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54396. /** @hidden */
  54397. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54398. /** @hidden */
  54399. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54400. /** @hidden */
  54401. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54402. }
  54403. }
  54404. declare module "babylonjs/Instrumentation/timeToken" {
  54405. import { Nullable } from "babylonjs/types";
  54406. /**
  54407. * @hidden
  54408. **/
  54409. export class _TimeToken {
  54410. _startTimeQuery: Nullable<WebGLQuery>;
  54411. _endTimeQuery: Nullable<WebGLQuery>;
  54412. _timeElapsedQuery: Nullable<WebGLQuery>;
  54413. _timeElapsedQueryEnded: boolean;
  54414. }
  54415. }
  54416. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54417. import { Nullable, int } from "babylonjs/types";
  54418. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54419. /** @hidden */
  54420. export class _OcclusionDataStorage {
  54421. /** @hidden */
  54422. occlusionInternalRetryCounter: number;
  54423. /** @hidden */
  54424. isOcclusionQueryInProgress: boolean;
  54425. /** @hidden */
  54426. isOccluded: boolean;
  54427. /** @hidden */
  54428. occlusionRetryCount: number;
  54429. /** @hidden */
  54430. occlusionType: number;
  54431. /** @hidden */
  54432. occlusionQueryAlgorithmType: number;
  54433. }
  54434. module "babylonjs/Engines/engine" {
  54435. interface Engine {
  54436. /**
  54437. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54438. * @return the new query
  54439. */
  54440. createQuery(): WebGLQuery;
  54441. /**
  54442. * Delete and release a webGL query
  54443. * @param query defines the query to delete
  54444. * @return the current engine
  54445. */
  54446. deleteQuery(query: WebGLQuery): Engine;
  54447. /**
  54448. * Check if a given query has resolved and got its value
  54449. * @param query defines the query to check
  54450. * @returns true if the query got its value
  54451. */
  54452. isQueryResultAvailable(query: WebGLQuery): boolean;
  54453. /**
  54454. * Gets the value of a given query
  54455. * @param query defines the query to check
  54456. * @returns the value of the query
  54457. */
  54458. getQueryResult(query: WebGLQuery): number;
  54459. /**
  54460. * Initiates an occlusion query
  54461. * @param algorithmType defines the algorithm to use
  54462. * @param query defines the query to use
  54463. * @returns the current engine
  54464. * @see https://doc.babylonjs.com/features/occlusionquery
  54465. */
  54466. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54467. /**
  54468. * Ends an occlusion query
  54469. * @see https://doc.babylonjs.com/features/occlusionquery
  54470. * @param algorithmType defines the algorithm to use
  54471. * @returns the current engine
  54472. */
  54473. endOcclusionQuery(algorithmType: number): Engine;
  54474. /**
  54475. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54476. * Please note that only one query can be issued at a time
  54477. * @returns a time token used to track the time span
  54478. */
  54479. startTimeQuery(): Nullable<_TimeToken>;
  54480. /**
  54481. * Ends a time query
  54482. * @param token defines the token used to measure the time span
  54483. * @returns the time spent (in ns)
  54484. */
  54485. endTimeQuery(token: _TimeToken): int;
  54486. /** @hidden */
  54487. _currentNonTimestampToken: Nullable<_TimeToken>;
  54488. /** @hidden */
  54489. _createTimeQuery(): WebGLQuery;
  54490. /** @hidden */
  54491. _deleteTimeQuery(query: WebGLQuery): void;
  54492. /** @hidden */
  54493. _getGlAlgorithmType(algorithmType: number): number;
  54494. /** @hidden */
  54495. _getTimeQueryResult(query: WebGLQuery): any;
  54496. /** @hidden */
  54497. _getTimeQueryAvailability(query: WebGLQuery): any;
  54498. }
  54499. }
  54500. module "babylonjs/Meshes/abstractMesh" {
  54501. interface AbstractMesh {
  54502. /**
  54503. * Backing filed
  54504. * @hidden
  54505. */
  54506. __occlusionDataStorage: _OcclusionDataStorage;
  54507. /**
  54508. * Access property
  54509. * @hidden
  54510. */
  54511. _occlusionDataStorage: _OcclusionDataStorage;
  54512. /**
  54513. * 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.
  54514. * The default value is -1 which means don't break the query and wait till the result
  54515. * @see https://doc.babylonjs.com/features/occlusionquery
  54516. */
  54517. occlusionRetryCount: number;
  54518. /**
  54519. * 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:
  54520. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54521. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54522. * * 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.
  54523. * @see https://doc.babylonjs.com/features/occlusionquery
  54524. */
  54525. occlusionType: number;
  54526. /**
  54527. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54528. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54529. * * 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.
  54530. * @see https://doc.babylonjs.com/features/occlusionquery
  54531. */
  54532. occlusionQueryAlgorithmType: number;
  54533. /**
  54534. * 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
  54535. * @see https://doc.babylonjs.com/features/occlusionquery
  54536. */
  54537. isOccluded: boolean;
  54538. /**
  54539. * Flag to check the progress status of the query
  54540. * @see https://doc.babylonjs.com/features/occlusionquery
  54541. */
  54542. isOcclusionQueryInProgress: boolean;
  54543. }
  54544. }
  54545. }
  54546. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54547. import { Nullable } from "babylonjs/types";
  54548. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54549. /** @hidden */
  54550. export var _forceTransformFeedbackToBundle: boolean;
  54551. module "babylonjs/Engines/engine" {
  54552. interface Engine {
  54553. /**
  54554. * Creates a webGL transform feedback object
  54555. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54556. * @returns the webGL transform feedback object
  54557. */
  54558. createTransformFeedback(): WebGLTransformFeedback;
  54559. /**
  54560. * Delete a webGL transform feedback object
  54561. * @param value defines the webGL transform feedback object to delete
  54562. */
  54563. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54564. /**
  54565. * Bind a webGL transform feedback object to the webgl context
  54566. * @param value defines the webGL transform feedback object to bind
  54567. */
  54568. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54569. /**
  54570. * Begins a transform feedback operation
  54571. * @param usePoints defines if points or triangles must be used
  54572. */
  54573. beginTransformFeedback(usePoints: boolean): void;
  54574. /**
  54575. * Ends a transform feedback operation
  54576. */
  54577. endTransformFeedback(): void;
  54578. /**
  54579. * Specify the varyings to use with transform feedback
  54580. * @param program defines the associated webGL program
  54581. * @param value defines the list of strings representing the varying names
  54582. */
  54583. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54584. /**
  54585. * Bind a webGL buffer for a transform feedback operation
  54586. * @param value defines the webGL buffer to bind
  54587. */
  54588. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54589. }
  54590. }
  54591. }
  54592. declare module "babylonjs/Engines/Extensions/engine.views" {
  54593. import { Camera } from "babylonjs/Cameras/camera";
  54594. import { Nullable } from "babylonjs/types";
  54595. /**
  54596. * Class used to define an additional view for the engine
  54597. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54598. */
  54599. export class EngineView {
  54600. /** Defines the canvas where to render the view */
  54601. target: HTMLCanvasElement;
  54602. /** Defines an optional camera used to render the view (will use active camera else) */
  54603. camera?: Camera;
  54604. }
  54605. module "babylonjs/Engines/engine" {
  54606. interface Engine {
  54607. /**
  54608. * Gets or sets the HTML element to use for attaching events
  54609. */
  54610. inputElement: Nullable<HTMLElement>;
  54611. /**
  54612. * Gets the current engine view
  54613. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54614. */
  54615. activeView: Nullable<EngineView>;
  54616. /** Gets or sets the list of views */
  54617. views: EngineView[];
  54618. /**
  54619. * Register a new child canvas
  54620. * @param canvas defines the canvas to register
  54621. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54622. * @returns the associated view
  54623. */
  54624. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54625. /**
  54626. * Remove a registered child canvas
  54627. * @param canvas defines the canvas to remove
  54628. * @returns the current engine
  54629. */
  54630. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54631. }
  54632. }
  54633. }
  54634. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54635. import { Nullable } from "babylonjs/types";
  54636. module "babylonjs/Engines/engine" {
  54637. interface Engine {
  54638. /** @hidden */
  54639. _excludedCompressedTextures: string[];
  54640. /** @hidden */
  54641. _textureFormatInUse: string;
  54642. /**
  54643. * Gets the list of texture formats supported
  54644. */
  54645. readonly texturesSupported: Array<string>;
  54646. /**
  54647. * Gets the texture format in use
  54648. */
  54649. readonly textureFormatInUse: Nullable<string>;
  54650. /**
  54651. * Set the compressed texture extensions or file names to skip.
  54652. *
  54653. * @param skippedFiles defines the list of those texture files you want to skip
  54654. * Example: [".dds", ".env", "myfile.png"]
  54655. */
  54656. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54657. /**
  54658. * Set the compressed texture format to use, based on the formats you have, and the formats
  54659. * supported by the hardware / browser.
  54660. *
  54661. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54662. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54663. * to API arguments needed to compressed textures. This puts the burden on the container
  54664. * generator to house the arcane code for determining these for current & future formats.
  54665. *
  54666. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54667. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54668. *
  54669. * Note: The result of this call is not taken into account when a texture is base64.
  54670. *
  54671. * @param formatsAvailable defines the list of those format families you have created
  54672. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54673. *
  54674. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54675. * @returns The extension selected.
  54676. */
  54677. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54678. }
  54679. }
  54680. }
  54681. declare module "babylonjs/Engines/Extensions/index" {
  54682. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54683. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54684. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54685. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54686. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54687. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54688. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54689. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54690. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54691. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54692. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54693. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54694. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54695. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54696. export * from "babylonjs/Engines/Extensions/engine.views";
  54697. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54698. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54699. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54700. }
  54701. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54702. import { Nullable } from "babylonjs/types";
  54703. /**
  54704. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54705. */
  54706. export interface CubeMapInfo {
  54707. /**
  54708. * The pixel array for the front face.
  54709. * This is stored in format, left to right, up to down format.
  54710. */
  54711. front: Nullable<ArrayBufferView>;
  54712. /**
  54713. * The pixel array for the back face.
  54714. * This is stored in format, left to right, up to down format.
  54715. */
  54716. back: Nullable<ArrayBufferView>;
  54717. /**
  54718. * The pixel array for the left face.
  54719. * This is stored in format, left to right, up to down format.
  54720. */
  54721. left: Nullable<ArrayBufferView>;
  54722. /**
  54723. * The pixel array for the right face.
  54724. * This is stored in format, left to right, up to down format.
  54725. */
  54726. right: Nullable<ArrayBufferView>;
  54727. /**
  54728. * The pixel array for the up face.
  54729. * This is stored in format, left to right, up to down format.
  54730. */
  54731. up: Nullable<ArrayBufferView>;
  54732. /**
  54733. * The pixel array for the down face.
  54734. * This is stored in format, left to right, up to down format.
  54735. */
  54736. down: Nullable<ArrayBufferView>;
  54737. /**
  54738. * The size of the cubemap stored.
  54739. *
  54740. * Each faces will be size * size pixels.
  54741. */
  54742. size: number;
  54743. /**
  54744. * The format of the texture.
  54745. *
  54746. * RGBA, RGB.
  54747. */
  54748. format: number;
  54749. /**
  54750. * The type of the texture data.
  54751. *
  54752. * UNSIGNED_INT, FLOAT.
  54753. */
  54754. type: number;
  54755. /**
  54756. * Specifies whether the texture is in gamma space.
  54757. */
  54758. gammaSpace: boolean;
  54759. }
  54760. /**
  54761. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54762. */
  54763. export class PanoramaToCubeMapTools {
  54764. private static FACE_LEFT;
  54765. private static FACE_RIGHT;
  54766. private static FACE_FRONT;
  54767. private static FACE_BACK;
  54768. private static FACE_DOWN;
  54769. private static FACE_UP;
  54770. /**
  54771. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54772. *
  54773. * @param float32Array The source data.
  54774. * @param inputWidth The width of the input panorama.
  54775. * @param inputHeight The height of the input panorama.
  54776. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54777. * @return The cubemap data
  54778. */
  54779. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54780. private static CreateCubemapTexture;
  54781. private static CalcProjectionSpherical;
  54782. }
  54783. }
  54784. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54785. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54786. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54787. import { Nullable } from "babylonjs/types";
  54788. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54789. /**
  54790. * Helper class dealing with the extraction of spherical polynomial dataArray
  54791. * from a cube map.
  54792. */
  54793. export class CubeMapToSphericalPolynomialTools {
  54794. private static FileFaces;
  54795. /**
  54796. * Converts a texture to the according Spherical Polynomial data.
  54797. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54798. *
  54799. * @param texture The texture to extract the information from.
  54800. * @return The Spherical Polynomial data.
  54801. */
  54802. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54803. /**
  54804. * Converts a cubemap to the according Spherical Polynomial data.
  54805. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54806. *
  54807. * @param cubeInfo The Cube map to extract the information from.
  54808. * @return The Spherical Polynomial data.
  54809. */
  54810. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54811. }
  54812. }
  54813. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54814. import { Nullable } from "babylonjs/types";
  54815. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54816. module "babylonjs/Materials/Textures/baseTexture" {
  54817. interface BaseTexture {
  54818. /**
  54819. * Get the polynomial representation of the texture data.
  54820. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54821. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54822. */
  54823. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54824. }
  54825. }
  54826. }
  54827. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54828. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54829. /** @hidden */
  54830. export var rgbdEncodePixelShader: {
  54831. name: string;
  54832. shader: string;
  54833. };
  54834. }
  54835. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54836. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54837. /** @hidden */
  54838. export var rgbdDecodePixelShader: {
  54839. name: string;
  54840. shader: string;
  54841. };
  54842. }
  54843. declare module "babylonjs/Misc/environmentTextureTools" {
  54844. import { Nullable } from "babylonjs/types";
  54845. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54846. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54847. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54848. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54849. import "babylonjs/Engines/Extensions/engine.readTexture";
  54850. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54851. import "babylonjs/Shaders/rgbdEncode.fragment";
  54852. import "babylonjs/Shaders/rgbdDecode.fragment";
  54853. /**
  54854. * Raw texture data and descriptor sufficient for WebGL texture upload
  54855. */
  54856. export interface EnvironmentTextureInfo {
  54857. /**
  54858. * Version of the environment map
  54859. */
  54860. version: number;
  54861. /**
  54862. * Width of image
  54863. */
  54864. width: number;
  54865. /**
  54866. * Irradiance information stored in the file.
  54867. */
  54868. irradiance: any;
  54869. /**
  54870. * Specular information stored in the file.
  54871. */
  54872. specular: any;
  54873. }
  54874. /**
  54875. * Defines One Image in the file. It requires only the position in the file
  54876. * as well as the length.
  54877. */
  54878. interface BufferImageData {
  54879. /**
  54880. * Length of the image data.
  54881. */
  54882. length: number;
  54883. /**
  54884. * Position of the data from the null terminator delimiting the end of the JSON.
  54885. */
  54886. position: number;
  54887. }
  54888. /**
  54889. * Defines the specular data enclosed in the file.
  54890. * This corresponds to the version 1 of the data.
  54891. */
  54892. export interface EnvironmentTextureSpecularInfoV1 {
  54893. /**
  54894. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  54895. */
  54896. specularDataPosition?: number;
  54897. /**
  54898. * This contains all the images data needed to reconstruct the cubemap.
  54899. */
  54900. mipmaps: Array<BufferImageData>;
  54901. /**
  54902. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  54903. */
  54904. lodGenerationScale: number;
  54905. }
  54906. /**
  54907. * Sets of helpers addressing the serialization and deserialization of environment texture
  54908. * stored in a BabylonJS env file.
  54909. * Those files are usually stored as .env files.
  54910. */
  54911. export class EnvironmentTextureTools {
  54912. /**
  54913. * Magic number identifying the env file.
  54914. */
  54915. private static _MagicBytes;
  54916. /**
  54917. * Gets the environment info from an env file.
  54918. * @param data The array buffer containing the .env bytes.
  54919. * @returns the environment file info (the json header) if successfully parsed.
  54920. */
  54921. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  54922. /**
  54923. * Creates an environment texture from a loaded cube texture.
  54924. * @param texture defines the cube texture to convert in env file
  54925. * @return a promise containing the environment data if succesfull.
  54926. */
  54927. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  54928. /**
  54929. * Creates a JSON representation of the spherical data.
  54930. * @param texture defines the texture containing the polynomials
  54931. * @return the JSON representation of the spherical info
  54932. */
  54933. private static _CreateEnvTextureIrradiance;
  54934. /**
  54935. * Creates the ArrayBufferViews used for initializing environment texture image data.
  54936. * @param data the image data
  54937. * @param info parameters that determine what views will be created for accessing the underlying buffer
  54938. * @return the views described by info providing access to the underlying buffer
  54939. */
  54940. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  54941. /**
  54942. * Uploads the texture info contained in the env file to the GPU.
  54943. * @param texture defines the internal texture to upload to
  54944. * @param data defines the data to load
  54945. * @param info defines the texture info retrieved through the GetEnvInfo method
  54946. * @returns a promise
  54947. */
  54948. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  54949. private static _OnImageReadyAsync;
  54950. /**
  54951. * Uploads the levels of image data to the GPU.
  54952. * @param texture defines the internal texture to upload to
  54953. * @param imageData defines the array buffer views of image data [mipmap][face]
  54954. * @returns a promise
  54955. */
  54956. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  54957. /**
  54958. * Uploads spherical polynomials information to the texture.
  54959. * @param texture defines the texture we are trying to upload the information to
  54960. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  54961. */
  54962. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  54963. /** @hidden */
  54964. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54965. }
  54966. }
  54967. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  54968. /**
  54969. * Class used to inline functions in shader code
  54970. */
  54971. export class ShaderCodeInliner {
  54972. private static readonly _RegexpFindFunctionNameAndType;
  54973. private _sourceCode;
  54974. private _functionDescr;
  54975. private _numMaxIterations;
  54976. /** Gets or sets the token used to mark the functions to inline */
  54977. inlineToken: string;
  54978. /** Gets or sets the debug mode */
  54979. debug: boolean;
  54980. /** Gets the code after the inlining process */
  54981. get code(): string;
  54982. /**
  54983. * Initializes the inliner
  54984. * @param sourceCode shader code source to inline
  54985. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  54986. */
  54987. constructor(sourceCode: string, numMaxIterations?: number);
  54988. /**
  54989. * Start the processing of the shader code
  54990. */
  54991. processCode(): void;
  54992. private _collectFunctions;
  54993. private _processInlining;
  54994. private _extractBetweenMarkers;
  54995. private _skipWhitespaces;
  54996. private _removeComments;
  54997. private _replaceFunctionCallsByCode;
  54998. private _findBackward;
  54999. private _escapeRegExp;
  55000. private _replaceNames;
  55001. }
  55002. }
  55003. declare module "babylonjs/Engines/nativeEngine" {
  55004. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55005. import { Engine } from "babylonjs/Engines/engine";
  55006. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55007. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55009. import { Effect } from "babylonjs/Materials/effect";
  55010. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55011. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55012. import { IColor4Like } from "babylonjs/Maths/math.like";
  55013. import { Scene } from "babylonjs/scene";
  55014. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55015. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55016. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55017. /**
  55018. * Container for accessors for natively-stored mesh data buffers.
  55019. */
  55020. class NativeDataBuffer extends DataBuffer {
  55021. /**
  55022. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55023. */
  55024. nativeIndexBuffer?: any;
  55025. /**
  55026. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55027. */
  55028. nativeVertexBuffer?: any;
  55029. }
  55030. /** @hidden */
  55031. class NativeTexture extends InternalTexture {
  55032. getInternalTexture(): InternalTexture;
  55033. getViewCount(): number;
  55034. }
  55035. /** @hidden */
  55036. export class NativeEngine extends Engine {
  55037. private readonly _native;
  55038. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55039. private readonly INVALID_HANDLE;
  55040. private _boundBuffersVertexArray;
  55041. getHardwareScalingLevel(): number;
  55042. constructor();
  55043. dispose(): void;
  55044. /**
  55045. * Can be used to override the current requestAnimationFrame requester.
  55046. * @hidden
  55047. */
  55048. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55049. /**
  55050. * Override default engine behavior.
  55051. * @param color
  55052. * @param backBuffer
  55053. * @param depth
  55054. * @param stencil
  55055. */
  55056. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55057. /**
  55058. * Gets host document
  55059. * @returns the host document object
  55060. */
  55061. getHostDocument(): Nullable<Document>;
  55062. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55063. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55064. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55065. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55066. [key: string]: VertexBuffer;
  55067. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55068. bindBuffers(vertexBuffers: {
  55069. [key: string]: VertexBuffer;
  55070. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55071. recordVertexArrayObject(vertexBuffers: {
  55072. [key: string]: VertexBuffer;
  55073. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55074. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55075. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55076. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55077. /**
  55078. * Draw a list of indexed primitives
  55079. * @param fillMode defines the primitive to use
  55080. * @param indexStart defines the starting index
  55081. * @param indexCount defines the number of index to draw
  55082. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55083. */
  55084. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55085. /**
  55086. * Draw a list of unindexed primitives
  55087. * @param fillMode defines the primitive to use
  55088. * @param verticesStart defines the index of first vertex to draw
  55089. * @param verticesCount defines the count of vertices to draw
  55090. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55091. */
  55092. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55093. createPipelineContext(): IPipelineContext;
  55094. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55095. /** @hidden */
  55096. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55097. /** @hidden */
  55098. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55099. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55100. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55101. protected _setProgram(program: WebGLProgram): void;
  55102. _releaseEffect(effect: Effect): void;
  55103. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55104. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55105. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55106. bindSamplers(effect: Effect): void;
  55107. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55108. getRenderWidth(useScreen?: boolean): number;
  55109. getRenderHeight(useScreen?: boolean): number;
  55110. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55111. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55112. /**
  55113. * Set the z offset to apply to current rendering
  55114. * @param value defines the offset to apply
  55115. */
  55116. setZOffset(value: number): void;
  55117. /**
  55118. * Gets the current value of the zOffset
  55119. * @returns the current zOffset state
  55120. */
  55121. getZOffset(): number;
  55122. /**
  55123. * Enable or disable depth buffering
  55124. * @param enable defines the state to set
  55125. */
  55126. setDepthBuffer(enable: boolean): void;
  55127. /**
  55128. * Gets a boolean indicating if depth writing is enabled
  55129. * @returns the current depth writing state
  55130. */
  55131. getDepthWrite(): boolean;
  55132. /**
  55133. * Enable or disable depth writing
  55134. * @param enable defines the state to set
  55135. */
  55136. setDepthWrite(enable: boolean): void;
  55137. /**
  55138. * Enable or disable color writing
  55139. * @param enable defines the state to set
  55140. */
  55141. setColorWrite(enable: boolean): void;
  55142. /**
  55143. * Gets a boolean indicating if color writing is enabled
  55144. * @returns the current color writing state
  55145. */
  55146. getColorWrite(): boolean;
  55147. /**
  55148. * Sets alpha constants used by some alpha blending modes
  55149. * @param r defines the red component
  55150. * @param g defines the green component
  55151. * @param b defines the blue component
  55152. * @param a defines the alpha component
  55153. */
  55154. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55155. /**
  55156. * Sets the current alpha mode
  55157. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55158. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55159. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55160. */
  55161. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55162. /**
  55163. * Gets the current alpha mode
  55164. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55165. * @returns the current alpha mode
  55166. */
  55167. getAlphaMode(): number;
  55168. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55169. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55170. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55171. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55172. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55173. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55174. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55175. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55176. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55177. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55178. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55179. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55180. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55181. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55182. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55183. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55184. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55185. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55186. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55187. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55188. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55189. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55190. wipeCaches(bruteForce?: boolean): void;
  55191. _createTexture(): WebGLTexture;
  55192. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55193. /**
  55194. * Usually called from Texture.ts.
  55195. * Passed information to create a WebGLTexture
  55196. * @param url defines a value which contains one of the following:
  55197. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55198. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55199. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55200. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55201. * @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)
  55202. * @param scene needed for loading to the correct scene
  55203. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55204. * @param onLoad optional callback to be called upon successful completion
  55205. * @param onError optional callback to be called upon failure
  55206. * @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
  55207. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55208. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55209. * @param forcedExtension defines the extension to use to pick the right loader
  55210. * @param mimeType defines an optional mime type
  55211. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55212. */
  55213. 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;
  55214. /**
  55215. * Creates a cube texture
  55216. * @param rootUrl defines the url where the files to load is located
  55217. * @param scene defines the current scene
  55218. * @param files defines the list of files to load (1 per face)
  55219. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55220. * @param onLoad defines an optional callback raised when the texture is loaded
  55221. * @param onError defines an optional callback raised if there is an issue to load the texture
  55222. * @param format defines the format of the data
  55223. * @param forcedExtension defines the extension to use to pick the right loader
  55224. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55225. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55226. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55227. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55228. * @returns the cube texture as an InternalTexture
  55229. */
  55230. 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;
  55231. private _getSamplingFilter;
  55232. private static _GetNativeTextureFormat;
  55233. createRenderTargetTexture(size: number | {
  55234. width: number;
  55235. height: number;
  55236. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55237. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55238. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55239. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55240. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55241. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55242. /**
  55243. * Updates a dynamic vertex buffer.
  55244. * @param vertexBuffer the vertex buffer to update
  55245. * @param data the data used to update the vertex buffer
  55246. * @param byteOffset the byte offset of the data (optional)
  55247. * @param byteLength the byte length of the data (optional)
  55248. */
  55249. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55250. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55251. private _updateAnisotropicLevel;
  55252. private _getAddressMode;
  55253. /** @hidden */
  55254. _bindTexture(channel: number, texture: InternalTexture): void;
  55255. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55256. releaseEffects(): void;
  55257. /** @hidden */
  55258. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55259. /** @hidden */
  55260. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55261. /** @hidden */
  55262. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55263. /** @hidden */
  55264. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55265. }
  55266. }
  55267. declare module "babylonjs/Engines/index" {
  55268. export * from "babylonjs/Engines/constants";
  55269. export * from "babylonjs/Engines/engineCapabilities";
  55270. export * from "babylonjs/Engines/instancingAttributeInfo";
  55271. export * from "babylonjs/Engines/thinEngine";
  55272. export * from "babylonjs/Engines/engine";
  55273. export * from "babylonjs/Engines/engineStore";
  55274. export * from "babylonjs/Engines/nullEngine";
  55275. export * from "babylonjs/Engines/Extensions/index";
  55276. export * from "babylonjs/Engines/IPipelineContext";
  55277. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55278. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55279. export * from "babylonjs/Engines/nativeEngine";
  55280. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55281. export * from "babylonjs/Engines/performanceConfigurator";
  55282. }
  55283. declare module "babylonjs/Events/clipboardEvents" {
  55284. /**
  55285. * Gather the list of clipboard event types as constants.
  55286. */
  55287. export class ClipboardEventTypes {
  55288. /**
  55289. * The clipboard event is fired when a copy command is active (pressed).
  55290. */
  55291. static readonly COPY: number;
  55292. /**
  55293. * The clipboard event is fired when a cut command is active (pressed).
  55294. */
  55295. static readonly CUT: number;
  55296. /**
  55297. * The clipboard event is fired when a paste command is active (pressed).
  55298. */
  55299. static readonly PASTE: number;
  55300. }
  55301. /**
  55302. * This class is used to store clipboard related info for the onClipboardObservable event.
  55303. */
  55304. export class ClipboardInfo {
  55305. /**
  55306. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55307. */
  55308. type: number;
  55309. /**
  55310. * Defines the related dom event
  55311. */
  55312. event: ClipboardEvent;
  55313. /**
  55314. *Creates an instance of ClipboardInfo.
  55315. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55316. * @param event Defines the related dom event
  55317. */
  55318. constructor(
  55319. /**
  55320. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55321. */
  55322. type: number,
  55323. /**
  55324. * Defines the related dom event
  55325. */
  55326. event: ClipboardEvent);
  55327. /**
  55328. * Get the clipboard event's type from the keycode.
  55329. * @param keyCode Defines the keyCode for the current keyboard event.
  55330. * @return {number}
  55331. */
  55332. static GetTypeFromCharacter(keyCode: number): number;
  55333. }
  55334. }
  55335. declare module "babylonjs/Events/index" {
  55336. export * from "babylonjs/Events/keyboardEvents";
  55337. export * from "babylonjs/Events/pointerEvents";
  55338. export * from "babylonjs/Events/clipboardEvents";
  55339. }
  55340. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55341. import { Scene } from "babylonjs/scene";
  55342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55343. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55344. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55345. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55346. /**
  55347. * Google Daydream controller
  55348. */
  55349. export class DaydreamController extends WebVRController {
  55350. /**
  55351. * Base Url for the controller model.
  55352. */
  55353. static MODEL_BASE_URL: string;
  55354. /**
  55355. * File name for the controller model.
  55356. */
  55357. static MODEL_FILENAME: string;
  55358. /**
  55359. * Gamepad Id prefix used to identify Daydream Controller.
  55360. */
  55361. static readonly GAMEPAD_ID_PREFIX: string;
  55362. /**
  55363. * Creates a new DaydreamController from a gamepad
  55364. * @param vrGamepad the gamepad that the controller should be created from
  55365. */
  55366. constructor(vrGamepad: any);
  55367. /**
  55368. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55369. * @param scene scene in which to add meshes
  55370. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55371. */
  55372. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55373. /**
  55374. * Called once for each button that changed state since the last frame
  55375. * @param buttonIdx Which button index changed
  55376. * @param state New state of the button
  55377. * @param changes Which properties on the state changed since last frame
  55378. */
  55379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55380. }
  55381. }
  55382. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55383. import { Scene } from "babylonjs/scene";
  55384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55385. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55386. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55387. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55388. /**
  55389. * Gear VR Controller
  55390. */
  55391. export class GearVRController extends WebVRController {
  55392. /**
  55393. * Base Url for the controller model.
  55394. */
  55395. static MODEL_BASE_URL: string;
  55396. /**
  55397. * File name for the controller model.
  55398. */
  55399. static MODEL_FILENAME: string;
  55400. /**
  55401. * Gamepad Id prefix used to identify this controller.
  55402. */
  55403. static readonly GAMEPAD_ID_PREFIX: string;
  55404. private readonly _buttonIndexToObservableNameMap;
  55405. /**
  55406. * Creates a new GearVRController from a gamepad
  55407. * @param vrGamepad the gamepad that the controller should be created from
  55408. */
  55409. constructor(vrGamepad: any);
  55410. /**
  55411. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55412. * @param scene scene in which to add meshes
  55413. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55414. */
  55415. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55416. /**
  55417. * Called once for each button that changed state since the last frame
  55418. * @param buttonIdx Which button index changed
  55419. * @param state New state of the button
  55420. * @param changes Which properties on the state changed since last frame
  55421. */
  55422. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55423. }
  55424. }
  55425. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55426. import { Scene } from "babylonjs/scene";
  55427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55428. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55429. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55430. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55431. /**
  55432. * Generic Controller
  55433. */
  55434. export class GenericController extends WebVRController {
  55435. /**
  55436. * Base Url for the controller model.
  55437. */
  55438. static readonly MODEL_BASE_URL: string;
  55439. /**
  55440. * File name for the controller model.
  55441. */
  55442. static readonly MODEL_FILENAME: string;
  55443. /**
  55444. * Creates a new GenericController from a gamepad
  55445. * @param vrGamepad the gamepad that the controller should be created from
  55446. */
  55447. constructor(vrGamepad: any);
  55448. /**
  55449. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55450. * @param scene scene in which to add meshes
  55451. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55452. */
  55453. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55454. /**
  55455. * Called once for each button that changed state since the last frame
  55456. * @param buttonIdx Which button index changed
  55457. * @param state New state of the button
  55458. * @param changes Which properties on the state changed since last frame
  55459. */
  55460. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55461. }
  55462. }
  55463. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55464. import { Observable } from "babylonjs/Misc/observable";
  55465. import { Scene } from "babylonjs/scene";
  55466. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55467. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55468. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55469. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55470. /**
  55471. * Oculus Touch Controller
  55472. */
  55473. export class OculusTouchController extends WebVRController {
  55474. /**
  55475. * Base Url for the controller model.
  55476. */
  55477. static MODEL_BASE_URL: string;
  55478. /**
  55479. * File name for the left controller model.
  55480. */
  55481. static MODEL_LEFT_FILENAME: string;
  55482. /**
  55483. * File name for the right controller model.
  55484. */
  55485. static MODEL_RIGHT_FILENAME: string;
  55486. /**
  55487. * Base Url for the Quest controller model.
  55488. */
  55489. static QUEST_MODEL_BASE_URL: string;
  55490. /**
  55491. * @hidden
  55492. * If the controllers are running on a device that needs the updated Quest controller models
  55493. */
  55494. static _IsQuest: boolean;
  55495. /**
  55496. * Fired when the secondary trigger on this controller is modified
  55497. */
  55498. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55499. /**
  55500. * Fired when the thumb rest on this controller is modified
  55501. */
  55502. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55503. /**
  55504. * Creates a new OculusTouchController from a gamepad
  55505. * @param vrGamepad the gamepad that the controller should be created from
  55506. */
  55507. constructor(vrGamepad: any);
  55508. /**
  55509. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55510. * @param scene scene in which to add meshes
  55511. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55512. */
  55513. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55514. /**
  55515. * Fired when the A button on this controller is modified
  55516. */
  55517. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55518. /**
  55519. * Fired when the B button on this controller is modified
  55520. */
  55521. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55522. /**
  55523. * Fired when the X button on this controller is modified
  55524. */
  55525. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55526. /**
  55527. * Fired when the Y button on this controller is modified
  55528. */
  55529. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55530. /**
  55531. * Called once for each button that changed state since the last frame
  55532. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55533. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55534. * 2) secondary trigger (same)
  55535. * 3) A (right) X (left), touch, pressed = value
  55536. * 4) B / Y
  55537. * 5) thumb rest
  55538. * @param buttonIdx Which button index changed
  55539. * @param state New state of the button
  55540. * @param changes Which properties on the state changed since last frame
  55541. */
  55542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55543. }
  55544. }
  55545. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55546. import { Scene } from "babylonjs/scene";
  55547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55548. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55549. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55550. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55551. import { Observable } from "babylonjs/Misc/observable";
  55552. /**
  55553. * Vive Controller
  55554. */
  55555. export class ViveController extends WebVRController {
  55556. /**
  55557. * Base Url for the controller model.
  55558. */
  55559. static MODEL_BASE_URL: string;
  55560. /**
  55561. * File name for the controller model.
  55562. */
  55563. static MODEL_FILENAME: string;
  55564. /**
  55565. * Creates a new ViveController from a gamepad
  55566. * @param vrGamepad the gamepad that the controller should be created from
  55567. */
  55568. constructor(vrGamepad: any);
  55569. /**
  55570. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55571. * @param scene scene in which to add meshes
  55572. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55573. */
  55574. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55575. /**
  55576. * Fired when the left button on this controller is modified
  55577. */
  55578. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55579. /**
  55580. * Fired when the right button on this controller is modified
  55581. */
  55582. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55583. /**
  55584. * Fired when the menu button on this controller is modified
  55585. */
  55586. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55587. /**
  55588. * Called once for each button that changed state since the last frame
  55589. * Vive mapping:
  55590. * 0: touchpad
  55591. * 1: trigger
  55592. * 2: left AND right buttons
  55593. * 3: menu button
  55594. * @param buttonIdx Which button index changed
  55595. * @param state New state of the button
  55596. * @param changes Which properties on the state changed since last frame
  55597. */
  55598. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55599. }
  55600. }
  55601. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55602. import { Observable } from "babylonjs/Misc/observable";
  55603. import { Scene } from "babylonjs/scene";
  55604. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55605. import { Ray } from "babylonjs/Culling/ray";
  55606. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55607. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55608. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55609. /**
  55610. * Defines the WindowsMotionController object that the state of the windows motion controller
  55611. */
  55612. export class WindowsMotionController extends WebVRController {
  55613. /**
  55614. * The base url used to load the left and right controller models
  55615. */
  55616. static MODEL_BASE_URL: string;
  55617. /**
  55618. * The name of the left controller model file
  55619. */
  55620. static MODEL_LEFT_FILENAME: string;
  55621. /**
  55622. * The name of the right controller model file
  55623. */
  55624. static MODEL_RIGHT_FILENAME: string;
  55625. /**
  55626. * The controller name prefix for this controller type
  55627. */
  55628. static readonly GAMEPAD_ID_PREFIX: string;
  55629. /**
  55630. * The controller id pattern for this controller type
  55631. */
  55632. private static readonly GAMEPAD_ID_PATTERN;
  55633. private _loadedMeshInfo;
  55634. protected readonly _mapping: {
  55635. buttons: string[];
  55636. buttonMeshNames: {
  55637. trigger: string;
  55638. menu: string;
  55639. grip: string;
  55640. thumbstick: string;
  55641. trackpad: string;
  55642. };
  55643. buttonObservableNames: {
  55644. trigger: string;
  55645. menu: string;
  55646. grip: string;
  55647. thumbstick: string;
  55648. trackpad: string;
  55649. };
  55650. axisMeshNames: string[];
  55651. pointingPoseMeshName: string;
  55652. };
  55653. /**
  55654. * Fired when the trackpad on this controller is clicked
  55655. */
  55656. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55657. /**
  55658. * Fired when the trackpad on this controller is modified
  55659. */
  55660. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55661. /**
  55662. * The current x and y values of this controller's trackpad
  55663. */
  55664. trackpad: StickValues;
  55665. /**
  55666. * Creates a new WindowsMotionController from a gamepad
  55667. * @param vrGamepad the gamepad that the controller should be created from
  55668. */
  55669. constructor(vrGamepad: any);
  55670. /**
  55671. * Fired when the trigger on this controller is modified
  55672. */
  55673. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55674. /**
  55675. * Fired when the menu button on this controller is modified
  55676. */
  55677. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55678. /**
  55679. * Fired when the grip button on this controller is modified
  55680. */
  55681. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55682. /**
  55683. * Fired when the thumbstick button on this controller is modified
  55684. */
  55685. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55686. /**
  55687. * Fired when the touchpad button on this controller is modified
  55688. */
  55689. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55690. /**
  55691. * Fired when the touchpad values on this controller are modified
  55692. */
  55693. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55694. protected _updateTrackpad(): void;
  55695. /**
  55696. * Called once per frame by the engine.
  55697. */
  55698. update(): void;
  55699. /**
  55700. * Called once for each button that changed state since the last frame
  55701. * @param buttonIdx Which button index changed
  55702. * @param state New state of the button
  55703. * @param changes Which properties on the state changed since last frame
  55704. */
  55705. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55706. /**
  55707. * Moves the buttons on the controller mesh based on their current state
  55708. * @param buttonName the name of the button to move
  55709. * @param buttonValue the value of the button which determines the buttons new position
  55710. */
  55711. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55712. /**
  55713. * Moves the axis on the controller mesh based on its current state
  55714. * @param axis the index of the axis
  55715. * @param axisValue the value of the axis which determines the meshes new position
  55716. * @hidden
  55717. */
  55718. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55719. /**
  55720. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55721. * @param scene scene in which to add meshes
  55722. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55723. */
  55724. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55725. /**
  55726. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55727. * can be transformed by button presses and axes values, based on this._mapping.
  55728. *
  55729. * @param scene scene in which the meshes exist
  55730. * @param meshes list of meshes that make up the controller model to process
  55731. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55732. */
  55733. private processModel;
  55734. private createMeshInfo;
  55735. /**
  55736. * Gets the ray of the controller in the direction the controller is pointing
  55737. * @param length the length the resulting ray should be
  55738. * @returns a ray in the direction the controller is pointing
  55739. */
  55740. getForwardRay(length?: number): Ray;
  55741. /**
  55742. * Disposes of the controller
  55743. */
  55744. dispose(): void;
  55745. }
  55746. /**
  55747. * This class represents a new windows motion controller in XR.
  55748. */
  55749. export class XRWindowsMotionController extends WindowsMotionController {
  55750. /**
  55751. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55752. */
  55753. protected readonly _mapping: {
  55754. buttons: string[];
  55755. buttonMeshNames: {
  55756. trigger: string;
  55757. menu: string;
  55758. grip: string;
  55759. thumbstick: string;
  55760. trackpad: string;
  55761. };
  55762. buttonObservableNames: {
  55763. trigger: string;
  55764. menu: string;
  55765. grip: string;
  55766. thumbstick: string;
  55767. trackpad: string;
  55768. };
  55769. axisMeshNames: string[];
  55770. pointingPoseMeshName: string;
  55771. };
  55772. /**
  55773. * Construct a new XR-Based windows motion controller
  55774. *
  55775. * @param gamepadInfo the gamepad object from the browser
  55776. */
  55777. constructor(gamepadInfo: any);
  55778. /**
  55779. * holds the thumbstick values (X,Y)
  55780. */
  55781. thumbstickValues: StickValues;
  55782. /**
  55783. * Fired when the thumbstick on this controller is clicked
  55784. */
  55785. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55786. /**
  55787. * Fired when the thumbstick on this controller is modified
  55788. */
  55789. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55790. /**
  55791. * Fired when the touchpad button on this controller is modified
  55792. */
  55793. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55794. /**
  55795. * Fired when the touchpad values on this controller are modified
  55796. */
  55797. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55798. /**
  55799. * Fired when the thumbstick button on this controller is modified
  55800. * here to prevent breaking changes
  55801. */
  55802. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55803. /**
  55804. * updating the thumbstick(!) and not the trackpad.
  55805. * This is named this way due to the difference between WebVR and XR and to avoid
  55806. * changing the parent class.
  55807. */
  55808. protected _updateTrackpad(): void;
  55809. /**
  55810. * Disposes the class with joy
  55811. */
  55812. dispose(): void;
  55813. }
  55814. }
  55815. declare module "babylonjs/Gamepads/Controllers/index" {
  55816. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55817. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55818. export * from "babylonjs/Gamepads/Controllers/genericController";
  55819. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55820. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55821. export * from "babylonjs/Gamepads/Controllers/viveController";
  55822. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55823. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55824. }
  55825. declare module "babylonjs/Gamepads/index" {
  55826. export * from "babylonjs/Gamepads/Controllers/index";
  55827. export * from "babylonjs/Gamepads/gamepad";
  55828. export * from "babylonjs/Gamepads/gamepadManager";
  55829. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55830. export * from "babylonjs/Gamepads/xboxGamepad";
  55831. export * from "babylonjs/Gamepads/dualShockGamepad";
  55832. }
  55833. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55834. import { Scene } from "babylonjs/scene";
  55835. import { Vector4 } from "babylonjs/Maths/math.vector";
  55836. import { Color4 } from "babylonjs/Maths/math.color";
  55837. import { Mesh } from "babylonjs/Meshes/mesh";
  55838. import { Nullable } from "babylonjs/types";
  55839. /**
  55840. * Class containing static functions to help procedurally build meshes
  55841. */
  55842. export class PolyhedronBuilder {
  55843. /**
  55844. * Creates a polyhedron mesh
  55845. * * 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
  55846. * * The parameter `size` (positive float, default 1) sets the polygon size
  55847. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55848. * * 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`
  55849. * * 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
  55850. * * 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)`)
  55851. * * 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
  55852. * * 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
  55853. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55854. * * 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
  55855. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55856. * @param name defines the name of the mesh
  55857. * @param options defines the options used to create the mesh
  55858. * @param scene defines the hosting scene
  55859. * @returns the polyhedron mesh
  55860. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55861. */
  55862. static CreatePolyhedron(name: string, options: {
  55863. type?: number;
  55864. size?: number;
  55865. sizeX?: number;
  55866. sizeY?: number;
  55867. sizeZ?: number;
  55868. custom?: any;
  55869. faceUV?: Vector4[];
  55870. faceColors?: Color4[];
  55871. flat?: boolean;
  55872. updatable?: boolean;
  55873. sideOrientation?: number;
  55874. frontUVs?: Vector4;
  55875. backUVs?: Vector4;
  55876. }, scene?: Nullable<Scene>): Mesh;
  55877. }
  55878. }
  55879. declare module "babylonjs/Gizmos/scaleGizmo" {
  55880. import { Observable } from "babylonjs/Misc/observable";
  55881. import { Nullable } from "babylonjs/types";
  55882. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55883. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55884. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  55885. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55886. import { Node } from "babylonjs/node";
  55887. /**
  55888. * Gizmo that enables scaling a mesh along 3 axis
  55889. */
  55890. export class ScaleGizmo extends Gizmo {
  55891. /**
  55892. * Internal gizmo used for interactions on the x axis
  55893. */
  55894. xGizmo: AxisScaleGizmo;
  55895. /**
  55896. * Internal gizmo used for interactions on the y axis
  55897. */
  55898. yGizmo: AxisScaleGizmo;
  55899. /**
  55900. * Internal gizmo used for interactions on the z axis
  55901. */
  55902. zGizmo: AxisScaleGizmo;
  55903. /**
  55904. * Internal gizmo used to scale all axis equally
  55905. */
  55906. uniformScaleGizmo: AxisScaleGizmo;
  55907. private _meshAttached;
  55908. private _nodeAttached;
  55909. private _snapDistance;
  55910. private _uniformScalingMesh;
  55911. private _octahedron;
  55912. private _sensitivity;
  55913. /** Fires an event when any of it's sub gizmos are dragged */
  55914. onDragStartObservable: Observable<unknown>;
  55915. /** Fires an event when any of it's sub gizmos are released from dragging */
  55916. onDragEndObservable: Observable<unknown>;
  55917. get attachedMesh(): Nullable<AbstractMesh>;
  55918. set attachedMesh(mesh: Nullable<AbstractMesh>);
  55919. get attachedNode(): Nullable<Node>;
  55920. set attachedNode(node: Nullable<Node>);
  55921. /**
  55922. * Creates a ScaleGizmo
  55923. * @param gizmoLayer The utility layer the gizmo will be added to
  55924. * @param thickness display gizmo axis thickness
  55925. */
  55926. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  55927. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  55928. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  55929. /**
  55930. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55931. */
  55932. set snapDistance(value: number);
  55933. get snapDistance(): number;
  55934. /**
  55935. * Ratio for the scale of the gizmo (Default: 1)
  55936. */
  55937. set scaleRatio(value: number);
  55938. get scaleRatio(): number;
  55939. /**
  55940. * Sensitivity factor for dragging (Default: 1)
  55941. */
  55942. set sensitivity(value: number);
  55943. get sensitivity(): number;
  55944. /**
  55945. * Disposes of the gizmo
  55946. */
  55947. dispose(): void;
  55948. }
  55949. }
  55950. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  55951. import { Observable } from "babylonjs/Misc/observable";
  55952. import { Nullable } from "babylonjs/types";
  55953. import { Vector3 } from "babylonjs/Maths/math.vector";
  55954. import { Node } from "babylonjs/node";
  55955. import { Mesh } from "babylonjs/Meshes/mesh";
  55956. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  55957. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  55958. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  55959. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  55960. import { Color3 } from "babylonjs/Maths/math.color";
  55961. /**
  55962. * Single axis scale gizmo
  55963. */
  55964. export class AxisScaleGizmo extends Gizmo {
  55965. /**
  55966. * Drag behavior responsible for the gizmos dragging interactions
  55967. */
  55968. dragBehavior: PointerDragBehavior;
  55969. private _pointerObserver;
  55970. /**
  55971. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  55972. */
  55973. snapDistance: number;
  55974. /**
  55975. * Event that fires each time the gizmo snaps to a new location.
  55976. * * snapDistance is the the change in distance
  55977. */
  55978. onSnapObservable: Observable<{
  55979. snapDistance: number;
  55980. }>;
  55981. /**
  55982. * If the scaling operation should be done on all axis (default: false)
  55983. */
  55984. uniformScaling: boolean;
  55985. /**
  55986. * Custom sensitivity value for the drag strength
  55987. */
  55988. sensitivity: number;
  55989. private _isEnabled;
  55990. private _parent;
  55991. private _arrow;
  55992. private _coloredMaterial;
  55993. private _hoverMaterial;
  55994. /**
  55995. * Creates an AxisScaleGizmo
  55996. * @param gizmoLayer The utility layer the gizmo will be added to
  55997. * @param dragAxis The axis which the gizmo will be able to scale on
  55998. * @param color The color of the gizmo
  55999. * @param thickness display gizmo axis thickness
  56000. */
  56001. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56002. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56003. /**
  56004. * If the gizmo is enabled
  56005. */
  56006. set isEnabled(value: boolean);
  56007. get isEnabled(): boolean;
  56008. /**
  56009. * Disposes of the gizmo
  56010. */
  56011. dispose(): void;
  56012. /**
  56013. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56014. * @param mesh The mesh to replace the default mesh of the gizmo
  56015. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56016. */
  56017. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56018. }
  56019. }
  56020. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56021. import { Observable } from "babylonjs/Misc/observable";
  56022. import { Nullable } from "babylonjs/types";
  56023. import { Vector3 } from "babylonjs/Maths/math.vector";
  56024. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56025. import { Mesh } from "babylonjs/Meshes/mesh";
  56026. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56027. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56028. import { Color3 } from "babylonjs/Maths/math.color";
  56029. import "babylonjs/Meshes/Builders/boxBuilder";
  56030. /**
  56031. * Bounding box gizmo
  56032. */
  56033. export class BoundingBoxGizmo extends Gizmo {
  56034. private _lineBoundingBox;
  56035. private _rotateSpheresParent;
  56036. private _scaleBoxesParent;
  56037. private _boundingDimensions;
  56038. private _renderObserver;
  56039. private _pointerObserver;
  56040. private _scaleDragSpeed;
  56041. private _tmpQuaternion;
  56042. private _tmpVector;
  56043. private _tmpRotationMatrix;
  56044. /**
  56045. * 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)
  56046. */
  56047. ignoreChildren: boolean;
  56048. /**
  56049. * 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)
  56050. */
  56051. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56052. /**
  56053. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56054. */
  56055. rotationSphereSize: number;
  56056. /**
  56057. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56058. */
  56059. scaleBoxSize: number;
  56060. /**
  56061. * 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)
  56062. */
  56063. fixedDragMeshScreenSize: boolean;
  56064. /**
  56065. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56066. */
  56067. fixedDragMeshScreenSizeDistanceFactor: number;
  56068. /**
  56069. * Fired when a rotation sphere or scale box is dragged
  56070. */
  56071. onDragStartObservable: Observable<{}>;
  56072. /**
  56073. * Fired when a scale box is dragged
  56074. */
  56075. onScaleBoxDragObservable: Observable<{}>;
  56076. /**
  56077. * Fired when a scale box drag is ended
  56078. */
  56079. onScaleBoxDragEndObservable: Observable<{}>;
  56080. /**
  56081. * Fired when a rotation sphere is dragged
  56082. */
  56083. onRotationSphereDragObservable: Observable<{}>;
  56084. /**
  56085. * Fired when a rotation sphere drag is ended
  56086. */
  56087. onRotationSphereDragEndObservable: Observable<{}>;
  56088. /**
  56089. * Relative bounding box pivot used when scaling the attached node. 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)
  56090. */
  56091. scalePivot: Nullable<Vector3>;
  56092. /**
  56093. * Mesh used as a pivot to rotate the attached node
  56094. */
  56095. private _anchorMesh;
  56096. private _existingMeshScale;
  56097. private _dragMesh;
  56098. private pointerDragBehavior;
  56099. private coloredMaterial;
  56100. private hoverColoredMaterial;
  56101. /**
  56102. * Sets the color of the bounding box gizmo
  56103. * @param color the color to set
  56104. */
  56105. setColor(color: Color3): void;
  56106. /**
  56107. * Creates an BoundingBoxGizmo
  56108. * @param gizmoLayer The utility layer the gizmo will be added to
  56109. * @param color The color of the gizmo
  56110. */
  56111. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56112. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56113. private _selectNode;
  56114. /**
  56115. * Updates the bounding box information for the Gizmo
  56116. */
  56117. updateBoundingBox(): void;
  56118. private _updateRotationSpheres;
  56119. private _updateScaleBoxes;
  56120. /**
  56121. * Enables rotation on the specified axis and disables rotation on the others
  56122. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56123. */
  56124. setEnabledRotationAxis(axis: string): void;
  56125. /**
  56126. * Enables/disables scaling
  56127. * @param enable if scaling should be enabled
  56128. * @param homogeneousScaling defines if scaling should only be homogeneous
  56129. */
  56130. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56131. private _updateDummy;
  56132. /**
  56133. * Enables a pointer drag behavior on the bounding box of the gizmo
  56134. */
  56135. enableDragBehavior(): void;
  56136. /**
  56137. * Disposes of the gizmo
  56138. */
  56139. dispose(): void;
  56140. /**
  56141. * 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)
  56142. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56143. * @returns the bounding box mesh with the passed in mesh as a child
  56144. */
  56145. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56146. /**
  56147. * CustomMeshes are not supported by this gizmo
  56148. * @param mesh The mesh to replace the default mesh of the gizmo
  56149. */
  56150. setCustomMesh(mesh: Mesh): void;
  56151. }
  56152. }
  56153. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56154. import { Observable } from "babylonjs/Misc/observable";
  56155. import { Nullable } from "babylonjs/types";
  56156. import { Vector3 } from "babylonjs/Maths/math.vector";
  56157. import { Color3 } from "babylonjs/Maths/math.color";
  56158. import { Node } from "babylonjs/node";
  56159. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56160. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56161. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56162. import "babylonjs/Meshes/Builders/linesBuilder";
  56163. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56164. /**
  56165. * Single plane rotation gizmo
  56166. */
  56167. export class PlaneRotationGizmo extends Gizmo {
  56168. /**
  56169. * Drag behavior responsible for the gizmos dragging interactions
  56170. */
  56171. dragBehavior: PointerDragBehavior;
  56172. private _pointerObserver;
  56173. /**
  56174. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56175. */
  56176. snapDistance: number;
  56177. /**
  56178. * Event that fires each time the gizmo snaps to a new location.
  56179. * * snapDistance is the the change in distance
  56180. */
  56181. onSnapObservable: Observable<{
  56182. snapDistance: number;
  56183. }>;
  56184. private _isEnabled;
  56185. private _parent;
  56186. /**
  56187. * Creates a PlaneRotationGizmo
  56188. * @param gizmoLayer The utility layer the gizmo will be added to
  56189. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56190. * @param color The color of the gizmo
  56191. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56192. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56193. * @param thickness display gizmo axis thickness
  56194. */
  56195. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56196. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56197. /**
  56198. * If the gizmo is enabled
  56199. */
  56200. set isEnabled(value: boolean);
  56201. get isEnabled(): boolean;
  56202. /**
  56203. * Disposes of the gizmo
  56204. */
  56205. dispose(): void;
  56206. }
  56207. }
  56208. declare module "babylonjs/Gizmos/rotationGizmo" {
  56209. import { Observable } from "babylonjs/Misc/observable";
  56210. import { Nullable } from "babylonjs/types";
  56211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56212. import { Mesh } from "babylonjs/Meshes/mesh";
  56213. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56214. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56215. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56216. import { Node } from "babylonjs/node";
  56217. /**
  56218. * Gizmo that enables rotating a mesh along 3 axis
  56219. */
  56220. export class RotationGizmo extends Gizmo {
  56221. /**
  56222. * Internal gizmo used for interactions on the x axis
  56223. */
  56224. xGizmo: PlaneRotationGizmo;
  56225. /**
  56226. * Internal gizmo used for interactions on the y axis
  56227. */
  56228. yGizmo: PlaneRotationGizmo;
  56229. /**
  56230. * Internal gizmo used for interactions on the z axis
  56231. */
  56232. zGizmo: PlaneRotationGizmo;
  56233. /** Fires an event when any of it's sub gizmos are dragged */
  56234. onDragStartObservable: Observable<unknown>;
  56235. /** Fires an event when any of it's sub gizmos are released from dragging */
  56236. onDragEndObservable: Observable<unknown>;
  56237. private _meshAttached;
  56238. private _nodeAttached;
  56239. get attachedMesh(): Nullable<AbstractMesh>;
  56240. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56241. get attachedNode(): Nullable<Node>;
  56242. set attachedNode(node: Nullable<Node>);
  56243. /**
  56244. * Creates a RotationGizmo
  56245. * @param gizmoLayer The utility layer the gizmo will be added to
  56246. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56247. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56248. * @param thickness display gizmo axis thickness
  56249. */
  56250. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56251. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56252. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56253. /**
  56254. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56255. */
  56256. set snapDistance(value: number);
  56257. get snapDistance(): number;
  56258. /**
  56259. * Ratio for the scale of the gizmo (Default: 1)
  56260. */
  56261. set scaleRatio(value: number);
  56262. get scaleRatio(): number;
  56263. /**
  56264. * Disposes of the gizmo
  56265. */
  56266. dispose(): void;
  56267. /**
  56268. * CustomMeshes are not supported by this gizmo
  56269. * @param mesh The mesh to replace the default mesh of the gizmo
  56270. */
  56271. setCustomMesh(mesh: Mesh): void;
  56272. }
  56273. }
  56274. declare module "babylonjs/Gizmos/gizmoManager" {
  56275. import { Observable } from "babylonjs/Misc/observable";
  56276. import { Nullable } from "babylonjs/types";
  56277. import { Scene, IDisposable } from "babylonjs/scene";
  56278. import { Node } from "babylonjs/node";
  56279. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56280. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56281. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56282. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56283. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56284. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56285. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56286. /**
  56287. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56288. */
  56289. export class GizmoManager implements IDisposable {
  56290. private scene;
  56291. /**
  56292. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56293. */
  56294. gizmos: {
  56295. positionGizmo: Nullable<PositionGizmo>;
  56296. rotationGizmo: Nullable<RotationGizmo>;
  56297. scaleGizmo: Nullable<ScaleGizmo>;
  56298. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56299. };
  56300. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56301. clearGizmoOnEmptyPointerEvent: boolean;
  56302. /** Fires an event when the manager is attached to a mesh */
  56303. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56304. /** Fires an event when the manager is attached to a node */
  56305. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56306. private _gizmosEnabled;
  56307. private _pointerObserver;
  56308. private _attachedMesh;
  56309. private _attachedNode;
  56310. private _boundingBoxColor;
  56311. private _defaultUtilityLayer;
  56312. private _defaultKeepDepthUtilityLayer;
  56313. private _thickness;
  56314. /**
  56315. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56316. */
  56317. boundingBoxDragBehavior: SixDofDragBehavior;
  56318. /**
  56319. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56320. */
  56321. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56322. /**
  56323. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56324. */
  56325. attachableNodes: Nullable<Array<Node>>;
  56326. /**
  56327. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56328. */
  56329. usePointerToAttachGizmos: boolean;
  56330. /**
  56331. * Utility layer that the bounding box gizmo belongs to
  56332. */
  56333. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56334. /**
  56335. * Utility layer that all gizmos besides bounding box belong to
  56336. */
  56337. get utilityLayer(): UtilityLayerRenderer;
  56338. /**
  56339. * Instatiates a gizmo manager
  56340. * @param scene the scene to overlay the gizmos on top of
  56341. * @param thickness display gizmo axis thickness
  56342. */
  56343. constructor(scene: Scene, thickness?: number);
  56344. /**
  56345. * Attaches a set of gizmos to the specified mesh
  56346. * @param mesh The mesh the gizmo's should be attached to
  56347. */
  56348. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56349. /**
  56350. * Attaches a set of gizmos to the specified node
  56351. * @param node The node the gizmo's should be attached to
  56352. */
  56353. attachToNode(node: Nullable<Node>): void;
  56354. /**
  56355. * If the position gizmo is enabled
  56356. */
  56357. set positionGizmoEnabled(value: boolean);
  56358. get positionGizmoEnabled(): boolean;
  56359. /**
  56360. * If the rotation gizmo is enabled
  56361. */
  56362. set rotationGizmoEnabled(value: boolean);
  56363. get rotationGizmoEnabled(): boolean;
  56364. /**
  56365. * If the scale gizmo is enabled
  56366. */
  56367. set scaleGizmoEnabled(value: boolean);
  56368. get scaleGizmoEnabled(): boolean;
  56369. /**
  56370. * If the boundingBox gizmo is enabled
  56371. */
  56372. set boundingBoxGizmoEnabled(value: boolean);
  56373. get boundingBoxGizmoEnabled(): boolean;
  56374. /**
  56375. * Disposes of the gizmo manager
  56376. */
  56377. dispose(): void;
  56378. }
  56379. }
  56380. declare module "babylonjs/Lights/directionalLight" {
  56381. import { Camera } from "babylonjs/Cameras/camera";
  56382. import { Scene } from "babylonjs/scene";
  56383. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56385. import { Light } from "babylonjs/Lights/light";
  56386. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56387. import { Effect } from "babylonjs/Materials/effect";
  56388. /**
  56389. * A directional light is defined by a direction (what a surprise!).
  56390. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56391. * 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.
  56392. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56393. */
  56394. export class DirectionalLight extends ShadowLight {
  56395. private _shadowFrustumSize;
  56396. /**
  56397. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56398. */
  56399. get shadowFrustumSize(): number;
  56400. /**
  56401. * Specifies a fix frustum size for the shadow generation.
  56402. */
  56403. set shadowFrustumSize(value: number);
  56404. private _shadowOrthoScale;
  56405. /**
  56406. * Gets the shadow projection scale against the optimal computed one.
  56407. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56408. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56409. */
  56410. get shadowOrthoScale(): number;
  56411. /**
  56412. * Sets the shadow projection scale against the optimal computed one.
  56413. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56414. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56415. */
  56416. set shadowOrthoScale(value: number);
  56417. /**
  56418. * Automatically compute the projection matrix to best fit (including all the casters)
  56419. * on each frame.
  56420. */
  56421. autoUpdateExtends: boolean;
  56422. /**
  56423. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56424. * on each frame. autoUpdateExtends must be set to true for this to work
  56425. */
  56426. autoCalcShadowZBounds: boolean;
  56427. private _orthoLeft;
  56428. private _orthoRight;
  56429. private _orthoTop;
  56430. private _orthoBottom;
  56431. /**
  56432. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56433. * The directional light is emitted from everywhere in the given direction.
  56434. * It can cast shadows.
  56435. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56436. * @param name The friendly name of the light
  56437. * @param direction The direction of the light
  56438. * @param scene The scene the light belongs to
  56439. */
  56440. constructor(name: string, direction: Vector3, scene: Scene);
  56441. /**
  56442. * Returns the string "DirectionalLight".
  56443. * @return The class name
  56444. */
  56445. getClassName(): string;
  56446. /**
  56447. * Returns the integer 1.
  56448. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56449. */
  56450. getTypeID(): number;
  56451. /**
  56452. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56453. * Returns the DirectionalLight Shadow projection matrix.
  56454. */
  56455. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56456. /**
  56457. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56458. * Returns the DirectionalLight Shadow projection matrix.
  56459. */
  56460. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56461. /**
  56462. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56463. * Returns the DirectionalLight Shadow projection matrix.
  56464. */
  56465. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56466. protected _buildUniformLayout(): void;
  56467. /**
  56468. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56469. * @param effect The effect to update
  56470. * @param lightIndex The index of the light in the effect to update
  56471. * @returns The directional light
  56472. */
  56473. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56474. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56475. /**
  56476. * Gets the minZ used for shadow according to both the scene and the light.
  56477. *
  56478. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56479. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56480. * @param activeCamera The camera we are returning the min for
  56481. * @returns the depth min z
  56482. */
  56483. getDepthMinZ(activeCamera: Camera): number;
  56484. /**
  56485. * Gets the maxZ used for shadow according to both the scene and the light.
  56486. *
  56487. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56488. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56489. * @param activeCamera The camera we are returning the max for
  56490. * @returns the depth max z
  56491. */
  56492. getDepthMaxZ(activeCamera: Camera): number;
  56493. /**
  56494. * Prepares the list of defines specific to the light type.
  56495. * @param defines the list of defines
  56496. * @param lightIndex defines the index of the light for the effect
  56497. */
  56498. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56499. }
  56500. }
  56501. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56502. import { Mesh } from "babylonjs/Meshes/mesh";
  56503. /**
  56504. * Class containing static functions to help procedurally build meshes
  56505. */
  56506. export class HemisphereBuilder {
  56507. /**
  56508. * Creates a hemisphere mesh
  56509. * @param name defines the name of the mesh
  56510. * @param options defines the options used to create the mesh
  56511. * @param scene defines the hosting scene
  56512. * @returns the hemisphere mesh
  56513. */
  56514. static CreateHemisphere(name: string, options: {
  56515. segments?: number;
  56516. diameter?: number;
  56517. sideOrientation?: number;
  56518. }, scene: any): Mesh;
  56519. }
  56520. }
  56521. declare module "babylonjs/Lights/spotLight" {
  56522. import { Nullable } from "babylonjs/types";
  56523. import { Scene } from "babylonjs/scene";
  56524. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56526. import { Effect } from "babylonjs/Materials/effect";
  56527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56528. import { Light } from "babylonjs/Lights/light";
  56529. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56530. /**
  56531. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56532. * These values define a cone of light starting from the position, emitting toward the direction.
  56533. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56534. * and the exponent defines the speed of the decay of the light with distance (reach).
  56535. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56536. */
  56537. export class SpotLight extends ShadowLight {
  56538. private _angle;
  56539. private _innerAngle;
  56540. private _cosHalfAngle;
  56541. private _lightAngleScale;
  56542. private _lightAngleOffset;
  56543. /**
  56544. * Gets the cone angle of the spot light in Radians.
  56545. */
  56546. get angle(): number;
  56547. /**
  56548. * Sets the cone angle of the spot light in Radians.
  56549. */
  56550. set angle(value: number);
  56551. /**
  56552. * Only used in gltf falloff mode, this defines the angle where
  56553. * the directional falloff will start before cutting at angle which could be seen
  56554. * as outer angle.
  56555. */
  56556. get innerAngle(): number;
  56557. /**
  56558. * Only used in gltf falloff mode, this defines the angle where
  56559. * the directional falloff will start before cutting at angle which could be seen
  56560. * as outer angle.
  56561. */
  56562. set innerAngle(value: number);
  56563. private _shadowAngleScale;
  56564. /**
  56565. * Allows scaling the angle of the light for shadow generation only.
  56566. */
  56567. get shadowAngleScale(): number;
  56568. /**
  56569. * Allows scaling the angle of the light for shadow generation only.
  56570. */
  56571. set shadowAngleScale(value: number);
  56572. /**
  56573. * The light decay speed with the distance from the emission spot.
  56574. */
  56575. exponent: number;
  56576. private _projectionTextureMatrix;
  56577. /**
  56578. * Allows reading the projecton texture
  56579. */
  56580. get projectionTextureMatrix(): Matrix;
  56581. protected _projectionTextureLightNear: number;
  56582. /**
  56583. * Gets the near clip of the Spotlight for texture projection.
  56584. */
  56585. get projectionTextureLightNear(): number;
  56586. /**
  56587. * Sets the near clip of the Spotlight for texture projection.
  56588. */
  56589. set projectionTextureLightNear(value: number);
  56590. protected _projectionTextureLightFar: number;
  56591. /**
  56592. * Gets the far clip of the Spotlight for texture projection.
  56593. */
  56594. get projectionTextureLightFar(): number;
  56595. /**
  56596. * Sets the far clip of the Spotlight for texture projection.
  56597. */
  56598. set projectionTextureLightFar(value: number);
  56599. protected _projectionTextureUpDirection: Vector3;
  56600. /**
  56601. * Gets the Up vector of the Spotlight for texture projection.
  56602. */
  56603. get projectionTextureUpDirection(): Vector3;
  56604. /**
  56605. * Sets the Up vector of the Spotlight for texture projection.
  56606. */
  56607. set projectionTextureUpDirection(value: Vector3);
  56608. private _projectionTexture;
  56609. /**
  56610. * Gets the projection texture of the light.
  56611. */
  56612. get projectionTexture(): Nullable<BaseTexture>;
  56613. /**
  56614. * Sets the projection texture of the light.
  56615. */
  56616. set projectionTexture(value: Nullable<BaseTexture>);
  56617. private _projectionTextureViewLightDirty;
  56618. private _projectionTextureProjectionLightDirty;
  56619. private _projectionTextureDirty;
  56620. private _projectionTextureViewTargetVector;
  56621. private _projectionTextureViewLightMatrix;
  56622. private _projectionTextureProjectionLightMatrix;
  56623. private _projectionTextureScalingMatrix;
  56624. /**
  56625. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56626. * It can cast shadows.
  56627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56628. * @param name The light friendly name
  56629. * @param position The position of the spot light in the scene
  56630. * @param direction The direction of the light in the scene
  56631. * @param angle The cone angle of the light in Radians
  56632. * @param exponent The light decay speed with the distance from the emission spot
  56633. * @param scene The scene the lights belongs to
  56634. */
  56635. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56636. /**
  56637. * Returns the string "SpotLight".
  56638. * @returns the class name
  56639. */
  56640. getClassName(): string;
  56641. /**
  56642. * Returns the integer 2.
  56643. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56644. */
  56645. getTypeID(): number;
  56646. /**
  56647. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56648. */
  56649. protected _setDirection(value: Vector3): void;
  56650. /**
  56651. * Overrides the position setter to recompute the projection texture view light Matrix.
  56652. */
  56653. protected _setPosition(value: Vector3): void;
  56654. /**
  56655. * 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.
  56656. * Returns the SpotLight.
  56657. */
  56658. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56659. protected _computeProjectionTextureViewLightMatrix(): void;
  56660. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56661. /**
  56662. * Main function for light texture projection matrix computing.
  56663. */
  56664. protected _computeProjectionTextureMatrix(): void;
  56665. protected _buildUniformLayout(): void;
  56666. private _computeAngleValues;
  56667. /**
  56668. * Sets the passed Effect "effect" with the Light textures.
  56669. * @param effect The effect to update
  56670. * @param lightIndex The index of the light in the effect to update
  56671. * @returns The light
  56672. */
  56673. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56674. /**
  56675. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56676. * @param effect The effect to update
  56677. * @param lightIndex The index of the light in the effect to update
  56678. * @returns The spot light
  56679. */
  56680. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56681. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56682. /**
  56683. * Disposes the light and the associated resources.
  56684. */
  56685. dispose(): void;
  56686. /**
  56687. * Prepares the list of defines specific to the light type.
  56688. * @param defines the list of defines
  56689. * @param lightIndex defines the index of the light for the effect
  56690. */
  56691. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56692. }
  56693. }
  56694. declare module "babylonjs/Gizmos/lightGizmo" {
  56695. import { Nullable } from "babylonjs/types";
  56696. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56697. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56698. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56699. import { Light } from "babylonjs/Lights/light";
  56700. import { Observable } from "babylonjs/Misc/observable";
  56701. /**
  56702. * Gizmo that enables viewing a light
  56703. */
  56704. export class LightGizmo extends Gizmo {
  56705. private _lightMesh;
  56706. private _material;
  56707. private _cachedPosition;
  56708. private _cachedForward;
  56709. private _attachedMeshParent;
  56710. private _pointerObserver;
  56711. /**
  56712. * Event that fires each time the gizmo is clicked
  56713. */
  56714. onClickedObservable: Observable<Light>;
  56715. /**
  56716. * Creates a LightGizmo
  56717. * @param gizmoLayer The utility layer the gizmo will be added to
  56718. */
  56719. constructor(gizmoLayer?: UtilityLayerRenderer);
  56720. private _light;
  56721. /**
  56722. * The light that the gizmo is attached to
  56723. */
  56724. set light(light: Nullable<Light>);
  56725. get light(): Nullable<Light>;
  56726. /**
  56727. * Gets the material used to render the light gizmo
  56728. */
  56729. get material(): StandardMaterial;
  56730. /**
  56731. * @hidden
  56732. * Updates the gizmo to match the attached mesh's position/rotation
  56733. */
  56734. protected _update(): void;
  56735. private static _Scale;
  56736. /**
  56737. * Creates the lines for a light mesh
  56738. */
  56739. private static _CreateLightLines;
  56740. /**
  56741. * Disposes of the light gizmo
  56742. */
  56743. dispose(): void;
  56744. private static _CreateHemisphericLightMesh;
  56745. private static _CreatePointLightMesh;
  56746. private static _CreateSpotLightMesh;
  56747. private static _CreateDirectionalLightMesh;
  56748. }
  56749. }
  56750. declare module "babylonjs/Gizmos/cameraGizmo" {
  56751. import { Nullable } from "babylonjs/types";
  56752. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56753. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56754. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56755. import { Camera } from "babylonjs/Cameras/camera";
  56756. import { Observable } from "babylonjs/Misc/observable";
  56757. /**
  56758. * Gizmo that enables viewing a camera
  56759. */
  56760. export class CameraGizmo extends Gizmo {
  56761. private _cameraMesh;
  56762. private _cameraLinesMesh;
  56763. private _material;
  56764. private _pointerObserver;
  56765. /**
  56766. * Event that fires each time the gizmo is clicked
  56767. */
  56768. onClickedObservable: Observable<Camera>;
  56769. /**
  56770. * Creates a CameraGizmo
  56771. * @param gizmoLayer The utility layer the gizmo will be added to
  56772. */
  56773. constructor(gizmoLayer?: UtilityLayerRenderer);
  56774. private _camera;
  56775. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56776. get displayFrustum(): boolean;
  56777. set displayFrustum(value: boolean);
  56778. /**
  56779. * The camera that the gizmo is attached to
  56780. */
  56781. set camera(camera: Nullable<Camera>);
  56782. get camera(): Nullable<Camera>;
  56783. /**
  56784. * Gets the material used to render the camera gizmo
  56785. */
  56786. get material(): StandardMaterial;
  56787. /**
  56788. * @hidden
  56789. * Updates the gizmo to match the attached mesh's position/rotation
  56790. */
  56791. protected _update(): void;
  56792. private static _Scale;
  56793. private _invProjection;
  56794. /**
  56795. * Disposes of the camera gizmo
  56796. */
  56797. dispose(): void;
  56798. private static _CreateCameraMesh;
  56799. private static _CreateCameraFrustum;
  56800. }
  56801. }
  56802. declare module "babylonjs/Gizmos/index" {
  56803. export * from "babylonjs/Gizmos/axisDragGizmo";
  56804. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56805. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56806. export * from "babylonjs/Gizmos/gizmo";
  56807. export * from "babylonjs/Gizmos/gizmoManager";
  56808. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56809. export * from "babylonjs/Gizmos/positionGizmo";
  56810. export * from "babylonjs/Gizmos/rotationGizmo";
  56811. export * from "babylonjs/Gizmos/scaleGizmo";
  56812. export * from "babylonjs/Gizmos/lightGizmo";
  56813. export * from "babylonjs/Gizmos/cameraGizmo";
  56814. export * from "babylonjs/Gizmos/planeDragGizmo";
  56815. }
  56816. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56817. /** @hidden */
  56818. export var backgroundFragmentDeclaration: {
  56819. name: string;
  56820. shader: string;
  56821. };
  56822. }
  56823. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56824. /** @hidden */
  56825. export var backgroundUboDeclaration: {
  56826. name: string;
  56827. shader: string;
  56828. };
  56829. }
  56830. declare module "babylonjs/Shaders/background.fragment" {
  56831. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56832. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56833. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56834. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56835. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56836. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56837. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56838. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56839. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56840. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56841. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  56842. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56843. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  56844. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56845. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  56846. /** @hidden */
  56847. export var backgroundPixelShader: {
  56848. name: string;
  56849. shader: string;
  56850. };
  56851. }
  56852. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  56853. /** @hidden */
  56854. export var backgroundVertexDeclaration: {
  56855. name: string;
  56856. shader: string;
  56857. };
  56858. }
  56859. declare module "babylonjs/Shaders/background.vertex" {
  56860. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  56861. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56862. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56863. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56864. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56865. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  56866. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  56867. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56868. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56869. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56871. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  56872. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  56873. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56874. /** @hidden */
  56875. export var backgroundVertexShader: {
  56876. name: string;
  56877. shader: string;
  56878. };
  56879. }
  56880. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  56881. import { Nullable, int, float } from "babylonjs/types";
  56882. import { Scene } from "babylonjs/scene";
  56883. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56885. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56886. import { Mesh } from "babylonjs/Meshes/mesh";
  56887. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  56888. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  56889. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  56890. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56891. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  56892. import { Color3 } from "babylonjs/Maths/math.color";
  56893. import "babylonjs/Shaders/background.fragment";
  56894. import "babylonjs/Shaders/background.vertex";
  56895. /**
  56896. * Background material used to create an efficient environement around your scene.
  56897. */
  56898. export class BackgroundMaterial extends PushMaterial {
  56899. /**
  56900. * Standard reflectance value at parallel view angle.
  56901. */
  56902. static StandardReflectance0: number;
  56903. /**
  56904. * Standard reflectance value at grazing angle.
  56905. */
  56906. static StandardReflectance90: number;
  56907. protected _primaryColor: Color3;
  56908. /**
  56909. * Key light Color (multiply against the environement texture)
  56910. */
  56911. primaryColor: Color3;
  56912. protected __perceptualColor: Nullable<Color3>;
  56913. /**
  56914. * Experimental Internal Use Only.
  56915. *
  56916. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  56917. * This acts as a helper to set the primary color to a more "human friendly" value.
  56918. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  56919. * output color as close as possible from the chosen value.
  56920. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  56921. * part of lighting setup.)
  56922. */
  56923. get _perceptualColor(): Nullable<Color3>;
  56924. set _perceptualColor(value: Nullable<Color3>);
  56925. protected _primaryColorShadowLevel: float;
  56926. /**
  56927. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  56928. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  56929. */
  56930. get primaryColorShadowLevel(): float;
  56931. set primaryColorShadowLevel(value: float);
  56932. protected _primaryColorHighlightLevel: float;
  56933. /**
  56934. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  56935. * The primary color is used at the level chosen to define what the white area would look.
  56936. */
  56937. get primaryColorHighlightLevel(): float;
  56938. set primaryColorHighlightLevel(value: float);
  56939. protected _reflectionTexture: Nullable<BaseTexture>;
  56940. /**
  56941. * Reflection Texture used in the material.
  56942. * Should be author in a specific way for the best result (refer to the documentation).
  56943. */
  56944. reflectionTexture: Nullable<BaseTexture>;
  56945. protected _reflectionBlur: float;
  56946. /**
  56947. * Reflection Texture level of blur.
  56948. *
  56949. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  56950. * texture twice.
  56951. */
  56952. reflectionBlur: float;
  56953. protected _diffuseTexture: Nullable<BaseTexture>;
  56954. /**
  56955. * Diffuse Texture used in the material.
  56956. * Should be author in a specific way for the best result (refer to the documentation).
  56957. */
  56958. diffuseTexture: Nullable<BaseTexture>;
  56959. protected _shadowLights: Nullable<IShadowLight[]>;
  56960. /**
  56961. * Specify the list of lights casting shadow on the material.
  56962. * All scene shadow lights will be included if null.
  56963. */
  56964. shadowLights: Nullable<IShadowLight[]>;
  56965. protected _shadowLevel: float;
  56966. /**
  56967. * Helps adjusting the shadow to a softer level if required.
  56968. * 0 means black shadows and 1 means no shadows.
  56969. */
  56970. shadowLevel: float;
  56971. protected _sceneCenter: Vector3;
  56972. /**
  56973. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  56974. * It is usually zero but might be interesting to modify according to your setup.
  56975. */
  56976. sceneCenter: Vector3;
  56977. protected _opacityFresnel: boolean;
  56978. /**
  56979. * This helps specifying that the material is falling off to the sky box at grazing angle.
  56980. * This helps ensuring a nice transition when the camera goes under the ground.
  56981. */
  56982. opacityFresnel: boolean;
  56983. protected _reflectionFresnel: boolean;
  56984. /**
  56985. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  56986. * This helps adding a mirror texture on the ground.
  56987. */
  56988. reflectionFresnel: boolean;
  56989. protected _reflectionFalloffDistance: number;
  56990. /**
  56991. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  56992. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  56993. */
  56994. reflectionFalloffDistance: number;
  56995. protected _reflectionAmount: number;
  56996. /**
  56997. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  56998. */
  56999. reflectionAmount: number;
  57000. protected _reflectionReflectance0: number;
  57001. /**
  57002. * This specifies the weight of the reflection at grazing angle.
  57003. */
  57004. reflectionReflectance0: number;
  57005. protected _reflectionReflectance90: number;
  57006. /**
  57007. * This specifies the weight of the reflection at a perpendicular point of view.
  57008. */
  57009. reflectionReflectance90: number;
  57010. /**
  57011. * Sets the reflection reflectance fresnel values according to the default standard
  57012. * empirically know to work well :-)
  57013. */
  57014. set reflectionStandardFresnelWeight(value: number);
  57015. protected _useRGBColor: boolean;
  57016. /**
  57017. * Helps to directly use the maps channels instead of their level.
  57018. */
  57019. useRGBColor: boolean;
  57020. protected _enableNoise: boolean;
  57021. /**
  57022. * This helps reducing the banding effect that could occur on the background.
  57023. */
  57024. enableNoise: boolean;
  57025. /**
  57026. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57027. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57028. * Recommended to be keep at 1.0 except for special cases.
  57029. */
  57030. get fovMultiplier(): number;
  57031. set fovMultiplier(value: number);
  57032. private _fovMultiplier;
  57033. /**
  57034. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57035. */
  57036. useEquirectangularFOV: boolean;
  57037. private _maxSimultaneousLights;
  57038. /**
  57039. * Number of Simultaneous lights allowed on the material.
  57040. */
  57041. maxSimultaneousLights: int;
  57042. private _shadowOnly;
  57043. /**
  57044. * Make the material only render shadows
  57045. */
  57046. shadowOnly: boolean;
  57047. /**
  57048. * Default configuration related to image processing available in the Background Material.
  57049. */
  57050. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57051. /**
  57052. * Keep track of the image processing observer to allow dispose and replace.
  57053. */
  57054. private _imageProcessingObserver;
  57055. /**
  57056. * Attaches a new image processing configuration to the PBR Material.
  57057. * @param configuration (if null the scene configuration will be use)
  57058. */
  57059. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57060. /**
  57061. * Gets the image processing configuration used either in this material.
  57062. */
  57063. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57064. /**
  57065. * Sets the Default image processing configuration used either in the this material.
  57066. *
  57067. * If sets to null, the scene one is in use.
  57068. */
  57069. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57070. /**
  57071. * Gets wether the color curves effect is enabled.
  57072. */
  57073. get cameraColorCurvesEnabled(): boolean;
  57074. /**
  57075. * Sets wether the color curves effect is enabled.
  57076. */
  57077. set cameraColorCurvesEnabled(value: boolean);
  57078. /**
  57079. * Gets wether the color grading effect is enabled.
  57080. */
  57081. get cameraColorGradingEnabled(): boolean;
  57082. /**
  57083. * Gets wether the color grading effect is enabled.
  57084. */
  57085. set cameraColorGradingEnabled(value: boolean);
  57086. /**
  57087. * Gets wether tonemapping is enabled or not.
  57088. */
  57089. get cameraToneMappingEnabled(): boolean;
  57090. /**
  57091. * Sets wether tonemapping is enabled or not
  57092. */
  57093. set cameraToneMappingEnabled(value: boolean);
  57094. /**
  57095. * The camera exposure used on this material.
  57096. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57097. * This corresponds to a photographic exposure.
  57098. */
  57099. get cameraExposure(): float;
  57100. /**
  57101. * The camera exposure used on this material.
  57102. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57103. * This corresponds to a photographic exposure.
  57104. */
  57105. set cameraExposure(value: float);
  57106. /**
  57107. * Gets The camera contrast used on this material.
  57108. */
  57109. get cameraContrast(): float;
  57110. /**
  57111. * Sets The camera contrast used on this material.
  57112. */
  57113. set cameraContrast(value: float);
  57114. /**
  57115. * Gets the Color Grading 2D Lookup Texture.
  57116. */
  57117. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57118. /**
  57119. * Sets the Color Grading 2D Lookup Texture.
  57120. */
  57121. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57122. /**
  57123. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57124. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57125. * 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;
  57126. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57127. */
  57128. get cameraColorCurves(): Nullable<ColorCurves>;
  57129. /**
  57130. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57131. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57132. * 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;
  57133. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57134. */
  57135. set cameraColorCurves(value: Nullable<ColorCurves>);
  57136. /**
  57137. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57138. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57139. */
  57140. switchToBGR: boolean;
  57141. private _renderTargets;
  57142. private _reflectionControls;
  57143. private _white;
  57144. private _primaryShadowColor;
  57145. private _primaryHighlightColor;
  57146. /**
  57147. * Instantiates a Background Material in the given scene
  57148. * @param name The friendly name of the material
  57149. * @param scene The scene to add the material to
  57150. */
  57151. constructor(name: string, scene: Scene);
  57152. /**
  57153. * Gets a boolean indicating that current material needs to register RTT
  57154. */
  57155. get hasRenderTargetTextures(): boolean;
  57156. /**
  57157. * The entire material has been created in order to prevent overdraw.
  57158. * @returns false
  57159. */
  57160. needAlphaTesting(): boolean;
  57161. /**
  57162. * The entire material has been created in order to prevent overdraw.
  57163. * @returns true if blending is enable
  57164. */
  57165. needAlphaBlending(): boolean;
  57166. /**
  57167. * Checks wether the material is ready to be rendered for a given mesh.
  57168. * @param mesh The mesh to render
  57169. * @param subMesh The submesh to check against
  57170. * @param useInstances Specify wether or not the material is used with instances
  57171. * @returns true if all the dependencies are ready (Textures, Effects...)
  57172. */
  57173. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57174. /**
  57175. * Compute the primary color according to the chosen perceptual color.
  57176. */
  57177. private _computePrimaryColorFromPerceptualColor;
  57178. /**
  57179. * Compute the highlights and shadow colors according to their chosen levels.
  57180. */
  57181. private _computePrimaryColors;
  57182. /**
  57183. * Build the uniform buffer used in the material.
  57184. */
  57185. buildUniformLayout(): void;
  57186. /**
  57187. * Unbind the material.
  57188. */
  57189. unbind(): void;
  57190. /**
  57191. * Bind only the world matrix to the material.
  57192. * @param world The world matrix to bind.
  57193. */
  57194. bindOnlyWorldMatrix(world: Matrix): void;
  57195. /**
  57196. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57197. * @param world The world matrix to bind.
  57198. * @param subMesh The submesh to bind for.
  57199. */
  57200. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57201. /**
  57202. * Checks to see if a texture is used in the material.
  57203. * @param texture - Base texture to use.
  57204. * @returns - Boolean specifying if a texture is used in the material.
  57205. */
  57206. hasTexture(texture: BaseTexture): boolean;
  57207. /**
  57208. * Dispose the material.
  57209. * @param forceDisposeEffect Force disposal of the associated effect.
  57210. * @param forceDisposeTextures Force disposal of the associated textures.
  57211. */
  57212. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57213. /**
  57214. * Clones the material.
  57215. * @param name The cloned name.
  57216. * @returns The cloned material.
  57217. */
  57218. clone(name: string): BackgroundMaterial;
  57219. /**
  57220. * Serializes the current material to its JSON representation.
  57221. * @returns The JSON representation.
  57222. */
  57223. serialize(): any;
  57224. /**
  57225. * Gets the class name of the material
  57226. * @returns "BackgroundMaterial"
  57227. */
  57228. getClassName(): string;
  57229. /**
  57230. * Parse a JSON input to create back a background material.
  57231. * @param source The JSON data to parse
  57232. * @param scene The scene to create the parsed material in
  57233. * @param rootUrl The root url of the assets the material depends upon
  57234. * @returns the instantiated BackgroundMaterial.
  57235. */
  57236. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57237. }
  57238. }
  57239. declare module "babylonjs/Helpers/environmentHelper" {
  57240. import { Observable } from "babylonjs/Misc/observable";
  57241. import { Nullable } from "babylonjs/types";
  57242. import { Scene } from "babylonjs/scene";
  57243. import { Vector3 } from "babylonjs/Maths/math.vector";
  57244. import { Color3 } from "babylonjs/Maths/math.color";
  57245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57246. import { Mesh } from "babylonjs/Meshes/mesh";
  57247. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57248. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57249. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57250. import "babylonjs/Meshes/Builders/planeBuilder";
  57251. import "babylonjs/Meshes/Builders/boxBuilder";
  57252. /**
  57253. * Represents the different options available during the creation of
  57254. * a Environment helper.
  57255. *
  57256. * This can control the default ground, skybox and image processing setup of your scene.
  57257. */
  57258. export interface IEnvironmentHelperOptions {
  57259. /**
  57260. * Specifies whether or not to create a ground.
  57261. * True by default.
  57262. */
  57263. createGround: boolean;
  57264. /**
  57265. * Specifies the ground size.
  57266. * 15 by default.
  57267. */
  57268. groundSize: number;
  57269. /**
  57270. * The texture used on the ground for the main color.
  57271. * Comes from the BabylonJS CDN by default.
  57272. *
  57273. * Remarks: Can be either a texture or a url.
  57274. */
  57275. groundTexture: string | BaseTexture;
  57276. /**
  57277. * The color mixed in the ground texture by default.
  57278. * BabylonJS clearColor by default.
  57279. */
  57280. groundColor: Color3;
  57281. /**
  57282. * Specifies the ground opacity.
  57283. * 1 by default.
  57284. */
  57285. groundOpacity: number;
  57286. /**
  57287. * Enables the ground to receive shadows.
  57288. * True by default.
  57289. */
  57290. enableGroundShadow: boolean;
  57291. /**
  57292. * Helps preventing the shadow to be fully black on the ground.
  57293. * 0.5 by default.
  57294. */
  57295. groundShadowLevel: number;
  57296. /**
  57297. * Creates a mirror texture attach to the ground.
  57298. * false by default.
  57299. */
  57300. enableGroundMirror: boolean;
  57301. /**
  57302. * Specifies the ground mirror size ratio.
  57303. * 0.3 by default as the default kernel is 64.
  57304. */
  57305. groundMirrorSizeRatio: number;
  57306. /**
  57307. * Specifies the ground mirror blur kernel size.
  57308. * 64 by default.
  57309. */
  57310. groundMirrorBlurKernel: number;
  57311. /**
  57312. * Specifies the ground mirror visibility amount.
  57313. * 1 by default
  57314. */
  57315. groundMirrorAmount: number;
  57316. /**
  57317. * Specifies the ground mirror reflectance weight.
  57318. * This uses the standard weight of the background material to setup the fresnel effect
  57319. * of the mirror.
  57320. * 1 by default.
  57321. */
  57322. groundMirrorFresnelWeight: number;
  57323. /**
  57324. * Specifies the ground mirror Falloff distance.
  57325. * This can helps reducing the size of the reflection.
  57326. * 0 by Default.
  57327. */
  57328. groundMirrorFallOffDistance: number;
  57329. /**
  57330. * Specifies the ground mirror texture type.
  57331. * Unsigned Int by Default.
  57332. */
  57333. groundMirrorTextureType: number;
  57334. /**
  57335. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57336. * the shown objects.
  57337. */
  57338. groundYBias: number;
  57339. /**
  57340. * Specifies whether or not to create a skybox.
  57341. * True by default.
  57342. */
  57343. createSkybox: boolean;
  57344. /**
  57345. * Specifies the skybox size.
  57346. * 20 by default.
  57347. */
  57348. skyboxSize: number;
  57349. /**
  57350. * The texture used on the skybox for the main color.
  57351. * Comes from the BabylonJS CDN by default.
  57352. *
  57353. * Remarks: Can be either a texture or a url.
  57354. */
  57355. skyboxTexture: string | BaseTexture;
  57356. /**
  57357. * The color mixed in the skybox texture by default.
  57358. * BabylonJS clearColor by default.
  57359. */
  57360. skyboxColor: Color3;
  57361. /**
  57362. * The background rotation around the Y axis of the scene.
  57363. * This helps aligning the key lights of your scene with the background.
  57364. * 0 by default.
  57365. */
  57366. backgroundYRotation: number;
  57367. /**
  57368. * Compute automatically the size of the elements to best fit with the scene.
  57369. */
  57370. sizeAuto: boolean;
  57371. /**
  57372. * Default position of the rootMesh if autoSize is not true.
  57373. */
  57374. rootPosition: Vector3;
  57375. /**
  57376. * Sets up the image processing in the scene.
  57377. * true by default.
  57378. */
  57379. setupImageProcessing: boolean;
  57380. /**
  57381. * The texture used as your environment texture in the scene.
  57382. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57383. *
  57384. * Remarks: Can be either a texture or a url.
  57385. */
  57386. environmentTexture: string | BaseTexture;
  57387. /**
  57388. * The value of the exposure to apply to the scene.
  57389. * 0.6 by default if setupImageProcessing is true.
  57390. */
  57391. cameraExposure: number;
  57392. /**
  57393. * The value of the contrast to apply to the scene.
  57394. * 1.6 by default if setupImageProcessing is true.
  57395. */
  57396. cameraContrast: number;
  57397. /**
  57398. * Specifies whether or not tonemapping should be enabled in the scene.
  57399. * true by default if setupImageProcessing is true.
  57400. */
  57401. toneMappingEnabled: boolean;
  57402. }
  57403. /**
  57404. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57405. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57406. * It also helps with the default setup of your imageProcessing configuration.
  57407. */
  57408. export class EnvironmentHelper {
  57409. /**
  57410. * Default ground texture URL.
  57411. */
  57412. private static _groundTextureCDNUrl;
  57413. /**
  57414. * Default skybox texture URL.
  57415. */
  57416. private static _skyboxTextureCDNUrl;
  57417. /**
  57418. * Default environment texture URL.
  57419. */
  57420. private static _environmentTextureCDNUrl;
  57421. /**
  57422. * Creates the default options for the helper.
  57423. */
  57424. private static _getDefaultOptions;
  57425. private _rootMesh;
  57426. /**
  57427. * Gets the root mesh created by the helper.
  57428. */
  57429. get rootMesh(): Mesh;
  57430. private _skybox;
  57431. /**
  57432. * Gets the skybox created by the helper.
  57433. */
  57434. get skybox(): Nullable<Mesh>;
  57435. private _skyboxTexture;
  57436. /**
  57437. * Gets the skybox texture created by the helper.
  57438. */
  57439. get skyboxTexture(): Nullable<BaseTexture>;
  57440. private _skyboxMaterial;
  57441. /**
  57442. * Gets the skybox material created by the helper.
  57443. */
  57444. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57445. private _ground;
  57446. /**
  57447. * Gets the ground mesh created by the helper.
  57448. */
  57449. get ground(): Nullable<Mesh>;
  57450. private _groundTexture;
  57451. /**
  57452. * Gets the ground texture created by the helper.
  57453. */
  57454. get groundTexture(): Nullable<BaseTexture>;
  57455. private _groundMirror;
  57456. /**
  57457. * Gets the ground mirror created by the helper.
  57458. */
  57459. get groundMirror(): Nullable<MirrorTexture>;
  57460. /**
  57461. * Gets the ground mirror render list to helps pushing the meshes
  57462. * you wish in the ground reflection.
  57463. */
  57464. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57465. private _groundMaterial;
  57466. /**
  57467. * Gets the ground material created by the helper.
  57468. */
  57469. get groundMaterial(): Nullable<BackgroundMaterial>;
  57470. /**
  57471. * Stores the creation options.
  57472. */
  57473. private readonly _scene;
  57474. private _options;
  57475. /**
  57476. * This observable will be notified with any error during the creation of the environment,
  57477. * mainly texture creation errors.
  57478. */
  57479. onErrorObservable: Observable<{
  57480. message?: string;
  57481. exception?: any;
  57482. }>;
  57483. /**
  57484. * constructor
  57485. * @param options Defines the options we want to customize the helper
  57486. * @param scene The scene to add the material to
  57487. */
  57488. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57489. /**
  57490. * Updates the background according to the new options
  57491. * @param options
  57492. */
  57493. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57494. /**
  57495. * Sets the primary color of all the available elements.
  57496. * @param color the main color to affect to the ground and the background
  57497. */
  57498. setMainColor(color: Color3): void;
  57499. /**
  57500. * Setup the image processing according to the specified options.
  57501. */
  57502. private _setupImageProcessing;
  57503. /**
  57504. * Setup the environment texture according to the specified options.
  57505. */
  57506. private _setupEnvironmentTexture;
  57507. /**
  57508. * Setup the background according to the specified options.
  57509. */
  57510. private _setupBackground;
  57511. /**
  57512. * Get the scene sizes according to the setup.
  57513. */
  57514. private _getSceneSize;
  57515. /**
  57516. * Setup the ground according to the specified options.
  57517. */
  57518. private _setupGround;
  57519. /**
  57520. * Setup the ground material according to the specified options.
  57521. */
  57522. private _setupGroundMaterial;
  57523. /**
  57524. * Setup the ground diffuse texture according to the specified options.
  57525. */
  57526. private _setupGroundDiffuseTexture;
  57527. /**
  57528. * Setup the ground mirror texture according to the specified options.
  57529. */
  57530. private _setupGroundMirrorTexture;
  57531. /**
  57532. * Setup the ground to receive the mirror texture.
  57533. */
  57534. private _setupMirrorInGroundMaterial;
  57535. /**
  57536. * Setup the skybox according to the specified options.
  57537. */
  57538. private _setupSkybox;
  57539. /**
  57540. * Setup the skybox material according to the specified options.
  57541. */
  57542. private _setupSkyboxMaterial;
  57543. /**
  57544. * Setup the skybox reflection texture according to the specified options.
  57545. */
  57546. private _setupSkyboxReflectionTexture;
  57547. private _errorHandler;
  57548. /**
  57549. * Dispose all the elements created by the Helper.
  57550. */
  57551. dispose(): void;
  57552. }
  57553. }
  57554. declare module "babylonjs/Helpers/textureDome" {
  57555. import { Scene } from "babylonjs/scene";
  57556. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57557. import { Mesh } from "babylonjs/Meshes/mesh";
  57558. import { Texture } from "babylonjs/Materials/Textures/texture";
  57559. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57560. import "babylonjs/Meshes/Builders/sphereBuilder";
  57561. import { Nullable } from "babylonjs/types";
  57562. import { Observable } from "babylonjs/Misc/observable";
  57563. /**
  57564. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57565. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57566. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57567. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57568. */
  57569. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57570. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57571. /**
  57572. * Define the source as a Monoscopic panoramic 360/180.
  57573. */
  57574. static readonly MODE_MONOSCOPIC: number;
  57575. /**
  57576. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57577. */
  57578. static readonly MODE_TOPBOTTOM: number;
  57579. /**
  57580. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57581. */
  57582. static readonly MODE_SIDEBYSIDE: number;
  57583. private _halfDome;
  57584. protected _useDirectMapping: boolean;
  57585. /**
  57586. * The texture being displayed on the sphere
  57587. */
  57588. protected _texture: T;
  57589. /**
  57590. * Gets the texture being displayed on the sphere
  57591. */
  57592. get texture(): T;
  57593. /**
  57594. * Sets the texture being displayed on the sphere
  57595. */
  57596. set texture(newTexture: T);
  57597. /**
  57598. * The skybox material
  57599. */
  57600. protected _material: BackgroundMaterial;
  57601. /**
  57602. * The surface used for the dome
  57603. */
  57604. protected _mesh: Mesh;
  57605. /**
  57606. * Gets the mesh used for the dome.
  57607. */
  57608. get mesh(): Mesh;
  57609. /**
  57610. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57611. */
  57612. private _halfDomeMask;
  57613. /**
  57614. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57615. * Also see the options.resolution property.
  57616. */
  57617. get fovMultiplier(): number;
  57618. set fovMultiplier(value: number);
  57619. protected _textureMode: number;
  57620. /**
  57621. * Gets or set the current texture mode for the texture. It can be:
  57622. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57623. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57624. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57625. */
  57626. get textureMode(): number;
  57627. /**
  57628. * Sets the current texture mode for the texture. It can be:
  57629. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57630. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57631. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57632. */
  57633. set textureMode(value: number);
  57634. /**
  57635. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57636. */
  57637. get halfDome(): boolean;
  57638. /**
  57639. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57640. */
  57641. set halfDome(enabled: boolean);
  57642. /**
  57643. * Oberserver used in Stereoscopic VR Mode.
  57644. */
  57645. private _onBeforeCameraRenderObserver;
  57646. /**
  57647. * Observable raised when an error occured while loading the 360 image
  57648. */
  57649. onLoadErrorObservable: Observable<string>;
  57650. /**
  57651. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57652. * @param name Element's name, child elements will append suffixes for their own names.
  57653. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57654. * @param options An object containing optional or exposed sub element properties
  57655. */
  57656. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57657. resolution?: number;
  57658. clickToPlay?: boolean;
  57659. autoPlay?: boolean;
  57660. loop?: boolean;
  57661. size?: number;
  57662. poster?: string;
  57663. faceForward?: boolean;
  57664. useDirectMapping?: boolean;
  57665. halfDomeMode?: boolean;
  57666. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57667. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57668. protected _changeTextureMode(value: number): void;
  57669. /**
  57670. * Releases resources associated with this node.
  57671. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57672. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57673. */
  57674. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57675. }
  57676. }
  57677. declare module "babylonjs/Helpers/photoDome" {
  57678. import { Scene } from "babylonjs/scene";
  57679. import { Texture } from "babylonjs/Materials/Textures/texture";
  57680. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57681. /**
  57682. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57683. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57684. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57685. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57686. */
  57687. export class PhotoDome extends TextureDome<Texture> {
  57688. /**
  57689. * Define the image as a Monoscopic panoramic 360 image.
  57690. */
  57691. static readonly MODE_MONOSCOPIC: number;
  57692. /**
  57693. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57694. */
  57695. static readonly MODE_TOPBOTTOM: number;
  57696. /**
  57697. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57698. */
  57699. static readonly MODE_SIDEBYSIDE: number;
  57700. /**
  57701. * Gets or sets the texture being displayed on the sphere
  57702. */
  57703. get photoTexture(): Texture;
  57704. /**
  57705. * sets the texture being displayed on the sphere
  57706. */
  57707. set photoTexture(value: Texture);
  57708. /**
  57709. * Gets the current video mode for the video. It can be:
  57710. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57711. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57712. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57713. */
  57714. get imageMode(): number;
  57715. /**
  57716. * Sets the current video mode for the video. It can be:
  57717. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57718. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57719. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57720. */
  57721. set imageMode(value: number);
  57722. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57723. }
  57724. }
  57725. declare module "babylonjs/Misc/rgbdTextureTools" {
  57726. import "babylonjs/Shaders/rgbdDecode.fragment";
  57727. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57728. import { Texture } from "babylonjs/Materials/Textures/texture";
  57729. /**
  57730. * Class used to host RGBD texture specific utilities
  57731. */
  57732. export class RGBDTextureTools {
  57733. /**
  57734. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57735. * @param texture the texture to expand.
  57736. */
  57737. static ExpandRGBDTexture(texture: Texture): void;
  57738. }
  57739. }
  57740. declare module "babylonjs/Misc/brdfTextureTools" {
  57741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57742. import { Scene } from "babylonjs/scene";
  57743. /**
  57744. * Class used to host texture specific utilities
  57745. */
  57746. export class BRDFTextureTools {
  57747. /**
  57748. * Prevents texture cache collision
  57749. */
  57750. private static _instanceNumber;
  57751. /**
  57752. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57753. * @param scene defines the hosting scene
  57754. * @returns the environment BRDF texture
  57755. */
  57756. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57757. private static _environmentBRDFBase64Texture;
  57758. }
  57759. }
  57760. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57761. import { Nullable } from "babylonjs/types";
  57762. import { Color3 } from "babylonjs/Maths/math.color";
  57763. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57764. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57765. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57766. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57767. import { Engine } from "babylonjs/Engines/engine";
  57768. import { Scene } from "babylonjs/scene";
  57769. /**
  57770. * @hidden
  57771. */
  57772. export interface IMaterialClearCoatDefines {
  57773. CLEARCOAT: boolean;
  57774. CLEARCOAT_DEFAULTIOR: boolean;
  57775. CLEARCOAT_TEXTURE: boolean;
  57776. CLEARCOAT_TEXTUREDIRECTUV: number;
  57777. CLEARCOAT_BUMP: boolean;
  57778. CLEARCOAT_BUMPDIRECTUV: number;
  57779. CLEARCOAT_TINT: boolean;
  57780. CLEARCOAT_TINT_TEXTURE: boolean;
  57781. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57782. /** @hidden */
  57783. _areTexturesDirty: boolean;
  57784. }
  57785. /**
  57786. * Define the code related to the clear coat parameters of the pbr material.
  57787. */
  57788. export class PBRClearCoatConfiguration {
  57789. /**
  57790. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57791. * The default fits with a polyurethane material.
  57792. */
  57793. private static readonly _DefaultIndexOfRefraction;
  57794. private _isEnabled;
  57795. /**
  57796. * Defines if the clear coat is enabled in the material.
  57797. */
  57798. isEnabled: boolean;
  57799. /**
  57800. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57801. */
  57802. intensity: number;
  57803. /**
  57804. * Defines the clear coat layer roughness.
  57805. */
  57806. roughness: number;
  57807. private _indexOfRefraction;
  57808. /**
  57809. * Defines the index of refraction of the clear coat.
  57810. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57811. * The default fits with a polyurethane material.
  57812. * Changing the default value is more performance intensive.
  57813. */
  57814. indexOfRefraction: number;
  57815. private _texture;
  57816. /**
  57817. * Stores the clear coat values in a texture.
  57818. */
  57819. texture: Nullable<BaseTexture>;
  57820. private _bumpTexture;
  57821. /**
  57822. * Define the clear coat specific bump texture.
  57823. */
  57824. bumpTexture: Nullable<BaseTexture>;
  57825. private _isTintEnabled;
  57826. /**
  57827. * Defines if the clear coat tint is enabled in the material.
  57828. */
  57829. isTintEnabled: boolean;
  57830. /**
  57831. * Defines the clear coat tint of the material.
  57832. * This is only use if tint is enabled
  57833. */
  57834. tintColor: Color3;
  57835. /**
  57836. * Defines the distance at which the tint color should be found in the
  57837. * clear coat media.
  57838. * This is only use if tint is enabled
  57839. */
  57840. tintColorAtDistance: number;
  57841. /**
  57842. * Defines the clear coat layer thickness.
  57843. * This is only use if tint is enabled
  57844. */
  57845. tintThickness: number;
  57846. private _tintTexture;
  57847. /**
  57848. * Stores the clear tint values in a texture.
  57849. * rgb is tint
  57850. * a is a thickness factor
  57851. */
  57852. tintTexture: Nullable<BaseTexture>;
  57853. /** @hidden */
  57854. private _internalMarkAllSubMeshesAsTexturesDirty;
  57855. /** @hidden */
  57856. _markAllSubMeshesAsTexturesDirty(): void;
  57857. /**
  57858. * Instantiate a new istance of clear coat configuration.
  57859. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  57860. */
  57861. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  57862. /**
  57863. * Gets wehter the submesh is ready to be used or not.
  57864. * @param defines the list of "defines" to update.
  57865. * @param scene defines the scene the material belongs to.
  57866. * @param engine defines the engine the material belongs to.
  57867. * @param disableBumpMap defines wether the material disables bump or not.
  57868. * @returns - boolean indicating that the submesh is ready or not.
  57869. */
  57870. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  57871. /**
  57872. * Checks to see if a texture is used in the material.
  57873. * @param defines the list of "defines" to update.
  57874. * @param scene defines the scene to the material belongs to.
  57875. */
  57876. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  57877. /**
  57878. * Binds the material data.
  57879. * @param uniformBuffer defines the Uniform buffer to fill in.
  57880. * @param scene defines the scene the material belongs to.
  57881. * @param engine defines the engine the material belongs to.
  57882. * @param disableBumpMap defines wether the material disables bump or not.
  57883. * @param isFrozen defines wether the material is frozen or not.
  57884. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  57885. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  57886. */
  57887. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  57888. /**
  57889. * Checks to see if a texture is used in the material.
  57890. * @param texture - Base texture to use.
  57891. * @returns - Boolean specifying if a texture is used in the material.
  57892. */
  57893. hasTexture(texture: BaseTexture): boolean;
  57894. /**
  57895. * Returns an array of the actively used textures.
  57896. * @param activeTextures Array of BaseTextures
  57897. */
  57898. getActiveTextures(activeTextures: BaseTexture[]): void;
  57899. /**
  57900. * Returns the animatable textures.
  57901. * @param animatables Array of animatable textures.
  57902. */
  57903. getAnimatables(animatables: IAnimatable[]): void;
  57904. /**
  57905. * Disposes the resources of the material.
  57906. * @param forceDisposeTextures - Forces the disposal of all textures.
  57907. */
  57908. dispose(forceDisposeTextures?: boolean): void;
  57909. /**
  57910. * Get the current class name of the texture useful for serialization or dynamic coding.
  57911. * @returns "PBRClearCoatConfiguration"
  57912. */
  57913. getClassName(): string;
  57914. /**
  57915. * Add fallbacks to the effect fallbacks list.
  57916. * @param defines defines the Base texture to use.
  57917. * @param fallbacks defines the current fallback list.
  57918. * @param currentRank defines the current fallback rank.
  57919. * @returns the new fallback rank.
  57920. */
  57921. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  57922. /**
  57923. * Add the required uniforms to the current list.
  57924. * @param uniforms defines the current uniform list.
  57925. */
  57926. static AddUniforms(uniforms: string[]): void;
  57927. /**
  57928. * Add the required samplers to the current list.
  57929. * @param samplers defines the current sampler list.
  57930. */
  57931. static AddSamplers(samplers: string[]): void;
  57932. /**
  57933. * Add the required uniforms to the current buffer.
  57934. * @param uniformBuffer defines the current uniform buffer.
  57935. */
  57936. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  57937. /**
  57938. * Makes a duplicate of the current configuration into another one.
  57939. * @param clearCoatConfiguration define the config where to copy the info
  57940. */
  57941. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  57942. /**
  57943. * Serializes this clear coat configuration.
  57944. * @returns - An object with the serialized config.
  57945. */
  57946. serialize(): any;
  57947. /**
  57948. * Parses a anisotropy Configuration from a serialized object.
  57949. * @param source - Serialized object.
  57950. * @param scene Defines the scene we are parsing for
  57951. * @param rootUrl Defines the rootUrl to load from
  57952. */
  57953. parse(source: any, scene: Scene, rootUrl: string): void;
  57954. }
  57955. }
  57956. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  57957. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57959. import { Vector2 } from "babylonjs/Maths/math.vector";
  57960. import { Scene } from "babylonjs/scene";
  57961. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57962. import { Nullable } from "babylonjs/types";
  57963. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57964. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57965. /**
  57966. * @hidden
  57967. */
  57968. export interface IMaterialAnisotropicDefines {
  57969. ANISOTROPIC: boolean;
  57970. ANISOTROPIC_TEXTURE: boolean;
  57971. ANISOTROPIC_TEXTUREDIRECTUV: number;
  57972. MAINUV1: boolean;
  57973. _areTexturesDirty: boolean;
  57974. _needUVs: boolean;
  57975. }
  57976. /**
  57977. * Define the code related to the anisotropic parameters of the pbr material.
  57978. */
  57979. export class PBRAnisotropicConfiguration {
  57980. private _isEnabled;
  57981. /**
  57982. * Defines if the anisotropy is enabled in the material.
  57983. */
  57984. isEnabled: boolean;
  57985. /**
  57986. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  57987. */
  57988. intensity: number;
  57989. /**
  57990. * Defines if the effect is along the tangents, bitangents or in between.
  57991. * By default, the effect is "strectching" the highlights along the tangents.
  57992. */
  57993. direction: Vector2;
  57994. private _texture;
  57995. /**
  57996. * Stores the anisotropy values in a texture.
  57997. * rg is direction (like normal from -1 to 1)
  57998. * b is a intensity
  57999. */
  58000. texture: Nullable<BaseTexture>;
  58001. /** @hidden */
  58002. private _internalMarkAllSubMeshesAsTexturesDirty;
  58003. /** @hidden */
  58004. _markAllSubMeshesAsTexturesDirty(): void;
  58005. /**
  58006. * Instantiate a new istance of anisotropy configuration.
  58007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58008. */
  58009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58010. /**
  58011. * Specifies that the submesh is ready to be used.
  58012. * @param defines the list of "defines" to update.
  58013. * @param scene defines the scene the material belongs to.
  58014. * @returns - boolean indicating that the submesh is ready or not.
  58015. */
  58016. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58017. /**
  58018. * Checks to see if a texture is used in the material.
  58019. * @param defines the list of "defines" to update.
  58020. * @param mesh the mesh we are preparing the defines for.
  58021. * @param scene defines the scene the material belongs to.
  58022. */
  58023. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58024. /**
  58025. * Binds the material data.
  58026. * @param uniformBuffer defines the Uniform buffer to fill in.
  58027. * @param scene defines the scene the material belongs to.
  58028. * @param isFrozen defines wether the material is frozen or not.
  58029. */
  58030. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58031. /**
  58032. * Checks to see if a texture is used in the material.
  58033. * @param texture - Base texture to use.
  58034. * @returns - Boolean specifying if a texture is used in the material.
  58035. */
  58036. hasTexture(texture: BaseTexture): boolean;
  58037. /**
  58038. * Returns an array of the actively used textures.
  58039. * @param activeTextures Array of BaseTextures
  58040. */
  58041. getActiveTextures(activeTextures: BaseTexture[]): void;
  58042. /**
  58043. * Returns the animatable textures.
  58044. * @param animatables Array of animatable textures.
  58045. */
  58046. getAnimatables(animatables: IAnimatable[]): void;
  58047. /**
  58048. * Disposes the resources of the material.
  58049. * @param forceDisposeTextures - Forces the disposal of all textures.
  58050. */
  58051. dispose(forceDisposeTextures?: boolean): void;
  58052. /**
  58053. * Get the current class name of the texture useful for serialization or dynamic coding.
  58054. * @returns "PBRAnisotropicConfiguration"
  58055. */
  58056. getClassName(): string;
  58057. /**
  58058. * Add fallbacks to the effect fallbacks list.
  58059. * @param defines defines the Base texture to use.
  58060. * @param fallbacks defines the current fallback list.
  58061. * @param currentRank defines the current fallback rank.
  58062. * @returns the new fallback rank.
  58063. */
  58064. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58065. /**
  58066. * Add the required uniforms to the current list.
  58067. * @param uniforms defines the current uniform list.
  58068. */
  58069. static AddUniforms(uniforms: string[]): void;
  58070. /**
  58071. * Add the required uniforms to the current buffer.
  58072. * @param uniformBuffer defines the current uniform buffer.
  58073. */
  58074. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58075. /**
  58076. * Add the required samplers to the current list.
  58077. * @param samplers defines the current sampler list.
  58078. */
  58079. static AddSamplers(samplers: string[]): void;
  58080. /**
  58081. * Makes a duplicate of the current configuration into another one.
  58082. * @param anisotropicConfiguration define the config where to copy the info
  58083. */
  58084. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58085. /**
  58086. * Serializes this anisotropy configuration.
  58087. * @returns - An object with the serialized config.
  58088. */
  58089. serialize(): any;
  58090. /**
  58091. * Parses a anisotropy Configuration from a serialized object.
  58092. * @param source - Serialized object.
  58093. * @param scene Defines the scene we are parsing for
  58094. * @param rootUrl Defines the rootUrl to load from
  58095. */
  58096. parse(source: any, scene: Scene, rootUrl: string): void;
  58097. }
  58098. }
  58099. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58100. import { Scene } from "babylonjs/scene";
  58101. /**
  58102. * @hidden
  58103. */
  58104. export interface IMaterialBRDFDefines {
  58105. BRDF_V_HEIGHT_CORRELATED: boolean;
  58106. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58107. SPHERICAL_HARMONICS: boolean;
  58108. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58109. /** @hidden */
  58110. _areMiscDirty: boolean;
  58111. }
  58112. /**
  58113. * Define the code related to the BRDF parameters of the pbr material.
  58114. */
  58115. export class PBRBRDFConfiguration {
  58116. /**
  58117. * Default value used for the energy conservation.
  58118. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58119. */
  58120. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58121. /**
  58122. * Default value used for the Smith Visibility Height Correlated mode.
  58123. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58124. */
  58125. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58126. /**
  58127. * Default value used for the IBL diffuse part.
  58128. * This can help switching back to the polynomials mode globally which is a tiny bit
  58129. * less GPU intensive at the drawback of a lower quality.
  58130. */
  58131. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58132. /**
  58133. * Default value used for activating energy conservation for the specular workflow.
  58134. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58135. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58136. */
  58137. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58138. private _useEnergyConservation;
  58139. /**
  58140. * Defines if the material uses energy conservation.
  58141. */
  58142. useEnergyConservation: boolean;
  58143. private _useSmithVisibilityHeightCorrelated;
  58144. /**
  58145. * LEGACY Mode set to false
  58146. * Defines if the material uses height smith correlated visibility term.
  58147. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58148. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58149. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58150. * Not relying on height correlated will also disable energy conservation.
  58151. */
  58152. useSmithVisibilityHeightCorrelated: boolean;
  58153. private _useSphericalHarmonics;
  58154. /**
  58155. * LEGACY Mode set to false
  58156. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58157. * diffuse part of the IBL.
  58158. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58159. * to the ground truth.
  58160. */
  58161. useSphericalHarmonics: boolean;
  58162. private _useSpecularGlossinessInputEnergyConservation;
  58163. /**
  58164. * Defines if the material uses energy conservation, when the specular workflow is active.
  58165. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58166. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58167. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58168. */
  58169. useSpecularGlossinessInputEnergyConservation: boolean;
  58170. /** @hidden */
  58171. private _internalMarkAllSubMeshesAsMiscDirty;
  58172. /** @hidden */
  58173. _markAllSubMeshesAsMiscDirty(): void;
  58174. /**
  58175. * Instantiate a new istance of clear coat configuration.
  58176. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58177. */
  58178. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58179. /**
  58180. * Checks to see if a texture is used in the material.
  58181. * @param defines the list of "defines" to update.
  58182. */
  58183. prepareDefines(defines: IMaterialBRDFDefines): void;
  58184. /**
  58185. * Get the current class name of the texture useful for serialization or dynamic coding.
  58186. * @returns "PBRClearCoatConfiguration"
  58187. */
  58188. getClassName(): string;
  58189. /**
  58190. * Makes a duplicate of the current configuration into another one.
  58191. * @param brdfConfiguration define the config where to copy the info
  58192. */
  58193. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58194. /**
  58195. * Serializes this BRDF configuration.
  58196. * @returns - An object with the serialized config.
  58197. */
  58198. serialize(): any;
  58199. /**
  58200. * Parses a anisotropy Configuration from a serialized object.
  58201. * @param source - Serialized object.
  58202. * @param scene Defines the scene we are parsing for
  58203. * @param rootUrl Defines the rootUrl to load from
  58204. */
  58205. parse(source: any, scene: Scene, rootUrl: string): void;
  58206. }
  58207. }
  58208. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58209. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58210. import { Color3 } from "babylonjs/Maths/math.color";
  58211. import { Scene } from "babylonjs/scene";
  58212. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58213. import { Nullable } from "babylonjs/types";
  58214. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58215. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58216. /**
  58217. * @hidden
  58218. */
  58219. export interface IMaterialSheenDefines {
  58220. SHEEN: boolean;
  58221. SHEEN_TEXTURE: boolean;
  58222. SHEEN_TEXTUREDIRECTUV: number;
  58223. SHEEN_LINKWITHALBEDO: boolean;
  58224. SHEEN_ROUGHNESS: boolean;
  58225. SHEEN_ALBEDOSCALING: boolean;
  58226. /** @hidden */
  58227. _areTexturesDirty: boolean;
  58228. }
  58229. /**
  58230. * Define the code related to the Sheen parameters of the pbr material.
  58231. */
  58232. export class PBRSheenConfiguration {
  58233. private _isEnabled;
  58234. /**
  58235. * Defines if the material uses sheen.
  58236. */
  58237. isEnabled: boolean;
  58238. private _linkSheenWithAlbedo;
  58239. /**
  58240. * Defines if the sheen is linked to the sheen color.
  58241. */
  58242. linkSheenWithAlbedo: boolean;
  58243. /**
  58244. * Defines the sheen intensity.
  58245. */
  58246. intensity: number;
  58247. /**
  58248. * Defines the sheen color.
  58249. */
  58250. color: Color3;
  58251. private _texture;
  58252. /**
  58253. * Stores the sheen tint values in a texture.
  58254. * rgb is tint
  58255. * a is a intensity or roughness if roughness has been defined
  58256. */
  58257. texture: Nullable<BaseTexture>;
  58258. private _roughness;
  58259. /**
  58260. * Defines the sheen roughness.
  58261. * It is not taken into account if linkSheenWithAlbedo is true.
  58262. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58263. */
  58264. roughness: Nullable<number>;
  58265. private _albedoScaling;
  58266. /**
  58267. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58268. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58269. * making it easier to setup and tweak the effect
  58270. */
  58271. albedoScaling: boolean;
  58272. /** @hidden */
  58273. private _internalMarkAllSubMeshesAsTexturesDirty;
  58274. /** @hidden */
  58275. _markAllSubMeshesAsTexturesDirty(): void;
  58276. /**
  58277. * Instantiate a new istance of clear coat configuration.
  58278. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58279. */
  58280. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58281. /**
  58282. * Specifies that the submesh is ready to be used.
  58283. * @param defines the list of "defines" to update.
  58284. * @param scene defines the scene the material belongs to.
  58285. * @returns - boolean indicating that the submesh is ready or not.
  58286. */
  58287. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58288. /**
  58289. * Checks to see if a texture is used in the material.
  58290. * @param defines the list of "defines" to update.
  58291. * @param scene defines the scene the material belongs to.
  58292. */
  58293. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58294. /**
  58295. * Binds the material data.
  58296. * @param uniformBuffer defines the Uniform buffer to fill in.
  58297. * @param scene defines the scene the material belongs to.
  58298. * @param isFrozen defines wether the material is frozen or not.
  58299. */
  58300. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58301. /**
  58302. * Checks to see if a texture is used in the material.
  58303. * @param texture - Base texture to use.
  58304. * @returns - Boolean specifying if a texture is used in the material.
  58305. */
  58306. hasTexture(texture: BaseTexture): boolean;
  58307. /**
  58308. * Returns an array of the actively used textures.
  58309. * @param activeTextures Array of BaseTextures
  58310. */
  58311. getActiveTextures(activeTextures: BaseTexture[]): void;
  58312. /**
  58313. * Returns the animatable textures.
  58314. * @param animatables Array of animatable textures.
  58315. */
  58316. getAnimatables(animatables: IAnimatable[]): void;
  58317. /**
  58318. * Disposes the resources of the material.
  58319. * @param forceDisposeTextures - Forces the disposal of all textures.
  58320. */
  58321. dispose(forceDisposeTextures?: boolean): void;
  58322. /**
  58323. * Get the current class name of the texture useful for serialization or dynamic coding.
  58324. * @returns "PBRSheenConfiguration"
  58325. */
  58326. getClassName(): string;
  58327. /**
  58328. * Add fallbacks to the effect fallbacks list.
  58329. * @param defines defines the Base texture to use.
  58330. * @param fallbacks defines the current fallback list.
  58331. * @param currentRank defines the current fallback rank.
  58332. * @returns the new fallback rank.
  58333. */
  58334. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58335. /**
  58336. * Add the required uniforms to the current list.
  58337. * @param uniforms defines the current uniform list.
  58338. */
  58339. static AddUniforms(uniforms: string[]): void;
  58340. /**
  58341. * Add the required uniforms to the current buffer.
  58342. * @param uniformBuffer defines the current uniform buffer.
  58343. */
  58344. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58345. /**
  58346. * Add the required samplers to the current list.
  58347. * @param samplers defines the current sampler list.
  58348. */
  58349. static AddSamplers(samplers: string[]): void;
  58350. /**
  58351. * Makes a duplicate of the current configuration into another one.
  58352. * @param sheenConfiguration define the config where to copy the info
  58353. */
  58354. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58355. /**
  58356. * Serializes this BRDF configuration.
  58357. * @returns - An object with the serialized config.
  58358. */
  58359. serialize(): any;
  58360. /**
  58361. * Parses a anisotropy Configuration from a serialized object.
  58362. * @param source - Serialized object.
  58363. * @param scene Defines the scene we are parsing for
  58364. * @param rootUrl Defines the rootUrl to load from
  58365. */
  58366. parse(source: any, scene: Scene, rootUrl: string): void;
  58367. }
  58368. }
  58369. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58370. import { Nullable } from "babylonjs/types";
  58371. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58372. import { Color3 } from "babylonjs/Maths/math.color";
  58373. import { SmartArray } from "babylonjs/Misc/smartArray";
  58374. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58376. import { Effect } from "babylonjs/Materials/effect";
  58377. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58378. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58379. import { Engine } from "babylonjs/Engines/engine";
  58380. import { Scene } from "babylonjs/scene";
  58381. /**
  58382. * @hidden
  58383. */
  58384. export interface IMaterialSubSurfaceDefines {
  58385. SUBSURFACE: boolean;
  58386. SS_REFRACTION: boolean;
  58387. SS_TRANSLUCENCY: boolean;
  58388. SS_SCATTERING: boolean;
  58389. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58390. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58391. SS_REFRACTIONMAP_3D: boolean;
  58392. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58393. SS_LODINREFRACTIONALPHA: boolean;
  58394. SS_GAMMAREFRACTION: boolean;
  58395. SS_RGBDREFRACTION: boolean;
  58396. SS_LINEARSPECULARREFRACTION: boolean;
  58397. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58398. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58399. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58400. /** @hidden */
  58401. _areTexturesDirty: boolean;
  58402. }
  58403. /**
  58404. * Define the code related to the sub surface parameters of the pbr material.
  58405. */
  58406. export class PBRSubSurfaceConfiguration {
  58407. private _isRefractionEnabled;
  58408. /**
  58409. * Defines if the refraction is enabled in the material.
  58410. */
  58411. isRefractionEnabled: boolean;
  58412. private _isTranslucencyEnabled;
  58413. /**
  58414. * Defines if the translucency is enabled in the material.
  58415. */
  58416. isTranslucencyEnabled: boolean;
  58417. private _isScatteringEnabled;
  58418. /**
  58419. * Defines if the sub surface scattering is enabled in the material.
  58420. */
  58421. isScatteringEnabled: boolean;
  58422. private _scatteringDiffusionProfileIndex;
  58423. /**
  58424. * Diffusion profile for subsurface scattering.
  58425. * Useful for better scattering in the skins or foliages.
  58426. */
  58427. get scatteringDiffusionProfile(): Nullable<Color3>;
  58428. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58429. /**
  58430. * Defines the refraction intensity of the material.
  58431. * The refraction when enabled replaces the Diffuse part of the material.
  58432. * The intensity helps transitionning between diffuse and refraction.
  58433. */
  58434. refractionIntensity: number;
  58435. /**
  58436. * Defines the translucency intensity of the material.
  58437. * When translucency has been enabled, this defines how much of the "translucency"
  58438. * is addded to the diffuse part of the material.
  58439. */
  58440. translucencyIntensity: number;
  58441. /**
  58442. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58443. */
  58444. useAlbedoToTintRefraction: boolean;
  58445. private _thicknessTexture;
  58446. /**
  58447. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58448. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58449. * 0 would mean minimumThickness
  58450. * 1 would mean maximumThickness
  58451. * The other channels might be use as a mask to vary the different effects intensity.
  58452. */
  58453. thicknessTexture: Nullable<BaseTexture>;
  58454. private _refractionTexture;
  58455. /**
  58456. * Defines the texture to use for refraction.
  58457. */
  58458. refractionTexture: Nullable<BaseTexture>;
  58459. private _indexOfRefraction;
  58460. /**
  58461. * Index of refraction of the material base layer.
  58462. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58463. *
  58464. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58465. *
  58466. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58467. */
  58468. indexOfRefraction: number;
  58469. private _volumeIndexOfRefraction;
  58470. /**
  58471. * Index of refraction of the material's volume.
  58472. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58473. *
  58474. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58475. * the volume will use the same IOR as the surface.
  58476. */
  58477. get volumeIndexOfRefraction(): number;
  58478. set volumeIndexOfRefraction(value: number);
  58479. private _invertRefractionY;
  58480. /**
  58481. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58482. */
  58483. invertRefractionY: boolean;
  58484. private _linkRefractionWithTransparency;
  58485. /**
  58486. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58487. * Materials half opaque for instance using refraction could benefit from this control.
  58488. */
  58489. linkRefractionWithTransparency: boolean;
  58490. /**
  58491. * Defines the minimum thickness stored in the thickness map.
  58492. * If no thickness map is defined, this value will be used to simulate thickness.
  58493. */
  58494. minimumThickness: number;
  58495. /**
  58496. * Defines the maximum thickness stored in the thickness map.
  58497. */
  58498. maximumThickness: number;
  58499. /**
  58500. * Defines the volume tint of the material.
  58501. * This is used for both translucency and scattering.
  58502. */
  58503. tintColor: Color3;
  58504. /**
  58505. * Defines the distance at which the tint color should be found in the media.
  58506. * This is used for refraction only.
  58507. */
  58508. tintColorAtDistance: number;
  58509. /**
  58510. * Defines how far each channel transmit through the media.
  58511. * It is defined as a color to simplify it selection.
  58512. */
  58513. diffusionDistance: Color3;
  58514. private _useMaskFromThicknessTexture;
  58515. /**
  58516. * Stores the intensity of the different subsurface effects in the thickness texture.
  58517. * * the green channel is the translucency intensity.
  58518. * * the blue channel is the scattering intensity.
  58519. * * the alpha channel is the refraction intensity.
  58520. */
  58521. useMaskFromThicknessTexture: boolean;
  58522. private _scene;
  58523. /** @hidden */
  58524. private _internalMarkAllSubMeshesAsTexturesDirty;
  58525. private _internalMarkScenePrePassDirty;
  58526. /** @hidden */
  58527. _markAllSubMeshesAsTexturesDirty(): void;
  58528. /** @hidden */
  58529. _markScenePrePassDirty(): void;
  58530. /**
  58531. * Instantiate a new istance of sub surface configuration.
  58532. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58533. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58534. * @param scene The scene
  58535. */
  58536. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58537. /**
  58538. * Gets wehter the submesh is ready to be used or not.
  58539. * @param defines the list of "defines" to update.
  58540. * @param scene defines the scene the material belongs to.
  58541. * @returns - boolean indicating that the submesh is ready or not.
  58542. */
  58543. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58544. /**
  58545. * Checks to see if a texture is used in the material.
  58546. * @param defines the list of "defines" to update.
  58547. * @param scene defines the scene to the material belongs to.
  58548. */
  58549. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58550. /**
  58551. * Binds the material data.
  58552. * @param uniformBuffer defines the Uniform buffer to fill in.
  58553. * @param scene defines the scene the material belongs to.
  58554. * @param engine defines the engine the material belongs to.
  58555. * @param isFrozen defines whether the material is frozen or not.
  58556. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58557. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58558. */
  58559. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58560. /**
  58561. * Unbinds the material from the mesh.
  58562. * @param activeEffect defines the effect that should be unbound from.
  58563. * @returns true if unbound, otherwise false
  58564. */
  58565. unbind(activeEffect: Effect): boolean;
  58566. /**
  58567. * Returns the texture used for refraction or null if none is used.
  58568. * @param scene defines the scene the material belongs to.
  58569. * @returns - Refraction texture if present. If no refraction texture and refraction
  58570. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58571. */
  58572. private _getRefractionTexture;
  58573. /**
  58574. * Returns true if alpha blending should be disabled.
  58575. */
  58576. get disableAlphaBlending(): boolean;
  58577. /**
  58578. * Fills the list of render target textures.
  58579. * @param renderTargets the list of render targets to update
  58580. */
  58581. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58582. /**
  58583. * Checks to see if a texture is used in the material.
  58584. * @param texture - Base texture to use.
  58585. * @returns - Boolean specifying if a texture is used in the material.
  58586. */
  58587. hasTexture(texture: BaseTexture): boolean;
  58588. /**
  58589. * Gets a boolean indicating that current material needs to register RTT
  58590. * @returns true if this uses a render target otherwise false.
  58591. */
  58592. hasRenderTargetTextures(): boolean;
  58593. /**
  58594. * Returns an array of the actively used textures.
  58595. * @param activeTextures Array of BaseTextures
  58596. */
  58597. getActiveTextures(activeTextures: BaseTexture[]): void;
  58598. /**
  58599. * Returns the animatable textures.
  58600. * @param animatables Array of animatable textures.
  58601. */
  58602. getAnimatables(animatables: IAnimatable[]): void;
  58603. /**
  58604. * Disposes the resources of the material.
  58605. * @param forceDisposeTextures - Forces the disposal of all textures.
  58606. */
  58607. dispose(forceDisposeTextures?: boolean): void;
  58608. /**
  58609. * Get the current class name of the texture useful for serialization or dynamic coding.
  58610. * @returns "PBRSubSurfaceConfiguration"
  58611. */
  58612. getClassName(): string;
  58613. /**
  58614. * Add fallbacks to the effect fallbacks list.
  58615. * @param defines defines the Base texture to use.
  58616. * @param fallbacks defines the current fallback list.
  58617. * @param currentRank defines the current fallback rank.
  58618. * @returns the new fallback rank.
  58619. */
  58620. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58621. /**
  58622. * Add the required uniforms to the current list.
  58623. * @param uniforms defines the current uniform list.
  58624. */
  58625. static AddUniforms(uniforms: string[]): void;
  58626. /**
  58627. * Add the required samplers to the current list.
  58628. * @param samplers defines the current sampler list.
  58629. */
  58630. static AddSamplers(samplers: string[]): void;
  58631. /**
  58632. * Add the required uniforms to the current buffer.
  58633. * @param uniformBuffer defines the current uniform buffer.
  58634. */
  58635. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58636. /**
  58637. * Makes a duplicate of the current configuration into another one.
  58638. * @param configuration define the config where to copy the info
  58639. */
  58640. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58641. /**
  58642. * Serializes this Sub Surface configuration.
  58643. * @returns - An object with the serialized config.
  58644. */
  58645. serialize(): any;
  58646. /**
  58647. * Parses a anisotropy Configuration from a serialized object.
  58648. * @param source - Serialized object.
  58649. * @param scene Defines the scene we are parsing for
  58650. * @param rootUrl Defines the rootUrl to load from
  58651. */
  58652. parse(source: any, scene: Scene, rootUrl: string): void;
  58653. }
  58654. }
  58655. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58656. /** @hidden */
  58657. export var pbrFragmentDeclaration: {
  58658. name: string;
  58659. shader: string;
  58660. };
  58661. }
  58662. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58663. /** @hidden */
  58664. export var pbrUboDeclaration: {
  58665. name: string;
  58666. shader: string;
  58667. };
  58668. }
  58669. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58670. /** @hidden */
  58671. export var pbrFragmentExtraDeclaration: {
  58672. name: string;
  58673. shader: string;
  58674. };
  58675. }
  58676. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58677. /** @hidden */
  58678. export var pbrFragmentSamplersDeclaration: {
  58679. name: string;
  58680. shader: string;
  58681. };
  58682. }
  58683. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58684. /** @hidden */
  58685. export var subSurfaceScatteringFunctions: {
  58686. name: string;
  58687. shader: string;
  58688. };
  58689. }
  58690. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58691. /** @hidden */
  58692. export var importanceSampling: {
  58693. name: string;
  58694. shader: string;
  58695. };
  58696. }
  58697. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58698. /** @hidden */
  58699. export var pbrHelperFunctions: {
  58700. name: string;
  58701. shader: string;
  58702. };
  58703. }
  58704. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58705. /** @hidden */
  58706. export var harmonicsFunctions: {
  58707. name: string;
  58708. shader: string;
  58709. };
  58710. }
  58711. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58712. /** @hidden */
  58713. export var pbrDirectLightingSetupFunctions: {
  58714. name: string;
  58715. shader: string;
  58716. };
  58717. }
  58718. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58719. /** @hidden */
  58720. export var pbrDirectLightingFalloffFunctions: {
  58721. name: string;
  58722. shader: string;
  58723. };
  58724. }
  58725. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58726. /** @hidden */
  58727. export var pbrBRDFFunctions: {
  58728. name: string;
  58729. shader: string;
  58730. };
  58731. }
  58732. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58733. /** @hidden */
  58734. export var hdrFilteringFunctions: {
  58735. name: string;
  58736. shader: string;
  58737. };
  58738. }
  58739. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58740. /** @hidden */
  58741. export var pbrDirectLightingFunctions: {
  58742. name: string;
  58743. shader: string;
  58744. };
  58745. }
  58746. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58747. /** @hidden */
  58748. export var pbrIBLFunctions: {
  58749. name: string;
  58750. shader: string;
  58751. };
  58752. }
  58753. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58754. /** @hidden */
  58755. export var pbrBlockAlbedoOpacity: {
  58756. name: string;
  58757. shader: string;
  58758. };
  58759. }
  58760. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58761. /** @hidden */
  58762. export var pbrBlockReflectivity: {
  58763. name: string;
  58764. shader: string;
  58765. };
  58766. }
  58767. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58768. /** @hidden */
  58769. export var pbrBlockAmbientOcclusion: {
  58770. name: string;
  58771. shader: string;
  58772. };
  58773. }
  58774. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58775. /** @hidden */
  58776. export var pbrBlockAlphaFresnel: {
  58777. name: string;
  58778. shader: string;
  58779. };
  58780. }
  58781. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58782. /** @hidden */
  58783. export var pbrBlockAnisotropic: {
  58784. name: string;
  58785. shader: string;
  58786. };
  58787. }
  58788. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58789. /** @hidden */
  58790. export var pbrBlockReflection: {
  58791. name: string;
  58792. shader: string;
  58793. };
  58794. }
  58795. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58796. /** @hidden */
  58797. export var pbrBlockSheen: {
  58798. name: string;
  58799. shader: string;
  58800. };
  58801. }
  58802. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58803. /** @hidden */
  58804. export var pbrBlockClearcoat: {
  58805. name: string;
  58806. shader: string;
  58807. };
  58808. }
  58809. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58810. /** @hidden */
  58811. export var pbrBlockSubSurface: {
  58812. name: string;
  58813. shader: string;
  58814. };
  58815. }
  58816. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58817. /** @hidden */
  58818. export var pbrBlockNormalGeometric: {
  58819. name: string;
  58820. shader: string;
  58821. };
  58822. }
  58823. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58824. /** @hidden */
  58825. export var pbrBlockNormalFinal: {
  58826. name: string;
  58827. shader: string;
  58828. };
  58829. }
  58830. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  58831. /** @hidden */
  58832. export var pbrBlockLightmapInit: {
  58833. name: string;
  58834. shader: string;
  58835. };
  58836. }
  58837. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  58838. /** @hidden */
  58839. export var pbrBlockGeometryInfo: {
  58840. name: string;
  58841. shader: string;
  58842. };
  58843. }
  58844. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  58845. /** @hidden */
  58846. export var pbrBlockReflectance0: {
  58847. name: string;
  58848. shader: string;
  58849. };
  58850. }
  58851. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  58852. /** @hidden */
  58853. export var pbrBlockReflectance: {
  58854. name: string;
  58855. shader: string;
  58856. };
  58857. }
  58858. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  58859. /** @hidden */
  58860. export var pbrBlockDirectLighting: {
  58861. name: string;
  58862. shader: string;
  58863. };
  58864. }
  58865. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  58866. /** @hidden */
  58867. export var pbrBlockFinalLitComponents: {
  58868. name: string;
  58869. shader: string;
  58870. };
  58871. }
  58872. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  58873. /** @hidden */
  58874. export var pbrBlockFinalUnlitComponents: {
  58875. name: string;
  58876. shader: string;
  58877. };
  58878. }
  58879. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  58880. /** @hidden */
  58881. export var pbrBlockFinalColorComposition: {
  58882. name: string;
  58883. shader: string;
  58884. };
  58885. }
  58886. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  58887. /** @hidden */
  58888. export var pbrBlockImageProcessing: {
  58889. name: string;
  58890. shader: string;
  58891. };
  58892. }
  58893. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  58894. /** @hidden */
  58895. export var pbrDebug: {
  58896. name: string;
  58897. shader: string;
  58898. };
  58899. }
  58900. declare module "babylonjs/Shaders/pbr.fragment" {
  58901. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  58902. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  58903. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58904. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  58905. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58906. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58907. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  58908. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  58909. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  58910. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58911. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  58912. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58913. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  58914. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  58915. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  58916. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  58917. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  58918. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58919. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  58920. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  58921. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  58922. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  58923. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  58924. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  58925. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  58926. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  58927. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  58928. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  58929. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  58930. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  58931. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  58932. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  58933. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  58934. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  58935. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  58936. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  58937. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  58938. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  58939. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  58940. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  58941. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  58942. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  58943. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  58944. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  58945. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  58946. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  58947. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  58948. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  58949. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  58950. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  58951. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  58952. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  58953. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  58954. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  58955. /** @hidden */
  58956. export var pbrPixelShader: {
  58957. name: string;
  58958. shader: string;
  58959. };
  58960. }
  58961. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  58962. /** @hidden */
  58963. export var pbrVertexDeclaration: {
  58964. name: string;
  58965. shader: string;
  58966. };
  58967. }
  58968. declare module "babylonjs/Shaders/pbr.vertex" {
  58969. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  58970. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  58971. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  58972. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  58973. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  58974. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  58975. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  58976. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  58977. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  58978. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  58979. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  58980. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  58981. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  58982. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  58983. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  58984. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  58985. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  58986. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  58987. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  58988. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  58989. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  58990. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  58991. /** @hidden */
  58992. export var pbrVertexShader: {
  58993. name: string;
  58994. shader: string;
  58995. };
  58996. }
  58997. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  58998. import { Nullable } from "babylonjs/types";
  58999. import { Scene } from "babylonjs/scene";
  59000. import { Matrix } from "babylonjs/Maths/math.vector";
  59001. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59002. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59003. import { Mesh } from "babylonjs/Meshes/mesh";
  59004. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59005. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59006. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59007. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59008. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59009. import { Color3 } from "babylonjs/Maths/math.color";
  59010. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59011. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59012. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59013. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59014. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59015. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59016. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59017. import "babylonjs/Shaders/pbr.fragment";
  59018. import "babylonjs/Shaders/pbr.vertex";
  59019. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59020. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59021. /**
  59022. * Manages the defines for the PBR Material.
  59023. * @hidden
  59024. */
  59025. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59026. PBR: boolean;
  59027. NUM_SAMPLES: string;
  59028. REALTIME_FILTERING: boolean;
  59029. MAINUV1: boolean;
  59030. MAINUV2: boolean;
  59031. UV1: boolean;
  59032. UV2: boolean;
  59033. ALBEDO: boolean;
  59034. GAMMAALBEDO: boolean;
  59035. ALBEDODIRECTUV: number;
  59036. VERTEXCOLOR: boolean;
  59037. DETAIL: boolean;
  59038. DETAILDIRECTUV: number;
  59039. DETAIL_NORMALBLENDMETHOD: number;
  59040. AMBIENT: boolean;
  59041. AMBIENTDIRECTUV: number;
  59042. AMBIENTINGRAYSCALE: boolean;
  59043. OPACITY: boolean;
  59044. VERTEXALPHA: boolean;
  59045. OPACITYDIRECTUV: number;
  59046. OPACITYRGB: boolean;
  59047. ALPHATEST: boolean;
  59048. DEPTHPREPASS: boolean;
  59049. ALPHABLEND: boolean;
  59050. ALPHAFROMALBEDO: boolean;
  59051. ALPHATESTVALUE: string;
  59052. SPECULAROVERALPHA: boolean;
  59053. RADIANCEOVERALPHA: boolean;
  59054. ALPHAFRESNEL: boolean;
  59055. LINEARALPHAFRESNEL: boolean;
  59056. PREMULTIPLYALPHA: boolean;
  59057. EMISSIVE: boolean;
  59058. EMISSIVEDIRECTUV: number;
  59059. REFLECTIVITY: boolean;
  59060. REFLECTIVITYDIRECTUV: number;
  59061. SPECULARTERM: boolean;
  59062. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59063. MICROSURFACEAUTOMATIC: boolean;
  59064. LODBASEDMICROSFURACE: boolean;
  59065. MICROSURFACEMAP: boolean;
  59066. MICROSURFACEMAPDIRECTUV: number;
  59067. METALLICWORKFLOW: boolean;
  59068. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59069. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59070. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59071. AOSTOREINMETALMAPRED: boolean;
  59072. METALLIC_REFLECTANCE: boolean;
  59073. METALLIC_REFLECTANCEDIRECTUV: number;
  59074. ENVIRONMENTBRDF: boolean;
  59075. ENVIRONMENTBRDF_RGBD: boolean;
  59076. NORMAL: boolean;
  59077. TANGENT: boolean;
  59078. BUMP: boolean;
  59079. BUMPDIRECTUV: number;
  59080. OBJECTSPACE_NORMALMAP: boolean;
  59081. PARALLAX: boolean;
  59082. PARALLAXOCCLUSION: boolean;
  59083. NORMALXYSCALE: boolean;
  59084. LIGHTMAP: boolean;
  59085. LIGHTMAPDIRECTUV: number;
  59086. USELIGHTMAPASSHADOWMAP: boolean;
  59087. GAMMALIGHTMAP: boolean;
  59088. RGBDLIGHTMAP: boolean;
  59089. REFLECTION: boolean;
  59090. REFLECTIONMAP_3D: boolean;
  59091. REFLECTIONMAP_SPHERICAL: boolean;
  59092. REFLECTIONMAP_PLANAR: boolean;
  59093. REFLECTIONMAP_CUBIC: boolean;
  59094. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59095. REFLECTIONMAP_PROJECTION: boolean;
  59096. REFLECTIONMAP_SKYBOX: boolean;
  59097. REFLECTIONMAP_EXPLICIT: boolean;
  59098. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59099. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59100. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59101. INVERTCUBICMAP: boolean;
  59102. USESPHERICALFROMREFLECTIONMAP: boolean;
  59103. USEIRRADIANCEMAP: boolean;
  59104. SPHERICAL_HARMONICS: boolean;
  59105. USESPHERICALINVERTEX: boolean;
  59106. REFLECTIONMAP_OPPOSITEZ: boolean;
  59107. LODINREFLECTIONALPHA: boolean;
  59108. GAMMAREFLECTION: boolean;
  59109. RGBDREFLECTION: boolean;
  59110. LINEARSPECULARREFLECTION: boolean;
  59111. RADIANCEOCCLUSION: boolean;
  59112. HORIZONOCCLUSION: boolean;
  59113. INSTANCES: boolean;
  59114. THIN_INSTANCES: boolean;
  59115. PREPASS: boolean;
  59116. PREPASS_IRRADIANCE: boolean;
  59117. PREPASS_IRRADIANCE_INDEX: number;
  59118. PREPASS_ALBEDO: boolean;
  59119. PREPASS_ALBEDO_INDEX: number;
  59120. PREPASS_DEPTHNORMAL: boolean;
  59121. PREPASS_DEPTHNORMAL_INDEX: number;
  59122. SCENE_MRT_COUNT: number;
  59123. NUM_BONE_INFLUENCERS: number;
  59124. BonesPerMesh: number;
  59125. BONETEXTURE: boolean;
  59126. NONUNIFORMSCALING: boolean;
  59127. MORPHTARGETS: boolean;
  59128. MORPHTARGETS_NORMAL: boolean;
  59129. MORPHTARGETS_TANGENT: boolean;
  59130. MORPHTARGETS_UV: boolean;
  59131. NUM_MORPH_INFLUENCERS: number;
  59132. IMAGEPROCESSING: boolean;
  59133. VIGNETTE: boolean;
  59134. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59135. VIGNETTEBLENDMODEOPAQUE: boolean;
  59136. TONEMAPPING: boolean;
  59137. TONEMAPPING_ACES: boolean;
  59138. CONTRAST: boolean;
  59139. COLORCURVES: boolean;
  59140. COLORGRADING: boolean;
  59141. COLORGRADING3D: boolean;
  59142. SAMPLER3DGREENDEPTH: boolean;
  59143. SAMPLER3DBGRMAP: boolean;
  59144. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59145. EXPOSURE: boolean;
  59146. MULTIVIEW: boolean;
  59147. USEPHYSICALLIGHTFALLOFF: boolean;
  59148. USEGLTFLIGHTFALLOFF: boolean;
  59149. TWOSIDEDLIGHTING: boolean;
  59150. SHADOWFLOAT: boolean;
  59151. CLIPPLANE: boolean;
  59152. CLIPPLANE2: boolean;
  59153. CLIPPLANE3: boolean;
  59154. CLIPPLANE4: boolean;
  59155. CLIPPLANE5: boolean;
  59156. CLIPPLANE6: boolean;
  59157. POINTSIZE: boolean;
  59158. FOG: boolean;
  59159. LOGARITHMICDEPTH: boolean;
  59160. FORCENORMALFORWARD: boolean;
  59161. SPECULARAA: boolean;
  59162. CLEARCOAT: boolean;
  59163. CLEARCOAT_DEFAULTIOR: boolean;
  59164. CLEARCOAT_TEXTURE: boolean;
  59165. CLEARCOAT_TEXTUREDIRECTUV: number;
  59166. CLEARCOAT_BUMP: boolean;
  59167. CLEARCOAT_BUMPDIRECTUV: number;
  59168. CLEARCOAT_TINT: boolean;
  59169. CLEARCOAT_TINT_TEXTURE: boolean;
  59170. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59171. ANISOTROPIC: boolean;
  59172. ANISOTROPIC_TEXTURE: boolean;
  59173. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59174. BRDF_V_HEIGHT_CORRELATED: boolean;
  59175. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59176. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59177. SHEEN: boolean;
  59178. SHEEN_TEXTURE: boolean;
  59179. SHEEN_TEXTUREDIRECTUV: number;
  59180. SHEEN_LINKWITHALBEDO: boolean;
  59181. SHEEN_ROUGHNESS: boolean;
  59182. SHEEN_ALBEDOSCALING: boolean;
  59183. SUBSURFACE: boolean;
  59184. SS_REFRACTION: boolean;
  59185. SS_TRANSLUCENCY: boolean;
  59186. SS_SCATTERING: boolean;
  59187. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59188. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59189. SS_REFRACTIONMAP_3D: boolean;
  59190. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59191. SS_LODINREFRACTIONALPHA: boolean;
  59192. SS_GAMMAREFRACTION: boolean;
  59193. SS_RGBDREFRACTION: boolean;
  59194. SS_LINEARSPECULARREFRACTION: boolean;
  59195. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59196. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59197. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59198. UNLIT: boolean;
  59199. DEBUGMODE: number;
  59200. /**
  59201. * Initializes the PBR Material defines.
  59202. */
  59203. constructor();
  59204. /**
  59205. * Resets the PBR Material defines.
  59206. */
  59207. reset(): void;
  59208. }
  59209. /**
  59210. * The Physically based material base class of BJS.
  59211. *
  59212. * This offers the main features of a standard PBR material.
  59213. * For more information, please refer to the documentation :
  59214. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59215. */
  59216. export abstract class PBRBaseMaterial extends PushMaterial {
  59217. /**
  59218. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59219. */
  59220. static readonly PBRMATERIAL_OPAQUE: number;
  59221. /**
  59222. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59223. */
  59224. static readonly PBRMATERIAL_ALPHATEST: number;
  59225. /**
  59226. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59227. */
  59228. static readonly PBRMATERIAL_ALPHABLEND: number;
  59229. /**
  59230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59231. * They are also discarded below the alpha cutoff threshold to improve performances.
  59232. */
  59233. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59234. /**
  59235. * Defines the default value of how much AO map is occluding the analytical lights
  59236. * (point spot...).
  59237. */
  59238. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59239. /**
  59240. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59241. */
  59242. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59243. /**
  59244. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59245. * to enhance interoperability with other engines.
  59246. */
  59247. static readonly LIGHTFALLOFF_GLTF: number;
  59248. /**
  59249. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59250. * to enhance interoperability with other materials.
  59251. */
  59252. static readonly LIGHTFALLOFF_STANDARD: number;
  59253. /**
  59254. * Intensity of the direct lights e.g. the four lights available in your scene.
  59255. * This impacts both the direct diffuse and specular highlights.
  59256. */
  59257. protected _directIntensity: number;
  59258. /**
  59259. * Intensity of the emissive part of the material.
  59260. * This helps controlling the emissive effect without modifying the emissive color.
  59261. */
  59262. protected _emissiveIntensity: number;
  59263. /**
  59264. * Intensity of the environment e.g. how much the environment will light the object
  59265. * either through harmonics for rough material or through the refelction for shiny ones.
  59266. */
  59267. protected _environmentIntensity: number;
  59268. /**
  59269. * This is a special control allowing the reduction of the specular highlights coming from the
  59270. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59271. */
  59272. protected _specularIntensity: number;
  59273. /**
  59274. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59275. */
  59276. private _lightingInfos;
  59277. /**
  59278. * Debug Control allowing disabling the bump map on this material.
  59279. */
  59280. protected _disableBumpMap: boolean;
  59281. /**
  59282. * AKA Diffuse Texture in standard nomenclature.
  59283. */
  59284. protected _albedoTexture: Nullable<BaseTexture>;
  59285. /**
  59286. * AKA Occlusion Texture in other nomenclature.
  59287. */
  59288. protected _ambientTexture: Nullable<BaseTexture>;
  59289. /**
  59290. * AKA Occlusion Texture Intensity in other nomenclature.
  59291. */
  59292. protected _ambientTextureStrength: number;
  59293. /**
  59294. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59295. * 1 means it completely occludes it
  59296. * 0 mean it has no impact
  59297. */
  59298. protected _ambientTextureImpactOnAnalyticalLights: number;
  59299. /**
  59300. * Stores the alpha values in a texture.
  59301. */
  59302. protected _opacityTexture: Nullable<BaseTexture>;
  59303. /**
  59304. * Stores the reflection values in a texture.
  59305. */
  59306. protected _reflectionTexture: Nullable<BaseTexture>;
  59307. /**
  59308. * Stores the emissive values in a texture.
  59309. */
  59310. protected _emissiveTexture: Nullable<BaseTexture>;
  59311. /**
  59312. * AKA Specular texture in other nomenclature.
  59313. */
  59314. protected _reflectivityTexture: Nullable<BaseTexture>;
  59315. /**
  59316. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59317. */
  59318. protected _metallicTexture: Nullable<BaseTexture>;
  59319. /**
  59320. * Specifies the metallic scalar of the metallic/roughness workflow.
  59321. * Can also be used to scale the metalness values of the metallic texture.
  59322. */
  59323. protected _metallic: Nullable<number>;
  59324. /**
  59325. * Specifies the roughness scalar of the metallic/roughness workflow.
  59326. * Can also be used to scale the roughness values of the metallic texture.
  59327. */
  59328. protected _roughness: Nullable<number>;
  59329. /**
  59330. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59331. * By default the indexOfrefraction is used to compute F0;
  59332. *
  59333. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59334. *
  59335. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59336. * F90 = metallicReflectanceColor;
  59337. */
  59338. protected _metallicF0Factor: number;
  59339. /**
  59340. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59341. * By default the F90 is always 1;
  59342. *
  59343. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59344. *
  59345. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59346. * F90 = metallicReflectanceColor;
  59347. */
  59348. protected _metallicReflectanceColor: Color3;
  59349. /**
  59350. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59351. * This is multiply against the scalar values defined in the material.
  59352. */
  59353. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59354. /**
  59355. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59356. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59357. */
  59358. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59359. /**
  59360. * Stores surface normal data used to displace a mesh in a texture.
  59361. */
  59362. protected _bumpTexture: Nullable<BaseTexture>;
  59363. /**
  59364. * Stores the pre-calculated light information of a mesh in a texture.
  59365. */
  59366. protected _lightmapTexture: Nullable<BaseTexture>;
  59367. /**
  59368. * The color of a material in ambient lighting.
  59369. */
  59370. protected _ambientColor: Color3;
  59371. /**
  59372. * AKA Diffuse Color in other nomenclature.
  59373. */
  59374. protected _albedoColor: Color3;
  59375. /**
  59376. * AKA Specular Color in other nomenclature.
  59377. */
  59378. protected _reflectivityColor: Color3;
  59379. /**
  59380. * The color applied when light is reflected from a material.
  59381. */
  59382. protected _reflectionColor: Color3;
  59383. /**
  59384. * The color applied when light is emitted from a material.
  59385. */
  59386. protected _emissiveColor: Color3;
  59387. /**
  59388. * AKA Glossiness in other nomenclature.
  59389. */
  59390. protected _microSurface: number;
  59391. /**
  59392. * Specifies that the material will use the light map as a show map.
  59393. */
  59394. protected _useLightmapAsShadowmap: boolean;
  59395. /**
  59396. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59397. * makes the reflect vector face the model (under horizon).
  59398. */
  59399. protected _useHorizonOcclusion: boolean;
  59400. /**
  59401. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59402. * too much the area relying on ambient texture to define their ambient occlusion.
  59403. */
  59404. protected _useRadianceOcclusion: boolean;
  59405. /**
  59406. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59407. */
  59408. protected _useAlphaFromAlbedoTexture: boolean;
  59409. /**
  59410. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59411. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59412. */
  59413. protected _useSpecularOverAlpha: boolean;
  59414. /**
  59415. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59416. */
  59417. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59418. /**
  59419. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59420. */
  59421. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59422. /**
  59423. * Specifies if the metallic texture contains the roughness information in its green channel.
  59424. */
  59425. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59426. /**
  59427. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59428. */
  59429. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59430. /**
  59431. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59432. */
  59433. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59434. /**
  59435. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59436. */
  59437. protected _useAmbientInGrayScale: boolean;
  59438. /**
  59439. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59440. * The material will try to infer what glossiness each pixel should be.
  59441. */
  59442. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59443. /**
  59444. * Defines the falloff type used in this material.
  59445. * It by default is Physical.
  59446. */
  59447. protected _lightFalloff: number;
  59448. /**
  59449. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59450. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59451. */
  59452. protected _useRadianceOverAlpha: boolean;
  59453. /**
  59454. * Allows using an object space normal map (instead of tangent space).
  59455. */
  59456. protected _useObjectSpaceNormalMap: boolean;
  59457. /**
  59458. * Allows using the bump map in parallax mode.
  59459. */
  59460. protected _useParallax: boolean;
  59461. /**
  59462. * Allows using the bump map in parallax occlusion mode.
  59463. */
  59464. protected _useParallaxOcclusion: boolean;
  59465. /**
  59466. * Controls the scale bias of the parallax mode.
  59467. */
  59468. protected _parallaxScaleBias: number;
  59469. /**
  59470. * If sets to true, disables all the lights affecting the material.
  59471. */
  59472. protected _disableLighting: boolean;
  59473. /**
  59474. * Number of Simultaneous lights allowed on the material.
  59475. */
  59476. protected _maxSimultaneousLights: number;
  59477. /**
  59478. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59479. */
  59480. protected _invertNormalMapX: boolean;
  59481. /**
  59482. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59483. */
  59484. protected _invertNormalMapY: boolean;
  59485. /**
  59486. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59487. */
  59488. protected _twoSidedLighting: boolean;
  59489. /**
  59490. * Defines the alpha limits in alpha test mode.
  59491. */
  59492. protected _alphaCutOff: number;
  59493. /**
  59494. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59495. */
  59496. protected _forceAlphaTest: boolean;
  59497. /**
  59498. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59499. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59500. */
  59501. protected _useAlphaFresnel: boolean;
  59502. /**
  59503. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59504. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59505. */
  59506. protected _useLinearAlphaFresnel: boolean;
  59507. /**
  59508. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59509. * from cos thetav and roughness:
  59510. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59511. */
  59512. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59513. /**
  59514. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59515. */
  59516. protected _forceIrradianceInFragment: boolean;
  59517. private _realTimeFiltering;
  59518. /**
  59519. * Enables realtime filtering on the texture.
  59520. */
  59521. get realTimeFiltering(): boolean;
  59522. set realTimeFiltering(b: boolean);
  59523. private _realTimeFilteringQuality;
  59524. /**
  59525. * Quality switch for realtime filtering
  59526. */
  59527. get realTimeFilteringQuality(): number;
  59528. set realTimeFilteringQuality(n: number);
  59529. /**
  59530. * Can this material render to several textures at once
  59531. */
  59532. get canRenderToMRT(): boolean;
  59533. /**
  59534. * Force normal to face away from face.
  59535. */
  59536. protected _forceNormalForward: boolean;
  59537. /**
  59538. * Enables specular anti aliasing in the PBR shader.
  59539. * It will both interacts on the Geometry for analytical and IBL lighting.
  59540. * It also prefilter the roughness map based on the bump values.
  59541. */
  59542. protected _enableSpecularAntiAliasing: boolean;
  59543. /**
  59544. * Default configuration related to image processing available in the PBR Material.
  59545. */
  59546. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59547. /**
  59548. * Keep track of the image processing observer to allow dispose and replace.
  59549. */
  59550. private _imageProcessingObserver;
  59551. /**
  59552. * Attaches a new image processing configuration to the PBR Material.
  59553. * @param configuration
  59554. */
  59555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59556. /**
  59557. * Stores the available render targets.
  59558. */
  59559. private _renderTargets;
  59560. /**
  59561. * Sets the global ambient color for the material used in lighting calculations.
  59562. */
  59563. private _globalAmbientColor;
  59564. /**
  59565. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59566. */
  59567. private _useLogarithmicDepth;
  59568. /**
  59569. * If set to true, no lighting calculations will be applied.
  59570. */
  59571. private _unlit;
  59572. private _debugMode;
  59573. /**
  59574. * @hidden
  59575. * This is reserved for the inspector.
  59576. * Defines the material debug mode.
  59577. * It helps seeing only some components of the material while troubleshooting.
  59578. */
  59579. debugMode: number;
  59580. /**
  59581. * @hidden
  59582. * This is reserved for the inspector.
  59583. * Specify from where on screen the debug mode should start.
  59584. * The value goes from -1 (full screen) to 1 (not visible)
  59585. * It helps with side by side comparison against the final render
  59586. * This defaults to -1
  59587. */
  59588. private debugLimit;
  59589. /**
  59590. * @hidden
  59591. * This is reserved for the inspector.
  59592. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59593. * You can use the factor to better multiply the final value.
  59594. */
  59595. private debugFactor;
  59596. /**
  59597. * Defines the clear coat layer parameters for the material.
  59598. */
  59599. readonly clearCoat: PBRClearCoatConfiguration;
  59600. /**
  59601. * Defines the anisotropic parameters for the material.
  59602. */
  59603. readonly anisotropy: PBRAnisotropicConfiguration;
  59604. /**
  59605. * Defines the BRDF parameters for the material.
  59606. */
  59607. readonly brdf: PBRBRDFConfiguration;
  59608. /**
  59609. * Defines the Sheen parameters for the material.
  59610. */
  59611. readonly sheen: PBRSheenConfiguration;
  59612. /**
  59613. * Defines the SubSurface parameters for the material.
  59614. */
  59615. readonly subSurface: PBRSubSurfaceConfiguration;
  59616. /**
  59617. * Defines the detail map parameters for the material.
  59618. */
  59619. readonly detailMap: DetailMapConfiguration;
  59620. protected _rebuildInParallel: boolean;
  59621. /**
  59622. * Instantiates a new PBRMaterial instance.
  59623. *
  59624. * @param name The material name
  59625. * @param scene The scene the material will be use in.
  59626. */
  59627. constructor(name: string, scene: Scene);
  59628. /**
  59629. * Gets a boolean indicating that current material needs to register RTT
  59630. */
  59631. get hasRenderTargetTextures(): boolean;
  59632. /**
  59633. * Gets the name of the material class.
  59634. */
  59635. getClassName(): string;
  59636. /**
  59637. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59638. */
  59639. get useLogarithmicDepth(): boolean;
  59640. /**
  59641. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59642. */
  59643. set useLogarithmicDepth(value: boolean);
  59644. /**
  59645. * Returns true if alpha blending should be disabled.
  59646. */
  59647. protected get _disableAlphaBlending(): boolean;
  59648. /**
  59649. * Specifies whether or not this material should be rendered in alpha blend mode.
  59650. */
  59651. needAlphaBlending(): boolean;
  59652. /**
  59653. * Specifies whether or not this material should be rendered in alpha test mode.
  59654. */
  59655. needAlphaTesting(): boolean;
  59656. /**
  59657. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59658. */
  59659. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59660. /**
  59661. * Gets the texture used for the alpha test.
  59662. */
  59663. getAlphaTestTexture(): Nullable<BaseTexture>;
  59664. /**
  59665. * Specifies that the submesh is ready to be used.
  59666. * @param mesh - BJS mesh.
  59667. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59668. * @param useInstances - Specifies that instances should be used.
  59669. * @returns - boolean indicating that the submesh is ready or not.
  59670. */
  59671. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59672. /**
  59673. * Specifies if the material uses metallic roughness workflow.
  59674. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59675. */
  59676. isMetallicWorkflow(): boolean;
  59677. private _prepareEffect;
  59678. private _prepareDefines;
  59679. /**
  59680. * Force shader compilation
  59681. */
  59682. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59683. /**
  59684. * Initializes the uniform buffer layout for the shader.
  59685. */
  59686. buildUniformLayout(): void;
  59687. /**
  59688. * Unbinds the material from the mesh
  59689. */
  59690. unbind(): void;
  59691. /**
  59692. * Binds the submesh data.
  59693. * @param world - The world matrix.
  59694. * @param mesh - The BJS mesh.
  59695. * @param subMesh - A submesh of the BJS mesh.
  59696. */
  59697. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59698. /**
  59699. * Returns the animatable textures.
  59700. * @returns - Array of animatable textures.
  59701. */
  59702. getAnimatables(): IAnimatable[];
  59703. /**
  59704. * Returns the texture used for reflections.
  59705. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59706. */
  59707. private _getReflectionTexture;
  59708. /**
  59709. * Returns an array of the actively used textures.
  59710. * @returns - Array of BaseTextures
  59711. */
  59712. getActiveTextures(): BaseTexture[];
  59713. /**
  59714. * Checks to see if a texture is used in the material.
  59715. * @param texture - Base texture to use.
  59716. * @returns - Boolean specifying if a texture is used in the material.
  59717. */
  59718. hasTexture(texture: BaseTexture): boolean;
  59719. /**
  59720. * Sets the required values to the prepass renderer.
  59721. * @param prePassRenderer defines the prepass renderer to setup
  59722. */
  59723. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59724. /**
  59725. * Disposes the resources of the material.
  59726. * @param forceDisposeEffect - Forces the disposal of effects.
  59727. * @param forceDisposeTextures - Forces the disposal of all textures.
  59728. */
  59729. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59730. }
  59731. }
  59732. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59733. import { Nullable } from "babylonjs/types";
  59734. import { Scene } from "babylonjs/scene";
  59735. import { Color3 } from "babylonjs/Maths/math.color";
  59736. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59737. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59738. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59739. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59740. /**
  59741. * The Physically based material of BJS.
  59742. *
  59743. * This offers the main features of a standard PBR material.
  59744. * For more information, please refer to the documentation :
  59745. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59746. */
  59747. export class PBRMaterial extends PBRBaseMaterial {
  59748. /**
  59749. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59750. */
  59751. static readonly PBRMATERIAL_OPAQUE: number;
  59752. /**
  59753. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59754. */
  59755. static readonly PBRMATERIAL_ALPHATEST: number;
  59756. /**
  59757. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59758. */
  59759. static readonly PBRMATERIAL_ALPHABLEND: number;
  59760. /**
  59761. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59762. * They are also discarded below the alpha cutoff threshold to improve performances.
  59763. */
  59764. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59765. /**
  59766. * Defines the default value of how much AO map is occluding the analytical lights
  59767. * (point spot...).
  59768. */
  59769. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59770. /**
  59771. * Intensity of the direct lights e.g. the four lights available in your scene.
  59772. * This impacts both the direct diffuse and specular highlights.
  59773. */
  59774. directIntensity: number;
  59775. /**
  59776. * Intensity of the emissive part of the material.
  59777. * This helps controlling the emissive effect without modifying the emissive color.
  59778. */
  59779. emissiveIntensity: number;
  59780. /**
  59781. * Intensity of the environment e.g. how much the environment will light the object
  59782. * either through harmonics for rough material or through the refelction for shiny ones.
  59783. */
  59784. environmentIntensity: number;
  59785. /**
  59786. * This is a special control allowing the reduction of the specular highlights coming from the
  59787. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59788. */
  59789. specularIntensity: number;
  59790. /**
  59791. * Debug Control allowing disabling the bump map on this material.
  59792. */
  59793. disableBumpMap: boolean;
  59794. /**
  59795. * AKA Diffuse Texture in standard nomenclature.
  59796. */
  59797. albedoTexture: BaseTexture;
  59798. /**
  59799. * AKA Occlusion Texture in other nomenclature.
  59800. */
  59801. ambientTexture: BaseTexture;
  59802. /**
  59803. * AKA Occlusion Texture Intensity in other nomenclature.
  59804. */
  59805. ambientTextureStrength: number;
  59806. /**
  59807. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59808. * 1 means it completely occludes it
  59809. * 0 mean it has no impact
  59810. */
  59811. ambientTextureImpactOnAnalyticalLights: number;
  59812. /**
  59813. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  59814. */
  59815. opacityTexture: BaseTexture;
  59816. /**
  59817. * Stores the reflection values in a texture.
  59818. */
  59819. reflectionTexture: Nullable<BaseTexture>;
  59820. /**
  59821. * Stores the emissive values in a texture.
  59822. */
  59823. emissiveTexture: BaseTexture;
  59824. /**
  59825. * AKA Specular texture in other nomenclature.
  59826. */
  59827. reflectivityTexture: BaseTexture;
  59828. /**
  59829. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59830. */
  59831. metallicTexture: BaseTexture;
  59832. /**
  59833. * Specifies the metallic scalar of the metallic/roughness workflow.
  59834. * Can also be used to scale the metalness values of the metallic texture.
  59835. */
  59836. metallic: Nullable<number>;
  59837. /**
  59838. * Specifies the roughness scalar of the metallic/roughness workflow.
  59839. * Can also be used to scale the roughness values of the metallic texture.
  59840. */
  59841. roughness: Nullable<number>;
  59842. /**
  59843. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59844. * By default the indexOfrefraction is used to compute F0;
  59845. *
  59846. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59847. *
  59848. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59849. * F90 = metallicReflectanceColor;
  59850. */
  59851. metallicF0Factor: number;
  59852. /**
  59853. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59854. * By default the F90 is always 1;
  59855. *
  59856. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59857. *
  59858. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59859. * F90 = metallicReflectanceColor;
  59860. */
  59861. metallicReflectanceColor: Color3;
  59862. /**
  59863. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59864. * This is multiply against the scalar values defined in the material.
  59865. */
  59866. metallicReflectanceTexture: Nullable<BaseTexture>;
  59867. /**
  59868. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59869. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59870. */
  59871. microSurfaceTexture: BaseTexture;
  59872. /**
  59873. * Stores surface normal data used to displace a mesh in a texture.
  59874. */
  59875. bumpTexture: BaseTexture;
  59876. /**
  59877. * Stores the pre-calculated light information of a mesh in a texture.
  59878. */
  59879. lightmapTexture: BaseTexture;
  59880. /**
  59881. * Stores the refracted light information in a texture.
  59882. */
  59883. get refractionTexture(): Nullable<BaseTexture>;
  59884. set refractionTexture(value: Nullable<BaseTexture>);
  59885. /**
  59886. * The color of a material in ambient lighting.
  59887. */
  59888. ambientColor: Color3;
  59889. /**
  59890. * AKA Diffuse Color in other nomenclature.
  59891. */
  59892. albedoColor: Color3;
  59893. /**
  59894. * AKA Specular Color in other nomenclature.
  59895. */
  59896. reflectivityColor: Color3;
  59897. /**
  59898. * The color reflected from the material.
  59899. */
  59900. reflectionColor: Color3;
  59901. /**
  59902. * The color emitted from the material.
  59903. */
  59904. emissiveColor: Color3;
  59905. /**
  59906. * AKA Glossiness in other nomenclature.
  59907. */
  59908. microSurface: number;
  59909. /**
  59910. * Index of refraction of the material base layer.
  59911. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  59912. *
  59913. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  59914. *
  59915. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  59916. */
  59917. get indexOfRefraction(): number;
  59918. set indexOfRefraction(value: number);
  59919. /**
  59920. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  59921. */
  59922. get invertRefractionY(): boolean;
  59923. set invertRefractionY(value: boolean);
  59924. /**
  59925. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  59926. * Materials half opaque for instance using refraction could benefit from this control.
  59927. */
  59928. get linkRefractionWithTransparency(): boolean;
  59929. set linkRefractionWithTransparency(value: boolean);
  59930. /**
  59931. * If true, the light map contains occlusion information instead of lighting info.
  59932. */
  59933. useLightmapAsShadowmap: boolean;
  59934. /**
  59935. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59936. */
  59937. useAlphaFromAlbedoTexture: boolean;
  59938. /**
  59939. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59940. */
  59941. forceAlphaTest: boolean;
  59942. /**
  59943. * Defines the alpha limits in alpha test mode.
  59944. */
  59945. alphaCutOff: number;
  59946. /**
  59947. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  59948. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59949. */
  59950. useSpecularOverAlpha: boolean;
  59951. /**
  59952. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59953. */
  59954. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59955. /**
  59956. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59957. */
  59958. useRoughnessFromMetallicTextureAlpha: boolean;
  59959. /**
  59960. * Specifies if the metallic texture contains the roughness information in its green channel.
  59961. */
  59962. useRoughnessFromMetallicTextureGreen: boolean;
  59963. /**
  59964. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59965. */
  59966. useMetallnessFromMetallicTextureBlue: boolean;
  59967. /**
  59968. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59969. */
  59970. useAmbientOcclusionFromMetallicTextureRed: boolean;
  59971. /**
  59972. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59973. */
  59974. useAmbientInGrayScale: boolean;
  59975. /**
  59976. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59977. * The material will try to infer what glossiness each pixel should be.
  59978. */
  59979. useAutoMicroSurfaceFromReflectivityMap: boolean;
  59980. /**
  59981. * BJS is using an harcoded light falloff based on a manually sets up range.
  59982. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59983. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59984. */
  59985. get usePhysicalLightFalloff(): boolean;
  59986. /**
  59987. * BJS is using an harcoded light falloff based on a manually sets up range.
  59988. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  59989. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  59990. */
  59991. set usePhysicalLightFalloff(value: boolean);
  59992. /**
  59993. * In order to support the falloff compatibility with gltf, a special mode has been added
  59994. * to reproduce the gltf light falloff.
  59995. */
  59996. get useGLTFLightFalloff(): boolean;
  59997. /**
  59998. * In order to support the falloff compatibility with gltf, a special mode has been added
  59999. * to reproduce the gltf light falloff.
  60000. */
  60001. set useGLTFLightFalloff(value: boolean);
  60002. /**
  60003. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60004. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60005. */
  60006. useRadianceOverAlpha: boolean;
  60007. /**
  60008. * Allows using an object space normal map (instead of tangent space).
  60009. */
  60010. useObjectSpaceNormalMap: boolean;
  60011. /**
  60012. * Allows using the bump map in parallax mode.
  60013. */
  60014. useParallax: boolean;
  60015. /**
  60016. * Allows using the bump map in parallax occlusion mode.
  60017. */
  60018. useParallaxOcclusion: boolean;
  60019. /**
  60020. * Controls the scale bias of the parallax mode.
  60021. */
  60022. parallaxScaleBias: number;
  60023. /**
  60024. * If sets to true, disables all the lights affecting the material.
  60025. */
  60026. disableLighting: boolean;
  60027. /**
  60028. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60029. */
  60030. forceIrradianceInFragment: boolean;
  60031. /**
  60032. * Number of Simultaneous lights allowed on the material.
  60033. */
  60034. maxSimultaneousLights: number;
  60035. /**
  60036. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60037. */
  60038. invertNormalMapX: boolean;
  60039. /**
  60040. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60041. */
  60042. invertNormalMapY: boolean;
  60043. /**
  60044. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60045. */
  60046. twoSidedLighting: boolean;
  60047. /**
  60048. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60049. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60050. */
  60051. useAlphaFresnel: boolean;
  60052. /**
  60053. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60054. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60055. */
  60056. useLinearAlphaFresnel: boolean;
  60057. /**
  60058. * Let user defines the brdf lookup texture used for IBL.
  60059. * A default 8bit version is embedded but you could point at :
  60060. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60061. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60062. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60063. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60064. */
  60065. environmentBRDFTexture: Nullable<BaseTexture>;
  60066. /**
  60067. * Force normal to face away from face.
  60068. */
  60069. forceNormalForward: boolean;
  60070. /**
  60071. * Enables specular anti aliasing in the PBR shader.
  60072. * It will both interacts on the Geometry for analytical and IBL lighting.
  60073. * It also prefilter the roughness map based on the bump values.
  60074. */
  60075. enableSpecularAntiAliasing: boolean;
  60076. /**
  60077. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60078. * makes the reflect vector face the model (under horizon).
  60079. */
  60080. useHorizonOcclusion: boolean;
  60081. /**
  60082. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60083. * too much the area relying on ambient texture to define their ambient occlusion.
  60084. */
  60085. useRadianceOcclusion: boolean;
  60086. /**
  60087. * If set to true, no lighting calculations will be applied.
  60088. */
  60089. unlit: boolean;
  60090. /**
  60091. * Gets the image processing configuration used either in this material.
  60092. */
  60093. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60094. /**
  60095. * Sets the Default image processing configuration used either in the this material.
  60096. *
  60097. * If sets to null, the scene one is in use.
  60098. */
  60099. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60100. /**
  60101. * Gets wether the color curves effect is enabled.
  60102. */
  60103. get cameraColorCurvesEnabled(): boolean;
  60104. /**
  60105. * Sets wether the color curves effect is enabled.
  60106. */
  60107. set cameraColorCurvesEnabled(value: boolean);
  60108. /**
  60109. * Gets wether the color grading effect is enabled.
  60110. */
  60111. get cameraColorGradingEnabled(): boolean;
  60112. /**
  60113. * Gets wether the color grading effect is enabled.
  60114. */
  60115. set cameraColorGradingEnabled(value: boolean);
  60116. /**
  60117. * Gets wether tonemapping is enabled or not.
  60118. */
  60119. get cameraToneMappingEnabled(): boolean;
  60120. /**
  60121. * Sets wether tonemapping is enabled or not
  60122. */
  60123. set cameraToneMappingEnabled(value: boolean);
  60124. /**
  60125. * The camera exposure used on this material.
  60126. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60127. * This corresponds to a photographic exposure.
  60128. */
  60129. get cameraExposure(): number;
  60130. /**
  60131. * The camera exposure used on this material.
  60132. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60133. * This corresponds to a photographic exposure.
  60134. */
  60135. set cameraExposure(value: number);
  60136. /**
  60137. * Gets The camera contrast used on this material.
  60138. */
  60139. get cameraContrast(): number;
  60140. /**
  60141. * Sets The camera contrast used on this material.
  60142. */
  60143. set cameraContrast(value: number);
  60144. /**
  60145. * Gets the Color Grading 2D Lookup Texture.
  60146. */
  60147. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60148. /**
  60149. * Sets the Color Grading 2D Lookup Texture.
  60150. */
  60151. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60152. /**
  60153. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60154. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60155. * 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;
  60156. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60157. */
  60158. get cameraColorCurves(): Nullable<ColorCurves>;
  60159. /**
  60160. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60161. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60162. * 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;
  60163. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60164. */
  60165. set cameraColorCurves(value: Nullable<ColorCurves>);
  60166. /**
  60167. * Instantiates a new PBRMaterial instance.
  60168. *
  60169. * @param name The material name
  60170. * @param scene The scene the material will be use in.
  60171. */
  60172. constructor(name: string, scene: Scene);
  60173. /**
  60174. * Returns the name of this material class.
  60175. */
  60176. getClassName(): string;
  60177. /**
  60178. * Makes a duplicate of the current material.
  60179. * @param name - name to use for the new material.
  60180. */
  60181. clone(name: string): PBRMaterial;
  60182. /**
  60183. * Serializes this PBR Material.
  60184. * @returns - An object with the serialized material.
  60185. */
  60186. serialize(): any;
  60187. /**
  60188. * Parses a PBR Material from a serialized object.
  60189. * @param source - Serialized object.
  60190. * @param scene - BJS scene instance.
  60191. * @param rootUrl - url for the scene object
  60192. * @returns - PBRMaterial
  60193. */
  60194. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60195. }
  60196. }
  60197. declare module "babylonjs/Misc/dds" {
  60198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60199. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60200. import { Nullable } from "babylonjs/types";
  60201. import { Scene } from "babylonjs/scene";
  60202. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60203. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60204. /**
  60205. * Direct draw surface info
  60206. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60207. */
  60208. export interface DDSInfo {
  60209. /**
  60210. * Width of the texture
  60211. */
  60212. width: number;
  60213. /**
  60214. * Width of the texture
  60215. */
  60216. height: number;
  60217. /**
  60218. * Number of Mipmaps for the texture
  60219. * @see https://en.wikipedia.org/wiki/Mipmap
  60220. */
  60221. mipmapCount: number;
  60222. /**
  60223. * If the textures format is a known fourCC format
  60224. * @see https://www.fourcc.org/
  60225. */
  60226. isFourCC: boolean;
  60227. /**
  60228. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60229. */
  60230. isRGB: boolean;
  60231. /**
  60232. * If the texture is a lumincance format
  60233. */
  60234. isLuminance: boolean;
  60235. /**
  60236. * If this is a cube texture
  60237. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60238. */
  60239. isCube: boolean;
  60240. /**
  60241. * If the texture is a compressed format eg. FOURCC_DXT1
  60242. */
  60243. isCompressed: boolean;
  60244. /**
  60245. * The dxgiFormat of the texture
  60246. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60247. */
  60248. dxgiFormat: number;
  60249. /**
  60250. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60251. */
  60252. textureType: number;
  60253. /**
  60254. * Sphericle polynomial created for the dds texture
  60255. */
  60256. sphericalPolynomial?: SphericalPolynomial;
  60257. }
  60258. /**
  60259. * Class used to provide DDS decompression tools
  60260. */
  60261. export class DDSTools {
  60262. /**
  60263. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60264. */
  60265. static StoreLODInAlphaChannel: boolean;
  60266. /**
  60267. * Gets DDS information from an array buffer
  60268. * @param data defines the array buffer view to read data from
  60269. * @returns the DDS information
  60270. */
  60271. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60272. private static _FloatView;
  60273. private static _Int32View;
  60274. private static _ToHalfFloat;
  60275. private static _FromHalfFloat;
  60276. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60277. private static _GetHalfFloatRGBAArrayBuffer;
  60278. private static _GetFloatRGBAArrayBuffer;
  60279. private static _GetFloatAsUIntRGBAArrayBuffer;
  60280. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60281. private static _GetRGBAArrayBuffer;
  60282. private static _ExtractLongWordOrder;
  60283. private static _GetRGBArrayBuffer;
  60284. private static _GetLuminanceArrayBuffer;
  60285. /**
  60286. * Uploads DDS Levels to a Babylon Texture
  60287. * @hidden
  60288. */
  60289. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60290. }
  60291. module "babylonjs/Engines/thinEngine" {
  60292. interface ThinEngine {
  60293. /**
  60294. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60295. * @param rootUrl defines the url where the file to load is located
  60296. * @param scene defines the current scene
  60297. * @param lodScale defines scale to apply to the mip map selection
  60298. * @param lodOffset defines offset to apply to the mip map selection
  60299. * @param onLoad defines an optional callback raised when the texture is loaded
  60300. * @param onError defines an optional callback raised if there is an issue to load the texture
  60301. * @param format defines the format of the data
  60302. * @param forcedExtension defines the extension to use to pick the right loader
  60303. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60304. * @returns the cube texture as an InternalTexture
  60305. */
  60306. 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;
  60307. }
  60308. }
  60309. }
  60310. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60311. import { Nullable } from "babylonjs/types";
  60312. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60313. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60314. /**
  60315. * Implementation of the DDS Texture Loader.
  60316. * @hidden
  60317. */
  60318. export class _DDSTextureLoader implements IInternalTextureLoader {
  60319. /**
  60320. * Defines wether the loader supports cascade loading the different faces.
  60321. */
  60322. readonly supportCascades: boolean;
  60323. /**
  60324. * This returns if the loader support the current file information.
  60325. * @param extension defines the file extension of the file being loaded
  60326. * @returns true if the loader can load the specified file
  60327. */
  60328. canLoad(extension: string): boolean;
  60329. /**
  60330. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60331. * @param data contains the texture data
  60332. * @param texture defines the BabylonJS internal texture
  60333. * @param createPolynomials will be true if polynomials have been requested
  60334. * @param onLoad defines the callback to trigger once the texture is ready
  60335. * @param onError defines the callback to trigger in case of error
  60336. */
  60337. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60338. /**
  60339. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60340. * @param data contains the texture data
  60341. * @param texture defines the BabylonJS internal texture
  60342. * @param callback defines the method to call once ready to upload
  60343. */
  60344. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60345. }
  60346. }
  60347. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60348. import { Nullable } from "babylonjs/types";
  60349. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60350. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60351. /**
  60352. * Implementation of the ENV Texture Loader.
  60353. * @hidden
  60354. */
  60355. export class _ENVTextureLoader implements IInternalTextureLoader {
  60356. /**
  60357. * Defines wether the loader supports cascade loading the different faces.
  60358. */
  60359. readonly supportCascades: boolean;
  60360. /**
  60361. * This returns if the loader support the current file information.
  60362. * @param extension defines the file extension of the file being loaded
  60363. * @returns true if the loader can load the specified file
  60364. */
  60365. canLoad(extension: string): boolean;
  60366. /**
  60367. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60368. * @param data contains the texture data
  60369. * @param texture defines the BabylonJS internal texture
  60370. * @param createPolynomials will be true if polynomials have been requested
  60371. * @param onLoad defines the callback to trigger once the texture is ready
  60372. * @param onError defines the callback to trigger in case of error
  60373. */
  60374. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60375. /**
  60376. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60377. * @param data contains the texture data
  60378. * @param texture defines the BabylonJS internal texture
  60379. * @param callback defines the method to call once ready to upload
  60380. */
  60381. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60382. }
  60383. }
  60384. declare module "babylonjs/Misc/khronosTextureContainer" {
  60385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60386. /**
  60387. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60388. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60389. */
  60390. export class KhronosTextureContainer {
  60391. /** contents of the KTX container file */
  60392. data: ArrayBufferView;
  60393. private static HEADER_LEN;
  60394. private static COMPRESSED_2D;
  60395. private static COMPRESSED_3D;
  60396. private static TEX_2D;
  60397. private static TEX_3D;
  60398. /**
  60399. * Gets the openGL type
  60400. */
  60401. glType: number;
  60402. /**
  60403. * Gets the openGL type size
  60404. */
  60405. glTypeSize: number;
  60406. /**
  60407. * Gets the openGL format
  60408. */
  60409. glFormat: number;
  60410. /**
  60411. * Gets the openGL internal format
  60412. */
  60413. glInternalFormat: number;
  60414. /**
  60415. * Gets the base internal format
  60416. */
  60417. glBaseInternalFormat: number;
  60418. /**
  60419. * Gets image width in pixel
  60420. */
  60421. pixelWidth: number;
  60422. /**
  60423. * Gets image height in pixel
  60424. */
  60425. pixelHeight: number;
  60426. /**
  60427. * Gets image depth in pixels
  60428. */
  60429. pixelDepth: number;
  60430. /**
  60431. * Gets the number of array elements
  60432. */
  60433. numberOfArrayElements: number;
  60434. /**
  60435. * Gets the number of faces
  60436. */
  60437. numberOfFaces: number;
  60438. /**
  60439. * Gets the number of mipmap levels
  60440. */
  60441. numberOfMipmapLevels: number;
  60442. /**
  60443. * Gets the bytes of key value data
  60444. */
  60445. bytesOfKeyValueData: number;
  60446. /**
  60447. * Gets the load type
  60448. */
  60449. loadType: number;
  60450. /**
  60451. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60452. */
  60453. isInvalid: boolean;
  60454. /**
  60455. * Creates a new KhronosTextureContainer
  60456. * @param data contents of the KTX container file
  60457. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60458. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60459. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60460. */
  60461. constructor(
  60462. /** contents of the KTX container file */
  60463. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60464. /**
  60465. * Uploads KTX content to a Babylon Texture.
  60466. * It is assumed that the texture has already been created & is currently bound
  60467. * @hidden
  60468. */
  60469. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60470. private _upload2DCompressedLevels;
  60471. /**
  60472. * Checks if the given data starts with a KTX file identifier.
  60473. * @param data the data to check
  60474. * @returns true if the data is a KTX file or false otherwise
  60475. */
  60476. static IsValid(data: ArrayBufferView): boolean;
  60477. }
  60478. }
  60479. declare module "babylonjs/Misc/workerPool" {
  60480. import { IDisposable } from "babylonjs/scene";
  60481. /**
  60482. * Helper class to push actions to a pool of workers.
  60483. */
  60484. export class WorkerPool implements IDisposable {
  60485. private _workerInfos;
  60486. private _pendingActions;
  60487. /**
  60488. * Constructor
  60489. * @param workers Array of workers to use for actions
  60490. */
  60491. constructor(workers: Array<Worker>);
  60492. /**
  60493. * Terminates all workers and clears any pending actions.
  60494. */
  60495. dispose(): void;
  60496. /**
  60497. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60498. * pended until a worker has completed its action.
  60499. * @param action The action to perform. Call onComplete when the action is complete.
  60500. */
  60501. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60502. private _execute;
  60503. }
  60504. }
  60505. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60506. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60507. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60508. /**
  60509. * Class for loading KTX2 files
  60510. * @hidden
  60511. */
  60512. export class KhronosTextureContainer2 {
  60513. private static _WorkerPoolPromise?;
  60514. private static _Initialized;
  60515. private static _Ktx2Decoder;
  60516. /**
  60517. * URL to use when loading the KTX2 decoder module
  60518. */
  60519. static JSModuleURL: string;
  60520. /**
  60521. * Default number of workers used to handle data decoding
  60522. */
  60523. static DefaultNumWorkers: number;
  60524. private static GetDefaultNumWorkers;
  60525. private _engine;
  60526. private static _CreateWorkerPool;
  60527. /**
  60528. * Constructor
  60529. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60530. */
  60531. constructor(engine: ThinEngine, numWorkers?: number);
  60532. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60533. /**
  60534. * Stop all async operations and release resources.
  60535. */
  60536. dispose(): void;
  60537. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60538. /**
  60539. * Checks if the given data starts with a KTX2 file identifier.
  60540. * @param data the data to check
  60541. * @returns true if the data is a KTX2 file or false otherwise
  60542. */
  60543. static IsValid(data: ArrayBufferView): boolean;
  60544. }
  60545. export function workerFunc(): void;
  60546. }
  60547. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60548. import { Nullable } from "babylonjs/types";
  60549. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60550. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60551. /**
  60552. * Implementation of the KTX Texture Loader.
  60553. * @hidden
  60554. */
  60555. export class _KTXTextureLoader implements IInternalTextureLoader {
  60556. /**
  60557. * Defines wether the loader supports cascade loading the different faces.
  60558. */
  60559. readonly supportCascades: boolean;
  60560. /**
  60561. * This returns if the loader support the current file information.
  60562. * @param extension defines the file extension of the file being loaded
  60563. * @param mimeType defines the optional mime type of the file being loaded
  60564. * @returns true if the loader can load the specified file
  60565. */
  60566. canLoad(extension: string, mimeType?: string): boolean;
  60567. /**
  60568. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60569. * @param data contains the texture data
  60570. * @param texture defines the BabylonJS internal texture
  60571. * @param createPolynomials will be true if polynomials have been requested
  60572. * @param onLoad defines the callback to trigger once the texture is ready
  60573. * @param onError defines the callback to trigger in case of error
  60574. */
  60575. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60576. /**
  60577. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60578. * @param data contains the texture data
  60579. * @param texture defines the BabylonJS internal texture
  60580. * @param callback defines the method to call once ready to upload
  60581. */
  60582. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60583. }
  60584. }
  60585. declare module "babylonjs/Helpers/sceneHelpers" {
  60586. import { Nullable } from "babylonjs/types";
  60587. import { Mesh } from "babylonjs/Meshes/mesh";
  60588. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60589. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60590. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60591. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60592. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60593. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60594. import "babylonjs/Meshes/Builders/boxBuilder";
  60595. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60596. /** @hidden */
  60597. export var _forceSceneHelpersToBundle: boolean;
  60598. module "babylonjs/scene" {
  60599. interface Scene {
  60600. /**
  60601. * Creates a default light for the scene.
  60602. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60603. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60604. */
  60605. createDefaultLight(replace?: boolean): void;
  60606. /**
  60607. * Creates a default camera for the scene.
  60608. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60609. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60610. * @param replace has default false, when true replaces the active camera in the scene
  60611. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60612. */
  60613. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60614. /**
  60615. * Creates a default camera and a default light.
  60616. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60617. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60618. * @param replace has the default false, when true replaces the active camera/light in the scene
  60619. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60620. */
  60621. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60622. /**
  60623. * Creates a new sky box
  60624. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60625. * @param environmentTexture defines the texture to use as environment texture
  60626. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60627. * @param scale defines the overall scale of the skybox
  60628. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60629. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60630. * @returns a new mesh holding the sky box
  60631. */
  60632. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60633. /**
  60634. * Creates a new environment
  60635. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60636. * @param options defines the options you can use to configure the environment
  60637. * @returns the new EnvironmentHelper
  60638. */
  60639. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60640. /**
  60641. * Creates a new VREXperienceHelper
  60642. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60643. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60644. * @returns a new VREXperienceHelper
  60645. */
  60646. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60647. /**
  60648. * Creates a new WebXRDefaultExperience
  60649. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60650. * @param options experience options
  60651. * @returns a promise for a new WebXRDefaultExperience
  60652. */
  60653. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60654. }
  60655. }
  60656. }
  60657. declare module "babylonjs/Helpers/videoDome" {
  60658. import { Scene } from "babylonjs/scene";
  60659. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60660. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60661. /**
  60662. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60663. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60664. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60665. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60666. */
  60667. export class VideoDome extends TextureDome<VideoTexture> {
  60668. /**
  60669. * Define the video source as a Monoscopic panoramic 360 video.
  60670. */
  60671. static readonly MODE_MONOSCOPIC: number;
  60672. /**
  60673. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60674. */
  60675. static readonly MODE_TOPBOTTOM: number;
  60676. /**
  60677. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60678. */
  60679. static readonly MODE_SIDEBYSIDE: number;
  60680. /**
  60681. * Get the video texture associated with this video dome
  60682. */
  60683. get videoTexture(): VideoTexture;
  60684. /**
  60685. * Get the video mode of this dome
  60686. */
  60687. get videoMode(): number;
  60688. /**
  60689. * Set the video mode of this dome.
  60690. * @see textureMode
  60691. */
  60692. set videoMode(value: number);
  60693. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60694. }
  60695. }
  60696. declare module "babylonjs/Helpers/index" {
  60697. export * from "babylonjs/Helpers/environmentHelper";
  60698. export * from "babylonjs/Helpers/photoDome";
  60699. export * from "babylonjs/Helpers/sceneHelpers";
  60700. export * from "babylonjs/Helpers/videoDome";
  60701. }
  60702. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60703. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60704. import { IDisposable } from "babylonjs/scene";
  60705. import { Engine } from "babylonjs/Engines/engine";
  60706. /**
  60707. * This class can be used to get instrumentation data from a Babylon engine
  60708. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60709. */
  60710. export class EngineInstrumentation implements IDisposable {
  60711. /**
  60712. * Define the instrumented engine.
  60713. */
  60714. engine: Engine;
  60715. private _captureGPUFrameTime;
  60716. private _gpuFrameTimeToken;
  60717. private _gpuFrameTime;
  60718. private _captureShaderCompilationTime;
  60719. private _shaderCompilationTime;
  60720. private _onBeginFrameObserver;
  60721. private _onEndFrameObserver;
  60722. private _onBeforeShaderCompilationObserver;
  60723. private _onAfterShaderCompilationObserver;
  60724. /**
  60725. * Gets the perf counter used for GPU frame time
  60726. */
  60727. get gpuFrameTimeCounter(): PerfCounter;
  60728. /**
  60729. * Gets the GPU frame time capture status
  60730. */
  60731. get captureGPUFrameTime(): boolean;
  60732. /**
  60733. * Enable or disable the GPU frame time capture
  60734. */
  60735. set captureGPUFrameTime(value: boolean);
  60736. /**
  60737. * Gets the perf counter used for shader compilation time
  60738. */
  60739. get shaderCompilationTimeCounter(): PerfCounter;
  60740. /**
  60741. * Gets the shader compilation time capture status
  60742. */
  60743. get captureShaderCompilationTime(): boolean;
  60744. /**
  60745. * Enable or disable the shader compilation time capture
  60746. */
  60747. set captureShaderCompilationTime(value: boolean);
  60748. /**
  60749. * Instantiates a new engine instrumentation.
  60750. * This class can be used to get instrumentation data from a Babylon engine
  60751. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60752. * @param engine Defines the engine to instrument
  60753. */
  60754. constructor(
  60755. /**
  60756. * Define the instrumented engine.
  60757. */
  60758. engine: Engine);
  60759. /**
  60760. * Dispose and release associated resources.
  60761. */
  60762. dispose(): void;
  60763. }
  60764. }
  60765. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60766. import { Scene, IDisposable } from "babylonjs/scene";
  60767. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60768. /**
  60769. * This class can be used to get instrumentation data from a Babylon engine
  60770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60771. */
  60772. export class SceneInstrumentation implements IDisposable {
  60773. /**
  60774. * Defines the scene to instrument
  60775. */
  60776. scene: Scene;
  60777. private _captureActiveMeshesEvaluationTime;
  60778. private _activeMeshesEvaluationTime;
  60779. private _captureRenderTargetsRenderTime;
  60780. private _renderTargetsRenderTime;
  60781. private _captureFrameTime;
  60782. private _frameTime;
  60783. private _captureRenderTime;
  60784. private _renderTime;
  60785. private _captureInterFrameTime;
  60786. private _interFrameTime;
  60787. private _captureParticlesRenderTime;
  60788. private _particlesRenderTime;
  60789. private _captureSpritesRenderTime;
  60790. private _spritesRenderTime;
  60791. private _capturePhysicsTime;
  60792. private _physicsTime;
  60793. private _captureAnimationsTime;
  60794. private _animationsTime;
  60795. private _captureCameraRenderTime;
  60796. private _cameraRenderTime;
  60797. private _onBeforeActiveMeshesEvaluationObserver;
  60798. private _onAfterActiveMeshesEvaluationObserver;
  60799. private _onBeforeRenderTargetsRenderObserver;
  60800. private _onAfterRenderTargetsRenderObserver;
  60801. private _onAfterRenderObserver;
  60802. private _onBeforeDrawPhaseObserver;
  60803. private _onAfterDrawPhaseObserver;
  60804. private _onBeforeAnimationsObserver;
  60805. private _onBeforeParticlesRenderingObserver;
  60806. private _onAfterParticlesRenderingObserver;
  60807. private _onBeforeSpritesRenderingObserver;
  60808. private _onAfterSpritesRenderingObserver;
  60809. private _onBeforePhysicsObserver;
  60810. private _onAfterPhysicsObserver;
  60811. private _onAfterAnimationsObserver;
  60812. private _onBeforeCameraRenderObserver;
  60813. private _onAfterCameraRenderObserver;
  60814. /**
  60815. * Gets the perf counter used for active meshes evaluation time
  60816. */
  60817. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  60818. /**
  60819. * Gets the active meshes evaluation time capture status
  60820. */
  60821. get captureActiveMeshesEvaluationTime(): boolean;
  60822. /**
  60823. * Enable or disable the active meshes evaluation time capture
  60824. */
  60825. set captureActiveMeshesEvaluationTime(value: boolean);
  60826. /**
  60827. * Gets the perf counter used for render targets render time
  60828. */
  60829. get renderTargetsRenderTimeCounter(): PerfCounter;
  60830. /**
  60831. * Gets the render targets render time capture status
  60832. */
  60833. get captureRenderTargetsRenderTime(): boolean;
  60834. /**
  60835. * Enable or disable the render targets render time capture
  60836. */
  60837. set captureRenderTargetsRenderTime(value: boolean);
  60838. /**
  60839. * Gets the perf counter used for particles render time
  60840. */
  60841. get particlesRenderTimeCounter(): PerfCounter;
  60842. /**
  60843. * Gets the particles render time capture status
  60844. */
  60845. get captureParticlesRenderTime(): boolean;
  60846. /**
  60847. * Enable or disable the particles render time capture
  60848. */
  60849. set captureParticlesRenderTime(value: boolean);
  60850. /**
  60851. * Gets the perf counter used for sprites render time
  60852. */
  60853. get spritesRenderTimeCounter(): PerfCounter;
  60854. /**
  60855. * Gets the sprites render time capture status
  60856. */
  60857. get captureSpritesRenderTime(): boolean;
  60858. /**
  60859. * Enable or disable the sprites render time capture
  60860. */
  60861. set captureSpritesRenderTime(value: boolean);
  60862. /**
  60863. * Gets the perf counter used for physics time
  60864. */
  60865. get physicsTimeCounter(): PerfCounter;
  60866. /**
  60867. * Gets the physics time capture status
  60868. */
  60869. get capturePhysicsTime(): boolean;
  60870. /**
  60871. * Enable or disable the physics time capture
  60872. */
  60873. set capturePhysicsTime(value: boolean);
  60874. /**
  60875. * Gets the perf counter used for animations time
  60876. */
  60877. get animationsTimeCounter(): PerfCounter;
  60878. /**
  60879. * Gets the animations time capture status
  60880. */
  60881. get captureAnimationsTime(): boolean;
  60882. /**
  60883. * Enable or disable the animations time capture
  60884. */
  60885. set captureAnimationsTime(value: boolean);
  60886. /**
  60887. * Gets the perf counter used for frame time capture
  60888. */
  60889. get frameTimeCounter(): PerfCounter;
  60890. /**
  60891. * Gets the frame time capture status
  60892. */
  60893. get captureFrameTime(): boolean;
  60894. /**
  60895. * Enable or disable the frame time capture
  60896. */
  60897. set captureFrameTime(value: boolean);
  60898. /**
  60899. * Gets the perf counter used for inter-frames time capture
  60900. */
  60901. get interFrameTimeCounter(): PerfCounter;
  60902. /**
  60903. * Gets the inter-frames time capture status
  60904. */
  60905. get captureInterFrameTime(): boolean;
  60906. /**
  60907. * Enable or disable the inter-frames time capture
  60908. */
  60909. set captureInterFrameTime(value: boolean);
  60910. /**
  60911. * Gets the perf counter used for render time capture
  60912. */
  60913. get renderTimeCounter(): PerfCounter;
  60914. /**
  60915. * Gets the render time capture status
  60916. */
  60917. get captureRenderTime(): boolean;
  60918. /**
  60919. * Enable or disable the render time capture
  60920. */
  60921. set captureRenderTime(value: boolean);
  60922. /**
  60923. * Gets the perf counter used for camera render time capture
  60924. */
  60925. get cameraRenderTimeCounter(): PerfCounter;
  60926. /**
  60927. * Gets the camera render time capture status
  60928. */
  60929. get captureCameraRenderTime(): boolean;
  60930. /**
  60931. * Enable or disable the camera render time capture
  60932. */
  60933. set captureCameraRenderTime(value: boolean);
  60934. /**
  60935. * Gets the perf counter used for draw calls
  60936. */
  60937. get drawCallsCounter(): PerfCounter;
  60938. /**
  60939. * Instantiates a new scene instrumentation.
  60940. * This class can be used to get instrumentation data from a Babylon engine
  60941. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60942. * @param scene Defines the scene to instrument
  60943. */
  60944. constructor(
  60945. /**
  60946. * Defines the scene to instrument
  60947. */
  60948. scene: Scene);
  60949. /**
  60950. * Dispose and release associated resources.
  60951. */
  60952. dispose(): void;
  60953. }
  60954. }
  60955. declare module "babylonjs/Instrumentation/index" {
  60956. export * from "babylonjs/Instrumentation/engineInstrumentation";
  60957. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  60958. export * from "babylonjs/Instrumentation/timeToken";
  60959. }
  60960. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  60961. /** @hidden */
  60962. export var glowMapGenerationPixelShader: {
  60963. name: string;
  60964. shader: string;
  60965. };
  60966. }
  60967. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  60968. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60969. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60970. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60971. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  60972. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  60973. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  60974. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60975. /** @hidden */
  60976. export var glowMapGenerationVertexShader: {
  60977. name: string;
  60978. shader: string;
  60979. };
  60980. }
  60981. declare module "babylonjs/Layers/effectLayer" {
  60982. import { Observable } from "babylonjs/Misc/observable";
  60983. import { Nullable } from "babylonjs/types";
  60984. import { Camera } from "babylonjs/Cameras/camera";
  60985. import { Scene } from "babylonjs/scene";
  60986. import { ISize } from "babylonjs/Maths/math.size";
  60987. import { Color4 } from "babylonjs/Maths/math.color";
  60988. import { Engine } from "babylonjs/Engines/engine";
  60989. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60991. import { Mesh } from "babylonjs/Meshes/mesh";
  60992. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  60993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60994. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  60995. import { Effect } from "babylonjs/Materials/effect";
  60996. import { Material } from "babylonjs/Materials/material";
  60997. import "babylonjs/Shaders/glowMapGeneration.fragment";
  60998. import "babylonjs/Shaders/glowMapGeneration.vertex";
  60999. /**
  61000. * Effect layer options. This helps customizing the behaviour
  61001. * of the effect layer.
  61002. */
  61003. export interface IEffectLayerOptions {
  61004. /**
  61005. * Multiplication factor apply to the canvas size to compute the render target size
  61006. * used to generated the objects (the smaller the faster).
  61007. */
  61008. mainTextureRatio: number;
  61009. /**
  61010. * Enforces a fixed size texture to ensure effect stability across devices.
  61011. */
  61012. mainTextureFixedSize?: number;
  61013. /**
  61014. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61015. */
  61016. alphaBlendingMode: number;
  61017. /**
  61018. * The camera attached to the layer.
  61019. */
  61020. camera: Nullable<Camera>;
  61021. /**
  61022. * The rendering group to draw the layer in.
  61023. */
  61024. renderingGroupId: number;
  61025. }
  61026. /**
  61027. * The effect layer Helps adding post process effect blended with the main pass.
  61028. *
  61029. * This can be for instance use to generate glow or higlight effects on the scene.
  61030. *
  61031. * The effect layer class can not be used directly and is intented to inherited from to be
  61032. * customized per effects.
  61033. */
  61034. export abstract class EffectLayer {
  61035. private _vertexBuffers;
  61036. private _indexBuffer;
  61037. private _cachedDefines;
  61038. private _effectLayerMapGenerationEffect;
  61039. private _effectLayerOptions;
  61040. private _mergeEffect;
  61041. protected _scene: Scene;
  61042. protected _engine: Engine;
  61043. protected _maxSize: number;
  61044. protected _mainTextureDesiredSize: ISize;
  61045. protected _mainTexture: RenderTargetTexture;
  61046. protected _shouldRender: boolean;
  61047. protected _postProcesses: PostProcess[];
  61048. protected _textures: BaseTexture[];
  61049. protected _emissiveTextureAndColor: {
  61050. texture: Nullable<BaseTexture>;
  61051. color: Color4;
  61052. };
  61053. /**
  61054. * The name of the layer
  61055. */
  61056. name: string;
  61057. /**
  61058. * The clear color of the texture used to generate the glow map.
  61059. */
  61060. neutralColor: Color4;
  61061. /**
  61062. * Specifies whether the highlight layer is enabled or not.
  61063. */
  61064. isEnabled: boolean;
  61065. /**
  61066. * Gets the camera attached to the layer.
  61067. */
  61068. get camera(): Nullable<Camera>;
  61069. /**
  61070. * Gets the rendering group id the layer should render in.
  61071. */
  61072. get renderingGroupId(): number;
  61073. set renderingGroupId(renderingGroupId: number);
  61074. /**
  61075. * An event triggered when the effect layer has been disposed.
  61076. */
  61077. onDisposeObservable: Observable<EffectLayer>;
  61078. /**
  61079. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61080. */
  61081. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61082. /**
  61083. * An event triggered when the generated texture is being merged in the scene.
  61084. */
  61085. onBeforeComposeObservable: Observable<EffectLayer>;
  61086. /**
  61087. * An event triggered when the mesh is rendered into the effect render target.
  61088. */
  61089. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61090. /**
  61091. * An event triggered after the mesh has been rendered into the effect render target.
  61092. */
  61093. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61094. /**
  61095. * An event triggered when the generated texture has been merged in the scene.
  61096. */
  61097. onAfterComposeObservable: Observable<EffectLayer>;
  61098. /**
  61099. * An event triggered when the efffect layer changes its size.
  61100. */
  61101. onSizeChangedObservable: Observable<EffectLayer>;
  61102. /** @hidden */
  61103. static _SceneComponentInitialization: (scene: Scene) => void;
  61104. /**
  61105. * Instantiates a new effect Layer and references it in the scene.
  61106. * @param name The name of the layer
  61107. * @param scene The scene to use the layer in
  61108. */
  61109. constructor(
  61110. /** The Friendly of the effect in the scene */
  61111. name: string, scene: Scene);
  61112. /**
  61113. * Get the effect name of the layer.
  61114. * @return The effect name
  61115. */
  61116. abstract getEffectName(): string;
  61117. /**
  61118. * Checks for the readiness of the element composing the layer.
  61119. * @param subMesh the mesh to check for
  61120. * @param useInstances specify whether or not to use instances to render the mesh
  61121. * @return true if ready otherwise, false
  61122. */
  61123. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61124. /**
  61125. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61126. * @returns true if the effect requires stencil during the main canvas render pass.
  61127. */
  61128. abstract needStencil(): boolean;
  61129. /**
  61130. * Create the merge effect. This is the shader use to blit the information back
  61131. * to the main canvas at the end of the scene rendering.
  61132. * @returns The effect containing the shader used to merge the effect on the main canvas
  61133. */
  61134. protected abstract _createMergeEffect(): Effect;
  61135. /**
  61136. * Creates the render target textures and post processes used in the effect layer.
  61137. */
  61138. protected abstract _createTextureAndPostProcesses(): void;
  61139. /**
  61140. * Implementation specific of rendering the generating effect on the main canvas.
  61141. * @param effect The effect used to render through
  61142. */
  61143. protected abstract _internalRender(effect: Effect): void;
  61144. /**
  61145. * Sets the required values for both the emissive texture and and the main color.
  61146. */
  61147. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61148. /**
  61149. * Free any resources and references associated to a mesh.
  61150. * Internal use
  61151. * @param mesh The mesh to free.
  61152. */
  61153. abstract _disposeMesh(mesh: Mesh): void;
  61154. /**
  61155. * Serializes this layer (Glow or Highlight for example)
  61156. * @returns a serialized layer object
  61157. */
  61158. abstract serialize?(): any;
  61159. /**
  61160. * Initializes the effect layer with the required options.
  61161. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61162. */
  61163. protected _init(options: Partial<IEffectLayerOptions>): void;
  61164. /**
  61165. * Generates the index buffer of the full screen quad blending to the main canvas.
  61166. */
  61167. private _generateIndexBuffer;
  61168. /**
  61169. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61170. */
  61171. private _generateVertexBuffer;
  61172. /**
  61173. * Sets the main texture desired size which is the closest power of two
  61174. * of the engine canvas size.
  61175. */
  61176. private _setMainTextureSize;
  61177. /**
  61178. * Creates the main texture for the effect layer.
  61179. */
  61180. protected _createMainTexture(): void;
  61181. /**
  61182. * Adds specific effects defines.
  61183. * @param defines The defines to add specifics to.
  61184. */
  61185. protected _addCustomEffectDefines(defines: string[]): void;
  61186. /**
  61187. * Checks for the readiness of the element composing the layer.
  61188. * @param subMesh the mesh to check for
  61189. * @param useInstances specify whether or not to use instances to render the mesh
  61190. * @param emissiveTexture the associated emissive texture used to generate the glow
  61191. * @return true if ready otherwise, false
  61192. */
  61193. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61194. /**
  61195. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61196. */
  61197. render(): void;
  61198. /**
  61199. * Determine if a given mesh will be used in the current effect.
  61200. * @param mesh mesh to test
  61201. * @returns true if the mesh will be used
  61202. */
  61203. hasMesh(mesh: AbstractMesh): boolean;
  61204. /**
  61205. * Returns true if the layer contains information to display, otherwise false.
  61206. * @returns true if the glow layer should be rendered
  61207. */
  61208. shouldRender(): boolean;
  61209. /**
  61210. * Returns true if the mesh should render, otherwise false.
  61211. * @param mesh The mesh to render
  61212. * @returns true if it should render otherwise false
  61213. */
  61214. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61215. /**
  61216. * Returns true if the mesh can be rendered, otherwise false.
  61217. * @param mesh The mesh to render
  61218. * @param material The material used on the mesh
  61219. * @returns true if it can be rendered otherwise false
  61220. */
  61221. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61222. /**
  61223. * Returns true if the mesh should render, otherwise false.
  61224. * @param mesh The mesh to render
  61225. * @returns true if it should render otherwise false
  61226. */
  61227. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61228. /**
  61229. * Renders the submesh passed in parameter to the generation map.
  61230. */
  61231. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61232. /**
  61233. * Defines whether the current material of the mesh should be use to render the effect.
  61234. * @param mesh defines the current mesh to render
  61235. */
  61236. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61237. /**
  61238. * Rebuild the required buffers.
  61239. * @hidden Internal use only.
  61240. */
  61241. _rebuild(): void;
  61242. /**
  61243. * Dispose only the render target textures and post process.
  61244. */
  61245. private _disposeTextureAndPostProcesses;
  61246. /**
  61247. * Dispose the highlight layer and free resources.
  61248. */
  61249. dispose(): void;
  61250. /**
  61251. * Gets the class name of the effect layer
  61252. * @returns the string with the class name of the effect layer
  61253. */
  61254. getClassName(): string;
  61255. /**
  61256. * Creates an effect layer from parsed effect layer data
  61257. * @param parsedEffectLayer defines effect layer data
  61258. * @param scene defines the current scene
  61259. * @param rootUrl defines the root URL containing the effect layer information
  61260. * @returns a parsed effect Layer
  61261. */
  61262. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61263. }
  61264. }
  61265. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61266. import { Scene } from "babylonjs/scene";
  61267. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61268. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61269. import { AbstractScene } from "babylonjs/abstractScene";
  61270. module "babylonjs/abstractScene" {
  61271. interface AbstractScene {
  61272. /**
  61273. * The list of effect layers (highlights/glow) added to the scene
  61274. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61275. * @see https://doc.babylonjs.com/how_to/glow_layer
  61276. */
  61277. effectLayers: Array<EffectLayer>;
  61278. /**
  61279. * Removes the given effect layer from this scene.
  61280. * @param toRemove defines the effect layer to remove
  61281. * @returns the index of the removed effect layer
  61282. */
  61283. removeEffectLayer(toRemove: EffectLayer): number;
  61284. /**
  61285. * Adds the given effect layer to this scene
  61286. * @param newEffectLayer defines the effect layer to add
  61287. */
  61288. addEffectLayer(newEffectLayer: EffectLayer): void;
  61289. }
  61290. }
  61291. /**
  61292. * Defines the layer scene component responsible to manage any effect layers
  61293. * in a given scene.
  61294. */
  61295. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61296. /**
  61297. * The component name helpfull to identify the component in the list of scene components.
  61298. */
  61299. readonly name: string;
  61300. /**
  61301. * The scene the component belongs to.
  61302. */
  61303. scene: Scene;
  61304. private _engine;
  61305. private _renderEffects;
  61306. private _needStencil;
  61307. private _previousStencilState;
  61308. /**
  61309. * Creates a new instance of the component for the given scene
  61310. * @param scene Defines the scene to register the component in
  61311. */
  61312. constructor(scene: Scene);
  61313. /**
  61314. * Registers the component in a given scene
  61315. */
  61316. register(): void;
  61317. /**
  61318. * Rebuilds the elements related to this component in case of
  61319. * context lost for instance.
  61320. */
  61321. rebuild(): void;
  61322. /**
  61323. * Serializes the component data to the specified json object
  61324. * @param serializationObject The object to serialize to
  61325. */
  61326. serialize(serializationObject: any): void;
  61327. /**
  61328. * Adds all the elements from the container to the scene
  61329. * @param container the container holding the elements
  61330. */
  61331. addFromContainer(container: AbstractScene): void;
  61332. /**
  61333. * Removes all the elements in the container from the scene
  61334. * @param container contains the elements to remove
  61335. * @param dispose if the removed element should be disposed (default: false)
  61336. */
  61337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61338. /**
  61339. * Disposes the component and the associated ressources.
  61340. */
  61341. dispose(): void;
  61342. private _isReadyForMesh;
  61343. private _renderMainTexture;
  61344. private _setStencil;
  61345. private _setStencilBack;
  61346. private _draw;
  61347. private _drawCamera;
  61348. private _drawRenderingGroup;
  61349. }
  61350. }
  61351. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61352. /** @hidden */
  61353. export var glowMapMergePixelShader: {
  61354. name: string;
  61355. shader: string;
  61356. };
  61357. }
  61358. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61359. /** @hidden */
  61360. export var glowMapMergeVertexShader: {
  61361. name: string;
  61362. shader: string;
  61363. };
  61364. }
  61365. declare module "babylonjs/Layers/glowLayer" {
  61366. import { Nullable } from "babylonjs/types";
  61367. import { Camera } from "babylonjs/Cameras/camera";
  61368. import { Scene } from "babylonjs/scene";
  61369. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61371. import { Mesh } from "babylonjs/Meshes/mesh";
  61372. import { Texture } from "babylonjs/Materials/Textures/texture";
  61373. import { Effect } from "babylonjs/Materials/effect";
  61374. import { Material } from "babylonjs/Materials/material";
  61375. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61376. import { Color4 } from "babylonjs/Maths/math.color";
  61377. import "babylonjs/Shaders/glowMapMerge.fragment";
  61378. import "babylonjs/Shaders/glowMapMerge.vertex";
  61379. import "babylonjs/Layers/effectLayerSceneComponent";
  61380. module "babylonjs/abstractScene" {
  61381. interface AbstractScene {
  61382. /**
  61383. * Return a the first highlight layer of the scene with a given name.
  61384. * @param name The name of the highlight layer to look for.
  61385. * @return The highlight layer if found otherwise null.
  61386. */
  61387. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61388. }
  61389. }
  61390. /**
  61391. * Glow layer options. This helps customizing the behaviour
  61392. * of the glow layer.
  61393. */
  61394. export interface IGlowLayerOptions {
  61395. /**
  61396. * Multiplication factor apply to the canvas size to compute the render target size
  61397. * used to generated the glowing objects (the smaller the faster).
  61398. */
  61399. mainTextureRatio: number;
  61400. /**
  61401. * Enforces a fixed size texture to ensure resize independant blur.
  61402. */
  61403. mainTextureFixedSize?: number;
  61404. /**
  61405. * How big is the kernel of the blur texture.
  61406. */
  61407. blurKernelSize: number;
  61408. /**
  61409. * The camera attached to the layer.
  61410. */
  61411. camera: Nullable<Camera>;
  61412. /**
  61413. * Enable MSAA by chosing the number of samples.
  61414. */
  61415. mainTextureSamples?: number;
  61416. /**
  61417. * The rendering group to draw the layer in.
  61418. */
  61419. renderingGroupId: number;
  61420. }
  61421. /**
  61422. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61423. *
  61424. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61425. *
  61426. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61427. */
  61428. export class GlowLayer extends EffectLayer {
  61429. /**
  61430. * Effect Name of the layer.
  61431. */
  61432. static readonly EffectName: string;
  61433. /**
  61434. * The default blur kernel size used for the glow.
  61435. */
  61436. static DefaultBlurKernelSize: number;
  61437. /**
  61438. * The default texture size ratio used for the glow.
  61439. */
  61440. static DefaultTextureRatio: number;
  61441. /**
  61442. * Sets the kernel size of the blur.
  61443. */
  61444. set blurKernelSize(value: number);
  61445. /**
  61446. * Gets the kernel size of the blur.
  61447. */
  61448. get blurKernelSize(): number;
  61449. /**
  61450. * Sets the glow intensity.
  61451. */
  61452. set intensity(value: number);
  61453. /**
  61454. * Gets the glow intensity.
  61455. */
  61456. get intensity(): number;
  61457. private _options;
  61458. private _intensity;
  61459. private _horizontalBlurPostprocess1;
  61460. private _verticalBlurPostprocess1;
  61461. private _horizontalBlurPostprocess2;
  61462. private _verticalBlurPostprocess2;
  61463. private _blurTexture1;
  61464. private _blurTexture2;
  61465. private _postProcesses1;
  61466. private _postProcesses2;
  61467. private _includedOnlyMeshes;
  61468. private _excludedMeshes;
  61469. private _meshesUsingTheirOwnMaterials;
  61470. /**
  61471. * Callback used to let the user override the color selection on a per mesh basis
  61472. */
  61473. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61474. /**
  61475. * Callback used to let the user override the texture selection on a per mesh basis
  61476. */
  61477. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61478. /**
  61479. * Instantiates a new glow Layer and references it to the scene.
  61480. * @param name The name of the layer
  61481. * @param scene The scene to use the layer in
  61482. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61483. */
  61484. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61485. /**
  61486. * Get the effect name of the layer.
  61487. * @return The effect name
  61488. */
  61489. getEffectName(): string;
  61490. /**
  61491. * Create the merge effect. This is the shader use to blit the information back
  61492. * to the main canvas at the end of the scene rendering.
  61493. */
  61494. protected _createMergeEffect(): Effect;
  61495. /**
  61496. * Creates the render target textures and post processes used in the glow layer.
  61497. */
  61498. protected _createTextureAndPostProcesses(): void;
  61499. /**
  61500. * Checks for the readiness of the element composing the layer.
  61501. * @param subMesh the mesh to check for
  61502. * @param useInstances specify wether or not to use instances to render the mesh
  61503. * @param emissiveTexture the associated emissive texture used to generate the glow
  61504. * @return true if ready otherwise, false
  61505. */
  61506. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61507. /**
  61508. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61509. */
  61510. needStencil(): boolean;
  61511. /**
  61512. * Returns true if the mesh can be rendered, otherwise false.
  61513. * @param mesh The mesh to render
  61514. * @param material The material used on the mesh
  61515. * @returns true if it can be rendered otherwise false
  61516. */
  61517. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61518. /**
  61519. * Implementation specific of rendering the generating effect on the main canvas.
  61520. * @param effect The effect used to render through
  61521. */
  61522. protected _internalRender(effect: Effect): void;
  61523. /**
  61524. * Sets the required values for both the emissive texture and and the main color.
  61525. */
  61526. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61527. /**
  61528. * Returns true if the mesh should render, otherwise false.
  61529. * @param mesh The mesh to render
  61530. * @returns true if it should render otherwise false
  61531. */
  61532. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61533. /**
  61534. * Adds specific effects defines.
  61535. * @param defines The defines to add specifics to.
  61536. */
  61537. protected _addCustomEffectDefines(defines: string[]): void;
  61538. /**
  61539. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61540. * @param mesh The mesh to exclude from the glow layer
  61541. */
  61542. addExcludedMesh(mesh: Mesh): void;
  61543. /**
  61544. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61545. * @param mesh The mesh to remove
  61546. */
  61547. removeExcludedMesh(mesh: Mesh): void;
  61548. /**
  61549. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61550. * @param mesh The mesh to include in the glow layer
  61551. */
  61552. addIncludedOnlyMesh(mesh: Mesh): void;
  61553. /**
  61554. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61555. * @param mesh The mesh to remove
  61556. */
  61557. removeIncludedOnlyMesh(mesh: Mesh): void;
  61558. /**
  61559. * Determine if a given mesh will be used in the glow layer
  61560. * @param mesh The mesh to test
  61561. * @returns true if the mesh will be highlighted by the current glow layer
  61562. */
  61563. hasMesh(mesh: AbstractMesh): boolean;
  61564. /**
  61565. * Defines whether the current material of the mesh should be use to render the effect.
  61566. * @param mesh defines the current mesh to render
  61567. */
  61568. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61569. /**
  61570. * Add a mesh to be rendered through its own material and not with emissive only.
  61571. * @param mesh The mesh for which we need to use its material
  61572. */
  61573. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61574. /**
  61575. * Remove a mesh from being rendered through its own material and not with emissive only.
  61576. * @param mesh The mesh for which we need to not use its material
  61577. */
  61578. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61579. /**
  61580. * Free any resources and references associated to a mesh.
  61581. * Internal use
  61582. * @param mesh The mesh to free.
  61583. * @hidden
  61584. */
  61585. _disposeMesh(mesh: Mesh): void;
  61586. /**
  61587. * Gets the class name of the effect layer
  61588. * @returns the string with the class name of the effect layer
  61589. */
  61590. getClassName(): string;
  61591. /**
  61592. * Serializes this glow layer
  61593. * @returns a serialized glow layer object
  61594. */
  61595. serialize(): any;
  61596. /**
  61597. * Creates a Glow Layer from parsed glow layer data
  61598. * @param parsedGlowLayer defines glow layer data
  61599. * @param scene defines the current scene
  61600. * @param rootUrl defines the root URL containing the glow layer information
  61601. * @returns a parsed Glow Layer
  61602. */
  61603. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61604. }
  61605. }
  61606. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61607. /** @hidden */
  61608. export var glowBlurPostProcessPixelShader: {
  61609. name: string;
  61610. shader: string;
  61611. };
  61612. }
  61613. declare module "babylonjs/Layers/highlightLayer" {
  61614. import { Observable } from "babylonjs/Misc/observable";
  61615. import { Nullable } from "babylonjs/types";
  61616. import { Camera } from "babylonjs/Cameras/camera";
  61617. import { Scene } from "babylonjs/scene";
  61618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61620. import { Mesh } from "babylonjs/Meshes/mesh";
  61621. import { Effect } from "babylonjs/Materials/effect";
  61622. import { Material } from "babylonjs/Materials/material";
  61623. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61624. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61625. import "babylonjs/Shaders/glowMapMerge.fragment";
  61626. import "babylonjs/Shaders/glowMapMerge.vertex";
  61627. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61628. module "babylonjs/abstractScene" {
  61629. interface AbstractScene {
  61630. /**
  61631. * Return a the first highlight layer of the scene with a given name.
  61632. * @param name The name of the highlight layer to look for.
  61633. * @return The highlight layer if found otherwise null.
  61634. */
  61635. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61636. }
  61637. }
  61638. /**
  61639. * Highlight layer options. This helps customizing the behaviour
  61640. * of the highlight layer.
  61641. */
  61642. export interface IHighlightLayerOptions {
  61643. /**
  61644. * Multiplication factor apply to the canvas size to compute the render target size
  61645. * used to generated the glowing objects (the smaller the faster).
  61646. */
  61647. mainTextureRatio: number;
  61648. /**
  61649. * Enforces a fixed size texture to ensure resize independant blur.
  61650. */
  61651. mainTextureFixedSize?: number;
  61652. /**
  61653. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61654. * of the picture to blur (the smaller the faster).
  61655. */
  61656. blurTextureSizeRatio: number;
  61657. /**
  61658. * How big in texel of the blur texture is the vertical blur.
  61659. */
  61660. blurVerticalSize: number;
  61661. /**
  61662. * How big in texel of the blur texture is the horizontal blur.
  61663. */
  61664. blurHorizontalSize: number;
  61665. /**
  61666. * Alpha blending mode used to apply the blur. Default is combine.
  61667. */
  61668. alphaBlendingMode: number;
  61669. /**
  61670. * The camera attached to the layer.
  61671. */
  61672. camera: Nullable<Camera>;
  61673. /**
  61674. * Should we display highlight as a solid stroke?
  61675. */
  61676. isStroke?: boolean;
  61677. /**
  61678. * The rendering group to draw the layer in.
  61679. */
  61680. renderingGroupId: number;
  61681. }
  61682. /**
  61683. * The highlight layer Helps adding a glow effect around a mesh.
  61684. *
  61685. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61686. * glowy meshes to your scene.
  61687. *
  61688. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61689. */
  61690. export class HighlightLayer extends EffectLayer {
  61691. name: string;
  61692. /**
  61693. * Effect Name of the highlight layer.
  61694. */
  61695. static readonly EffectName: string;
  61696. /**
  61697. * The neutral color used during the preparation of the glow effect.
  61698. * This is black by default as the blend operation is a blend operation.
  61699. */
  61700. static NeutralColor: Color4;
  61701. /**
  61702. * Stencil value used for glowing meshes.
  61703. */
  61704. static GlowingMeshStencilReference: number;
  61705. /**
  61706. * Stencil value used for the other meshes in the scene.
  61707. */
  61708. static NormalMeshStencilReference: number;
  61709. /**
  61710. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61711. */
  61712. innerGlow: boolean;
  61713. /**
  61714. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61715. */
  61716. outerGlow: boolean;
  61717. /**
  61718. * Specifies the horizontal size of the blur.
  61719. */
  61720. set blurHorizontalSize(value: number);
  61721. /**
  61722. * Specifies the vertical size of the blur.
  61723. */
  61724. set blurVerticalSize(value: number);
  61725. /**
  61726. * Gets the horizontal size of the blur.
  61727. */
  61728. get blurHorizontalSize(): number;
  61729. /**
  61730. * Gets the vertical size of the blur.
  61731. */
  61732. get blurVerticalSize(): number;
  61733. /**
  61734. * An event triggered when the highlight layer is being blurred.
  61735. */
  61736. onBeforeBlurObservable: Observable<HighlightLayer>;
  61737. /**
  61738. * An event triggered when the highlight layer has been blurred.
  61739. */
  61740. onAfterBlurObservable: Observable<HighlightLayer>;
  61741. private _instanceGlowingMeshStencilReference;
  61742. private _options;
  61743. private _downSamplePostprocess;
  61744. private _horizontalBlurPostprocess;
  61745. private _verticalBlurPostprocess;
  61746. private _blurTexture;
  61747. private _meshes;
  61748. private _excludedMeshes;
  61749. /**
  61750. * Instantiates a new highlight Layer and references it to the scene..
  61751. * @param name The name of the layer
  61752. * @param scene The scene to use the layer in
  61753. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61754. */
  61755. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61756. /**
  61757. * Get the effect name of the layer.
  61758. * @return The effect name
  61759. */
  61760. getEffectName(): string;
  61761. /**
  61762. * Create the merge effect. This is the shader use to blit the information back
  61763. * to the main canvas at the end of the scene rendering.
  61764. */
  61765. protected _createMergeEffect(): Effect;
  61766. /**
  61767. * Creates the render target textures and post processes used in the highlight layer.
  61768. */
  61769. protected _createTextureAndPostProcesses(): void;
  61770. /**
  61771. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61772. */
  61773. needStencil(): boolean;
  61774. /**
  61775. * Checks for the readiness of the element composing the layer.
  61776. * @param subMesh the mesh to check for
  61777. * @param useInstances specify wether or not to use instances to render the mesh
  61778. * @param emissiveTexture the associated emissive texture used to generate the glow
  61779. * @return true if ready otherwise, false
  61780. */
  61781. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61782. /**
  61783. * Implementation specific of rendering the generating effect on the main canvas.
  61784. * @param effect The effect used to render through
  61785. */
  61786. protected _internalRender(effect: Effect): void;
  61787. /**
  61788. * Returns true if the layer contains information to display, otherwise false.
  61789. */
  61790. shouldRender(): boolean;
  61791. /**
  61792. * Returns true if the mesh should render, otherwise false.
  61793. * @param mesh The mesh to render
  61794. * @returns true if it should render otherwise false
  61795. */
  61796. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61797. /**
  61798. * Returns true if the mesh can be rendered, otherwise false.
  61799. * @param mesh The mesh to render
  61800. * @param material The material used on the mesh
  61801. * @returns true if it can be rendered otherwise false
  61802. */
  61803. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61804. /**
  61805. * Adds specific effects defines.
  61806. * @param defines The defines to add specifics to.
  61807. */
  61808. protected _addCustomEffectDefines(defines: string[]): void;
  61809. /**
  61810. * Sets the required values for both the emissive texture and and the main color.
  61811. */
  61812. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61813. /**
  61814. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  61815. * @param mesh The mesh to exclude from the highlight layer
  61816. */
  61817. addExcludedMesh(mesh: Mesh): void;
  61818. /**
  61819. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  61820. * @param mesh The mesh to highlight
  61821. */
  61822. removeExcludedMesh(mesh: Mesh): void;
  61823. /**
  61824. * Determine if a given mesh will be highlighted by the current HighlightLayer
  61825. * @param mesh mesh to test
  61826. * @returns true if the mesh will be highlighted by the current HighlightLayer
  61827. */
  61828. hasMesh(mesh: AbstractMesh): boolean;
  61829. /**
  61830. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  61831. * @param mesh The mesh to highlight
  61832. * @param color The color of the highlight
  61833. * @param glowEmissiveOnly Extract the glow from the emissive texture
  61834. */
  61835. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  61836. /**
  61837. * Remove a mesh from the highlight layer in order to make it stop glowing.
  61838. * @param mesh The mesh to highlight
  61839. */
  61840. removeMesh(mesh: Mesh): void;
  61841. /**
  61842. * Remove all the meshes currently referenced in the highlight layer
  61843. */
  61844. removeAllMeshes(): void;
  61845. /**
  61846. * Force the stencil to the normal expected value for none glowing parts
  61847. */
  61848. private _defaultStencilReference;
  61849. /**
  61850. * Free any resources and references associated to a mesh.
  61851. * Internal use
  61852. * @param mesh The mesh to free.
  61853. * @hidden
  61854. */
  61855. _disposeMesh(mesh: Mesh): void;
  61856. /**
  61857. * Dispose the highlight layer and free resources.
  61858. */
  61859. dispose(): void;
  61860. /**
  61861. * Gets the class name of the effect layer
  61862. * @returns the string with the class name of the effect layer
  61863. */
  61864. getClassName(): string;
  61865. /**
  61866. * Serializes this Highlight layer
  61867. * @returns a serialized Highlight layer object
  61868. */
  61869. serialize(): any;
  61870. /**
  61871. * Creates a Highlight layer from parsed Highlight layer data
  61872. * @param parsedHightlightLayer defines the Highlight layer data
  61873. * @param scene defines the current scene
  61874. * @param rootUrl defines the root URL containing the Highlight layer information
  61875. * @returns a parsed Highlight layer
  61876. */
  61877. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  61878. }
  61879. }
  61880. declare module "babylonjs/Layers/layerSceneComponent" {
  61881. import { Scene } from "babylonjs/scene";
  61882. import { ISceneComponent } from "babylonjs/sceneComponent";
  61883. import { Layer } from "babylonjs/Layers/layer";
  61884. import { AbstractScene } from "babylonjs/abstractScene";
  61885. module "babylonjs/abstractScene" {
  61886. interface AbstractScene {
  61887. /**
  61888. * The list of layers (background and foreground) of the scene
  61889. */
  61890. layers: Array<Layer>;
  61891. }
  61892. }
  61893. /**
  61894. * Defines the layer scene component responsible to manage any layers
  61895. * in a given scene.
  61896. */
  61897. export class LayerSceneComponent implements ISceneComponent {
  61898. /**
  61899. * The component name helpfull to identify the component in the list of scene components.
  61900. */
  61901. readonly name: string;
  61902. /**
  61903. * The scene the component belongs to.
  61904. */
  61905. scene: Scene;
  61906. private _engine;
  61907. /**
  61908. * Creates a new instance of the component for the given scene
  61909. * @param scene Defines the scene to register the component in
  61910. */
  61911. constructor(scene: Scene);
  61912. /**
  61913. * Registers the component in a given scene
  61914. */
  61915. register(): void;
  61916. /**
  61917. * Rebuilds the elements related to this component in case of
  61918. * context lost for instance.
  61919. */
  61920. rebuild(): void;
  61921. /**
  61922. * Disposes the component and the associated ressources.
  61923. */
  61924. dispose(): void;
  61925. private _draw;
  61926. private _drawCameraPredicate;
  61927. private _drawCameraBackground;
  61928. private _drawCameraForeground;
  61929. private _drawRenderTargetPredicate;
  61930. private _drawRenderTargetBackground;
  61931. private _drawRenderTargetForeground;
  61932. /**
  61933. * Adds all the elements from the container to the scene
  61934. * @param container the container holding the elements
  61935. */
  61936. addFromContainer(container: AbstractScene): void;
  61937. /**
  61938. * Removes all the elements in the container from the scene
  61939. * @param container contains the elements to remove
  61940. * @param dispose if the removed element should be disposed (default: false)
  61941. */
  61942. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61943. }
  61944. }
  61945. declare module "babylonjs/Shaders/layer.fragment" {
  61946. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61947. /** @hidden */
  61948. export var layerPixelShader: {
  61949. name: string;
  61950. shader: string;
  61951. };
  61952. }
  61953. declare module "babylonjs/Shaders/layer.vertex" {
  61954. /** @hidden */
  61955. export var layerVertexShader: {
  61956. name: string;
  61957. shader: string;
  61958. };
  61959. }
  61960. declare module "babylonjs/Layers/layer" {
  61961. import { Observable } from "babylonjs/Misc/observable";
  61962. import { Nullable } from "babylonjs/types";
  61963. import { Scene } from "babylonjs/scene";
  61964. import { Vector2 } from "babylonjs/Maths/math.vector";
  61965. import { Color4 } from "babylonjs/Maths/math.color";
  61966. import { Texture } from "babylonjs/Materials/Textures/texture";
  61967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61968. import "babylonjs/Shaders/layer.fragment";
  61969. import "babylonjs/Shaders/layer.vertex";
  61970. /**
  61971. * This represents a full screen 2d layer.
  61972. * This can be useful to display a picture in the background of your scene for instance.
  61973. * @see https://www.babylonjs-playground.com/#08A2BS#1
  61974. */
  61975. export class Layer {
  61976. /**
  61977. * Define the name of the layer.
  61978. */
  61979. name: string;
  61980. /**
  61981. * Define the texture the layer should display.
  61982. */
  61983. texture: Nullable<Texture>;
  61984. /**
  61985. * Is the layer in background or foreground.
  61986. */
  61987. isBackground: boolean;
  61988. /**
  61989. * Define the color of the layer (instead of texture).
  61990. */
  61991. color: Color4;
  61992. /**
  61993. * Define the scale of the layer in order to zoom in out of the texture.
  61994. */
  61995. scale: Vector2;
  61996. /**
  61997. * Define an offset for the layer in order to shift the texture.
  61998. */
  61999. offset: Vector2;
  62000. /**
  62001. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62002. */
  62003. alphaBlendingMode: number;
  62004. /**
  62005. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62006. * Alpha test will not mix with the background color in case of transparency.
  62007. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62008. */
  62009. alphaTest: boolean;
  62010. /**
  62011. * Define a mask to restrict the layer to only some of the scene cameras.
  62012. */
  62013. layerMask: number;
  62014. /**
  62015. * Define the list of render target the layer is visible into.
  62016. */
  62017. renderTargetTextures: RenderTargetTexture[];
  62018. /**
  62019. * Define if the layer is only used in renderTarget or if it also
  62020. * renders in the main frame buffer of the canvas.
  62021. */
  62022. renderOnlyInRenderTargetTextures: boolean;
  62023. private _scene;
  62024. private _vertexBuffers;
  62025. private _indexBuffer;
  62026. private _effect;
  62027. private _previousDefines;
  62028. /**
  62029. * An event triggered when the layer is disposed.
  62030. */
  62031. onDisposeObservable: Observable<Layer>;
  62032. private _onDisposeObserver;
  62033. /**
  62034. * Back compatibility with callback before the onDisposeObservable existed.
  62035. * The set callback will be triggered when the layer has been disposed.
  62036. */
  62037. set onDispose(callback: () => void);
  62038. /**
  62039. * An event triggered before rendering the scene
  62040. */
  62041. onBeforeRenderObservable: Observable<Layer>;
  62042. private _onBeforeRenderObserver;
  62043. /**
  62044. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62045. * The set callback will be triggered just before rendering the layer.
  62046. */
  62047. set onBeforeRender(callback: () => void);
  62048. /**
  62049. * An event triggered after rendering the scene
  62050. */
  62051. onAfterRenderObservable: Observable<Layer>;
  62052. private _onAfterRenderObserver;
  62053. /**
  62054. * Back compatibility with callback before the onAfterRenderObservable existed.
  62055. * The set callback will be triggered just after rendering the layer.
  62056. */
  62057. set onAfterRender(callback: () => void);
  62058. /**
  62059. * Instantiates a new layer.
  62060. * This represents a full screen 2d layer.
  62061. * This can be useful to display a picture in the background of your scene for instance.
  62062. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62063. * @param name Define the name of the layer in the scene
  62064. * @param imgUrl Define the url of the texture to display in the layer
  62065. * @param scene Define the scene the layer belongs to
  62066. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62067. * @param color Defines a color for the layer
  62068. */
  62069. constructor(
  62070. /**
  62071. * Define the name of the layer.
  62072. */
  62073. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62074. private _createIndexBuffer;
  62075. /** @hidden */
  62076. _rebuild(): void;
  62077. /**
  62078. * Renders the layer in the scene.
  62079. */
  62080. render(): void;
  62081. /**
  62082. * Disposes and releases the associated ressources.
  62083. */
  62084. dispose(): void;
  62085. }
  62086. }
  62087. declare module "babylonjs/Layers/index" {
  62088. export * from "babylonjs/Layers/effectLayer";
  62089. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62090. export * from "babylonjs/Layers/glowLayer";
  62091. export * from "babylonjs/Layers/highlightLayer";
  62092. export * from "babylonjs/Layers/layer";
  62093. export * from "babylonjs/Layers/layerSceneComponent";
  62094. }
  62095. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62096. /** @hidden */
  62097. export var lensFlarePixelShader: {
  62098. name: string;
  62099. shader: string;
  62100. };
  62101. }
  62102. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62103. /** @hidden */
  62104. export var lensFlareVertexShader: {
  62105. name: string;
  62106. shader: string;
  62107. };
  62108. }
  62109. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62110. import { Scene } from "babylonjs/scene";
  62111. import { Vector3 } from "babylonjs/Maths/math.vector";
  62112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62113. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62114. import "babylonjs/Shaders/lensFlare.fragment";
  62115. import "babylonjs/Shaders/lensFlare.vertex";
  62116. import { Viewport } from "babylonjs/Maths/math.viewport";
  62117. /**
  62118. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62119. * It is usually composed of several `lensFlare`.
  62120. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62121. */
  62122. export class LensFlareSystem {
  62123. /**
  62124. * Define the name of the lens flare system
  62125. */
  62126. name: string;
  62127. /**
  62128. * List of lens flares used in this system.
  62129. */
  62130. lensFlares: LensFlare[];
  62131. /**
  62132. * Define a limit from the border the lens flare can be visible.
  62133. */
  62134. borderLimit: number;
  62135. /**
  62136. * Define a viewport border we do not want to see the lens flare in.
  62137. */
  62138. viewportBorder: number;
  62139. /**
  62140. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62141. */
  62142. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62143. /**
  62144. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62145. */
  62146. layerMask: number;
  62147. /**
  62148. * Define the id of the lens flare system in the scene.
  62149. * (equal to name by default)
  62150. */
  62151. id: string;
  62152. private _scene;
  62153. private _emitter;
  62154. private _vertexBuffers;
  62155. private _indexBuffer;
  62156. private _effect;
  62157. private _positionX;
  62158. private _positionY;
  62159. private _isEnabled;
  62160. /** @hidden */
  62161. static _SceneComponentInitialization: (scene: Scene) => void;
  62162. /**
  62163. * Instantiates a lens flare system.
  62164. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62165. * It is usually composed of several `lensFlare`.
  62166. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62167. * @param name Define the name of the lens flare system in the scene
  62168. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62169. * @param scene Define the scene the lens flare system belongs to
  62170. */
  62171. constructor(
  62172. /**
  62173. * Define the name of the lens flare system
  62174. */
  62175. name: string, emitter: any, scene: Scene);
  62176. /**
  62177. * Define if the lens flare system is enabled.
  62178. */
  62179. get isEnabled(): boolean;
  62180. set isEnabled(value: boolean);
  62181. /**
  62182. * Get the scene the effects belongs to.
  62183. * @returns the scene holding the lens flare system
  62184. */
  62185. getScene(): Scene;
  62186. /**
  62187. * Get the emitter of the lens flare system.
  62188. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62189. * @returns the emitter of the lens flare system
  62190. */
  62191. getEmitter(): any;
  62192. /**
  62193. * Set the emitter of the lens flare system.
  62194. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62195. * @param newEmitter Define the new emitter of the system
  62196. */
  62197. setEmitter(newEmitter: any): void;
  62198. /**
  62199. * Get the lens flare system emitter position.
  62200. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62201. * @returns the position
  62202. */
  62203. getEmitterPosition(): Vector3;
  62204. /**
  62205. * @hidden
  62206. */
  62207. computeEffectivePosition(globalViewport: Viewport): boolean;
  62208. /** @hidden */
  62209. _isVisible(): boolean;
  62210. /**
  62211. * @hidden
  62212. */
  62213. render(): boolean;
  62214. /**
  62215. * Dispose and release the lens flare with its associated resources.
  62216. */
  62217. dispose(): void;
  62218. /**
  62219. * Parse a lens flare system from a JSON repressentation
  62220. * @param parsedLensFlareSystem Define the JSON to parse
  62221. * @param scene Define the scene the parsed system should be instantiated in
  62222. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62223. * @returns the parsed system
  62224. */
  62225. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62226. /**
  62227. * Serialize the current Lens Flare System into a JSON representation.
  62228. * @returns the serialized JSON
  62229. */
  62230. serialize(): any;
  62231. }
  62232. }
  62233. declare module "babylonjs/LensFlares/lensFlare" {
  62234. import { Nullable } from "babylonjs/types";
  62235. import { Color3 } from "babylonjs/Maths/math.color";
  62236. import { Texture } from "babylonjs/Materials/Textures/texture";
  62237. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62238. /**
  62239. * This represents one of the lens effect in a `lensFlareSystem`.
  62240. * It controls one of the indiviual texture used in the effect.
  62241. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62242. */
  62243. export class LensFlare {
  62244. /**
  62245. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62246. */
  62247. size: number;
  62248. /**
  62249. * 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.
  62250. */
  62251. position: number;
  62252. /**
  62253. * Define the lens color.
  62254. */
  62255. color: Color3;
  62256. /**
  62257. * Define the lens texture.
  62258. */
  62259. texture: Nullable<Texture>;
  62260. /**
  62261. * Define the alpha mode to render this particular lens.
  62262. */
  62263. alphaMode: number;
  62264. private _system;
  62265. /**
  62266. * Creates a new Lens Flare.
  62267. * This represents one of the lens effect in a `lensFlareSystem`.
  62268. * It controls one of the indiviual texture used in the effect.
  62269. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62270. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62271. * @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.
  62272. * @param color Define the lens color
  62273. * @param imgUrl Define the lens texture url
  62274. * @param system Define the `lensFlareSystem` this flare is part of
  62275. * @returns The newly created Lens Flare
  62276. */
  62277. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62278. /**
  62279. * Instantiates a new Lens Flare.
  62280. * This represents one of the lens effect in a `lensFlareSystem`.
  62281. * It controls one of the indiviual texture used in the effect.
  62282. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62283. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62284. * @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.
  62285. * @param color Define the lens color
  62286. * @param imgUrl Define the lens texture url
  62287. * @param system Define the `lensFlareSystem` this flare is part of
  62288. */
  62289. constructor(
  62290. /**
  62291. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62292. */
  62293. size: number,
  62294. /**
  62295. * 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.
  62296. */
  62297. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62298. /**
  62299. * Dispose and release the lens flare with its associated resources.
  62300. */
  62301. dispose(): void;
  62302. }
  62303. }
  62304. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62305. import { Nullable } from "babylonjs/types";
  62306. import { Scene } from "babylonjs/scene";
  62307. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62308. import { AbstractScene } from "babylonjs/abstractScene";
  62309. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62310. module "babylonjs/abstractScene" {
  62311. interface AbstractScene {
  62312. /**
  62313. * The list of lens flare system added to the scene
  62314. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62315. */
  62316. lensFlareSystems: Array<LensFlareSystem>;
  62317. /**
  62318. * Removes the given lens flare system from this scene.
  62319. * @param toRemove The lens flare system to remove
  62320. * @returns The index of the removed lens flare system
  62321. */
  62322. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62323. /**
  62324. * Adds the given lens flare system to this scene
  62325. * @param newLensFlareSystem The lens flare system to add
  62326. */
  62327. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62328. /**
  62329. * Gets a lens flare system using its name
  62330. * @param name defines the name to look for
  62331. * @returns the lens flare system or null if not found
  62332. */
  62333. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62334. /**
  62335. * Gets a lens flare system using its id
  62336. * @param id defines the id to look for
  62337. * @returns the lens flare system or null if not found
  62338. */
  62339. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62340. }
  62341. }
  62342. /**
  62343. * Defines the lens flare scene component responsible to manage any lens flares
  62344. * in a given scene.
  62345. */
  62346. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62347. /**
  62348. * The component name helpfull to identify the component in the list of scene components.
  62349. */
  62350. readonly name: string;
  62351. /**
  62352. * The scene the component belongs to.
  62353. */
  62354. scene: Scene;
  62355. /**
  62356. * Creates a new instance of the component for the given scene
  62357. * @param scene Defines the scene to register the component in
  62358. */
  62359. constructor(scene: Scene);
  62360. /**
  62361. * Registers the component in a given scene
  62362. */
  62363. register(): void;
  62364. /**
  62365. * Rebuilds the elements related to this component in case of
  62366. * context lost for instance.
  62367. */
  62368. rebuild(): void;
  62369. /**
  62370. * Adds all the elements from the container to the scene
  62371. * @param container the container holding the elements
  62372. */
  62373. addFromContainer(container: AbstractScene): void;
  62374. /**
  62375. * Removes all the elements in the container from the scene
  62376. * @param container contains the elements to remove
  62377. * @param dispose if the removed element should be disposed (default: false)
  62378. */
  62379. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62380. /**
  62381. * Serializes the component data to the specified json object
  62382. * @param serializationObject The object to serialize to
  62383. */
  62384. serialize(serializationObject: any): void;
  62385. /**
  62386. * Disposes the component and the associated ressources.
  62387. */
  62388. dispose(): void;
  62389. private _draw;
  62390. }
  62391. }
  62392. declare module "babylonjs/LensFlares/index" {
  62393. export * from "babylonjs/LensFlares/lensFlare";
  62394. export * from "babylonjs/LensFlares/lensFlareSystem";
  62395. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62396. }
  62397. declare module "babylonjs/Shaders/depth.fragment" {
  62398. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62399. /** @hidden */
  62400. export var depthPixelShader: {
  62401. name: string;
  62402. shader: string;
  62403. };
  62404. }
  62405. declare module "babylonjs/Shaders/depth.vertex" {
  62406. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62407. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62408. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62409. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62410. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62411. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62412. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62413. /** @hidden */
  62414. export var depthVertexShader: {
  62415. name: string;
  62416. shader: string;
  62417. };
  62418. }
  62419. declare module "babylonjs/Rendering/depthRenderer" {
  62420. import { Nullable } from "babylonjs/types";
  62421. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62422. import { Scene } from "babylonjs/scene";
  62423. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62424. import { Camera } from "babylonjs/Cameras/camera";
  62425. import "babylonjs/Shaders/depth.fragment";
  62426. import "babylonjs/Shaders/depth.vertex";
  62427. /**
  62428. * This represents a depth renderer in Babylon.
  62429. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62430. */
  62431. export class DepthRenderer {
  62432. private _scene;
  62433. private _depthMap;
  62434. private _effect;
  62435. private readonly _storeNonLinearDepth;
  62436. private readonly _clearColor;
  62437. /** Get if the depth renderer is using packed depth or not */
  62438. readonly isPacked: boolean;
  62439. private _cachedDefines;
  62440. private _camera;
  62441. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62442. enabled: boolean;
  62443. /**
  62444. * Specifiess that the depth renderer will only be used within
  62445. * the camera it is created for.
  62446. * This can help forcing its rendering during the camera processing.
  62447. */
  62448. useOnlyInActiveCamera: boolean;
  62449. /** @hidden */
  62450. static _SceneComponentInitialization: (scene: Scene) => void;
  62451. /**
  62452. * Instantiates a depth renderer
  62453. * @param scene The scene the renderer belongs to
  62454. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62455. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62456. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62457. */
  62458. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62459. /**
  62460. * Creates the depth rendering effect and checks if the effect is ready.
  62461. * @param subMesh The submesh to be used to render the depth map of
  62462. * @param useInstances If multiple world instances should be used
  62463. * @returns if the depth renderer is ready to render the depth map
  62464. */
  62465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62466. /**
  62467. * Gets the texture which the depth map will be written to.
  62468. * @returns The depth map texture
  62469. */
  62470. getDepthMap(): RenderTargetTexture;
  62471. /**
  62472. * Disposes of the depth renderer.
  62473. */
  62474. dispose(): void;
  62475. }
  62476. }
  62477. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62478. /** @hidden */
  62479. export var minmaxReduxPixelShader: {
  62480. name: string;
  62481. shader: string;
  62482. };
  62483. }
  62484. declare module "babylonjs/Misc/minMaxReducer" {
  62485. import { Nullable } from "babylonjs/types";
  62486. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62487. import { Camera } from "babylonjs/Cameras/camera";
  62488. import { Observer } from "babylonjs/Misc/observable";
  62489. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62490. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62491. import { Observable } from "babylonjs/Misc/observable";
  62492. import "babylonjs/Shaders/minmaxRedux.fragment";
  62493. /**
  62494. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62495. * and maximum values from all values of the texture.
  62496. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62497. * The source values are read from the red channel of the texture.
  62498. */
  62499. export class MinMaxReducer {
  62500. /**
  62501. * Observable triggered when the computation has been performed
  62502. */
  62503. onAfterReductionPerformed: Observable<{
  62504. min: number;
  62505. max: number;
  62506. }>;
  62507. protected _camera: Camera;
  62508. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62509. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62510. protected _postProcessManager: PostProcessManager;
  62511. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62512. protected _forceFullscreenViewport: boolean;
  62513. /**
  62514. * Creates a min/max reducer
  62515. * @param camera The camera to use for the post processes
  62516. */
  62517. constructor(camera: Camera);
  62518. /**
  62519. * Gets the texture used to read the values from.
  62520. */
  62521. get sourceTexture(): Nullable<RenderTargetTexture>;
  62522. /**
  62523. * Sets the source texture to read the values from.
  62524. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62525. * because in such textures '1' value must not be taken into account to compute the maximum
  62526. * as this value is used to clear the texture.
  62527. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62528. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62529. * @param depthRedux Indicates if the texture is a depth texture or not
  62530. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62531. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62532. */
  62533. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62534. /**
  62535. * Defines the refresh rate of the computation.
  62536. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62537. */
  62538. get refreshRate(): number;
  62539. set refreshRate(value: number);
  62540. protected _activated: boolean;
  62541. /**
  62542. * Gets the activation status of the reducer
  62543. */
  62544. get activated(): boolean;
  62545. /**
  62546. * Activates the reduction computation.
  62547. * When activated, the observers registered in onAfterReductionPerformed are
  62548. * called after the compuation is performed
  62549. */
  62550. activate(): void;
  62551. /**
  62552. * Deactivates the reduction computation.
  62553. */
  62554. deactivate(): void;
  62555. /**
  62556. * Disposes the min/max reducer
  62557. * @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.
  62558. */
  62559. dispose(disposeAll?: boolean): void;
  62560. }
  62561. }
  62562. declare module "babylonjs/Misc/depthReducer" {
  62563. import { Nullable } from "babylonjs/types";
  62564. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62565. import { Camera } from "babylonjs/Cameras/camera";
  62566. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62567. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62568. /**
  62569. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62570. */
  62571. export class DepthReducer extends MinMaxReducer {
  62572. private _depthRenderer;
  62573. private _depthRendererId;
  62574. /**
  62575. * Gets the depth renderer used for the computation.
  62576. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62577. */
  62578. get depthRenderer(): Nullable<DepthRenderer>;
  62579. /**
  62580. * Creates a depth reducer
  62581. * @param camera The camera used to render the depth texture
  62582. */
  62583. constructor(camera: Camera);
  62584. /**
  62585. * Sets the depth renderer to use to generate the depth map
  62586. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62587. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62588. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62589. */
  62590. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62591. /** @hidden */
  62592. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62593. /**
  62594. * Activates the reduction computation.
  62595. * When activated, the observers registered in onAfterReductionPerformed are
  62596. * called after the compuation is performed
  62597. */
  62598. activate(): void;
  62599. /**
  62600. * Deactivates the reduction computation.
  62601. */
  62602. deactivate(): void;
  62603. /**
  62604. * Disposes the depth reducer
  62605. * @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.
  62606. */
  62607. dispose(disposeAll?: boolean): void;
  62608. }
  62609. }
  62610. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62611. import { Nullable } from "babylonjs/types";
  62612. import { Scene } from "babylonjs/scene";
  62613. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62614. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62616. import { Effect } from "babylonjs/Materials/effect";
  62617. import "babylonjs/Shaders/shadowMap.fragment";
  62618. import "babylonjs/Shaders/shadowMap.vertex";
  62619. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62620. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62621. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62622. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62623. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62624. /**
  62625. * A CSM implementation allowing casting shadows on large scenes.
  62626. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62627. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62628. */
  62629. export class CascadedShadowGenerator extends ShadowGenerator {
  62630. private static readonly frustumCornersNDCSpace;
  62631. /**
  62632. * Name of the CSM class
  62633. */
  62634. static CLASSNAME: string;
  62635. /**
  62636. * Defines the default number of cascades used by the CSM.
  62637. */
  62638. static readonly DEFAULT_CASCADES_COUNT: number;
  62639. /**
  62640. * Defines the minimum number of cascades used by the CSM.
  62641. */
  62642. static readonly MIN_CASCADES_COUNT: number;
  62643. /**
  62644. * Defines the maximum number of cascades used by the CSM.
  62645. */
  62646. static readonly MAX_CASCADES_COUNT: number;
  62647. protected _validateFilter(filter: number): number;
  62648. /**
  62649. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62650. */
  62651. penumbraDarkness: number;
  62652. private _numCascades;
  62653. /**
  62654. * Gets or set the number of cascades used by the CSM.
  62655. */
  62656. get numCascades(): number;
  62657. set numCascades(value: number);
  62658. /**
  62659. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62660. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62661. */
  62662. stabilizeCascades: boolean;
  62663. private _freezeShadowCastersBoundingInfo;
  62664. private _freezeShadowCastersBoundingInfoObservable;
  62665. /**
  62666. * Enables or disables the shadow casters bounding info computation.
  62667. * If your shadow casters don't move, you can disable this feature.
  62668. * If it is enabled, the bounding box computation is done every frame.
  62669. */
  62670. get freezeShadowCastersBoundingInfo(): boolean;
  62671. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62672. private _scbiMin;
  62673. private _scbiMax;
  62674. protected _computeShadowCastersBoundingInfo(): void;
  62675. protected _shadowCastersBoundingInfo: BoundingInfo;
  62676. /**
  62677. * Gets or sets the shadow casters bounding info.
  62678. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62679. * so that the system won't overwrite the bounds you provide
  62680. */
  62681. get shadowCastersBoundingInfo(): BoundingInfo;
  62682. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62683. protected _breaksAreDirty: boolean;
  62684. protected _minDistance: number;
  62685. protected _maxDistance: number;
  62686. /**
  62687. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62688. *
  62689. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62690. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62691. * @param min minimal distance for the breaks (default to 0.)
  62692. * @param max maximal distance for the breaks (default to 1.)
  62693. */
  62694. setMinMaxDistance(min: number, max: number): void;
  62695. /** Gets the minimal distance used in the cascade break computation */
  62696. get minDistance(): number;
  62697. /** Gets the maximal distance used in the cascade break computation */
  62698. get maxDistance(): number;
  62699. /**
  62700. * Gets the class name of that object
  62701. * @returns "CascadedShadowGenerator"
  62702. */
  62703. getClassName(): string;
  62704. private _cascadeMinExtents;
  62705. private _cascadeMaxExtents;
  62706. /**
  62707. * Gets a cascade minimum extents
  62708. * @param cascadeIndex index of the cascade
  62709. * @returns the minimum cascade extents
  62710. */
  62711. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62712. /**
  62713. * Gets a cascade maximum extents
  62714. * @param cascadeIndex index of the cascade
  62715. * @returns the maximum cascade extents
  62716. */
  62717. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62718. private _cascades;
  62719. private _currentLayer;
  62720. private _viewSpaceFrustumsZ;
  62721. private _viewMatrices;
  62722. private _projectionMatrices;
  62723. private _transformMatrices;
  62724. private _transformMatricesAsArray;
  62725. private _frustumLengths;
  62726. private _lightSizeUVCorrection;
  62727. private _depthCorrection;
  62728. private _frustumCornersWorldSpace;
  62729. private _frustumCenter;
  62730. private _shadowCameraPos;
  62731. private _shadowMaxZ;
  62732. /**
  62733. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62734. * It defaults to camera.maxZ
  62735. */
  62736. get shadowMaxZ(): number;
  62737. /**
  62738. * Sets the shadow max z distance.
  62739. */
  62740. set shadowMaxZ(value: number);
  62741. protected _debug: boolean;
  62742. /**
  62743. * Gets or sets the debug flag.
  62744. * When enabled, the cascades are materialized by different colors on the screen.
  62745. */
  62746. get debug(): boolean;
  62747. set debug(dbg: boolean);
  62748. private _depthClamp;
  62749. /**
  62750. * Gets or sets the depth clamping value.
  62751. *
  62752. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62753. * to account for the shadow casters far away.
  62754. *
  62755. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62756. */
  62757. get depthClamp(): boolean;
  62758. set depthClamp(value: boolean);
  62759. private _cascadeBlendPercentage;
  62760. /**
  62761. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62762. * It defaults to 0.1 (10% blending).
  62763. */
  62764. get cascadeBlendPercentage(): number;
  62765. set cascadeBlendPercentage(value: number);
  62766. private _lambda;
  62767. /**
  62768. * Gets or set the lambda parameter.
  62769. * This parameter is used to split the camera frustum and create the cascades.
  62770. * 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.
  62771. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62772. */
  62773. get lambda(): number;
  62774. set lambda(value: number);
  62775. /**
  62776. * Gets the view matrix corresponding to a given cascade
  62777. * @param cascadeNum cascade to retrieve the view matrix from
  62778. * @returns the cascade view matrix
  62779. */
  62780. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62781. /**
  62782. * Gets the projection matrix corresponding to a given cascade
  62783. * @param cascadeNum cascade to retrieve the projection matrix from
  62784. * @returns the cascade projection matrix
  62785. */
  62786. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62787. /**
  62788. * Gets the transformation matrix corresponding to a given cascade
  62789. * @param cascadeNum cascade to retrieve the transformation matrix from
  62790. * @returns the cascade transformation matrix
  62791. */
  62792. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62793. private _depthRenderer;
  62794. /**
  62795. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62796. *
  62797. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62798. *
  62799. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  62800. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  62801. * @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
  62802. */
  62803. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  62804. private _depthReducer;
  62805. private _autoCalcDepthBounds;
  62806. /**
  62807. * Gets or sets the autoCalcDepthBounds property.
  62808. *
  62809. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  62810. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  62811. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  62812. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  62813. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  62814. */
  62815. get autoCalcDepthBounds(): boolean;
  62816. set autoCalcDepthBounds(value: boolean);
  62817. /**
  62818. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  62819. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62820. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  62821. * for setting the refresh rate on the renderer yourself!
  62822. */
  62823. get autoCalcDepthBoundsRefreshRate(): number;
  62824. set autoCalcDepthBoundsRefreshRate(value: number);
  62825. /**
  62826. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  62827. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  62828. * you change the camera near/far planes!
  62829. */
  62830. splitFrustum(): void;
  62831. private _splitFrustum;
  62832. private _computeMatrices;
  62833. private _computeFrustumInWorldSpace;
  62834. private _computeCascadeFrustum;
  62835. /**
  62836. * Support test.
  62837. */
  62838. static get IsSupported(): boolean;
  62839. /** @hidden */
  62840. static _SceneComponentInitialization: (scene: Scene) => void;
  62841. /**
  62842. * Creates a Cascaded Shadow Generator object.
  62843. * A ShadowGenerator is the required tool to use the shadows.
  62844. * Each directional light casting shadows needs to use its own ShadowGenerator.
  62845. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62846. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  62847. * @param light The directional light object generating the shadows.
  62848. * @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.
  62849. */
  62850. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  62851. protected _initializeGenerator(): void;
  62852. protected _createTargetRenderTexture(): void;
  62853. protected _initializeShadowMap(): void;
  62854. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  62855. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  62856. /**
  62857. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  62858. * @param defines Defines of the material we want to update
  62859. * @param lightIndex Index of the light in the enabled light list of the material
  62860. */
  62861. prepareDefines(defines: any, lightIndex: number): void;
  62862. /**
  62863. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  62864. * defined in the generator but impacting the effect).
  62865. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  62866. * @param effect The effect we are binfing the information for
  62867. */
  62868. bindShadowLight(lightIndex: string, effect: Effect): void;
  62869. /**
  62870. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  62871. * (eq to view projection * shadow projection matrices)
  62872. * @returns The transform matrix used to create the shadow map
  62873. */
  62874. getTransformMatrix(): Matrix;
  62875. /**
  62876. * Disposes the ShadowGenerator.
  62877. * Returns nothing.
  62878. */
  62879. dispose(): void;
  62880. /**
  62881. * Serializes the shadow generator setup to a json object.
  62882. * @returns The serialized JSON object
  62883. */
  62884. serialize(): any;
  62885. /**
  62886. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  62887. * @param parsedShadowGenerator The JSON object to parse
  62888. * @param scene The scene to create the shadow map for
  62889. * @returns The parsed shadow generator
  62890. */
  62891. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  62892. }
  62893. }
  62894. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  62895. import { Scene } from "babylonjs/scene";
  62896. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62897. import { AbstractScene } from "babylonjs/abstractScene";
  62898. /**
  62899. * Defines the shadow generator component responsible to manage any shadow generators
  62900. * in a given scene.
  62901. */
  62902. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  62903. /**
  62904. * The component name helpfull to identify the component in the list of scene components.
  62905. */
  62906. readonly name: string;
  62907. /**
  62908. * The scene the component belongs to.
  62909. */
  62910. scene: Scene;
  62911. /**
  62912. * Creates a new instance of the component for the given scene
  62913. * @param scene Defines the scene to register the component in
  62914. */
  62915. constructor(scene: Scene);
  62916. /**
  62917. * Registers the component in a given scene
  62918. */
  62919. register(): void;
  62920. /**
  62921. * Rebuilds the elements related to this component in case of
  62922. * context lost for instance.
  62923. */
  62924. rebuild(): void;
  62925. /**
  62926. * Serializes the component data to the specified json object
  62927. * @param serializationObject The object to serialize to
  62928. */
  62929. serialize(serializationObject: any): void;
  62930. /**
  62931. * Adds all the elements from the container to the scene
  62932. * @param container the container holding the elements
  62933. */
  62934. addFromContainer(container: AbstractScene): void;
  62935. /**
  62936. * Removes all the elements in the container from the scene
  62937. * @param container contains the elements to remove
  62938. * @param dispose if the removed element should be disposed (default: false)
  62939. */
  62940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62941. /**
  62942. * Rebuilds the elements related to this component in case of
  62943. * context lost for instance.
  62944. */
  62945. dispose(): void;
  62946. private _gatherRenderTargets;
  62947. }
  62948. }
  62949. declare module "babylonjs/Lights/Shadows/index" {
  62950. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  62951. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  62952. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  62953. }
  62954. declare module "babylonjs/Lights/pointLight" {
  62955. import { Scene } from "babylonjs/scene";
  62956. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62958. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  62959. import { Effect } from "babylonjs/Materials/effect";
  62960. /**
  62961. * A point light is a light defined by an unique point in world space.
  62962. * The light is emitted in every direction from this point.
  62963. * A good example of a point light is a standard light bulb.
  62964. * Documentation: https://doc.babylonjs.com/babylon101/lights
  62965. */
  62966. export class PointLight extends ShadowLight {
  62967. private _shadowAngle;
  62968. /**
  62969. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62970. * This specifies what angle the shadow will use to be created.
  62971. *
  62972. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62973. */
  62974. get shadowAngle(): number;
  62975. /**
  62976. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62977. * This specifies what angle the shadow will use to be created.
  62978. *
  62979. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  62980. */
  62981. set shadowAngle(value: number);
  62982. /**
  62983. * Gets the direction if it has been set.
  62984. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62985. */
  62986. get direction(): Vector3;
  62987. /**
  62988. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  62989. */
  62990. set direction(value: Vector3);
  62991. /**
  62992. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  62993. * A PointLight emits the light in every direction.
  62994. * It can cast shadows.
  62995. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  62996. * ```javascript
  62997. * var pointLight = new PointLight("pl", camera.position, scene);
  62998. * ```
  62999. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63000. * @param name The light friendly name
  63001. * @param position The position of the point light in the scene
  63002. * @param scene The scene the lights belongs to
  63003. */
  63004. constructor(name: string, position: Vector3, scene: Scene);
  63005. /**
  63006. * Returns the string "PointLight"
  63007. * @returns the class name
  63008. */
  63009. getClassName(): string;
  63010. /**
  63011. * Returns the integer 0.
  63012. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63013. */
  63014. getTypeID(): number;
  63015. /**
  63016. * Specifies wether or not the shadowmap should be a cube texture.
  63017. * @returns true if the shadowmap needs to be a cube texture.
  63018. */
  63019. needCube(): boolean;
  63020. /**
  63021. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63022. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63023. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63024. */
  63025. getShadowDirection(faceIndex?: number): Vector3;
  63026. /**
  63027. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63028. * - fov = PI / 2
  63029. * - aspect ratio : 1.0
  63030. * - z-near and far equal to the active camera minZ and maxZ.
  63031. * Returns the PointLight.
  63032. */
  63033. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63034. protected _buildUniformLayout(): void;
  63035. /**
  63036. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63037. * @param effect The effect to update
  63038. * @param lightIndex The index of the light in the effect to update
  63039. * @returns The point light
  63040. */
  63041. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63042. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63043. /**
  63044. * Prepares the list of defines specific to the light type.
  63045. * @param defines the list of defines
  63046. * @param lightIndex defines the index of the light for the effect
  63047. */
  63048. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63049. }
  63050. }
  63051. declare module "babylonjs/Lights/index" {
  63052. export * from "babylonjs/Lights/light";
  63053. export * from "babylonjs/Lights/shadowLight";
  63054. export * from "babylonjs/Lights/Shadows/index";
  63055. export * from "babylonjs/Lights/directionalLight";
  63056. export * from "babylonjs/Lights/hemisphericLight";
  63057. export * from "babylonjs/Lights/pointLight";
  63058. export * from "babylonjs/Lights/spotLight";
  63059. }
  63060. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63061. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63062. /**
  63063. * Header information of HDR texture files.
  63064. */
  63065. export interface HDRInfo {
  63066. /**
  63067. * The height of the texture in pixels.
  63068. */
  63069. height: number;
  63070. /**
  63071. * The width of the texture in pixels.
  63072. */
  63073. width: number;
  63074. /**
  63075. * The index of the beginning of the data in the binary file.
  63076. */
  63077. dataPosition: number;
  63078. }
  63079. /**
  63080. * This groups tools to convert HDR texture to native colors array.
  63081. */
  63082. export class HDRTools {
  63083. private static Ldexp;
  63084. private static Rgbe2float;
  63085. private static readStringLine;
  63086. /**
  63087. * Reads header information from an RGBE texture stored in a native array.
  63088. * More information on this format are available here:
  63089. * https://en.wikipedia.org/wiki/RGBE_image_format
  63090. *
  63091. * @param uint8array The binary file stored in native array.
  63092. * @return The header information.
  63093. */
  63094. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63095. /**
  63096. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63097. * This RGBE texture needs to store the information as a panorama.
  63098. *
  63099. * More information on this format are available here:
  63100. * https://en.wikipedia.org/wiki/RGBE_image_format
  63101. *
  63102. * @param buffer The binary file stored in an array buffer.
  63103. * @param size The expected size of the extracted cubemap.
  63104. * @return The Cube Map information.
  63105. */
  63106. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63107. /**
  63108. * Returns the pixels data extracted from an RGBE texture.
  63109. * This pixels will be stored left to right up to down in the R G B order in one array.
  63110. *
  63111. * More information on this format are available here:
  63112. * https://en.wikipedia.org/wiki/RGBE_image_format
  63113. *
  63114. * @param uint8array The binary file stored in an array buffer.
  63115. * @param hdrInfo The header information of the file.
  63116. * @return The pixels data in RGB right to left up to down order.
  63117. */
  63118. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63119. private static RGBE_ReadPixels_RLE;
  63120. private static RGBE_ReadPixels_NOT_RLE;
  63121. }
  63122. }
  63123. declare module "babylonjs/Materials/effectRenderer" {
  63124. import { Nullable } from "babylonjs/types";
  63125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63126. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63127. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63128. import { Viewport } from "babylonjs/Maths/math.viewport";
  63129. import { Observable } from "babylonjs/Misc/observable";
  63130. import { Effect } from "babylonjs/Materials/effect";
  63131. import "babylonjs/Shaders/postprocess.vertex";
  63132. /**
  63133. * Effect Render Options
  63134. */
  63135. export interface IEffectRendererOptions {
  63136. /**
  63137. * Defines the vertices positions.
  63138. */
  63139. positions?: number[];
  63140. /**
  63141. * Defines the indices.
  63142. */
  63143. indices?: number[];
  63144. }
  63145. /**
  63146. * Helper class to render one or more effects.
  63147. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63148. */
  63149. export class EffectRenderer {
  63150. private engine;
  63151. private static _DefaultOptions;
  63152. private _vertexBuffers;
  63153. private _indexBuffer;
  63154. private _fullscreenViewport;
  63155. /**
  63156. * Creates an effect renderer
  63157. * @param engine the engine to use for rendering
  63158. * @param options defines the options of the effect renderer
  63159. */
  63160. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63161. /**
  63162. * Sets the current viewport in normalized coordinates 0-1
  63163. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63164. */
  63165. setViewport(viewport?: Viewport): void;
  63166. /**
  63167. * Binds the embedded attributes buffer to the effect.
  63168. * @param effect Defines the effect to bind the attributes for
  63169. */
  63170. bindBuffers(effect: Effect): void;
  63171. /**
  63172. * Sets the current effect wrapper to use during draw.
  63173. * The effect needs to be ready before calling this api.
  63174. * This also sets the default full screen position attribute.
  63175. * @param effectWrapper Defines the effect to draw with
  63176. */
  63177. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63178. /**
  63179. * Restores engine states
  63180. */
  63181. restoreStates(): void;
  63182. /**
  63183. * Draws a full screen quad.
  63184. */
  63185. draw(): void;
  63186. private isRenderTargetTexture;
  63187. /**
  63188. * renders one or more effects to a specified texture
  63189. * @param effectWrapper the effect to renderer
  63190. * @param outputTexture texture to draw to, if null it will render to the screen.
  63191. */
  63192. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63193. /**
  63194. * Disposes of the effect renderer
  63195. */
  63196. dispose(): void;
  63197. }
  63198. /**
  63199. * Options to create an EffectWrapper
  63200. */
  63201. interface EffectWrapperCreationOptions {
  63202. /**
  63203. * Engine to use to create the effect
  63204. */
  63205. engine: ThinEngine;
  63206. /**
  63207. * Fragment shader for the effect
  63208. */
  63209. fragmentShader: string;
  63210. /**
  63211. * Use the shader store instead of direct source code
  63212. */
  63213. useShaderStore?: boolean;
  63214. /**
  63215. * Vertex shader for the effect
  63216. */
  63217. vertexShader?: string;
  63218. /**
  63219. * Attributes to use in the shader
  63220. */
  63221. attributeNames?: Array<string>;
  63222. /**
  63223. * Uniforms to use in the shader
  63224. */
  63225. uniformNames?: Array<string>;
  63226. /**
  63227. * Texture sampler names to use in the shader
  63228. */
  63229. samplerNames?: Array<string>;
  63230. /**
  63231. * Defines to use in the shader
  63232. */
  63233. defines?: Array<string>;
  63234. /**
  63235. * Callback when effect is compiled
  63236. */
  63237. onCompiled?: Nullable<(effect: Effect) => void>;
  63238. /**
  63239. * The friendly name of the effect displayed in Spector.
  63240. */
  63241. name?: string;
  63242. }
  63243. /**
  63244. * Wraps an effect to be used for rendering
  63245. */
  63246. export class EffectWrapper {
  63247. /**
  63248. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63249. */
  63250. onApplyObservable: Observable<{}>;
  63251. /**
  63252. * The underlying effect
  63253. */
  63254. effect: Effect;
  63255. /**
  63256. * Creates an effect to be renderer
  63257. * @param creationOptions options to create the effect
  63258. */
  63259. constructor(creationOptions: EffectWrapperCreationOptions);
  63260. /**
  63261. * Disposes of the effect wrapper
  63262. */
  63263. dispose(): void;
  63264. }
  63265. }
  63266. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63267. /** @hidden */
  63268. export var hdrFilteringVertexShader: {
  63269. name: string;
  63270. shader: string;
  63271. };
  63272. }
  63273. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63274. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63275. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63276. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63277. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63278. /** @hidden */
  63279. export var hdrFilteringPixelShader: {
  63280. name: string;
  63281. shader: string;
  63282. };
  63283. }
  63284. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63285. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63286. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63287. import { Nullable } from "babylonjs/types";
  63288. import "babylonjs/Shaders/hdrFiltering.vertex";
  63289. import "babylonjs/Shaders/hdrFiltering.fragment";
  63290. /**
  63291. * Options for texture filtering
  63292. */
  63293. interface IHDRFilteringOptions {
  63294. /**
  63295. * Scales pixel intensity for the input HDR map.
  63296. */
  63297. hdrScale?: number;
  63298. /**
  63299. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63300. */
  63301. quality?: number;
  63302. }
  63303. /**
  63304. * Filters HDR maps to get correct renderings of PBR reflections
  63305. */
  63306. export class HDRFiltering {
  63307. private _engine;
  63308. private _effectRenderer;
  63309. private _effectWrapper;
  63310. private _lodGenerationOffset;
  63311. private _lodGenerationScale;
  63312. /**
  63313. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63314. * you care about baking speed.
  63315. */
  63316. quality: number;
  63317. /**
  63318. * Scales pixel intensity for the input HDR map.
  63319. */
  63320. hdrScale: number;
  63321. /**
  63322. * Instantiates HDR filter for reflection maps
  63323. *
  63324. * @param engine Thin engine
  63325. * @param options Options
  63326. */
  63327. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63328. private _createRenderTarget;
  63329. private _prefilterInternal;
  63330. private _createEffect;
  63331. /**
  63332. * Get a value indicating if the filter is ready to be used
  63333. * @param texture Texture to filter
  63334. * @returns true if the filter is ready
  63335. */
  63336. isReady(texture: BaseTexture): boolean;
  63337. /**
  63338. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63339. * Prefiltering will be invoked at the end of next rendering pass.
  63340. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63341. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63342. * @param texture Texture to filter
  63343. * @param onFinished Callback when filtering is done
  63344. * @return Promise called when prefiltering is done
  63345. */
  63346. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63347. }
  63348. }
  63349. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63350. import { Nullable } from "babylonjs/types";
  63351. import { Scene } from "babylonjs/scene";
  63352. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63353. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63354. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63355. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63356. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63357. /**
  63358. * This represents a texture coming from an HDR input.
  63359. *
  63360. * The only supported format is currently panorama picture stored in RGBE format.
  63361. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63362. */
  63363. export class HDRCubeTexture extends BaseTexture {
  63364. private static _facesMapping;
  63365. private _generateHarmonics;
  63366. private _noMipmap;
  63367. private _prefilterOnLoad;
  63368. private _textureMatrix;
  63369. private _size;
  63370. private _onLoad;
  63371. private _onError;
  63372. /**
  63373. * The texture URL.
  63374. */
  63375. url: string;
  63376. protected _isBlocking: boolean;
  63377. /**
  63378. * Sets wether or not the texture is blocking during loading.
  63379. */
  63380. set isBlocking(value: boolean);
  63381. /**
  63382. * Gets wether or not the texture is blocking during loading.
  63383. */
  63384. get isBlocking(): boolean;
  63385. protected _rotationY: number;
  63386. /**
  63387. * Sets texture matrix rotation angle around Y axis in radians.
  63388. */
  63389. set rotationY(value: number);
  63390. /**
  63391. * Gets texture matrix rotation angle around Y axis radians.
  63392. */
  63393. get rotationY(): number;
  63394. /**
  63395. * Gets or sets the center of the bounding box associated with the cube texture
  63396. * It must define where the camera used to render the texture was set
  63397. */
  63398. boundingBoxPosition: Vector3;
  63399. private _boundingBoxSize;
  63400. /**
  63401. * Gets or sets the size of the bounding box associated with the cube texture
  63402. * When defined, the cubemap will switch to local mode
  63403. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63404. * @example https://www.babylonjs-playground.com/#RNASML
  63405. */
  63406. set boundingBoxSize(value: Vector3);
  63407. get boundingBoxSize(): Vector3;
  63408. /**
  63409. * Instantiates an HDRTexture from the following parameters.
  63410. *
  63411. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63412. * @param sceneOrEngine The scene or engine the texture will be used in
  63413. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63414. * @param noMipmap Forces to not generate the mipmap if true
  63415. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63416. * @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)
  63417. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63418. */
  63419. 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>);
  63420. /**
  63421. * Get the current class name of the texture useful for serialization or dynamic coding.
  63422. * @returns "HDRCubeTexture"
  63423. */
  63424. getClassName(): string;
  63425. /**
  63426. * Occurs when the file is raw .hdr file.
  63427. */
  63428. private loadTexture;
  63429. clone(): HDRCubeTexture;
  63430. delayLoad(): void;
  63431. /**
  63432. * Get the texture reflection matrix used to rotate/transform the reflection.
  63433. * @returns the reflection matrix
  63434. */
  63435. getReflectionTextureMatrix(): Matrix;
  63436. /**
  63437. * Set the texture reflection matrix used to rotate/transform the reflection.
  63438. * @param value Define the reflection matrix to set
  63439. */
  63440. setReflectionTextureMatrix(value: Matrix): void;
  63441. /**
  63442. * Parses a JSON representation of an HDR Texture in order to create the texture
  63443. * @param parsedTexture Define the JSON representation
  63444. * @param scene Define the scene the texture should be created in
  63445. * @param rootUrl Define the root url in case we need to load relative dependencies
  63446. * @returns the newly created texture after parsing
  63447. */
  63448. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63449. serialize(): any;
  63450. }
  63451. }
  63452. declare module "babylonjs/Physics/physicsEngine" {
  63453. import { Nullable } from "babylonjs/types";
  63454. import { Vector3 } from "babylonjs/Maths/math.vector";
  63455. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63456. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63457. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63458. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63459. /**
  63460. * Class used to control physics engine
  63461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63462. */
  63463. export class PhysicsEngine implements IPhysicsEngine {
  63464. private _physicsPlugin;
  63465. /**
  63466. * Global value used to control the smallest number supported by the simulation
  63467. */
  63468. static Epsilon: number;
  63469. private _impostors;
  63470. private _joints;
  63471. private _subTimeStep;
  63472. /**
  63473. * Gets the gravity vector used by the simulation
  63474. */
  63475. gravity: Vector3;
  63476. /**
  63477. * Factory used to create the default physics plugin.
  63478. * @returns The default physics plugin
  63479. */
  63480. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63481. /**
  63482. * Creates a new Physics Engine
  63483. * @param gravity defines the gravity vector used by the simulation
  63484. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63485. */
  63486. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63487. /**
  63488. * Sets the gravity vector used by the simulation
  63489. * @param gravity defines the gravity vector to use
  63490. */
  63491. setGravity(gravity: Vector3): void;
  63492. /**
  63493. * Set the time step of the physics engine.
  63494. * Default is 1/60.
  63495. * To slow it down, enter 1/600 for example.
  63496. * To speed it up, 1/30
  63497. * @param newTimeStep defines the new timestep to apply to this world.
  63498. */
  63499. setTimeStep(newTimeStep?: number): void;
  63500. /**
  63501. * Get the time step of the physics engine.
  63502. * @returns the current time step
  63503. */
  63504. getTimeStep(): number;
  63505. /**
  63506. * Set the sub time step of the physics engine.
  63507. * Default is 0 meaning there is no sub steps
  63508. * To increase physics resolution precision, set a small value (like 1 ms)
  63509. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63510. */
  63511. setSubTimeStep(subTimeStep?: number): void;
  63512. /**
  63513. * Get the sub time step of the physics engine.
  63514. * @returns the current sub time step
  63515. */
  63516. getSubTimeStep(): number;
  63517. /**
  63518. * Release all resources
  63519. */
  63520. dispose(): void;
  63521. /**
  63522. * Gets the name of the current physics plugin
  63523. * @returns the name of the plugin
  63524. */
  63525. getPhysicsPluginName(): string;
  63526. /**
  63527. * Adding a new impostor for the impostor tracking.
  63528. * This will be done by the impostor itself.
  63529. * @param impostor the impostor to add
  63530. */
  63531. addImpostor(impostor: PhysicsImpostor): void;
  63532. /**
  63533. * Remove an impostor from the engine.
  63534. * This impostor and its mesh will not longer be updated by the physics engine.
  63535. * @param impostor the impostor to remove
  63536. */
  63537. removeImpostor(impostor: PhysicsImpostor): void;
  63538. /**
  63539. * Add a joint to the physics engine
  63540. * @param mainImpostor defines the main impostor to which the joint is added.
  63541. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63542. * @param joint defines the joint that will connect both impostors.
  63543. */
  63544. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63545. /**
  63546. * Removes a joint from the simulation
  63547. * @param mainImpostor defines the impostor used with the joint
  63548. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63549. * @param joint defines the joint to remove
  63550. */
  63551. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63552. /**
  63553. * Called by the scene. No need to call it.
  63554. * @param delta defines the timespam between frames
  63555. */
  63556. _step(delta: number): void;
  63557. /**
  63558. * Gets the current plugin used to run the simulation
  63559. * @returns current plugin
  63560. */
  63561. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63562. /**
  63563. * Gets the list of physic impostors
  63564. * @returns an array of PhysicsImpostor
  63565. */
  63566. getImpostors(): Array<PhysicsImpostor>;
  63567. /**
  63568. * Gets the impostor for a physics enabled object
  63569. * @param object defines the object impersonated by the impostor
  63570. * @returns the PhysicsImpostor or null if not found
  63571. */
  63572. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63573. /**
  63574. * Gets the impostor for a physics body object
  63575. * @param body defines physics body used by the impostor
  63576. * @returns the PhysicsImpostor or null if not found
  63577. */
  63578. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63579. /**
  63580. * Does a raycast in the physics world
  63581. * @param from when should the ray start?
  63582. * @param to when should the ray end?
  63583. * @returns PhysicsRaycastResult
  63584. */
  63585. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63586. }
  63587. }
  63588. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63589. import { Nullable } from "babylonjs/types";
  63590. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63592. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63593. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63594. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63595. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63596. /** @hidden */
  63597. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63598. private _useDeltaForWorldStep;
  63599. world: any;
  63600. name: string;
  63601. private _physicsMaterials;
  63602. private _fixedTimeStep;
  63603. private _cannonRaycastResult;
  63604. private _raycastResult;
  63605. private _physicsBodysToRemoveAfterStep;
  63606. private _firstFrame;
  63607. BJSCANNON: any;
  63608. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63609. setGravity(gravity: Vector3): void;
  63610. setTimeStep(timeStep: number): void;
  63611. getTimeStep(): number;
  63612. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63613. private _removeMarkedPhysicsBodiesFromWorld;
  63614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63617. private _processChildMeshes;
  63618. removePhysicsBody(impostor: PhysicsImpostor): void;
  63619. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63620. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63621. private _addMaterial;
  63622. private _checkWithEpsilon;
  63623. private _createShape;
  63624. private _createHeightmap;
  63625. private _minus90X;
  63626. private _plus90X;
  63627. private _tmpPosition;
  63628. private _tmpDeltaPosition;
  63629. private _tmpUnityRotation;
  63630. private _updatePhysicsBodyTransformation;
  63631. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63632. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63633. isSupported(): boolean;
  63634. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63635. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63637. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63638. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63639. getBodyMass(impostor: PhysicsImpostor): number;
  63640. getBodyFriction(impostor: PhysicsImpostor): number;
  63641. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63642. getBodyRestitution(impostor: PhysicsImpostor): number;
  63643. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63644. sleepBody(impostor: PhysicsImpostor): void;
  63645. wakeUpBody(impostor: PhysicsImpostor): void;
  63646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63647. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63649. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63650. getRadius(impostor: PhysicsImpostor): number;
  63651. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63652. dispose(): void;
  63653. private _extendNamespace;
  63654. /**
  63655. * Does a raycast in the physics world
  63656. * @param from when should the ray start?
  63657. * @param to when should the ray end?
  63658. * @returns PhysicsRaycastResult
  63659. */
  63660. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63661. }
  63662. }
  63663. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63664. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63665. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63666. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63667. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63668. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63669. import { Nullable } from "babylonjs/types";
  63670. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63671. /** @hidden */
  63672. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63673. private _useDeltaForWorldStep;
  63674. world: any;
  63675. name: string;
  63676. BJSOIMO: any;
  63677. private _raycastResult;
  63678. private _fixedTimeStep;
  63679. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63680. setGravity(gravity: Vector3): void;
  63681. setTimeStep(timeStep: number): void;
  63682. getTimeStep(): number;
  63683. private _tmpImpostorsArray;
  63684. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63685. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63686. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63687. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63688. private _tmpPositionVector;
  63689. removePhysicsBody(impostor: PhysicsImpostor): void;
  63690. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63691. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63692. isSupported(): boolean;
  63693. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63694. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63695. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63696. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63697. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63698. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63699. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63700. getBodyMass(impostor: PhysicsImpostor): number;
  63701. getBodyFriction(impostor: PhysicsImpostor): number;
  63702. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63703. getBodyRestitution(impostor: PhysicsImpostor): number;
  63704. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63705. sleepBody(impostor: PhysicsImpostor): void;
  63706. wakeUpBody(impostor: PhysicsImpostor): void;
  63707. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63708. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63709. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63710. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63711. getRadius(impostor: PhysicsImpostor): number;
  63712. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63713. dispose(): void;
  63714. /**
  63715. * Does a raycast in the physics world
  63716. * @param from when should the ray start?
  63717. * @param to when should the ray end?
  63718. * @returns PhysicsRaycastResult
  63719. */
  63720. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63721. }
  63722. }
  63723. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63724. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63725. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63726. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63727. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63728. import { Nullable } from "babylonjs/types";
  63729. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63730. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63731. /**
  63732. * AmmoJS Physics plugin
  63733. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63734. * @see https://github.com/kripken/ammo.js/
  63735. */
  63736. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63737. private _useDeltaForWorldStep;
  63738. /**
  63739. * Reference to the Ammo library
  63740. */
  63741. bjsAMMO: any;
  63742. /**
  63743. * Created ammoJS world which physics bodies are added to
  63744. */
  63745. world: any;
  63746. /**
  63747. * Name of the plugin
  63748. */
  63749. name: string;
  63750. private _timeStep;
  63751. private _fixedTimeStep;
  63752. private _maxSteps;
  63753. private _tmpQuaternion;
  63754. private _tmpAmmoTransform;
  63755. private _tmpAmmoQuaternion;
  63756. private _tmpAmmoConcreteContactResultCallback;
  63757. private _collisionConfiguration;
  63758. private _dispatcher;
  63759. private _overlappingPairCache;
  63760. private _solver;
  63761. private _softBodySolver;
  63762. private _tmpAmmoVectorA;
  63763. private _tmpAmmoVectorB;
  63764. private _tmpAmmoVectorC;
  63765. private _tmpAmmoVectorD;
  63766. private _tmpContactCallbackResult;
  63767. private _tmpAmmoVectorRCA;
  63768. private _tmpAmmoVectorRCB;
  63769. private _raycastResult;
  63770. private static readonly DISABLE_COLLISION_FLAG;
  63771. private static readonly KINEMATIC_FLAG;
  63772. private static readonly DISABLE_DEACTIVATION_FLAG;
  63773. /**
  63774. * Initializes the ammoJS plugin
  63775. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63776. * @param ammoInjection can be used to inject your own ammo reference
  63777. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63778. */
  63779. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63780. /**
  63781. * Sets the gravity of the physics world (m/(s^2))
  63782. * @param gravity Gravity to set
  63783. */
  63784. setGravity(gravity: Vector3): void;
  63785. /**
  63786. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63787. * @param timeStep timestep to use in seconds
  63788. */
  63789. setTimeStep(timeStep: number): void;
  63790. /**
  63791. * 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)
  63792. * @param fixedTimeStep fixedTimeStep to use in seconds
  63793. */
  63794. setFixedTimeStep(fixedTimeStep: number): void;
  63795. /**
  63796. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63797. * @param maxSteps the maximum number of steps by the physics engine per frame
  63798. */
  63799. setMaxSteps(maxSteps: number): void;
  63800. /**
  63801. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  63802. * @returns the current timestep in seconds
  63803. */
  63804. getTimeStep(): number;
  63805. /**
  63806. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  63807. */
  63808. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  63809. private _isImpostorInContact;
  63810. private _isImpostorPairInContact;
  63811. private _stepSimulation;
  63812. /**
  63813. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  63814. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  63815. * After the step the babylon meshes are set to the position of the physics imposters
  63816. * @param delta amount of time to step forward
  63817. * @param impostors array of imposters to update before/after the step
  63818. */
  63819. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63820. /**
  63821. * Update babylon mesh to match physics world object
  63822. * @param impostor imposter to match
  63823. */
  63824. private _afterSoftStep;
  63825. /**
  63826. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63827. * @param impostor imposter to match
  63828. */
  63829. private _ropeStep;
  63830. /**
  63831. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  63832. * @param impostor imposter to match
  63833. */
  63834. private _softbodyOrClothStep;
  63835. private _tmpMatrix;
  63836. /**
  63837. * Applies an impulse on the imposter
  63838. * @param impostor imposter to apply impulse to
  63839. * @param force amount of force to be applied to the imposter
  63840. * @param contactPoint the location to apply the impulse on the imposter
  63841. */
  63842. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63843. /**
  63844. * Applies a force on the imposter
  63845. * @param impostor imposter to apply force
  63846. * @param force amount of force to be applied to the imposter
  63847. * @param contactPoint the location to apply the force on the imposter
  63848. */
  63849. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63850. /**
  63851. * Creates a physics body using the plugin
  63852. * @param impostor the imposter to create the physics body on
  63853. */
  63854. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63855. /**
  63856. * Removes the physics body from the imposter and disposes of the body's memory
  63857. * @param impostor imposter to remove the physics body from
  63858. */
  63859. removePhysicsBody(impostor: PhysicsImpostor): void;
  63860. /**
  63861. * Generates a joint
  63862. * @param impostorJoint the imposter joint to create the joint with
  63863. */
  63864. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63865. /**
  63866. * Removes a joint
  63867. * @param impostorJoint the imposter joint to remove the joint from
  63868. */
  63869. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63870. private _addMeshVerts;
  63871. /**
  63872. * Initialise the soft body vertices to match its object's (mesh) vertices
  63873. * Softbody vertices (nodes) are in world space and to match this
  63874. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  63875. * @param impostor to create the softbody for
  63876. */
  63877. private _softVertexData;
  63878. /**
  63879. * Create an impostor's soft body
  63880. * @param impostor to create the softbody for
  63881. */
  63882. private _createSoftbody;
  63883. /**
  63884. * Create cloth for an impostor
  63885. * @param impostor to create the softbody for
  63886. */
  63887. private _createCloth;
  63888. /**
  63889. * Create rope for an impostor
  63890. * @param impostor to create the softbody for
  63891. */
  63892. private _createRope;
  63893. /**
  63894. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  63895. * @param impostor to create the custom physics shape for
  63896. */
  63897. private _createCustom;
  63898. private _addHullVerts;
  63899. private _createShape;
  63900. /**
  63901. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  63902. * @param impostor imposter containing the physics body and babylon object
  63903. */
  63904. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63905. /**
  63906. * Sets the babylon object's position/rotation from the physics body's position/rotation
  63907. * @param impostor imposter containing the physics body and babylon object
  63908. * @param newPosition new position
  63909. * @param newRotation new rotation
  63910. */
  63911. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63912. /**
  63913. * If this plugin is supported
  63914. * @returns true if its supported
  63915. */
  63916. isSupported(): boolean;
  63917. /**
  63918. * Sets the linear velocity of the physics body
  63919. * @param impostor imposter to set the velocity on
  63920. * @param velocity velocity to set
  63921. */
  63922. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63923. /**
  63924. * Sets the angular velocity of the physics body
  63925. * @param impostor imposter to set the velocity on
  63926. * @param velocity velocity to set
  63927. */
  63928. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63929. /**
  63930. * gets the linear velocity
  63931. * @param impostor imposter to get linear velocity from
  63932. * @returns linear velocity
  63933. */
  63934. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63935. /**
  63936. * gets the angular velocity
  63937. * @param impostor imposter to get angular velocity from
  63938. * @returns angular velocity
  63939. */
  63940. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63941. /**
  63942. * Sets the mass of physics body
  63943. * @param impostor imposter to set the mass on
  63944. * @param mass mass to set
  63945. */
  63946. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63947. /**
  63948. * Gets the mass of the physics body
  63949. * @param impostor imposter to get the mass from
  63950. * @returns mass
  63951. */
  63952. getBodyMass(impostor: PhysicsImpostor): number;
  63953. /**
  63954. * Gets friction of the impostor
  63955. * @param impostor impostor to get friction from
  63956. * @returns friction value
  63957. */
  63958. getBodyFriction(impostor: PhysicsImpostor): number;
  63959. /**
  63960. * Sets friction of the impostor
  63961. * @param impostor impostor to set friction on
  63962. * @param friction friction value
  63963. */
  63964. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63965. /**
  63966. * Gets restitution of the impostor
  63967. * @param impostor impostor to get restitution from
  63968. * @returns restitution value
  63969. */
  63970. getBodyRestitution(impostor: PhysicsImpostor): number;
  63971. /**
  63972. * Sets resitution of the impostor
  63973. * @param impostor impostor to set resitution on
  63974. * @param restitution resitution value
  63975. */
  63976. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63977. /**
  63978. * Gets pressure inside the impostor
  63979. * @param impostor impostor to get pressure from
  63980. * @returns pressure value
  63981. */
  63982. getBodyPressure(impostor: PhysicsImpostor): number;
  63983. /**
  63984. * Sets pressure inside a soft body impostor
  63985. * Cloth and rope must remain 0 pressure
  63986. * @param impostor impostor to set pressure on
  63987. * @param pressure pressure value
  63988. */
  63989. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  63990. /**
  63991. * Gets stiffness of the impostor
  63992. * @param impostor impostor to get stiffness from
  63993. * @returns pressure value
  63994. */
  63995. getBodyStiffness(impostor: PhysicsImpostor): number;
  63996. /**
  63997. * Sets stiffness of the impostor
  63998. * @param impostor impostor to set stiffness on
  63999. * @param stiffness stiffness value from 0 to 1
  64000. */
  64001. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64002. /**
  64003. * Gets velocityIterations of the impostor
  64004. * @param impostor impostor to get velocity iterations from
  64005. * @returns velocityIterations value
  64006. */
  64007. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64008. /**
  64009. * Sets velocityIterations of the impostor
  64010. * @param impostor impostor to set velocity iterations on
  64011. * @param velocityIterations velocityIterations value
  64012. */
  64013. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64014. /**
  64015. * Gets positionIterations of the impostor
  64016. * @param impostor impostor to get position iterations from
  64017. * @returns positionIterations value
  64018. */
  64019. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64020. /**
  64021. * Sets positionIterations of the impostor
  64022. * @param impostor impostor to set position on
  64023. * @param positionIterations positionIterations value
  64024. */
  64025. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64026. /**
  64027. * Append an anchor to a cloth object
  64028. * @param impostor is the cloth impostor to add anchor to
  64029. * @param otherImpostor is the rigid impostor to anchor to
  64030. * @param width ratio across width from 0 to 1
  64031. * @param height ratio up height from 0 to 1
  64032. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64033. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64034. */
  64035. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64036. /**
  64037. * Append an hook to a rope object
  64038. * @param impostor is the rope impostor to add hook to
  64039. * @param otherImpostor is the rigid impostor to hook to
  64040. * @param length ratio along the rope from 0 to 1
  64041. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64042. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64043. */
  64044. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64045. /**
  64046. * Sleeps the physics body and stops it from being active
  64047. * @param impostor impostor to sleep
  64048. */
  64049. sleepBody(impostor: PhysicsImpostor): void;
  64050. /**
  64051. * Activates the physics body
  64052. * @param impostor impostor to activate
  64053. */
  64054. wakeUpBody(impostor: PhysicsImpostor): void;
  64055. /**
  64056. * Updates the distance parameters of the joint
  64057. * @param joint joint to update
  64058. * @param maxDistance maximum distance of the joint
  64059. * @param minDistance minimum distance of the joint
  64060. */
  64061. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64062. /**
  64063. * Sets a motor on the joint
  64064. * @param joint joint to set motor on
  64065. * @param speed speed of the motor
  64066. * @param maxForce maximum force of the motor
  64067. * @param motorIndex index of the motor
  64068. */
  64069. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64070. /**
  64071. * Sets the motors limit
  64072. * @param joint joint to set limit on
  64073. * @param upperLimit upper limit
  64074. * @param lowerLimit lower limit
  64075. */
  64076. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64077. /**
  64078. * Syncs the position and rotation of a mesh with the impostor
  64079. * @param mesh mesh to sync
  64080. * @param impostor impostor to update the mesh with
  64081. */
  64082. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64083. /**
  64084. * Gets the radius of the impostor
  64085. * @param impostor impostor to get radius from
  64086. * @returns the radius
  64087. */
  64088. getRadius(impostor: PhysicsImpostor): number;
  64089. /**
  64090. * Gets the box size of the impostor
  64091. * @param impostor impostor to get box size from
  64092. * @param result the resulting box size
  64093. */
  64094. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64095. /**
  64096. * Disposes of the impostor
  64097. */
  64098. dispose(): void;
  64099. /**
  64100. * Does a raycast in the physics world
  64101. * @param from when should the ray start?
  64102. * @param to when should the ray end?
  64103. * @returns PhysicsRaycastResult
  64104. */
  64105. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64106. }
  64107. }
  64108. declare module "babylonjs/Probes/reflectionProbe" {
  64109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64110. import { Vector3 } from "babylonjs/Maths/math.vector";
  64111. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64112. import { Nullable } from "babylonjs/types";
  64113. import { Scene } from "babylonjs/scene";
  64114. module "babylonjs/abstractScene" {
  64115. interface AbstractScene {
  64116. /**
  64117. * The list of reflection probes added to the scene
  64118. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64119. */
  64120. reflectionProbes: Array<ReflectionProbe>;
  64121. /**
  64122. * Removes the given reflection probe from this scene.
  64123. * @param toRemove The reflection probe to remove
  64124. * @returns The index of the removed reflection probe
  64125. */
  64126. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64127. /**
  64128. * Adds the given reflection probe to this scene.
  64129. * @param newReflectionProbe The reflection probe to add
  64130. */
  64131. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64132. }
  64133. }
  64134. /**
  64135. * Class used to generate realtime reflection / refraction cube textures
  64136. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64137. */
  64138. export class ReflectionProbe {
  64139. /** defines the name of the probe */
  64140. name: string;
  64141. private _scene;
  64142. private _renderTargetTexture;
  64143. private _projectionMatrix;
  64144. private _viewMatrix;
  64145. private _target;
  64146. private _add;
  64147. private _attachedMesh;
  64148. private _invertYAxis;
  64149. /** Gets or sets probe position (center of the cube map) */
  64150. position: Vector3;
  64151. /**
  64152. * Creates a new reflection probe
  64153. * @param name defines the name of the probe
  64154. * @param size defines the texture resolution (for each face)
  64155. * @param scene defines the hosting scene
  64156. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64157. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64158. */
  64159. constructor(
  64160. /** defines the name of the probe */
  64161. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64162. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64163. get samples(): number;
  64164. set samples(value: number);
  64165. /** Gets or sets the refresh rate to use (on every frame by default) */
  64166. get refreshRate(): number;
  64167. set refreshRate(value: number);
  64168. /**
  64169. * Gets the hosting scene
  64170. * @returns a Scene
  64171. */
  64172. getScene(): Scene;
  64173. /** Gets the internal CubeTexture used to render to */
  64174. get cubeTexture(): RenderTargetTexture;
  64175. /** Gets the list of meshes to render */
  64176. get renderList(): Nullable<AbstractMesh[]>;
  64177. /**
  64178. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64179. * @param mesh defines the mesh to attach to
  64180. */
  64181. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64182. /**
  64183. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64184. * @param renderingGroupId The rendering group id corresponding to its index
  64185. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64186. */
  64187. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64188. /**
  64189. * Clean all associated resources
  64190. */
  64191. dispose(): void;
  64192. /**
  64193. * Converts the reflection probe information to a readable string for debug purpose.
  64194. * @param fullDetails Supports for multiple levels of logging within scene loading
  64195. * @returns the human readable reflection probe info
  64196. */
  64197. toString(fullDetails?: boolean): string;
  64198. /**
  64199. * Get the class name of the relfection probe.
  64200. * @returns "ReflectionProbe"
  64201. */
  64202. getClassName(): string;
  64203. /**
  64204. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64205. * @returns The JSON representation of the texture
  64206. */
  64207. serialize(): any;
  64208. /**
  64209. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64210. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64211. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64212. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64213. * @returns The parsed reflection probe if successful
  64214. */
  64215. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64216. }
  64217. }
  64218. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64219. /** @hidden */
  64220. export var _BabylonLoaderRegistered: boolean;
  64221. /**
  64222. * Helps setting up some configuration for the babylon file loader.
  64223. */
  64224. export class BabylonFileLoaderConfiguration {
  64225. /**
  64226. * The loader does not allow injecting custom physix engine into the plugins.
  64227. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64228. * So you could set this variable to your engine import to make it work.
  64229. */
  64230. static LoaderInjectedPhysicsEngine: any;
  64231. }
  64232. }
  64233. declare module "babylonjs/Loading/Plugins/index" {
  64234. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64235. }
  64236. declare module "babylonjs/Loading/index" {
  64237. export * from "babylonjs/Loading/loadingScreen";
  64238. export * from "babylonjs/Loading/Plugins/index";
  64239. export * from "babylonjs/Loading/sceneLoader";
  64240. export * from "babylonjs/Loading/sceneLoaderFlags";
  64241. }
  64242. declare module "babylonjs/Materials/Background/index" {
  64243. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64244. }
  64245. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64246. import { Scene } from "babylonjs/scene";
  64247. import { Color3 } from "babylonjs/Maths/math.color";
  64248. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64250. /**
  64251. * The Physically based simple base material of BJS.
  64252. *
  64253. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64254. * It is used as the base class for both the specGloss and metalRough conventions.
  64255. */
  64256. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64257. /**
  64258. * Number of Simultaneous lights allowed on the material.
  64259. */
  64260. maxSimultaneousLights: number;
  64261. /**
  64262. * If sets to true, disables all the lights affecting the material.
  64263. */
  64264. disableLighting: boolean;
  64265. /**
  64266. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64267. */
  64268. environmentTexture: BaseTexture;
  64269. /**
  64270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64271. */
  64272. invertNormalMapX: boolean;
  64273. /**
  64274. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64275. */
  64276. invertNormalMapY: boolean;
  64277. /**
  64278. * Normal map used in the model.
  64279. */
  64280. normalTexture: BaseTexture;
  64281. /**
  64282. * Emissivie color used to self-illuminate the model.
  64283. */
  64284. emissiveColor: Color3;
  64285. /**
  64286. * Emissivie texture used to self-illuminate the model.
  64287. */
  64288. emissiveTexture: BaseTexture;
  64289. /**
  64290. * Occlusion Channel Strenght.
  64291. */
  64292. occlusionStrength: number;
  64293. /**
  64294. * Occlusion Texture of the material (adding extra occlusion effects).
  64295. */
  64296. occlusionTexture: BaseTexture;
  64297. /**
  64298. * Defines the alpha limits in alpha test mode.
  64299. */
  64300. alphaCutOff: number;
  64301. /**
  64302. * Gets the current double sided mode.
  64303. */
  64304. get doubleSided(): boolean;
  64305. /**
  64306. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64307. */
  64308. set doubleSided(value: boolean);
  64309. /**
  64310. * Stores the pre-calculated light information of a mesh in a texture.
  64311. */
  64312. lightmapTexture: BaseTexture;
  64313. /**
  64314. * If true, the light map contains occlusion information instead of lighting info.
  64315. */
  64316. useLightmapAsShadowmap: boolean;
  64317. /**
  64318. * Instantiates a new PBRMaterial instance.
  64319. *
  64320. * @param name The material name
  64321. * @param scene The scene the material will be use in.
  64322. */
  64323. constructor(name: string, scene: Scene);
  64324. getClassName(): string;
  64325. }
  64326. }
  64327. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64328. import { Scene } from "babylonjs/scene";
  64329. import { Color3 } from "babylonjs/Maths/math.color";
  64330. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64331. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64332. /**
  64333. * The PBR material of BJS following the metal roughness convention.
  64334. *
  64335. * This fits to the PBR convention in the GLTF definition:
  64336. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64337. */
  64338. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64339. /**
  64340. * The base color has two different interpretations depending on the value of metalness.
  64341. * When the material is a metal, the base color is the specific measured reflectance value
  64342. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64343. * of the material.
  64344. */
  64345. baseColor: Color3;
  64346. /**
  64347. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64348. * well as opacity information in the alpha channel.
  64349. */
  64350. baseTexture: BaseTexture;
  64351. /**
  64352. * Specifies the metallic scalar value of the material.
  64353. * Can also be used to scale the metalness values of the metallic texture.
  64354. */
  64355. metallic: number;
  64356. /**
  64357. * Specifies the roughness scalar value of the material.
  64358. * Can also be used to scale the roughness values of the metallic texture.
  64359. */
  64360. roughness: number;
  64361. /**
  64362. * Texture containing both the metallic value in the B channel and the
  64363. * roughness value in the G channel to keep better precision.
  64364. */
  64365. metallicRoughnessTexture: BaseTexture;
  64366. /**
  64367. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64368. *
  64369. * @param name The material name
  64370. * @param scene The scene the material will be use in.
  64371. */
  64372. constructor(name: string, scene: Scene);
  64373. /**
  64374. * Return the currrent class name of the material.
  64375. */
  64376. getClassName(): string;
  64377. /**
  64378. * Makes a duplicate of the current material.
  64379. * @param name - name to use for the new material.
  64380. */
  64381. clone(name: string): PBRMetallicRoughnessMaterial;
  64382. /**
  64383. * Serialize the material to a parsable JSON object.
  64384. */
  64385. serialize(): any;
  64386. /**
  64387. * Parses a JSON object correponding to the serialize function.
  64388. */
  64389. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64390. }
  64391. }
  64392. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64393. import { Scene } from "babylonjs/scene";
  64394. import { Color3 } from "babylonjs/Maths/math.color";
  64395. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64396. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64397. /**
  64398. * The PBR material of BJS following the specular glossiness convention.
  64399. *
  64400. * This fits to the PBR convention in the GLTF definition:
  64401. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64402. */
  64403. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64404. /**
  64405. * Specifies the diffuse color of the material.
  64406. */
  64407. diffuseColor: Color3;
  64408. /**
  64409. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64410. * channel.
  64411. */
  64412. diffuseTexture: BaseTexture;
  64413. /**
  64414. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64415. */
  64416. specularColor: Color3;
  64417. /**
  64418. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64419. */
  64420. glossiness: number;
  64421. /**
  64422. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64423. */
  64424. specularGlossinessTexture: BaseTexture;
  64425. /**
  64426. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64427. *
  64428. * @param name The material name
  64429. * @param scene The scene the material will be use in.
  64430. */
  64431. constructor(name: string, scene: Scene);
  64432. /**
  64433. * Return the currrent class name of the material.
  64434. */
  64435. getClassName(): string;
  64436. /**
  64437. * Makes a duplicate of the current material.
  64438. * @param name - name to use for the new material.
  64439. */
  64440. clone(name: string): PBRSpecularGlossinessMaterial;
  64441. /**
  64442. * Serialize the material to a parsable JSON object.
  64443. */
  64444. serialize(): any;
  64445. /**
  64446. * Parses a JSON object correponding to the serialize function.
  64447. */
  64448. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64449. }
  64450. }
  64451. declare module "babylonjs/Materials/PBR/index" {
  64452. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64453. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64454. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64455. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64456. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64457. }
  64458. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64459. import { Nullable } from "babylonjs/types";
  64460. import { Scene } from "babylonjs/scene";
  64461. import { Matrix } from "babylonjs/Maths/math.vector";
  64462. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64463. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64464. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64465. /**
  64466. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64467. * It can help converting any input color in a desired output one. This can then be used to create effects
  64468. * from sepia, black and white to sixties or futuristic rendering...
  64469. *
  64470. * The only supported format is currently 3dl.
  64471. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64472. */
  64473. export class ColorGradingTexture extends BaseTexture {
  64474. /**
  64475. * The texture URL.
  64476. */
  64477. url: string;
  64478. /**
  64479. * Empty line regex stored for GC.
  64480. */
  64481. private static _noneEmptyLineRegex;
  64482. private _textureMatrix;
  64483. private _onLoad;
  64484. /**
  64485. * Instantiates a ColorGradingTexture from the following parameters.
  64486. *
  64487. * @param url The location of the color gradind data (currently only supporting 3dl)
  64488. * @param sceneOrEngine The scene or engine the texture will be used in
  64489. * @param onLoad defines a callback triggered when the texture has been loaded
  64490. */
  64491. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64492. /**
  64493. * Fires the onload event from the constructor if requested.
  64494. */
  64495. private _triggerOnLoad;
  64496. /**
  64497. * Returns the texture matrix used in most of the material.
  64498. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64499. */
  64500. getTextureMatrix(): Matrix;
  64501. /**
  64502. * Occurs when the file being loaded is a .3dl LUT file.
  64503. */
  64504. private load3dlTexture;
  64505. /**
  64506. * Starts the loading process of the texture.
  64507. */
  64508. private loadTexture;
  64509. /**
  64510. * Clones the color gradind texture.
  64511. */
  64512. clone(): ColorGradingTexture;
  64513. /**
  64514. * Called during delayed load for textures.
  64515. */
  64516. delayLoad(): void;
  64517. /**
  64518. * Parses a color grading texture serialized by Babylon.
  64519. * @param parsedTexture The texture information being parsedTexture
  64520. * @param scene The scene to load the texture in
  64521. * @param rootUrl The root url of the data assets to load
  64522. * @return A color gradind texture
  64523. */
  64524. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64525. /**
  64526. * Serializes the LUT texture to json format.
  64527. */
  64528. serialize(): any;
  64529. }
  64530. }
  64531. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64533. import { Scene } from "babylonjs/scene";
  64534. import { Nullable } from "babylonjs/types";
  64535. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64536. /**
  64537. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64538. */
  64539. export class EquiRectangularCubeTexture extends BaseTexture {
  64540. /** The six faces of the cube. */
  64541. private static _FacesMapping;
  64542. private _noMipmap;
  64543. private _onLoad;
  64544. private _onError;
  64545. /** The size of the cubemap. */
  64546. private _size;
  64547. /** The buffer of the image. */
  64548. private _buffer;
  64549. /** The width of the input image. */
  64550. private _width;
  64551. /** The height of the input image. */
  64552. private _height;
  64553. /** The URL to the image. */
  64554. url: string;
  64555. /**
  64556. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64557. * @param url The location of the image
  64558. * @param scene The scene the texture will be used in
  64559. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64560. * @param noMipmap Forces to not generate the mipmap if true
  64561. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64562. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64563. * @param onLoad — defines a callback called when texture is loaded
  64564. * @param onError — defines a callback called if there is an error
  64565. */
  64566. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64567. /**
  64568. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64569. */
  64570. private loadImage;
  64571. /**
  64572. * Convert the image buffer into a cubemap and create a CubeTexture.
  64573. */
  64574. private loadTexture;
  64575. /**
  64576. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64577. * @param buffer The ArrayBuffer that should be converted.
  64578. * @returns The buffer as Float32Array.
  64579. */
  64580. private getFloat32ArrayFromArrayBuffer;
  64581. /**
  64582. * Get the current class name of the texture useful for serialization or dynamic coding.
  64583. * @returns "EquiRectangularCubeTexture"
  64584. */
  64585. getClassName(): string;
  64586. /**
  64587. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64588. * @returns A clone of the current EquiRectangularCubeTexture.
  64589. */
  64590. clone(): EquiRectangularCubeTexture;
  64591. }
  64592. }
  64593. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64594. import { Nullable } from "babylonjs/types";
  64595. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64596. import { Matrix } from "babylonjs/Maths/math.vector";
  64597. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64598. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64599. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64600. import { Scene } from "babylonjs/scene";
  64601. /**
  64602. * Defines the options related to the creation of an HtmlElementTexture
  64603. */
  64604. export interface IHtmlElementTextureOptions {
  64605. /**
  64606. * Defines wether mip maps should be created or not.
  64607. */
  64608. generateMipMaps?: boolean;
  64609. /**
  64610. * Defines the sampling mode of the texture.
  64611. */
  64612. samplingMode?: number;
  64613. /**
  64614. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64615. */
  64616. engine: Nullable<ThinEngine>;
  64617. /**
  64618. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64619. */
  64620. scene: Nullable<Scene>;
  64621. }
  64622. /**
  64623. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64624. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64625. * is automatically managed.
  64626. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64627. * in your application.
  64628. *
  64629. * As the update is not automatic, you need to call them manually.
  64630. */
  64631. export class HtmlElementTexture extends BaseTexture {
  64632. /**
  64633. * The texture URL.
  64634. */
  64635. element: HTMLVideoElement | HTMLCanvasElement;
  64636. private static readonly DefaultOptions;
  64637. private _textureMatrix;
  64638. private _isVideo;
  64639. private _generateMipMaps;
  64640. private _samplingMode;
  64641. /**
  64642. * Instantiates a HtmlElementTexture from the following parameters.
  64643. *
  64644. * @param name Defines the name of the texture
  64645. * @param element Defines the video or canvas the texture is filled with
  64646. * @param options Defines the other none mandatory texture creation options
  64647. */
  64648. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64649. private _createInternalTexture;
  64650. /**
  64651. * Returns the texture matrix used in most of the material.
  64652. */
  64653. getTextureMatrix(): Matrix;
  64654. /**
  64655. * Updates the content of the texture.
  64656. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64657. */
  64658. update(invertY?: Nullable<boolean>): void;
  64659. }
  64660. }
  64661. declare module "babylonjs/Misc/tga" {
  64662. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64663. /**
  64664. * Based on jsTGALoader - Javascript loader for TGA file
  64665. * By Vincent Thibault
  64666. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64667. */
  64668. export class TGATools {
  64669. private static _TYPE_INDEXED;
  64670. private static _TYPE_RGB;
  64671. private static _TYPE_GREY;
  64672. private static _TYPE_RLE_INDEXED;
  64673. private static _TYPE_RLE_RGB;
  64674. private static _TYPE_RLE_GREY;
  64675. private static _ORIGIN_MASK;
  64676. private static _ORIGIN_SHIFT;
  64677. private static _ORIGIN_BL;
  64678. private static _ORIGIN_BR;
  64679. private static _ORIGIN_UL;
  64680. private static _ORIGIN_UR;
  64681. /**
  64682. * Gets the header of a TGA file
  64683. * @param data defines the TGA data
  64684. * @returns the header
  64685. */
  64686. static GetTGAHeader(data: Uint8Array): any;
  64687. /**
  64688. * Uploads TGA content to a Babylon Texture
  64689. * @hidden
  64690. */
  64691. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64692. /** @hidden */
  64693. 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;
  64694. /** @hidden */
  64695. 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;
  64696. /** @hidden */
  64697. 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;
  64698. /** @hidden */
  64699. 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;
  64700. /** @hidden */
  64701. 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;
  64702. /** @hidden */
  64703. 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;
  64704. }
  64705. }
  64706. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64707. import { Nullable } from "babylonjs/types";
  64708. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64709. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64710. /**
  64711. * Implementation of the TGA Texture Loader.
  64712. * @hidden
  64713. */
  64714. export class _TGATextureLoader implements IInternalTextureLoader {
  64715. /**
  64716. * Defines wether the loader supports cascade loading the different faces.
  64717. */
  64718. readonly supportCascades: boolean;
  64719. /**
  64720. * This returns if the loader support the current file information.
  64721. * @param extension defines the file extension of the file being loaded
  64722. * @returns true if the loader can load the specified file
  64723. */
  64724. canLoad(extension: string): boolean;
  64725. /**
  64726. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64727. * @param data contains the texture data
  64728. * @param texture defines the BabylonJS internal texture
  64729. * @param createPolynomials will be true if polynomials have been requested
  64730. * @param onLoad defines the callback to trigger once the texture is ready
  64731. * @param onError defines the callback to trigger in case of error
  64732. */
  64733. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64734. /**
  64735. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64736. * @param data contains the texture data
  64737. * @param texture defines the BabylonJS internal texture
  64738. * @param callback defines the method to call once ready to upload
  64739. */
  64740. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64741. }
  64742. }
  64743. declare module "babylonjs/Misc/basis" {
  64744. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64745. /**
  64746. * Info about the .basis files
  64747. */
  64748. class BasisFileInfo {
  64749. /**
  64750. * If the file has alpha
  64751. */
  64752. hasAlpha: boolean;
  64753. /**
  64754. * Info about each image of the basis file
  64755. */
  64756. images: Array<{
  64757. levels: Array<{
  64758. width: number;
  64759. height: number;
  64760. transcodedPixels: ArrayBufferView;
  64761. }>;
  64762. }>;
  64763. }
  64764. /**
  64765. * Result of transcoding a basis file
  64766. */
  64767. class TranscodeResult {
  64768. /**
  64769. * Info about the .basis file
  64770. */
  64771. fileInfo: BasisFileInfo;
  64772. /**
  64773. * Format to use when loading the file
  64774. */
  64775. format: number;
  64776. }
  64777. /**
  64778. * Configuration options for the Basis transcoder
  64779. */
  64780. export class BasisTranscodeConfiguration {
  64781. /**
  64782. * Supported compression formats used to determine the supported output format of the transcoder
  64783. */
  64784. supportedCompressionFormats?: {
  64785. /**
  64786. * etc1 compression format
  64787. */
  64788. etc1?: boolean;
  64789. /**
  64790. * s3tc compression format
  64791. */
  64792. s3tc?: boolean;
  64793. /**
  64794. * pvrtc compression format
  64795. */
  64796. pvrtc?: boolean;
  64797. /**
  64798. * etc2 compression format
  64799. */
  64800. etc2?: boolean;
  64801. };
  64802. /**
  64803. * If mipmap levels should be loaded for transcoded images (Default: true)
  64804. */
  64805. loadMipmapLevels?: boolean;
  64806. /**
  64807. * Index of a single image to load (Default: all images)
  64808. */
  64809. loadSingleImage?: number;
  64810. }
  64811. /**
  64812. * Used to load .Basis files
  64813. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  64814. */
  64815. export class BasisTools {
  64816. private static _IgnoreSupportedFormats;
  64817. /**
  64818. * URL to use when loading the basis transcoder
  64819. */
  64820. static JSModuleURL: string;
  64821. /**
  64822. * URL to use when loading the wasm module for the transcoder
  64823. */
  64824. static WasmModuleURL: string;
  64825. /**
  64826. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  64827. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  64828. * @returns internal format corresponding to the Basis format
  64829. */
  64830. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  64831. private static _WorkerPromise;
  64832. private static _Worker;
  64833. private static _actionId;
  64834. private static _CreateWorkerAsync;
  64835. /**
  64836. * Transcodes a loaded image file to compressed pixel data
  64837. * @param data image data to transcode
  64838. * @param config configuration options for the transcoding
  64839. * @returns a promise resulting in the transcoded image
  64840. */
  64841. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  64842. /**
  64843. * Loads a texture from the transcode result
  64844. * @param texture texture load to
  64845. * @param transcodeResult the result of transcoding the basis file to load from
  64846. */
  64847. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  64848. }
  64849. }
  64850. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  64851. import { Nullable } from "babylonjs/types";
  64852. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64853. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64854. /**
  64855. * Loader for .basis file format
  64856. */
  64857. export class _BasisTextureLoader implements IInternalTextureLoader {
  64858. /**
  64859. * Defines whether the loader supports cascade loading the different faces.
  64860. */
  64861. readonly supportCascades: boolean;
  64862. /**
  64863. * This returns if the loader support the current file information.
  64864. * @param extension defines the file extension of the file being loaded
  64865. * @returns true if the loader can load the specified file
  64866. */
  64867. canLoad(extension: string): boolean;
  64868. /**
  64869. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64870. * @param data contains the texture data
  64871. * @param texture defines the BabylonJS internal texture
  64872. * @param createPolynomials will be true if polynomials have been requested
  64873. * @param onLoad defines the callback to trigger once the texture is ready
  64874. * @param onError defines the callback to trigger in case of error
  64875. */
  64876. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64877. /**
  64878. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64879. * @param data contains the texture data
  64880. * @param texture defines the BabylonJS internal texture
  64881. * @param callback defines the method to call once ready to upload
  64882. */
  64883. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64884. }
  64885. }
  64886. declare module "babylonjs/Materials/Textures/Loaders/index" {
  64887. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  64888. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  64889. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  64890. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  64891. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  64892. }
  64893. declare module "babylonjs/Materials/Textures/Packer/frame" {
  64894. import { Vector2 } from "babylonjs/Maths/math.vector";
  64895. /**
  64896. * Defines the basic options interface of a TexturePacker Frame
  64897. */
  64898. export interface ITexturePackerFrame {
  64899. /**
  64900. * The frame ID
  64901. */
  64902. id: number;
  64903. /**
  64904. * The frames Scale
  64905. */
  64906. scale: Vector2;
  64907. /**
  64908. * The Frames offset
  64909. */
  64910. offset: Vector2;
  64911. }
  64912. /**
  64913. * This is a support class for frame Data on texture packer sets.
  64914. */
  64915. export class TexturePackerFrame implements ITexturePackerFrame {
  64916. /**
  64917. * The frame ID
  64918. */
  64919. id: number;
  64920. /**
  64921. * The frames Scale
  64922. */
  64923. scale: Vector2;
  64924. /**
  64925. * The Frames offset
  64926. */
  64927. offset: Vector2;
  64928. /**
  64929. * Initializes a texture package frame.
  64930. * @param id The numerical frame identifier
  64931. * @param scale Scalar Vector2 for UV frame
  64932. * @param offset Vector2 for the frame position in UV units.
  64933. * @returns TexturePackerFrame
  64934. */
  64935. constructor(id: number, scale: Vector2, offset: Vector2);
  64936. }
  64937. }
  64938. declare module "babylonjs/Materials/Textures/Packer/packer" {
  64939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64940. import { Scene } from "babylonjs/scene";
  64941. import { Nullable } from "babylonjs/types";
  64942. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  64943. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  64944. /**
  64945. * Defines the basic options interface of a TexturePacker
  64946. */
  64947. export interface ITexturePackerOptions {
  64948. /**
  64949. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  64950. */
  64951. map?: string[];
  64952. /**
  64953. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64954. */
  64955. uvsIn?: string;
  64956. /**
  64957. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  64958. */
  64959. uvsOut?: string;
  64960. /**
  64961. * number representing the layout style. Defaults to LAYOUT_STRIP
  64962. */
  64963. layout?: number;
  64964. /**
  64965. * number of columns if using custom column count layout(2). This defaults to 4.
  64966. */
  64967. colnum?: number;
  64968. /**
  64969. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  64970. */
  64971. updateInputMeshes?: boolean;
  64972. /**
  64973. * boolean flag to dispose all the source textures. Defaults to true.
  64974. */
  64975. disposeSources?: boolean;
  64976. /**
  64977. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  64978. */
  64979. fillBlanks?: boolean;
  64980. /**
  64981. * string value representing the context fill style color. Defaults to 'black'.
  64982. */
  64983. customFillColor?: string;
  64984. /**
  64985. * Width and Height Value of each Frame in the TexturePacker Sets
  64986. */
  64987. frameSize?: number;
  64988. /**
  64989. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  64990. */
  64991. paddingRatio?: number;
  64992. /**
  64993. * Number that declares the fill method for the padding gutter.
  64994. */
  64995. paddingMode?: number;
  64996. /**
  64997. * If in SUBUV_COLOR padding mode what color to use.
  64998. */
  64999. paddingColor?: Color3 | Color4;
  65000. }
  65001. /**
  65002. * Defines the basic interface of a TexturePacker JSON File
  65003. */
  65004. export interface ITexturePackerJSON {
  65005. /**
  65006. * The frame ID
  65007. */
  65008. name: string;
  65009. /**
  65010. * The base64 channel data
  65011. */
  65012. sets: any;
  65013. /**
  65014. * The options of the Packer
  65015. */
  65016. options: ITexturePackerOptions;
  65017. /**
  65018. * The frame data of the Packer
  65019. */
  65020. frames: Array<number>;
  65021. }
  65022. /**
  65023. * This is a support class that generates a series of packed texture sets.
  65024. * @see https://doc.babylonjs.com/babylon101/materials
  65025. */
  65026. export class TexturePacker {
  65027. /** Packer Layout Constant 0 */
  65028. static readonly LAYOUT_STRIP: number;
  65029. /** Packer Layout Constant 1 */
  65030. static readonly LAYOUT_POWER2: number;
  65031. /** Packer Layout Constant 2 */
  65032. static readonly LAYOUT_COLNUM: number;
  65033. /** Packer Layout Constant 0 */
  65034. static readonly SUBUV_WRAP: number;
  65035. /** Packer Layout Constant 1 */
  65036. static readonly SUBUV_EXTEND: number;
  65037. /** Packer Layout Constant 2 */
  65038. static readonly SUBUV_COLOR: number;
  65039. /** The Name of the Texture Package */
  65040. name: string;
  65041. /** The scene scope of the TexturePacker */
  65042. scene: Scene;
  65043. /** The Meshes to target */
  65044. meshes: AbstractMesh[];
  65045. /** Arguments passed with the Constructor */
  65046. options: ITexturePackerOptions;
  65047. /** The promise that is started upon initialization */
  65048. promise: Nullable<Promise<TexturePacker | string>>;
  65049. /** The Container object for the channel sets that are generated */
  65050. sets: object;
  65051. /** The Container array for the frames that are generated */
  65052. frames: TexturePackerFrame[];
  65053. /** The expected number of textures the system is parsing. */
  65054. private _expecting;
  65055. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65056. private _paddingValue;
  65057. /**
  65058. * Initializes a texture package series from an array of meshes or a single mesh.
  65059. * @param name The name of the package
  65060. * @param meshes The target meshes to compose the package from
  65061. * @param options The arguments that texture packer should follow while building.
  65062. * @param scene The scene which the textures are scoped to.
  65063. * @returns TexturePacker
  65064. */
  65065. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65066. /**
  65067. * Starts the package process
  65068. * @param resolve The promises resolution function
  65069. * @returns TexturePacker
  65070. */
  65071. private _createFrames;
  65072. /**
  65073. * Calculates the Size of the Channel Sets
  65074. * @returns Vector2
  65075. */
  65076. private _calculateSize;
  65077. /**
  65078. * Calculates the UV data for the frames.
  65079. * @param baseSize the base frameSize
  65080. * @param padding the base frame padding
  65081. * @param dtSize size of the Dynamic Texture for that channel
  65082. * @param dtUnits is 1/dtSize
  65083. * @param update flag to update the input meshes
  65084. */
  65085. private _calculateMeshUVFrames;
  65086. /**
  65087. * Calculates the frames Offset.
  65088. * @param index of the frame
  65089. * @returns Vector2
  65090. */
  65091. private _getFrameOffset;
  65092. /**
  65093. * Updates a Mesh to the frame data
  65094. * @param mesh that is the target
  65095. * @param frameID or the frame index
  65096. */
  65097. private _updateMeshUV;
  65098. /**
  65099. * Updates a Meshes materials to use the texture packer channels
  65100. * @param m is the mesh to target
  65101. * @param force all channels on the packer to be set.
  65102. */
  65103. private _updateTextureReferences;
  65104. /**
  65105. * Public method to set a Mesh to a frame
  65106. * @param m that is the target
  65107. * @param frameID or the frame index
  65108. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65109. */
  65110. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65111. /**
  65112. * Starts the async promise to compile the texture packer.
  65113. * @returns Promise<void>
  65114. */
  65115. processAsync(): Promise<void>;
  65116. /**
  65117. * Disposes all textures associated with this packer
  65118. */
  65119. dispose(): void;
  65120. /**
  65121. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65122. * @param imageType is the image type to use.
  65123. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65124. */
  65125. download(imageType?: string, quality?: number): void;
  65126. /**
  65127. * Public method to load a texturePacker JSON file.
  65128. * @param data of the JSON file in string format.
  65129. */
  65130. updateFromJSON(data: string): void;
  65131. }
  65132. }
  65133. declare module "babylonjs/Materials/Textures/Packer/index" {
  65134. export * from "babylonjs/Materials/Textures/Packer/packer";
  65135. export * from "babylonjs/Materials/Textures/Packer/frame";
  65136. }
  65137. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65138. import { Scene } from "babylonjs/scene";
  65139. import { Texture } from "babylonjs/Materials/Textures/texture";
  65140. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65141. /**
  65142. * 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.
  65143. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65144. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65145. */
  65146. export class CustomProceduralTexture extends ProceduralTexture {
  65147. private _animate;
  65148. private _time;
  65149. private _config;
  65150. private _texturePath;
  65151. /**
  65152. * Instantiates a new Custom Procedural Texture.
  65153. * 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.
  65154. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65155. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65156. * @param name Define the name of the texture
  65157. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65158. * @param size Define the size of the texture to create
  65159. * @param scene Define the scene the texture belongs to
  65160. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65161. * @param generateMipMaps Define if the texture should creates mip maps or not
  65162. */
  65163. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65164. private _loadJson;
  65165. /**
  65166. * Is the texture ready to be used ? (rendered at least once)
  65167. * @returns true if ready, otherwise, false.
  65168. */
  65169. isReady(): boolean;
  65170. /**
  65171. * Render the texture to its associated render target.
  65172. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65173. */
  65174. render(useCameraPostProcess?: boolean): void;
  65175. /**
  65176. * Update the list of dependant textures samplers in the shader.
  65177. */
  65178. updateTextures(): void;
  65179. /**
  65180. * Update the uniform values of the procedural texture in the shader.
  65181. */
  65182. updateShaderUniforms(): void;
  65183. /**
  65184. * Define if the texture animates or not.
  65185. */
  65186. get animate(): boolean;
  65187. set animate(value: boolean);
  65188. }
  65189. }
  65190. declare module "babylonjs/Shaders/noise.fragment" {
  65191. /** @hidden */
  65192. export var noisePixelShader: {
  65193. name: string;
  65194. shader: string;
  65195. };
  65196. }
  65197. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65198. import { Nullable } from "babylonjs/types";
  65199. import { Scene } from "babylonjs/scene";
  65200. import { Texture } from "babylonjs/Materials/Textures/texture";
  65201. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65202. import "babylonjs/Shaders/noise.fragment";
  65203. /**
  65204. * Class used to generate noise procedural textures
  65205. */
  65206. export class NoiseProceduralTexture extends ProceduralTexture {
  65207. /** Gets or sets the start time (default is 0) */
  65208. time: number;
  65209. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65210. brightness: number;
  65211. /** Defines the number of octaves to process */
  65212. octaves: number;
  65213. /** Defines the level of persistence (0.8 by default) */
  65214. persistence: number;
  65215. /** Gets or sets animation speed factor (default is 1) */
  65216. animationSpeedFactor: number;
  65217. /**
  65218. * Creates a new NoiseProceduralTexture
  65219. * @param name defines the name fo the texture
  65220. * @param size defines the size of the texture (default is 256)
  65221. * @param scene defines the hosting scene
  65222. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65223. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65224. */
  65225. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65226. private _updateShaderUniforms;
  65227. protected _getDefines(): string;
  65228. /** Generate the current state of the procedural texture */
  65229. render(useCameraPostProcess?: boolean): void;
  65230. /**
  65231. * Serializes this noise procedural texture
  65232. * @returns a serialized noise procedural texture object
  65233. */
  65234. serialize(): any;
  65235. /**
  65236. * Clone the texture.
  65237. * @returns the cloned texture
  65238. */
  65239. clone(): NoiseProceduralTexture;
  65240. /**
  65241. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65242. * @param parsedTexture defines parsed texture data
  65243. * @param scene defines the current scene
  65244. * @param rootUrl defines the root URL containing noise procedural texture information
  65245. * @returns a parsed NoiseProceduralTexture
  65246. */
  65247. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65248. }
  65249. }
  65250. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65251. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65252. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65253. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65254. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65255. }
  65256. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65257. import { Nullable } from "babylonjs/types";
  65258. import { Scene } from "babylonjs/scene";
  65259. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65260. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65261. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65262. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65263. /**
  65264. * Raw cube texture where the raw buffers are passed in
  65265. */
  65266. export class RawCubeTexture extends CubeTexture {
  65267. /**
  65268. * Creates a cube texture where the raw buffers are passed in.
  65269. * @param scene defines the scene the texture is attached to
  65270. * @param data defines the array of data to use to create each face
  65271. * @param size defines the size of the textures
  65272. * @param format defines the format of the data
  65273. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65274. * @param generateMipMaps defines if the engine should generate the mip levels
  65275. * @param invertY defines if data must be stored with Y axis inverted
  65276. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65277. * @param compression defines the compression used (null by default)
  65278. */
  65279. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65280. /**
  65281. * Updates the raw cube texture.
  65282. * @param data defines the data to store
  65283. * @param format defines the data format
  65284. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65285. * @param invertY defines if data must be stored with Y axis inverted
  65286. * @param compression defines the compression used (null by default)
  65287. * @param level defines which level of the texture to update
  65288. */
  65289. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65290. /**
  65291. * Updates a raw cube texture with RGBD encoded data.
  65292. * @param data defines the array of data [mipmap][face] to use to create each face
  65293. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65294. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65295. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65296. * @returns a promsie that resolves when the operation is complete
  65297. */
  65298. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65299. /**
  65300. * Clones the raw cube texture.
  65301. * @return a new cube texture
  65302. */
  65303. clone(): CubeTexture;
  65304. /** @hidden */
  65305. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65306. }
  65307. }
  65308. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65309. import { Scene } from "babylonjs/scene";
  65310. import { Texture } from "babylonjs/Materials/Textures/texture";
  65311. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65312. /**
  65313. * Class used to store 2D array textures containing user data
  65314. */
  65315. export class RawTexture2DArray extends Texture {
  65316. /** Gets or sets the texture format to use */
  65317. format: number;
  65318. /**
  65319. * Create a new RawTexture2DArray
  65320. * @param data defines the data of the texture
  65321. * @param width defines the width of the texture
  65322. * @param height defines the height of the texture
  65323. * @param depth defines the number of layers of the texture
  65324. * @param format defines the texture format to use
  65325. * @param scene defines the hosting scene
  65326. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65327. * @param invertY defines if texture must be stored with Y axis inverted
  65328. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65329. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65330. */
  65331. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65332. /** Gets or sets the texture format to use */
  65333. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65334. /**
  65335. * Update the texture with new data
  65336. * @param data defines the data to store in the texture
  65337. */
  65338. update(data: ArrayBufferView): void;
  65339. }
  65340. }
  65341. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65342. import { Scene } from "babylonjs/scene";
  65343. import { Texture } from "babylonjs/Materials/Textures/texture";
  65344. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65345. /**
  65346. * Class used to store 3D textures containing user data
  65347. */
  65348. export class RawTexture3D extends Texture {
  65349. /** Gets or sets the texture format to use */
  65350. format: number;
  65351. /**
  65352. * Create a new RawTexture3D
  65353. * @param data defines the data of the texture
  65354. * @param width defines the width of the texture
  65355. * @param height defines the height of the texture
  65356. * @param depth defines the depth of the texture
  65357. * @param format defines the texture format to use
  65358. * @param scene defines the hosting scene
  65359. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65360. * @param invertY defines if texture must be stored with Y axis inverted
  65361. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65362. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65363. */
  65364. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65365. /** Gets or sets the texture format to use */
  65366. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65367. /**
  65368. * Update the texture with new data
  65369. * @param data defines the data to store in the texture
  65370. */
  65371. update(data: ArrayBufferView): void;
  65372. }
  65373. }
  65374. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65375. import { Scene } from "babylonjs/scene";
  65376. import { Plane } from "babylonjs/Maths/math.plane";
  65377. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65378. /**
  65379. * Creates a refraction texture used by refraction channel of the standard material.
  65380. * It is like a mirror but to see through a material.
  65381. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65382. */
  65383. export class RefractionTexture extends RenderTargetTexture {
  65384. /**
  65385. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65386. * 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.
  65387. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65388. */
  65389. refractionPlane: Plane;
  65390. /**
  65391. * Define how deep under the surface we should see.
  65392. */
  65393. depth: number;
  65394. /**
  65395. * Creates a refraction texture used by refraction channel of the standard material.
  65396. * It is like a mirror but to see through a material.
  65397. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65398. * @param name Define the texture name
  65399. * @param size Define the size of the underlying texture
  65400. * @param scene Define the scene the refraction belongs to
  65401. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65402. */
  65403. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65404. /**
  65405. * Clone the refraction texture.
  65406. * @returns the cloned texture
  65407. */
  65408. clone(): RefractionTexture;
  65409. /**
  65410. * Serialize the texture to a JSON representation you could use in Parse later on
  65411. * @returns the serialized JSON representation
  65412. */
  65413. serialize(): any;
  65414. }
  65415. }
  65416. declare module "babylonjs/Materials/Textures/index" {
  65417. export * from "babylonjs/Materials/Textures/baseTexture";
  65418. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65419. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65420. export * from "babylonjs/Materials/Textures/cubeTexture";
  65421. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65422. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65423. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65424. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65425. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65426. export * from "babylonjs/Materials/Textures/internalTexture";
  65427. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65428. export * from "babylonjs/Materials/Textures/Loaders/index";
  65429. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65430. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65431. export * from "babylonjs/Materials/Textures/Packer/index";
  65432. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65433. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65434. export * from "babylonjs/Materials/Textures/rawTexture";
  65435. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65436. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65437. export * from "babylonjs/Materials/Textures/refractionTexture";
  65438. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65439. export * from "babylonjs/Materials/Textures/texture";
  65440. export * from "babylonjs/Materials/Textures/videoTexture";
  65441. }
  65442. declare module "babylonjs/Materials/Node/Enums/index" {
  65443. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65444. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65445. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65446. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65447. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65448. }
  65449. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65450. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65451. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65452. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65453. import { Mesh } from "babylonjs/Meshes/mesh";
  65454. import { Effect } from "babylonjs/Materials/effect";
  65455. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65456. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65457. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65458. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65459. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65460. /**
  65461. * Block used to add support for vertex skinning (bones)
  65462. */
  65463. export class BonesBlock extends NodeMaterialBlock {
  65464. /**
  65465. * Creates a new BonesBlock
  65466. * @param name defines the block name
  65467. */
  65468. constructor(name: string);
  65469. /**
  65470. * Initialize the block and prepare the context for build
  65471. * @param state defines the state that will be used for the build
  65472. */
  65473. initialize(state: NodeMaterialBuildState): void;
  65474. /**
  65475. * Gets the current class name
  65476. * @returns the class name
  65477. */
  65478. getClassName(): string;
  65479. /**
  65480. * Gets the matrix indices input component
  65481. */
  65482. get matricesIndices(): NodeMaterialConnectionPoint;
  65483. /**
  65484. * Gets the matrix weights input component
  65485. */
  65486. get matricesWeights(): NodeMaterialConnectionPoint;
  65487. /**
  65488. * Gets the extra matrix indices input component
  65489. */
  65490. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65491. /**
  65492. * Gets the extra matrix weights input component
  65493. */
  65494. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65495. /**
  65496. * Gets the world input component
  65497. */
  65498. get world(): NodeMaterialConnectionPoint;
  65499. /**
  65500. * Gets the output component
  65501. */
  65502. get output(): NodeMaterialConnectionPoint;
  65503. autoConfigure(material: NodeMaterial): void;
  65504. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65505. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65506. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65507. protected _buildBlock(state: NodeMaterialBuildState): this;
  65508. }
  65509. }
  65510. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65511. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65512. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65513. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65515. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65516. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65517. /**
  65518. * Block used to add support for instances
  65519. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65520. */
  65521. export class InstancesBlock extends NodeMaterialBlock {
  65522. /**
  65523. * Creates a new InstancesBlock
  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 first world row input component
  65534. */
  65535. get world0(): NodeMaterialConnectionPoint;
  65536. /**
  65537. * Gets the second world row input component
  65538. */
  65539. get world1(): NodeMaterialConnectionPoint;
  65540. /**
  65541. * Gets the third world row input component
  65542. */
  65543. get world2(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the forth world row input component
  65546. */
  65547. get world3(): NodeMaterialConnectionPoint;
  65548. /**
  65549. * Gets the world input component
  65550. */
  65551. get world(): NodeMaterialConnectionPoint;
  65552. /**
  65553. * Gets the output component
  65554. */
  65555. get output(): NodeMaterialConnectionPoint;
  65556. /**
  65557. * Gets the isntanceID component
  65558. */
  65559. get instanceID(): NodeMaterialConnectionPoint;
  65560. autoConfigure(material: NodeMaterial): void;
  65561. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65562. protected _buildBlock(state: NodeMaterialBuildState): this;
  65563. }
  65564. }
  65565. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65570. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65571. import { Effect } from "babylonjs/Materials/effect";
  65572. import { Mesh } from "babylonjs/Meshes/mesh";
  65573. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65574. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65575. /**
  65576. * Block used to add morph targets support to vertex shader
  65577. */
  65578. export class MorphTargetsBlock extends NodeMaterialBlock {
  65579. private _repeatableContentAnchor;
  65580. /**
  65581. * Create a new MorphTargetsBlock
  65582. * @param name defines the block name
  65583. */
  65584. constructor(name: string);
  65585. /**
  65586. * Gets the current class name
  65587. * @returns the class name
  65588. */
  65589. getClassName(): string;
  65590. /**
  65591. * Gets the position input component
  65592. */
  65593. get position(): NodeMaterialConnectionPoint;
  65594. /**
  65595. * Gets the normal input component
  65596. */
  65597. get normal(): NodeMaterialConnectionPoint;
  65598. /**
  65599. * Gets the tangent input component
  65600. */
  65601. get tangent(): NodeMaterialConnectionPoint;
  65602. /**
  65603. * Gets the tangent input component
  65604. */
  65605. get uv(): NodeMaterialConnectionPoint;
  65606. /**
  65607. * Gets the position output component
  65608. */
  65609. get positionOutput(): NodeMaterialConnectionPoint;
  65610. /**
  65611. * Gets the normal output component
  65612. */
  65613. get normalOutput(): NodeMaterialConnectionPoint;
  65614. /**
  65615. * Gets the tangent output component
  65616. */
  65617. get tangentOutput(): NodeMaterialConnectionPoint;
  65618. /**
  65619. * Gets the tangent output component
  65620. */
  65621. get uvOutput(): NodeMaterialConnectionPoint;
  65622. initialize(state: NodeMaterialBuildState): void;
  65623. autoConfigure(material: NodeMaterial): void;
  65624. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65625. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65626. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65627. protected _buildBlock(state: NodeMaterialBuildState): this;
  65628. }
  65629. }
  65630. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65633. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65634. import { Nullable } from "babylonjs/types";
  65635. import { Scene } from "babylonjs/scene";
  65636. import { Effect } from "babylonjs/Materials/effect";
  65637. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65638. import { Mesh } from "babylonjs/Meshes/mesh";
  65639. import { Light } from "babylonjs/Lights/light";
  65640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65641. /**
  65642. * Block used to get data information from a light
  65643. */
  65644. export class LightInformationBlock extends NodeMaterialBlock {
  65645. private _lightDataUniformName;
  65646. private _lightColorUniformName;
  65647. private _lightTypeDefineName;
  65648. /**
  65649. * Gets or sets the light associated with this block
  65650. */
  65651. light: Nullable<Light>;
  65652. /**
  65653. * Creates a new LightInformationBlock
  65654. * @param name defines the block name
  65655. */
  65656. constructor(name: string);
  65657. /**
  65658. * Gets the current class name
  65659. * @returns the class name
  65660. */
  65661. getClassName(): string;
  65662. /**
  65663. * Gets the world position input component
  65664. */
  65665. get worldPosition(): NodeMaterialConnectionPoint;
  65666. /**
  65667. * Gets the direction output component
  65668. */
  65669. get direction(): NodeMaterialConnectionPoint;
  65670. /**
  65671. * Gets the direction output component
  65672. */
  65673. get color(): NodeMaterialConnectionPoint;
  65674. /**
  65675. * Gets the direction output component
  65676. */
  65677. get intensity(): NodeMaterialConnectionPoint;
  65678. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65679. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65680. protected _buildBlock(state: NodeMaterialBuildState): this;
  65681. serialize(): any;
  65682. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65683. }
  65684. }
  65685. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65686. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65687. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65688. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65689. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65690. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65691. }
  65692. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65693. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65694. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65695. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65696. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65697. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65698. import { Effect } from "babylonjs/Materials/effect";
  65699. import { Mesh } from "babylonjs/Meshes/mesh";
  65700. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65701. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65702. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65703. /**
  65704. * Block used to add image processing support to fragment shader
  65705. */
  65706. export class ImageProcessingBlock extends NodeMaterialBlock {
  65707. /**
  65708. * Create a new ImageProcessingBlock
  65709. * @param name defines the block name
  65710. */
  65711. constructor(name: string);
  65712. /**
  65713. * Gets the current class name
  65714. * @returns the class name
  65715. */
  65716. getClassName(): string;
  65717. /**
  65718. * Gets the color input component
  65719. */
  65720. get color(): NodeMaterialConnectionPoint;
  65721. /**
  65722. * Gets the output component
  65723. */
  65724. get output(): NodeMaterialConnectionPoint;
  65725. /**
  65726. * Initialize the block and prepare the context for build
  65727. * @param state defines the state that will be used for the build
  65728. */
  65729. initialize(state: NodeMaterialBuildState): void;
  65730. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65731. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65732. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65733. protected _buildBlock(state: NodeMaterialBuildState): this;
  65734. }
  65735. }
  65736. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65737. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65738. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65739. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65740. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65742. import { Effect } from "babylonjs/Materials/effect";
  65743. import { Mesh } from "babylonjs/Meshes/mesh";
  65744. import { Scene } from "babylonjs/scene";
  65745. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65746. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65747. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65748. /**
  65749. * Block used to pertub normals based on a normal map
  65750. */
  65751. export class PerturbNormalBlock extends NodeMaterialBlock {
  65752. private _tangentSpaceParameterName;
  65753. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65754. invertX: boolean;
  65755. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65756. invertY: boolean;
  65757. /**
  65758. * Create a new PerturbNormalBlock
  65759. * @param name defines the block name
  65760. */
  65761. constructor(name: string);
  65762. /**
  65763. * Gets the current class name
  65764. * @returns the class name
  65765. */
  65766. getClassName(): string;
  65767. /**
  65768. * Gets the world position input component
  65769. */
  65770. get worldPosition(): NodeMaterialConnectionPoint;
  65771. /**
  65772. * Gets the world normal input component
  65773. */
  65774. get worldNormal(): NodeMaterialConnectionPoint;
  65775. /**
  65776. * Gets the world tangent input component
  65777. */
  65778. get worldTangent(): NodeMaterialConnectionPoint;
  65779. /**
  65780. * Gets the uv input component
  65781. */
  65782. get uv(): NodeMaterialConnectionPoint;
  65783. /**
  65784. * Gets the normal map color input component
  65785. */
  65786. get normalMapColor(): NodeMaterialConnectionPoint;
  65787. /**
  65788. * Gets the strength input component
  65789. */
  65790. get strength(): NodeMaterialConnectionPoint;
  65791. /**
  65792. * Gets the output component
  65793. */
  65794. get output(): NodeMaterialConnectionPoint;
  65795. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65796. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65797. autoConfigure(material: NodeMaterial): void;
  65798. protected _buildBlock(state: NodeMaterialBuildState): this;
  65799. protected _dumpPropertiesCode(): string;
  65800. serialize(): any;
  65801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65802. }
  65803. }
  65804. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  65805. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65806. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65808. /**
  65809. * Block used to discard a pixel if a value is smaller than a cutoff
  65810. */
  65811. export class DiscardBlock extends NodeMaterialBlock {
  65812. /**
  65813. * Create a new DiscardBlock
  65814. * @param name defines the block name
  65815. */
  65816. constructor(name: string);
  65817. /**
  65818. * Gets the current class name
  65819. * @returns the class name
  65820. */
  65821. getClassName(): string;
  65822. /**
  65823. * Gets the color input component
  65824. */
  65825. get value(): NodeMaterialConnectionPoint;
  65826. /**
  65827. * Gets the cutoff input component
  65828. */
  65829. get cutoff(): NodeMaterialConnectionPoint;
  65830. protected _buildBlock(state: NodeMaterialBuildState): this;
  65831. }
  65832. }
  65833. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  65834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65837. /**
  65838. * Block used to test if the fragment shader is front facing
  65839. */
  65840. export class FrontFacingBlock extends NodeMaterialBlock {
  65841. /**
  65842. * Creates a new FrontFacingBlock
  65843. * @param name defines the block name
  65844. */
  65845. constructor(name: string);
  65846. /**
  65847. * Gets the current class name
  65848. * @returns the class name
  65849. */
  65850. getClassName(): string;
  65851. /**
  65852. * Gets the output component
  65853. */
  65854. get output(): NodeMaterialConnectionPoint;
  65855. protected _buildBlock(state: NodeMaterialBuildState): this;
  65856. }
  65857. }
  65858. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  65859. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65860. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65861. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65862. /**
  65863. * Block used to get the derivative value on x and y of a given input
  65864. */
  65865. export class DerivativeBlock extends NodeMaterialBlock {
  65866. /**
  65867. * Create a new DerivativeBlock
  65868. * @param name defines the block name
  65869. */
  65870. constructor(name: string);
  65871. /**
  65872. * Gets the current class name
  65873. * @returns the class name
  65874. */
  65875. getClassName(): string;
  65876. /**
  65877. * Gets the input component
  65878. */
  65879. get input(): NodeMaterialConnectionPoint;
  65880. /**
  65881. * Gets the derivative output on x
  65882. */
  65883. get dx(): NodeMaterialConnectionPoint;
  65884. /**
  65885. * Gets the derivative output on y
  65886. */
  65887. get dy(): NodeMaterialConnectionPoint;
  65888. protected _buildBlock(state: NodeMaterialBuildState): this;
  65889. }
  65890. }
  65891. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  65892. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65893. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65894. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65895. /**
  65896. * Block used to make gl_FragCoord available
  65897. */
  65898. export class FragCoordBlock extends NodeMaterialBlock {
  65899. /**
  65900. * Creates a new FragCoordBlock
  65901. * @param name defines the block name
  65902. */
  65903. constructor(name: string);
  65904. /**
  65905. * Gets the current class name
  65906. * @returns the class name
  65907. */
  65908. getClassName(): string;
  65909. /**
  65910. * Gets the xy component
  65911. */
  65912. get xy(): NodeMaterialConnectionPoint;
  65913. /**
  65914. * Gets the xyz component
  65915. */
  65916. get xyz(): NodeMaterialConnectionPoint;
  65917. /**
  65918. * Gets the xyzw component
  65919. */
  65920. get xyzw(): NodeMaterialConnectionPoint;
  65921. /**
  65922. * Gets the x component
  65923. */
  65924. get x(): NodeMaterialConnectionPoint;
  65925. /**
  65926. * Gets the y component
  65927. */
  65928. get y(): NodeMaterialConnectionPoint;
  65929. /**
  65930. * Gets the z component
  65931. */
  65932. get z(): NodeMaterialConnectionPoint;
  65933. /**
  65934. * Gets the w component
  65935. */
  65936. get output(): NodeMaterialConnectionPoint;
  65937. protected writeOutputs(state: NodeMaterialBuildState): string;
  65938. protected _buildBlock(state: NodeMaterialBuildState): this;
  65939. }
  65940. }
  65941. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  65942. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65943. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65944. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65945. import { Effect } from "babylonjs/Materials/effect";
  65946. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  65947. import { Mesh } from "babylonjs/Meshes/mesh";
  65948. /**
  65949. * Block used to get the screen sizes
  65950. */
  65951. export class ScreenSizeBlock extends NodeMaterialBlock {
  65952. private _varName;
  65953. private _scene;
  65954. /**
  65955. * Creates a new ScreenSizeBlock
  65956. * @param name defines the block name
  65957. */
  65958. constructor(name: string);
  65959. /**
  65960. * Gets the current class name
  65961. * @returns the class name
  65962. */
  65963. getClassName(): string;
  65964. /**
  65965. * Gets the xy component
  65966. */
  65967. get xy(): NodeMaterialConnectionPoint;
  65968. /**
  65969. * Gets the x component
  65970. */
  65971. get x(): NodeMaterialConnectionPoint;
  65972. /**
  65973. * Gets the y component
  65974. */
  65975. get y(): NodeMaterialConnectionPoint;
  65976. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65977. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  65978. protected _buildBlock(state: NodeMaterialBuildState): this;
  65979. }
  65980. }
  65981. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  65982. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  65983. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  65984. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  65985. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  65986. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  65987. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  65988. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  65989. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  65990. }
  65991. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  65992. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65993. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65994. import { Mesh } from "babylonjs/Meshes/mesh";
  65995. import { Effect } from "babylonjs/Materials/effect";
  65996. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65998. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65999. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66000. /**
  66001. * Block used to add support for scene fog
  66002. */
  66003. export class FogBlock extends NodeMaterialBlock {
  66004. private _fogDistanceName;
  66005. private _fogParameters;
  66006. /**
  66007. * Create a new FogBlock
  66008. * @param name defines the block name
  66009. */
  66010. constructor(name: string);
  66011. /**
  66012. * Gets the current class name
  66013. * @returns the class name
  66014. */
  66015. getClassName(): string;
  66016. /**
  66017. * Gets the world position input component
  66018. */
  66019. get worldPosition(): NodeMaterialConnectionPoint;
  66020. /**
  66021. * Gets the view input component
  66022. */
  66023. get view(): NodeMaterialConnectionPoint;
  66024. /**
  66025. * Gets the color input component
  66026. */
  66027. get input(): NodeMaterialConnectionPoint;
  66028. /**
  66029. * Gets the fog color input component
  66030. */
  66031. get fogColor(): NodeMaterialConnectionPoint;
  66032. /**
  66033. * Gets the output component
  66034. */
  66035. get output(): NodeMaterialConnectionPoint;
  66036. autoConfigure(material: NodeMaterial): void;
  66037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66038. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66039. protected _buildBlock(state: NodeMaterialBuildState): this;
  66040. }
  66041. }
  66042. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66043. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66044. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66045. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66046. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66047. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66048. import { Effect } from "babylonjs/Materials/effect";
  66049. import { Mesh } from "babylonjs/Meshes/mesh";
  66050. import { Light } from "babylonjs/Lights/light";
  66051. import { Nullable } from "babylonjs/types";
  66052. import { Scene } from "babylonjs/scene";
  66053. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66054. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66055. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66056. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66057. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66058. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66059. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66060. /**
  66061. * Block used to add light in the fragment shader
  66062. */
  66063. export class LightBlock extends NodeMaterialBlock {
  66064. private _lightId;
  66065. /**
  66066. * Gets or sets the light associated with this block
  66067. */
  66068. light: Nullable<Light>;
  66069. /**
  66070. * Create a new LightBlock
  66071. * @param name defines the block name
  66072. */
  66073. constructor(name: string);
  66074. /**
  66075. * Gets the current class name
  66076. * @returns the class name
  66077. */
  66078. getClassName(): string;
  66079. /**
  66080. * Gets the world position input component
  66081. */
  66082. get worldPosition(): NodeMaterialConnectionPoint;
  66083. /**
  66084. * Gets the world normal input component
  66085. */
  66086. get worldNormal(): NodeMaterialConnectionPoint;
  66087. /**
  66088. * Gets the camera (or eye) position component
  66089. */
  66090. get cameraPosition(): NodeMaterialConnectionPoint;
  66091. /**
  66092. * Gets the glossiness component
  66093. */
  66094. get glossiness(): NodeMaterialConnectionPoint;
  66095. /**
  66096. * Gets the glossinness power component
  66097. */
  66098. get glossPower(): NodeMaterialConnectionPoint;
  66099. /**
  66100. * Gets the diffuse color component
  66101. */
  66102. get diffuseColor(): NodeMaterialConnectionPoint;
  66103. /**
  66104. * Gets the specular color component
  66105. */
  66106. get specularColor(): NodeMaterialConnectionPoint;
  66107. /**
  66108. * Gets the diffuse output component
  66109. */
  66110. get diffuseOutput(): NodeMaterialConnectionPoint;
  66111. /**
  66112. * Gets the specular output component
  66113. */
  66114. get specularOutput(): NodeMaterialConnectionPoint;
  66115. /**
  66116. * Gets the shadow output component
  66117. */
  66118. get shadow(): NodeMaterialConnectionPoint;
  66119. autoConfigure(material: NodeMaterial): void;
  66120. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66121. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66122. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66123. private _injectVertexCode;
  66124. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66125. serialize(): any;
  66126. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66127. }
  66128. }
  66129. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66130. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66132. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66133. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66134. /**
  66135. * Block used to read a reflection texture from a sampler
  66136. */
  66137. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66138. /**
  66139. * Create a new ReflectionTextureBlock
  66140. * @param name defines the block name
  66141. */
  66142. constructor(name: string);
  66143. /**
  66144. * Gets the current class name
  66145. * @returns the class name
  66146. */
  66147. getClassName(): string;
  66148. /**
  66149. * Gets the world position input component
  66150. */
  66151. get position(): NodeMaterialConnectionPoint;
  66152. /**
  66153. * Gets the world position input component
  66154. */
  66155. get worldPosition(): NodeMaterialConnectionPoint;
  66156. /**
  66157. * Gets the world normal input component
  66158. */
  66159. get worldNormal(): NodeMaterialConnectionPoint;
  66160. /**
  66161. * Gets the world input component
  66162. */
  66163. get world(): NodeMaterialConnectionPoint;
  66164. /**
  66165. * Gets the camera (or eye) position component
  66166. */
  66167. get cameraPosition(): NodeMaterialConnectionPoint;
  66168. /**
  66169. * Gets the view input component
  66170. */
  66171. get view(): NodeMaterialConnectionPoint;
  66172. /**
  66173. * Gets the rgb output component
  66174. */
  66175. get rgb(): NodeMaterialConnectionPoint;
  66176. /**
  66177. * Gets the rgba output component
  66178. */
  66179. get rgba(): NodeMaterialConnectionPoint;
  66180. /**
  66181. * Gets the r output component
  66182. */
  66183. get r(): NodeMaterialConnectionPoint;
  66184. /**
  66185. * Gets the g output component
  66186. */
  66187. get g(): NodeMaterialConnectionPoint;
  66188. /**
  66189. * Gets the b output component
  66190. */
  66191. get b(): NodeMaterialConnectionPoint;
  66192. /**
  66193. * Gets the a output component
  66194. */
  66195. get a(): NodeMaterialConnectionPoint;
  66196. autoConfigure(material: NodeMaterial): void;
  66197. protected _buildBlock(state: NodeMaterialBuildState): this;
  66198. }
  66199. }
  66200. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66201. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66202. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66203. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66204. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66205. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66206. }
  66207. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66208. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66209. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66210. }
  66211. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66212. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66213. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66214. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66215. /**
  66216. * Block used to add 2 vectors
  66217. */
  66218. export class AddBlock extends NodeMaterialBlock {
  66219. /**
  66220. * Creates a new AddBlock
  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 left operand input component
  66231. */
  66232. get left(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the right operand input component
  66235. */
  66236. get right(): NodeMaterialConnectionPoint;
  66237. /**
  66238. * Gets the output component
  66239. */
  66240. get output(): NodeMaterialConnectionPoint;
  66241. protected _buildBlock(state: NodeMaterialBuildState): this;
  66242. }
  66243. }
  66244. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66245. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66246. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66247. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66248. /**
  66249. * Block used to scale a vector by a float
  66250. */
  66251. export class ScaleBlock extends NodeMaterialBlock {
  66252. /**
  66253. * Creates a new ScaleBlock
  66254. * @param name defines the block name
  66255. */
  66256. constructor(name: string);
  66257. /**
  66258. * Gets the current class name
  66259. * @returns the class name
  66260. */
  66261. getClassName(): string;
  66262. /**
  66263. * Gets the input component
  66264. */
  66265. get input(): NodeMaterialConnectionPoint;
  66266. /**
  66267. * Gets the factor input component
  66268. */
  66269. get factor(): NodeMaterialConnectionPoint;
  66270. /**
  66271. * Gets the output component
  66272. */
  66273. get output(): NodeMaterialConnectionPoint;
  66274. protected _buildBlock(state: NodeMaterialBuildState): this;
  66275. }
  66276. }
  66277. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66278. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66279. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66280. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66281. import { Scene } from "babylonjs/scene";
  66282. /**
  66283. * Block used to clamp a float
  66284. */
  66285. export class ClampBlock extends NodeMaterialBlock {
  66286. /** Gets or sets the minimum range */
  66287. minimum: number;
  66288. /** Gets or sets the maximum range */
  66289. maximum: number;
  66290. /**
  66291. * Creates a new ClampBlock
  66292. * @param name defines the block name
  66293. */
  66294. constructor(name: string);
  66295. /**
  66296. * Gets the current class name
  66297. * @returns the class name
  66298. */
  66299. getClassName(): string;
  66300. /**
  66301. * Gets the value input component
  66302. */
  66303. get value(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the output component
  66306. */
  66307. get output(): NodeMaterialConnectionPoint;
  66308. protected _buildBlock(state: NodeMaterialBuildState): this;
  66309. protected _dumpPropertiesCode(): string;
  66310. serialize(): any;
  66311. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66312. }
  66313. }
  66314. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66316. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66317. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66318. /**
  66319. * Block used to apply a cross product between 2 vectors
  66320. */
  66321. export class CrossBlock extends NodeMaterialBlock {
  66322. /**
  66323. * Creates a new CrossBlock
  66324. * @param name defines the block name
  66325. */
  66326. constructor(name: string);
  66327. /**
  66328. * Gets the current class name
  66329. * @returns the class name
  66330. */
  66331. getClassName(): string;
  66332. /**
  66333. * Gets the left operand input component
  66334. */
  66335. get left(): NodeMaterialConnectionPoint;
  66336. /**
  66337. * Gets the right operand input component
  66338. */
  66339. get right(): NodeMaterialConnectionPoint;
  66340. /**
  66341. * Gets the output component
  66342. */
  66343. get output(): NodeMaterialConnectionPoint;
  66344. protected _buildBlock(state: NodeMaterialBuildState): this;
  66345. }
  66346. }
  66347. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66348. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66349. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66350. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66351. /**
  66352. * Block used to apply a dot product between 2 vectors
  66353. */
  66354. export class DotBlock extends NodeMaterialBlock {
  66355. /**
  66356. * Creates a new DotBlock
  66357. * @param name defines the block name
  66358. */
  66359. constructor(name: string);
  66360. /**
  66361. * Gets the current class name
  66362. * @returns the class name
  66363. */
  66364. getClassName(): string;
  66365. /**
  66366. * Gets the left operand input component
  66367. */
  66368. get left(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the right operand input component
  66371. */
  66372. get right(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the output component
  66375. */
  66376. get output(): NodeMaterialConnectionPoint;
  66377. protected _buildBlock(state: NodeMaterialBuildState): this;
  66378. }
  66379. }
  66380. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66381. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66382. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66383. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66384. /**
  66385. * Block used to normalize a vector
  66386. */
  66387. export class NormalizeBlock extends NodeMaterialBlock {
  66388. /**
  66389. * Creates a new NormalizeBlock
  66390. * @param name defines the block name
  66391. */
  66392. constructor(name: string);
  66393. /**
  66394. * Gets the current class name
  66395. * @returns the class name
  66396. */
  66397. getClassName(): string;
  66398. /**
  66399. * Gets the input component
  66400. */
  66401. get input(): NodeMaterialConnectionPoint;
  66402. /**
  66403. * Gets the output component
  66404. */
  66405. get output(): NodeMaterialConnectionPoint;
  66406. protected _buildBlock(state: NodeMaterialBuildState): this;
  66407. }
  66408. }
  66409. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66410. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66411. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66412. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66413. /**
  66414. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66415. */
  66416. export class ColorMergerBlock extends NodeMaterialBlock {
  66417. /**
  66418. * Create a new ColorMergerBlock
  66419. * @param name defines the block name
  66420. */
  66421. constructor(name: string);
  66422. /**
  66423. * Gets the current class name
  66424. * @returns the class name
  66425. */
  66426. getClassName(): string;
  66427. /**
  66428. * Gets the rgb component (input)
  66429. */
  66430. get rgbIn(): NodeMaterialConnectionPoint;
  66431. /**
  66432. * Gets the r component (input)
  66433. */
  66434. get r(): NodeMaterialConnectionPoint;
  66435. /**
  66436. * Gets the g component (input)
  66437. */
  66438. get g(): NodeMaterialConnectionPoint;
  66439. /**
  66440. * Gets the b component (input)
  66441. */
  66442. get b(): NodeMaterialConnectionPoint;
  66443. /**
  66444. * Gets the a component (input)
  66445. */
  66446. get a(): NodeMaterialConnectionPoint;
  66447. /**
  66448. * Gets the rgba component (output)
  66449. */
  66450. get rgba(): NodeMaterialConnectionPoint;
  66451. /**
  66452. * Gets the rgb component (output)
  66453. */
  66454. get rgbOut(): NodeMaterialConnectionPoint;
  66455. /**
  66456. * Gets the rgb component (output)
  66457. * @deprecated Please use rgbOut instead.
  66458. */
  66459. get rgb(): NodeMaterialConnectionPoint;
  66460. protected _buildBlock(state: NodeMaterialBuildState): this;
  66461. }
  66462. }
  66463. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66464. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66465. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66466. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66467. /**
  66468. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66469. */
  66470. export class VectorSplitterBlock extends NodeMaterialBlock {
  66471. /**
  66472. * Create a new VectorSplitterBlock
  66473. * @param name defines the block name
  66474. */
  66475. constructor(name: string);
  66476. /**
  66477. * Gets the current class name
  66478. * @returns the class name
  66479. */
  66480. getClassName(): string;
  66481. /**
  66482. * Gets the xyzw component (input)
  66483. */
  66484. get xyzw(): NodeMaterialConnectionPoint;
  66485. /**
  66486. * Gets the xyz component (input)
  66487. */
  66488. get xyzIn(): NodeMaterialConnectionPoint;
  66489. /**
  66490. * Gets the xy component (input)
  66491. */
  66492. get xyIn(): NodeMaterialConnectionPoint;
  66493. /**
  66494. * Gets the xyz component (output)
  66495. */
  66496. get xyzOut(): NodeMaterialConnectionPoint;
  66497. /**
  66498. * Gets the xy component (output)
  66499. */
  66500. get xyOut(): NodeMaterialConnectionPoint;
  66501. /**
  66502. * Gets the x component (output)
  66503. */
  66504. get x(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the y component (output)
  66507. */
  66508. get y(): NodeMaterialConnectionPoint;
  66509. /**
  66510. * Gets the z component (output)
  66511. */
  66512. get z(): NodeMaterialConnectionPoint;
  66513. /**
  66514. * Gets the w component (output)
  66515. */
  66516. get w(): NodeMaterialConnectionPoint;
  66517. protected _inputRename(name: string): string;
  66518. protected _outputRename(name: string): string;
  66519. protected _buildBlock(state: NodeMaterialBuildState): this;
  66520. }
  66521. }
  66522. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66523. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66524. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66525. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66526. /**
  66527. * Block used to lerp between 2 values
  66528. */
  66529. export class LerpBlock extends NodeMaterialBlock {
  66530. /**
  66531. * Creates a new LerpBlock
  66532. * @param name defines the block name
  66533. */
  66534. constructor(name: string);
  66535. /**
  66536. * Gets the current class name
  66537. * @returns the class name
  66538. */
  66539. getClassName(): string;
  66540. /**
  66541. * Gets the left operand input component
  66542. */
  66543. get left(): NodeMaterialConnectionPoint;
  66544. /**
  66545. * Gets the right operand input component
  66546. */
  66547. get right(): NodeMaterialConnectionPoint;
  66548. /**
  66549. * Gets the gradient operand input component
  66550. */
  66551. get gradient(): NodeMaterialConnectionPoint;
  66552. /**
  66553. * Gets the output component
  66554. */
  66555. get output(): NodeMaterialConnectionPoint;
  66556. protected _buildBlock(state: NodeMaterialBuildState): this;
  66557. }
  66558. }
  66559. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66560. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66561. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66562. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66563. /**
  66564. * Block used to divide 2 vectors
  66565. */
  66566. export class DivideBlock extends NodeMaterialBlock {
  66567. /**
  66568. * Creates a new DivideBlock
  66569. * @param name defines the block name
  66570. */
  66571. constructor(name: string);
  66572. /**
  66573. * Gets the current class name
  66574. * @returns the class name
  66575. */
  66576. getClassName(): string;
  66577. /**
  66578. * Gets the left operand input component
  66579. */
  66580. get left(): NodeMaterialConnectionPoint;
  66581. /**
  66582. * Gets the right operand input component
  66583. */
  66584. get right(): NodeMaterialConnectionPoint;
  66585. /**
  66586. * Gets the output component
  66587. */
  66588. get output(): NodeMaterialConnectionPoint;
  66589. protected _buildBlock(state: NodeMaterialBuildState): this;
  66590. }
  66591. }
  66592. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66593. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66594. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66595. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66596. /**
  66597. * Block used to subtract 2 vectors
  66598. */
  66599. export class SubtractBlock extends NodeMaterialBlock {
  66600. /**
  66601. * Creates a new SubtractBlock
  66602. * @param name defines the block name
  66603. */
  66604. constructor(name: string);
  66605. /**
  66606. * Gets the current class name
  66607. * @returns the class name
  66608. */
  66609. getClassName(): string;
  66610. /**
  66611. * Gets the left operand input component
  66612. */
  66613. get left(): NodeMaterialConnectionPoint;
  66614. /**
  66615. * Gets the right operand input component
  66616. */
  66617. get right(): NodeMaterialConnectionPoint;
  66618. /**
  66619. * Gets the output component
  66620. */
  66621. get output(): NodeMaterialConnectionPoint;
  66622. protected _buildBlock(state: NodeMaterialBuildState): this;
  66623. }
  66624. }
  66625. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66626. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66627. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66628. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66629. /**
  66630. * Block used to step a value
  66631. */
  66632. export class StepBlock extends NodeMaterialBlock {
  66633. /**
  66634. * Creates a new StepBlock
  66635. * @param name defines the block name
  66636. */
  66637. constructor(name: string);
  66638. /**
  66639. * Gets the current class name
  66640. * @returns the class name
  66641. */
  66642. getClassName(): string;
  66643. /**
  66644. * Gets the value operand input component
  66645. */
  66646. get value(): NodeMaterialConnectionPoint;
  66647. /**
  66648. * Gets the edge operand input component
  66649. */
  66650. get edge(): NodeMaterialConnectionPoint;
  66651. /**
  66652. * Gets the output component
  66653. */
  66654. get output(): NodeMaterialConnectionPoint;
  66655. protected _buildBlock(state: NodeMaterialBuildState): this;
  66656. }
  66657. }
  66658. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66659. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66660. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66661. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66662. /**
  66663. * Block used to get the opposite (1 - x) of a value
  66664. */
  66665. export class OneMinusBlock extends NodeMaterialBlock {
  66666. /**
  66667. * Creates a new OneMinusBlock
  66668. * @param name defines the block name
  66669. */
  66670. constructor(name: string);
  66671. /**
  66672. * Gets the current class name
  66673. * @returns the class name
  66674. */
  66675. getClassName(): string;
  66676. /**
  66677. * Gets the input component
  66678. */
  66679. get input(): NodeMaterialConnectionPoint;
  66680. /**
  66681. * Gets the output component
  66682. */
  66683. get output(): NodeMaterialConnectionPoint;
  66684. protected _buildBlock(state: NodeMaterialBuildState): this;
  66685. }
  66686. }
  66687. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66688. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66689. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66690. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66691. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66692. /**
  66693. * Block used to get the view direction
  66694. */
  66695. export class ViewDirectionBlock extends NodeMaterialBlock {
  66696. /**
  66697. * Creates a new ViewDirectionBlock
  66698. * @param name defines the block name
  66699. */
  66700. constructor(name: string);
  66701. /**
  66702. * Gets the current class name
  66703. * @returns the class name
  66704. */
  66705. getClassName(): string;
  66706. /**
  66707. * Gets the world position component
  66708. */
  66709. get worldPosition(): NodeMaterialConnectionPoint;
  66710. /**
  66711. * Gets the camera position component
  66712. */
  66713. get cameraPosition(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the output component
  66716. */
  66717. get output(): NodeMaterialConnectionPoint;
  66718. autoConfigure(material: NodeMaterial): void;
  66719. protected _buildBlock(state: NodeMaterialBuildState): this;
  66720. }
  66721. }
  66722. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  66723. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66724. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66725. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66726. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66727. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66728. /**
  66729. * Block used to compute fresnel value
  66730. */
  66731. export class FresnelBlock extends NodeMaterialBlock {
  66732. /**
  66733. * Create a new FresnelBlock
  66734. * @param name defines the block name
  66735. */
  66736. constructor(name: string);
  66737. /**
  66738. * Gets the current class name
  66739. * @returns the class name
  66740. */
  66741. getClassName(): string;
  66742. /**
  66743. * Gets the world normal input component
  66744. */
  66745. get worldNormal(): NodeMaterialConnectionPoint;
  66746. /**
  66747. * Gets the view direction input component
  66748. */
  66749. get viewDirection(): NodeMaterialConnectionPoint;
  66750. /**
  66751. * Gets the bias input component
  66752. */
  66753. get bias(): NodeMaterialConnectionPoint;
  66754. /**
  66755. * Gets the camera (or eye) position component
  66756. */
  66757. get power(): NodeMaterialConnectionPoint;
  66758. /**
  66759. * Gets the fresnel output component
  66760. */
  66761. get fresnel(): NodeMaterialConnectionPoint;
  66762. autoConfigure(material: NodeMaterial): void;
  66763. protected _buildBlock(state: NodeMaterialBuildState): this;
  66764. }
  66765. }
  66766. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66770. /**
  66771. * Block used to get the max of 2 values
  66772. */
  66773. export class MaxBlock extends NodeMaterialBlock {
  66774. /**
  66775. * Creates a new MaxBlock
  66776. * @param name defines the block name
  66777. */
  66778. constructor(name: string);
  66779. /**
  66780. * Gets the current class name
  66781. * @returns the class name
  66782. */
  66783. getClassName(): string;
  66784. /**
  66785. * Gets the left operand input component
  66786. */
  66787. get left(): NodeMaterialConnectionPoint;
  66788. /**
  66789. * Gets the right operand input component
  66790. */
  66791. get right(): NodeMaterialConnectionPoint;
  66792. /**
  66793. * Gets the output component
  66794. */
  66795. get output(): NodeMaterialConnectionPoint;
  66796. protected _buildBlock(state: NodeMaterialBuildState): this;
  66797. }
  66798. }
  66799. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  66800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66803. /**
  66804. * Block used to get the min of 2 values
  66805. */
  66806. export class MinBlock extends NodeMaterialBlock {
  66807. /**
  66808. * Creates a new MinBlock
  66809. * @param name defines the block name
  66810. */
  66811. constructor(name: string);
  66812. /**
  66813. * Gets the current class name
  66814. * @returns the class name
  66815. */
  66816. getClassName(): string;
  66817. /**
  66818. * Gets the left operand input component
  66819. */
  66820. get left(): NodeMaterialConnectionPoint;
  66821. /**
  66822. * Gets the right operand input component
  66823. */
  66824. get right(): NodeMaterialConnectionPoint;
  66825. /**
  66826. * Gets the output component
  66827. */
  66828. get output(): NodeMaterialConnectionPoint;
  66829. protected _buildBlock(state: NodeMaterialBuildState): this;
  66830. }
  66831. }
  66832. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  66833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66836. /**
  66837. * Block used to get the distance between 2 values
  66838. */
  66839. export class DistanceBlock extends NodeMaterialBlock {
  66840. /**
  66841. * Creates a new DistanceBlock
  66842. * @param name defines the block name
  66843. */
  66844. constructor(name: string);
  66845. /**
  66846. * Gets the current class name
  66847. * @returns the class name
  66848. */
  66849. getClassName(): string;
  66850. /**
  66851. * Gets the left operand input component
  66852. */
  66853. get left(): NodeMaterialConnectionPoint;
  66854. /**
  66855. * Gets the right operand input component
  66856. */
  66857. get right(): NodeMaterialConnectionPoint;
  66858. /**
  66859. * Gets the output component
  66860. */
  66861. get output(): NodeMaterialConnectionPoint;
  66862. protected _buildBlock(state: NodeMaterialBuildState): this;
  66863. }
  66864. }
  66865. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  66866. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66867. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66868. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66869. /**
  66870. * Block used to get the length of a vector
  66871. */
  66872. export class LengthBlock extends NodeMaterialBlock {
  66873. /**
  66874. * Creates a new LengthBlock
  66875. * @param name defines the block name
  66876. */
  66877. constructor(name: string);
  66878. /**
  66879. * Gets the current class name
  66880. * @returns the class name
  66881. */
  66882. getClassName(): string;
  66883. /**
  66884. * Gets the value input component
  66885. */
  66886. get value(): NodeMaterialConnectionPoint;
  66887. /**
  66888. * Gets the output component
  66889. */
  66890. get output(): NodeMaterialConnectionPoint;
  66891. protected _buildBlock(state: NodeMaterialBuildState): this;
  66892. }
  66893. }
  66894. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  66895. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66896. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66897. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66898. /**
  66899. * Block used to get negative version of a value (i.e. x * -1)
  66900. */
  66901. export class NegateBlock extends NodeMaterialBlock {
  66902. /**
  66903. * Creates a new NegateBlock
  66904. * @param name defines the block name
  66905. */
  66906. constructor(name: string);
  66907. /**
  66908. * Gets the current class name
  66909. * @returns the class name
  66910. */
  66911. getClassName(): string;
  66912. /**
  66913. * Gets the value input component
  66914. */
  66915. get value(): NodeMaterialConnectionPoint;
  66916. /**
  66917. * Gets the output component
  66918. */
  66919. get output(): NodeMaterialConnectionPoint;
  66920. protected _buildBlock(state: NodeMaterialBuildState): this;
  66921. }
  66922. }
  66923. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  66924. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66925. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66926. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66927. /**
  66928. * Block used to get the value of the first parameter raised to the power of the second
  66929. */
  66930. export class PowBlock extends NodeMaterialBlock {
  66931. /**
  66932. * Creates a new PowBlock
  66933. * @param name defines the block name
  66934. */
  66935. constructor(name: string);
  66936. /**
  66937. * Gets the current class name
  66938. * @returns the class name
  66939. */
  66940. getClassName(): string;
  66941. /**
  66942. * Gets the value operand input component
  66943. */
  66944. get value(): NodeMaterialConnectionPoint;
  66945. /**
  66946. * Gets the power operand input component
  66947. */
  66948. get power(): NodeMaterialConnectionPoint;
  66949. /**
  66950. * Gets the output component
  66951. */
  66952. get output(): NodeMaterialConnectionPoint;
  66953. protected _buildBlock(state: NodeMaterialBuildState): this;
  66954. }
  66955. }
  66956. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  66957. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66958. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66959. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66960. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66961. /**
  66962. * Block used to get a random number
  66963. */
  66964. export class RandomNumberBlock extends NodeMaterialBlock {
  66965. /**
  66966. * Creates a new RandomNumberBlock
  66967. * @param name defines the block name
  66968. */
  66969. constructor(name: string);
  66970. /**
  66971. * Gets the current class name
  66972. * @returns the class name
  66973. */
  66974. getClassName(): string;
  66975. /**
  66976. * Gets the seed input component
  66977. */
  66978. get seed(): NodeMaterialConnectionPoint;
  66979. /**
  66980. * Gets the output component
  66981. */
  66982. get output(): NodeMaterialConnectionPoint;
  66983. protected _buildBlock(state: NodeMaterialBuildState): this;
  66984. }
  66985. }
  66986. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  66987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66990. /**
  66991. * Block used to compute arc tangent of 2 values
  66992. */
  66993. export class ArcTan2Block extends NodeMaterialBlock {
  66994. /**
  66995. * Creates a new ArcTan2Block
  66996. * @param name defines the block name
  66997. */
  66998. constructor(name: string);
  66999. /**
  67000. * Gets the current class name
  67001. * @returns the class name
  67002. */
  67003. getClassName(): string;
  67004. /**
  67005. * Gets the x operand input component
  67006. */
  67007. get x(): NodeMaterialConnectionPoint;
  67008. /**
  67009. * Gets the y operand input component
  67010. */
  67011. get y(): NodeMaterialConnectionPoint;
  67012. /**
  67013. * Gets the output component
  67014. */
  67015. get output(): NodeMaterialConnectionPoint;
  67016. protected _buildBlock(state: NodeMaterialBuildState): this;
  67017. }
  67018. }
  67019. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67023. /**
  67024. * Block used to smooth step a value
  67025. */
  67026. export class SmoothStepBlock extends NodeMaterialBlock {
  67027. /**
  67028. * Creates a new SmoothStepBlock
  67029. * @param name defines the block name
  67030. */
  67031. constructor(name: string);
  67032. /**
  67033. * Gets the current class name
  67034. * @returns the class name
  67035. */
  67036. getClassName(): string;
  67037. /**
  67038. * Gets the value operand input component
  67039. */
  67040. get value(): NodeMaterialConnectionPoint;
  67041. /**
  67042. * Gets the first edge operand input component
  67043. */
  67044. get edge0(): NodeMaterialConnectionPoint;
  67045. /**
  67046. * Gets the second edge operand input component
  67047. */
  67048. get edge1(): NodeMaterialConnectionPoint;
  67049. /**
  67050. * Gets the output component
  67051. */
  67052. get output(): NodeMaterialConnectionPoint;
  67053. protected _buildBlock(state: NodeMaterialBuildState): this;
  67054. }
  67055. }
  67056. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67060. /**
  67061. * Block used to get the reciprocal (1 / x) of a value
  67062. */
  67063. export class ReciprocalBlock extends NodeMaterialBlock {
  67064. /**
  67065. * Creates a new ReciprocalBlock
  67066. * @param name defines the block name
  67067. */
  67068. constructor(name: string);
  67069. /**
  67070. * Gets the current class name
  67071. * @returns the class name
  67072. */
  67073. getClassName(): string;
  67074. /**
  67075. * Gets the input component
  67076. */
  67077. get input(): NodeMaterialConnectionPoint;
  67078. /**
  67079. * Gets the output component
  67080. */
  67081. get output(): NodeMaterialConnectionPoint;
  67082. protected _buildBlock(state: NodeMaterialBuildState): this;
  67083. }
  67084. }
  67085. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67086. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67087. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67088. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67089. /**
  67090. * Block used to replace a color by another one
  67091. */
  67092. export class ReplaceColorBlock extends NodeMaterialBlock {
  67093. /**
  67094. * Creates a new ReplaceColorBlock
  67095. * @param name defines the block name
  67096. */
  67097. constructor(name: string);
  67098. /**
  67099. * Gets the current class name
  67100. * @returns the class name
  67101. */
  67102. getClassName(): string;
  67103. /**
  67104. * Gets the value input component
  67105. */
  67106. get value(): NodeMaterialConnectionPoint;
  67107. /**
  67108. * Gets the reference input component
  67109. */
  67110. get reference(): NodeMaterialConnectionPoint;
  67111. /**
  67112. * Gets the distance input component
  67113. */
  67114. get distance(): NodeMaterialConnectionPoint;
  67115. /**
  67116. * Gets the replacement input component
  67117. */
  67118. get replacement(): NodeMaterialConnectionPoint;
  67119. /**
  67120. * Gets the output component
  67121. */
  67122. get output(): NodeMaterialConnectionPoint;
  67123. protected _buildBlock(state: NodeMaterialBuildState): this;
  67124. }
  67125. }
  67126. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67127. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67128. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67129. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67130. /**
  67131. * Block used to posterize a value
  67132. * @see https://en.wikipedia.org/wiki/Posterization
  67133. */
  67134. export class PosterizeBlock extends NodeMaterialBlock {
  67135. /**
  67136. * Creates a new PosterizeBlock
  67137. * @param name defines the block name
  67138. */
  67139. constructor(name: string);
  67140. /**
  67141. * Gets the current class name
  67142. * @returns the class name
  67143. */
  67144. getClassName(): string;
  67145. /**
  67146. * Gets the value input component
  67147. */
  67148. get value(): NodeMaterialConnectionPoint;
  67149. /**
  67150. * Gets the steps input component
  67151. */
  67152. get steps(): NodeMaterialConnectionPoint;
  67153. /**
  67154. * Gets the output component
  67155. */
  67156. get output(): NodeMaterialConnectionPoint;
  67157. protected _buildBlock(state: NodeMaterialBuildState): this;
  67158. }
  67159. }
  67160. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67161. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67162. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67163. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67164. import { Scene } from "babylonjs/scene";
  67165. /**
  67166. * Operations supported by the Wave block
  67167. */
  67168. export enum WaveBlockKind {
  67169. /** SawTooth */
  67170. SawTooth = 0,
  67171. /** Square */
  67172. Square = 1,
  67173. /** Triangle */
  67174. Triangle = 2
  67175. }
  67176. /**
  67177. * Block used to apply wave operation to floats
  67178. */
  67179. export class WaveBlock extends NodeMaterialBlock {
  67180. /**
  67181. * Gets or sets the kibnd of wave to be applied by the block
  67182. */
  67183. kind: WaveBlockKind;
  67184. /**
  67185. * Creates a new WaveBlock
  67186. * @param name defines the block name
  67187. */
  67188. constructor(name: string);
  67189. /**
  67190. * Gets the current class name
  67191. * @returns the class name
  67192. */
  67193. getClassName(): string;
  67194. /**
  67195. * Gets the input component
  67196. */
  67197. get input(): NodeMaterialConnectionPoint;
  67198. /**
  67199. * Gets the output component
  67200. */
  67201. get output(): NodeMaterialConnectionPoint;
  67202. protected _buildBlock(state: NodeMaterialBuildState): this;
  67203. serialize(): any;
  67204. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67205. }
  67206. }
  67207. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67211. import { Color3 } from "babylonjs/Maths/math.color";
  67212. import { Scene } from "babylonjs/scene";
  67213. import { Observable } from "babylonjs/Misc/observable";
  67214. /**
  67215. * Class used to store a color step for the GradientBlock
  67216. */
  67217. export class GradientBlockColorStep {
  67218. private _step;
  67219. /**
  67220. * Gets value indicating which step this color is associated with (between 0 and 1)
  67221. */
  67222. get step(): number;
  67223. /**
  67224. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67225. */
  67226. set step(val: number);
  67227. private _color;
  67228. /**
  67229. * Gets the color associated with this step
  67230. */
  67231. get color(): Color3;
  67232. /**
  67233. * Sets the color associated with this step
  67234. */
  67235. set color(val: Color3);
  67236. /**
  67237. * Creates a new GradientBlockColorStep
  67238. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67239. * @param color defines the color associated with this step
  67240. */
  67241. constructor(step: number, color: Color3);
  67242. }
  67243. /**
  67244. * Block used to return a color from a gradient based on an input value between 0 and 1
  67245. */
  67246. export class GradientBlock extends NodeMaterialBlock {
  67247. /**
  67248. * Gets or sets the list of color steps
  67249. */
  67250. colorSteps: GradientBlockColorStep[];
  67251. /** Gets an observable raised when the value is changed */
  67252. onValueChangedObservable: Observable<GradientBlock>;
  67253. /** calls observable when the value is changed*/
  67254. colorStepsUpdated(): void;
  67255. /**
  67256. * Creates a new GradientBlock
  67257. * @param name defines the block name
  67258. */
  67259. constructor(name: string);
  67260. /**
  67261. * Gets the current class name
  67262. * @returns the class name
  67263. */
  67264. getClassName(): string;
  67265. /**
  67266. * Gets the gradient input component
  67267. */
  67268. get gradient(): NodeMaterialConnectionPoint;
  67269. /**
  67270. * Gets the output component
  67271. */
  67272. get output(): NodeMaterialConnectionPoint;
  67273. private _writeColorConstant;
  67274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67275. serialize(): any;
  67276. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67277. protected _dumpPropertiesCode(): string;
  67278. }
  67279. }
  67280. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67281. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67282. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67283. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67284. /**
  67285. * Block used to normalize lerp between 2 values
  67286. */
  67287. export class NLerpBlock extends NodeMaterialBlock {
  67288. /**
  67289. * Creates a new NLerpBlock
  67290. * @param name defines the block name
  67291. */
  67292. constructor(name: string);
  67293. /**
  67294. * Gets the current class name
  67295. * @returns the class name
  67296. */
  67297. getClassName(): string;
  67298. /**
  67299. * Gets the left operand input component
  67300. */
  67301. get left(): NodeMaterialConnectionPoint;
  67302. /**
  67303. * Gets the right operand input component
  67304. */
  67305. get right(): NodeMaterialConnectionPoint;
  67306. /**
  67307. * Gets the gradient operand input component
  67308. */
  67309. get gradient(): NodeMaterialConnectionPoint;
  67310. /**
  67311. * Gets the output component
  67312. */
  67313. get output(): NodeMaterialConnectionPoint;
  67314. protected _buildBlock(state: NodeMaterialBuildState): this;
  67315. }
  67316. }
  67317. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67320. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67321. import { Scene } from "babylonjs/scene";
  67322. /**
  67323. * block used to Generate a Worley Noise 3D Noise Pattern
  67324. */
  67325. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67326. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67327. manhattanDistance: boolean;
  67328. /**
  67329. * Creates a new WorleyNoise3DBlock
  67330. * @param name defines the block name
  67331. */
  67332. constructor(name: string);
  67333. /**
  67334. * Gets the current class name
  67335. * @returns the class name
  67336. */
  67337. getClassName(): string;
  67338. /**
  67339. * Gets the seed input component
  67340. */
  67341. get seed(): NodeMaterialConnectionPoint;
  67342. /**
  67343. * Gets the jitter input component
  67344. */
  67345. get jitter(): NodeMaterialConnectionPoint;
  67346. /**
  67347. * Gets the output component
  67348. */
  67349. get output(): NodeMaterialConnectionPoint;
  67350. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67351. /**
  67352. * Exposes the properties to the UI?
  67353. */
  67354. protected _dumpPropertiesCode(): string;
  67355. /**
  67356. * Exposes the properties to the Seralize?
  67357. */
  67358. serialize(): any;
  67359. /**
  67360. * Exposes the properties to the deseralize?
  67361. */
  67362. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67363. }
  67364. }
  67365. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67369. /**
  67370. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67371. */
  67372. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67373. /**
  67374. * Creates a new SimplexPerlin3DBlock
  67375. * @param name defines the block name
  67376. */
  67377. constructor(name: string);
  67378. /**
  67379. * Gets the current class name
  67380. * @returns the class name
  67381. */
  67382. getClassName(): string;
  67383. /**
  67384. * Gets the seed operand input component
  67385. */
  67386. get seed(): NodeMaterialConnectionPoint;
  67387. /**
  67388. * Gets the output component
  67389. */
  67390. get output(): NodeMaterialConnectionPoint;
  67391. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67392. }
  67393. }
  67394. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67395. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67396. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67397. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67398. /**
  67399. * Block used to blend normals
  67400. */
  67401. export class NormalBlendBlock extends NodeMaterialBlock {
  67402. /**
  67403. * Creates a new NormalBlendBlock
  67404. * @param name defines the block name
  67405. */
  67406. constructor(name: string);
  67407. /**
  67408. * Gets the current class name
  67409. * @returns the class name
  67410. */
  67411. getClassName(): string;
  67412. /**
  67413. * Gets the first input component
  67414. */
  67415. get normalMap0(): NodeMaterialConnectionPoint;
  67416. /**
  67417. * Gets the second input component
  67418. */
  67419. get normalMap1(): NodeMaterialConnectionPoint;
  67420. /**
  67421. * Gets the output component
  67422. */
  67423. get output(): NodeMaterialConnectionPoint;
  67424. protected _buildBlock(state: NodeMaterialBuildState): this;
  67425. }
  67426. }
  67427. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67428. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67429. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67430. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67431. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67432. /**
  67433. * Block used to rotate a 2d vector by a given angle
  67434. */
  67435. export class Rotate2dBlock extends NodeMaterialBlock {
  67436. /**
  67437. * Creates a new Rotate2dBlock
  67438. * @param name defines the block name
  67439. */
  67440. constructor(name: string);
  67441. /**
  67442. * Gets the current class name
  67443. * @returns the class name
  67444. */
  67445. getClassName(): string;
  67446. /**
  67447. * Gets the input vector
  67448. */
  67449. get input(): NodeMaterialConnectionPoint;
  67450. /**
  67451. * Gets the input angle
  67452. */
  67453. get angle(): NodeMaterialConnectionPoint;
  67454. /**
  67455. * Gets the output component
  67456. */
  67457. get output(): NodeMaterialConnectionPoint;
  67458. autoConfigure(material: NodeMaterial): void;
  67459. protected _buildBlock(state: NodeMaterialBuildState): this;
  67460. }
  67461. }
  67462. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67466. /**
  67467. * Block used to get the reflected vector from a direction and a normal
  67468. */
  67469. export class ReflectBlock extends NodeMaterialBlock {
  67470. /**
  67471. * Creates a new ReflectBlock
  67472. * @param name defines the block name
  67473. */
  67474. constructor(name: string);
  67475. /**
  67476. * Gets the current class name
  67477. * @returns the class name
  67478. */
  67479. getClassName(): string;
  67480. /**
  67481. * Gets the incident component
  67482. */
  67483. get incident(): NodeMaterialConnectionPoint;
  67484. /**
  67485. * Gets the normal component
  67486. */
  67487. get normal(): NodeMaterialConnectionPoint;
  67488. /**
  67489. * Gets the output component
  67490. */
  67491. get output(): NodeMaterialConnectionPoint;
  67492. protected _buildBlock(state: NodeMaterialBuildState): this;
  67493. }
  67494. }
  67495. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67496. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67497. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67498. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67499. /**
  67500. * Block used to get the refracted vector from a direction and a normal
  67501. */
  67502. export class RefractBlock extends NodeMaterialBlock {
  67503. /**
  67504. * Creates a new RefractBlock
  67505. * @param name defines the block name
  67506. */
  67507. constructor(name: string);
  67508. /**
  67509. * Gets the current class name
  67510. * @returns the class name
  67511. */
  67512. getClassName(): string;
  67513. /**
  67514. * Gets the incident component
  67515. */
  67516. get incident(): NodeMaterialConnectionPoint;
  67517. /**
  67518. * Gets the normal component
  67519. */
  67520. get normal(): NodeMaterialConnectionPoint;
  67521. /**
  67522. * Gets the index of refraction component
  67523. */
  67524. get ior(): NodeMaterialConnectionPoint;
  67525. /**
  67526. * Gets the output component
  67527. */
  67528. get output(): NodeMaterialConnectionPoint;
  67529. protected _buildBlock(state: NodeMaterialBuildState): this;
  67530. }
  67531. }
  67532. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67533. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67534. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67535. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67536. /**
  67537. * Block used to desaturate a color
  67538. */
  67539. export class DesaturateBlock extends NodeMaterialBlock {
  67540. /**
  67541. * Creates a new DesaturateBlock
  67542. * @param name defines the block name
  67543. */
  67544. constructor(name: string);
  67545. /**
  67546. * Gets the current class name
  67547. * @returns the class name
  67548. */
  67549. getClassName(): string;
  67550. /**
  67551. * Gets the color operand input component
  67552. */
  67553. get color(): NodeMaterialConnectionPoint;
  67554. /**
  67555. * Gets the level operand input component
  67556. */
  67557. get level(): NodeMaterialConnectionPoint;
  67558. /**
  67559. * Gets the output component
  67560. */
  67561. get output(): NodeMaterialConnectionPoint;
  67562. protected _buildBlock(state: NodeMaterialBuildState): this;
  67563. }
  67564. }
  67565. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67566. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67568. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67569. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67570. import { Nullable } from "babylonjs/types";
  67571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67572. import { Scene } from "babylonjs/scene";
  67573. /**
  67574. * Block used to implement the ambient occlusion module of the PBR material
  67575. */
  67576. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67577. /**
  67578. * Create a new AmbientOcclusionBlock
  67579. * @param name defines the block name
  67580. */
  67581. constructor(name: string);
  67582. /**
  67583. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67584. */
  67585. useAmbientInGrayScale: boolean;
  67586. /**
  67587. * Initialize the block and prepare the context for build
  67588. * @param state defines the state that will be used for the build
  67589. */
  67590. initialize(state: NodeMaterialBuildState): void;
  67591. /**
  67592. * Gets the current class name
  67593. * @returns the class name
  67594. */
  67595. getClassName(): string;
  67596. /**
  67597. * Gets the texture input component
  67598. */
  67599. get texture(): NodeMaterialConnectionPoint;
  67600. /**
  67601. * Gets the texture intensity component
  67602. */
  67603. get intensity(): NodeMaterialConnectionPoint;
  67604. /**
  67605. * Gets the direct light intensity input component
  67606. */
  67607. get directLightIntensity(): NodeMaterialConnectionPoint;
  67608. /**
  67609. * Gets the ambient occlusion object output component
  67610. */
  67611. get ambientOcclusion(): NodeMaterialConnectionPoint;
  67612. /**
  67613. * Gets the main code of the block (fragment side)
  67614. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67615. * @returns the shader code
  67616. */
  67617. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67618. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67619. protected _buildBlock(state: NodeMaterialBuildState): this;
  67620. protected _dumpPropertiesCode(): string;
  67621. serialize(): any;
  67622. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67623. }
  67624. }
  67625. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67626. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67627. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67628. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67629. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67630. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67631. import { Nullable } from "babylonjs/types";
  67632. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67633. import { Mesh } from "babylonjs/Meshes/mesh";
  67634. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67635. import { Effect } from "babylonjs/Materials/effect";
  67636. import { Scene } from "babylonjs/scene";
  67637. /**
  67638. * Block used to implement the reflection module of the PBR material
  67639. */
  67640. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67641. /** @hidden */
  67642. _defineLODReflectionAlpha: string;
  67643. /** @hidden */
  67644. _defineLinearSpecularReflection: string;
  67645. private _vEnvironmentIrradianceName;
  67646. /** @hidden */
  67647. _vReflectionMicrosurfaceInfosName: string;
  67648. /** @hidden */
  67649. _vReflectionInfosName: string;
  67650. /** @hidden */
  67651. _vReflectionFilteringInfoName: string;
  67652. private _scene;
  67653. /**
  67654. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67655. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67656. * It's less burden on the user side in the editor part.
  67657. */
  67658. /** @hidden */
  67659. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67660. /** @hidden */
  67661. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67662. /** @hidden */
  67663. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67664. /**
  67665. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67666. * diffuse part of the IBL.
  67667. */
  67668. useSphericalHarmonics: boolean;
  67669. /**
  67670. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67671. */
  67672. forceIrradianceInFragment: boolean;
  67673. /**
  67674. * Create a new ReflectionBlock
  67675. * @param name defines the block name
  67676. */
  67677. constructor(name: string);
  67678. /**
  67679. * Gets the current class name
  67680. * @returns the class name
  67681. */
  67682. getClassName(): string;
  67683. /**
  67684. * Gets the position input component
  67685. */
  67686. get position(): NodeMaterialConnectionPoint;
  67687. /**
  67688. * Gets the world position input component
  67689. */
  67690. get worldPosition(): NodeMaterialConnectionPoint;
  67691. /**
  67692. * Gets the world normal input component
  67693. */
  67694. get worldNormal(): NodeMaterialConnectionPoint;
  67695. /**
  67696. * Gets the world input component
  67697. */
  67698. get world(): NodeMaterialConnectionPoint;
  67699. /**
  67700. * Gets the camera (or eye) position component
  67701. */
  67702. get cameraPosition(): NodeMaterialConnectionPoint;
  67703. /**
  67704. * Gets the view input component
  67705. */
  67706. get view(): NodeMaterialConnectionPoint;
  67707. /**
  67708. * Gets the color input component
  67709. */
  67710. get color(): NodeMaterialConnectionPoint;
  67711. /**
  67712. * Gets the reflection object output component
  67713. */
  67714. get reflection(): NodeMaterialConnectionPoint;
  67715. /**
  67716. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67717. */
  67718. get hasTexture(): boolean;
  67719. /**
  67720. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67721. */
  67722. get reflectionColor(): string;
  67723. protected _getTexture(): Nullable<BaseTexture>;
  67724. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67726. /**
  67727. * Gets the code to inject in the vertex shader
  67728. * @param state current state of the node material building
  67729. * @returns the shader code
  67730. */
  67731. handleVertexSide(state: NodeMaterialBuildState): string;
  67732. /**
  67733. * Gets the main code of the block (fragment side)
  67734. * @param state current state of the node material building
  67735. * @param normalVarName name of the existing variable corresponding to the normal
  67736. * @returns the shader code
  67737. */
  67738. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67739. protected _buildBlock(state: NodeMaterialBuildState): this;
  67740. protected _dumpPropertiesCode(): string;
  67741. serialize(): any;
  67742. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67743. }
  67744. }
  67745. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67746. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67747. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67748. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67749. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67751. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67752. import { Scene } from "babylonjs/scene";
  67753. import { Nullable } from "babylonjs/types";
  67754. /**
  67755. * Block used to implement the sheen module of the PBR material
  67756. */
  67757. export class SheenBlock extends NodeMaterialBlock {
  67758. /**
  67759. * Create a new SheenBlock
  67760. * @param name defines the block name
  67761. */
  67762. constructor(name: string);
  67763. /**
  67764. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67765. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67766. * making it easier to setup and tweak the effect
  67767. */
  67768. albedoScaling: boolean;
  67769. /**
  67770. * Defines if the sheen is linked to the sheen color.
  67771. */
  67772. linkSheenWithAlbedo: boolean;
  67773. /**
  67774. * Initialize the block and prepare the context for build
  67775. * @param state defines the state that will be used for the build
  67776. */
  67777. initialize(state: NodeMaterialBuildState): void;
  67778. /**
  67779. * Gets the current class name
  67780. * @returns the class name
  67781. */
  67782. getClassName(): string;
  67783. /**
  67784. * Gets the intensity input component
  67785. */
  67786. get intensity(): NodeMaterialConnectionPoint;
  67787. /**
  67788. * Gets the color input component
  67789. */
  67790. get color(): NodeMaterialConnectionPoint;
  67791. /**
  67792. * Gets the roughness input component
  67793. */
  67794. get roughness(): NodeMaterialConnectionPoint;
  67795. /**
  67796. * Gets the sheen object output component
  67797. */
  67798. get sheen(): NodeMaterialConnectionPoint;
  67799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67800. /**
  67801. * Gets the main code of the block (fragment side)
  67802. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  67803. * @returns the shader code
  67804. */
  67805. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  67806. protected _buildBlock(state: NodeMaterialBuildState): this;
  67807. protected _dumpPropertiesCode(): string;
  67808. serialize(): any;
  67809. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67810. }
  67811. }
  67812. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  67813. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67814. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67818. import { Scene } from "babylonjs/scene";
  67819. import { Nullable } from "babylonjs/types";
  67820. import { Mesh } from "babylonjs/Meshes/mesh";
  67821. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67822. import { Effect } from "babylonjs/Materials/effect";
  67823. /**
  67824. * Block used to implement the reflectivity module of the PBR material
  67825. */
  67826. export class ReflectivityBlock extends NodeMaterialBlock {
  67827. private _metallicReflectanceColor;
  67828. private _metallicF0Factor;
  67829. /** @hidden */
  67830. _vMetallicReflectanceFactorsName: string;
  67831. /**
  67832. * The property below is set by the main PBR block prior to calling methods of this class.
  67833. */
  67834. /** @hidden */
  67835. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  67836. /**
  67837. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  67838. */
  67839. useAmbientOcclusionFromMetallicTextureRed: boolean;
  67840. /**
  67841. * Specifies if the metallic texture contains the metallness information in its blue channel.
  67842. */
  67843. useMetallnessFromMetallicTextureBlue: boolean;
  67844. /**
  67845. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  67846. */
  67847. useRoughnessFromMetallicTextureAlpha: boolean;
  67848. /**
  67849. * Specifies if the metallic texture contains the roughness information in its green channel.
  67850. */
  67851. useRoughnessFromMetallicTextureGreen: boolean;
  67852. /**
  67853. * Create a new ReflectivityBlock
  67854. * @param name defines the block name
  67855. */
  67856. constructor(name: string);
  67857. /**
  67858. * Initialize the block and prepare the context for build
  67859. * @param state defines the state that will be used for the build
  67860. */
  67861. initialize(state: NodeMaterialBuildState): void;
  67862. /**
  67863. * Gets the current class name
  67864. * @returns the class name
  67865. */
  67866. getClassName(): string;
  67867. /**
  67868. * Gets the metallic input component
  67869. */
  67870. get metallic(): NodeMaterialConnectionPoint;
  67871. /**
  67872. * Gets the roughness input component
  67873. */
  67874. get roughness(): NodeMaterialConnectionPoint;
  67875. /**
  67876. * Gets the texture input component
  67877. */
  67878. get texture(): NodeMaterialConnectionPoint;
  67879. /**
  67880. * Gets the reflectivity object output component
  67881. */
  67882. get reflectivity(): NodeMaterialConnectionPoint;
  67883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67884. /**
  67885. * Gets the main code of the block (fragment side)
  67886. * @param state current state of the node material building
  67887. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  67888. * @returns the shader code
  67889. */
  67890. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  67891. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67892. protected _buildBlock(state: NodeMaterialBuildState): this;
  67893. protected _dumpPropertiesCode(): string;
  67894. serialize(): any;
  67895. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67896. }
  67897. }
  67898. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  67899. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67904. /**
  67905. * Block used to implement the anisotropy module of the PBR material
  67906. */
  67907. export class AnisotropyBlock extends NodeMaterialBlock {
  67908. /**
  67909. * The two properties below are set by the main PBR block prior to calling methods of this class.
  67910. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67911. * It's less burden on the user side in the editor part.
  67912. */
  67913. /** @hidden */
  67914. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67915. /** @hidden */
  67916. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67917. /**
  67918. * Create a new AnisotropyBlock
  67919. * @param name defines the block name
  67920. */
  67921. constructor(name: string);
  67922. /**
  67923. * Initialize the block and prepare the context for build
  67924. * @param state defines the state that will be used for the build
  67925. */
  67926. initialize(state: NodeMaterialBuildState): void;
  67927. /**
  67928. * Gets the current class name
  67929. * @returns the class name
  67930. */
  67931. getClassName(): string;
  67932. /**
  67933. * Gets the intensity input component
  67934. */
  67935. get intensity(): NodeMaterialConnectionPoint;
  67936. /**
  67937. * Gets the direction input component
  67938. */
  67939. get direction(): NodeMaterialConnectionPoint;
  67940. /**
  67941. * Gets the texture input component
  67942. */
  67943. get texture(): NodeMaterialConnectionPoint;
  67944. /**
  67945. * Gets the uv input component
  67946. */
  67947. get uv(): NodeMaterialConnectionPoint;
  67948. /**
  67949. * Gets the worldTangent input component
  67950. */
  67951. get worldTangent(): NodeMaterialConnectionPoint;
  67952. /**
  67953. * Gets the anisotropy object output component
  67954. */
  67955. get anisotropy(): NodeMaterialConnectionPoint;
  67956. private _generateTBNSpace;
  67957. /**
  67958. * Gets the main code of the block (fragment side)
  67959. * @param state current state of the node material building
  67960. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  67961. * @returns the shader code
  67962. */
  67963. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  67964. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67965. protected _buildBlock(state: NodeMaterialBuildState): this;
  67966. }
  67967. }
  67968. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  67969. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67970. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67971. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67972. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67974. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67975. import { Nullable } from "babylonjs/types";
  67976. import { Mesh } from "babylonjs/Meshes/mesh";
  67977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67978. import { Effect } from "babylonjs/Materials/effect";
  67979. /**
  67980. * Block used to implement the clear coat module of the PBR material
  67981. */
  67982. export class ClearCoatBlock extends NodeMaterialBlock {
  67983. private _scene;
  67984. /**
  67985. * Create a new ClearCoatBlock
  67986. * @param name defines the block name
  67987. */
  67988. constructor(name: string);
  67989. /**
  67990. * Initialize the block and prepare the context for build
  67991. * @param state defines the state that will be used for the build
  67992. */
  67993. initialize(state: NodeMaterialBuildState): void;
  67994. /**
  67995. * Gets the current class name
  67996. * @returns the class name
  67997. */
  67998. getClassName(): string;
  67999. /**
  68000. * Gets the intensity input component
  68001. */
  68002. get intensity(): NodeMaterialConnectionPoint;
  68003. /**
  68004. * Gets the roughness input component
  68005. */
  68006. get roughness(): NodeMaterialConnectionPoint;
  68007. /**
  68008. * Gets the ior input component
  68009. */
  68010. get ior(): NodeMaterialConnectionPoint;
  68011. /**
  68012. * Gets the texture input component
  68013. */
  68014. get texture(): NodeMaterialConnectionPoint;
  68015. /**
  68016. * Gets the bump texture input component
  68017. */
  68018. get bumpTexture(): NodeMaterialConnectionPoint;
  68019. /**
  68020. * Gets the uv input component
  68021. */
  68022. get uv(): NodeMaterialConnectionPoint;
  68023. /**
  68024. * Gets the tint color input component
  68025. */
  68026. get tintColor(): NodeMaterialConnectionPoint;
  68027. /**
  68028. * Gets the tint "at distance" input component
  68029. */
  68030. get tintAtDistance(): NodeMaterialConnectionPoint;
  68031. /**
  68032. * Gets the tint thickness input component
  68033. */
  68034. get tintThickness(): NodeMaterialConnectionPoint;
  68035. /**
  68036. * Gets the world tangent input component
  68037. */
  68038. get worldTangent(): NodeMaterialConnectionPoint;
  68039. /**
  68040. * Gets the clear coat object output component
  68041. */
  68042. get clearcoat(): NodeMaterialConnectionPoint;
  68043. autoConfigure(material: NodeMaterial): void;
  68044. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68045. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68046. private _generateTBNSpace;
  68047. /**
  68048. * Gets the main code of the block (fragment side)
  68049. * @param state current state of the node material building
  68050. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68051. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68052. * @param worldPosVarName name of the variable holding the world position
  68053. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68054. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68055. * @param worldNormalVarName name of the variable holding the world normal
  68056. * @returns the shader code
  68057. */
  68058. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68059. protected _buildBlock(state: NodeMaterialBuildState): this;
  68060. }
  68061. }
  68062. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68063. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68064. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68065. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68066. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68068. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68069. import { Nullable } from "babylonjs/types";
  68070. /**
  68071. * Block used to implement the sub surface module of the PBR material
  68072. */
  68073. export class SubSurfaceBlock extends NodeMaterialBlock {
  68074. /**
  68075. * Create a new SubSurfaceBlock
  68076. * @param name defines the block name
  68077. */
  68078. constructor(name: string);
  68079. /**
  68080. * Stores the intensity of the different subsurface effects in the thickness texture.
  68081. * * the green channel is the translucency intensity.
  68082. * * the blue channel is the scattering intensity.
  68083. * * the alpha channel is the refraction intensity.
  68084. */
  68085. useMaskFromThicknessTexture: boolean;
  68086. /**
  68087. * Initialize the block and prepare the context for build
  68088. * @param state defines the state that will be used for the build
  68089. */
  68090. initialize(state: NodeMaterialBuildState): void;
  68091. /**
  68092. * Gets the current class name
  68093. * @returns the class name
  68094. */
  68095. getClassName(): string;
  68096. /**
  68097. * Gets the min thickness input component
  68098. */
  68099. get minThickness(): NodeMaterialConnectionPoint;
  68100. /**
  68101. * Gets the max thickness input component
  68102. */
  68103. get maxThickness(): NodeMaterialConnectionPoint;
  68104. /**
  68105. * Gets the thickness texture component
  68106. */
  68107. get thicknessTexture(): NodeMaterialConnectionPoint;
  68108. /**
  68109. * Gets the tint color input component
  68110. */
  68111. get tintColor(): NodeMaterialConnectionPoint;
  68112. /**
  68113. * Gets the translucency intensity input component
  68114. */
  68115. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68116. /**
  68117. * Gets the translucency diffusion distance input component
  68118. */
  68119. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68120. /**
  68121. * Gets the refraction object parameters
  68122. */
  68123. get refraction(): NodeMaterialConnectionPoint;
  68124. /**
  68125. * Gets the sub surface object output component
  68126. */
  68127. get subsurface(): NodeMaterialConnectionPoint;
  68128. autoConfigure(material: NodeMaterial): void;
  68129. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68130. /**
  68131. * Gets the main code of the block (fragment side)
  68132. * @param state current state of the node material building
  68133. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68134. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68135. * @param worldPosVarName name of the variable holding the world position
  68136. * @returns the shader code
  68137. */
  68138. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68139. protected _buildBlock(state: NodeMaterialBuildState): this;
  68140. }
  68141. }
  68142. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68146. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68147. import { Light } from "babylonjs/Lights/light";
  68148. import { Nullable } from "babylonjs/types";
  68149. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68150. import { Effect } from "babylonjs/Materials/effect";
  68151. import { Mesh } from "babylonjs/Meshes/mesh";
  68152. import { Scene } from "babylonjs/scene";
  68153. /**
  68154. * Block used to implement the PBR metallic/roughness model
  68155. */
  68156. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68157. /**
  68158. * Gets or sets the light associated with this block
  68159. */
  68160. light: Nullable<Light>;
  68161. private _lightId;
  68162. private _scene;
  68163. private _environmentBRDFTexture;
  68164. private _environmentBrdfSamplerName;
  68165. private _vNormalWName;
  68166. private _invertNormalName;
  68167. /**
  68168. * Create a new ReflectionBlock
  68169. * @param name defines the block name
  68170. */
  68171. constructor(name: string);
  68172. /**
  68173. * Intensity of the direct lights e.g. the four lights available in your scene.
  68174. * This impacts both the direct diffuse and specular highlights.
  68175. */
  68176. directIntensity: number;
  68177. /**
  68178. * Intensity of the environment e.g. how much the environment will light the object
  68179. * either through harmonics for rough material or through the refelction for shiny ones.
  68180. */
  68181. environmentIntensity: number;
  68182. /**
  68183. * This is a special control allowing the reduction of the specular highlights coming from the
  68184. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68185. */
  68186. specularIntensity: number;
  68187. /**
  68188. * Defines the falloff type used in this material.
  68189. * It by default is Physical.
  68190. */
  68191. lightFalloff: number;
  68192. /**
  68193. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68194. */
  68195. useAlphaFromAlbedoTexture: boolean;
  68196. /**
  68197. * Specifies that alpha test should be used
  68198. */
  68199. useAlphaTest: boolean;
  68200. /**
  68201. * Defines the alpha limits in alpha test mode.
  68202. */
  68203. alphaTestCutoff: number;
  68204. /**
  68205. * Specifies that alpha blending should be used
  68206. */
  68207. useAlphaBlending: boolean;
  68208. /**
  68209. * Defines if the alpha value should be determined via the rgb values.
  68210. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68211. */
  68212. opacityRGB: boolean;
  68213. /**
  68214. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68215. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68216. */
  68217. useRadianceOverAlpha: boolean;
  68218. /**
  68219. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68221. */
  68222. useSpecularOverAlpha: boolean;
  68223. /**
  68224. * Enables specular anti aliasing in the PBR shader.
  68225. * It will both interacts on the Geometry for analytical and IBL lighting.
  68226. * It also prefilter the roughness map based on the bump values.
  68227. */
  68228. enableSpecularAntiAliasing: boolean;
  68229. /**
  68230. * Enables realtime filtering on the texture.
  68231. */
  68232. realTimeFiltering: boolean;
  68233. /**
  68234. * Quality switch for realtime filtering
  68235. */
  68236. realTimeFilteringQuality: number;
  68237. /**
  68238. * Defines if the material uses energy conservation.
  68239. */
  68240. useEnergyConservation: boolean;
  68241. /**
  68242. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68243. * too much the area relying on ambient texture to define their ambient occlusion.
  68244. */
  68245. useRadianceOcclusion: boolean;
  68246. /**
  68247. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68248. * makes the reflect vector face the model (under horizon).
  68249. */
  68250. useHorizonOcclusion: boolean;
  68251. /**
  68252. * If set to true, no lighting calculations will be applied.
  68253. */
  68254. unlit: boolean;
  68255. /**
  68256. * Force normal to face away from face.
  68257. */
  68258. forceNormalForward: boolean;
  68259. /**
  68260. * Defines the material debug mode.
  68261. * It helps seeing only some components of the material while troubleshooting.
  68262. */
  68263. debugMode: number;
  68264. /**
  68265. * Specify from where on screen the debug mode should start.
  68266. * The value goes from -1 (full screen) to 1 (not visible)
  68267. * It helps with side by side comparison against the final render
  68268. * This defaults to 0
  68269. */
  68270. debugLimit: number;
  68271. /**
  68272. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68273. * You can use the factor to better multiply the final value.
  68274. */
  68275. debugFactor: number;
  68276. /**
  68277. * Initialize the block and prepare the context for build
  68278. * @param state defines the state that will be used for the build
  68279. */
  68280. initialize(state: NodeMaterialBuildState): void;
  68281. /**
  68282. * Gets the current class name
  68283. * @returns the class name
  68284. */
  68285. getClassName(): string;
  68286. /**
  68287. * Gets the world position input component
  68288. */
  68289. get worldPosition(): NodeMaterialConnectionPoint;
  68290. /**
  68291. * Gets the world normal input component
  68292. */
  68293. get worldNormal(): NodeMaterialConnectionPoint;
  68294. /**
  68295. * Gets the perturbed normal input component
  68296. */
  68297. get perturbedNormal(): NodeMaterialConnectionPoint;
  68298. /**
  68299. * Gets the camera position input component
  68300. */
  68301. get cameraPosition(): NodeMaterialConnectionPoint;
  68302. /**
  68303. * Gets the base color input component
  68304. */
  68305. get baseColor(): NodeMaterialConnectionPoint;
  68306. /**
  68307. * Gets the opacity texture input component
  68308. */
  68309. get opacityTexture(): NodeMaterialConnectionPoint;
  68310. /**
  68311. * Gets the ambient color input component
  68312. */
  68313. get ambientColor(): NodeMaterialConnectionPoint;
  68314. /**
  68315. * Gets the reflectivity object parameters
  68316. */
  68317. get reflectivity(): NodeMaterialConnectionPoint;
  68318. /**
  68319. * Gets the ambient occlusion object parameters
  68320. */
  68321. get ambientOcclusion(): NodeMaterialConnectionPoint;
  68322. /**
  68323. * Gets the reflection object parameters
  68324. */
  68325. get reflection(): NodeMaterialConnectionPoint;
  68326. /**
  68327. * Gets the sheen object parameters
  68328. */
  68329. get sheen(): NodeMaterialConnectionPoint;
  68330. /**
  68331. * Gets the clear coat object parameters
  68332. */
  68333. get clearcoat(): NodeMaterialConnectionPoint;
  68334. /**
  68335. * Gets the sub surface object parameters
  68336. */
  68337. get subsurface(): NodeMaterialConnectionPoint;
  68338. /**
  68339. * Gets the anisotropy object parameters
  68340. */
  68341. get anisotropy(): NodeMaterialConnectionPoint;
  68342. /**
  68343. * Gets the ambient output component
  68344. */
  68345. get ambient(): NodeMaterialConnectionPoint;
  68346. /**
  68347. * Gets the diffuse output component
  68348. */
  68349. get diffuse(): NodeMaterialConnectionPoint;
  68350. /**
  68351. * Gets the specular output component
  68352. */
  68353. get specular(): NodeMaterialConnectionPoint;
  68354. /**
  68355. * Gets the sheen output component
  68356. */
  68357. get sheenDir(): NodeMaterialConnectionPoint;
  68358. /**
  68359. * Gets the clear coat output component
  68360. */
  68361. get clearcoatDir(): NodeMaterialConnectionPoint;
  68362. /**
  68363. * Gets the indirect diffuse output component
  68364. */
  68365. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68366. /**
  68367. * Gets the indirect specular output component
  68368. */
  68369. get specularIndirect(): NodeMaterialConnectionPoint;
  68370. /**
  68371. * Gets the indirect sheen output component
  68372. */
  68373. get sheenIndirect(): NodeMaterialConnectionPoint;
  68374. /**
  68375. * Gets the indirect clear coat output component
  68376. */
  68377. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68378. /**
  68379. * Gets the refraction output component
  68380. */
  68381. get refraction(): NodeMaterialConnectionPoint;
  68382. /**
  68383. * Gets the global lighting output component
  68384. */
  68385. get lighting(): NodeMaterialConnectionPoint;
  68386. /**
  68387. * Gets the shadow output component
  68388. */
  68389. get shadow(): NodeMaterialConnectionPoint;
  68390. /**
  68391. * Gets the alpha output component
  68392. */
  68393. get alpha(): NodeMaterialConnectionPoint;
  68394. autoConfigure(material: NodeMaterial): void;
  68395. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68396. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68397. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68398. private _injectVertexCode;
  68399. /**
  68400. * Gets the code corresponding to the albedo/opacity module
  68401. * @returns the shader code
  68402. */
  68403. getAlbedoOpacityCode(): string;
  68404. protected _buildBlock(state: NodeMaterialBuildState): this;
  68405. protected _dumpPropertiesCode(): string;
  68406. serialize(): any;
  68407. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68408. }
  68409. }
  68410. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68411. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68412. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68413. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68414. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68415. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68416. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68417. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68418. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68419. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68420. }
  68421. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68422. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68423. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68424. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68425. }
  68426. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68427. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68428. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68429. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68430. /**
  68431. * Block used to compute value of one parameter modulo another
  68432. */
  68433. export class ModBlock extends NodeMaterialBlock {
  68434. /**
  68435. * Creates a new ModBlock
  68436. * @param name defines the block name
  68437. */
  68438. constructor(name: string);
  68439. /**
  68440. * Gets the current class name
  68441. * @returns the class name
  68442. */
  68443. getClassName(): string;
  68444. /**
  68445. * Gets the left operand input component
  68446. */
  68447. get left(): NodeMaterialConnectionPoint;
  68448. /**
  68449. * Gets the right operand input component
  68450. */
  68451. get right(): NodeMaterialConnectionPoint;
  68452. /**
  68453. * Gets the output component
  68454. */
  68455. get output(): NodeMaterialConnectionPoint;
  68456. protected _buildBlock(state: NodeMaterialBuildState): this;
  68457. }
  68458. }
  68459. declare module "babylonjs/Materials/Node/Blocks/index" {
  68460. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68461. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68462. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68463. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68464. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68465. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68466. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68467. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68468. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68469. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68470. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68471. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68472. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68473. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68474. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68475. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68476. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68477. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68478. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68479. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68480. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68481. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68482. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68483. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68484. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68485. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68486. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68487. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68488. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68489. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68490. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68491. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68492. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68493. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68494. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68495. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68496. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68497. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68498. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68499. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68500. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68501. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68502. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68503. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68504. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68505. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68506. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68507. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68508. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68509. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68510. }
  68511. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68512. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68513. }
  68514. declare module "babylonjs/Materials/Node/index" {
  68515. export * from "babylonjs/Materials/Node/Enums/index";
  68516. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68517. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68518. export * from "babylonjs/Materials/Node/nodeMaterial";
  68519. export * from "babylonjs/Materials/Node/Blocks/index";
  68520. export * from "babylonjs/Materials/Node/Optimizers/index";
  68521. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68522. }
  68523. declare module "babylonjs/Materials/index" {
  68524. export * from "babylonjs/Materials/Background/index";
  68525. export * from "babylonjs/Materials/colorCurves";
  68526. export * from "babylonjs/Materials/iEffectFallbacks";
  68527. export * from "babylonjs/Materials/effectFallbacks";
  68528. export * from "babylonjs/Materials/effect";
  68529. export * from "babylonjs/Materials/fresnelParameters";
  68530. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68531. export * from "babylonjs/Materials/material";
  68532. export * from "babylonjs/Materials/materialDefines";
  68533. export * from "babylonjs/Materials/thinMaterialHelper";
  68534. export * from "babylonjs/Materials/materialHelper";
  68535. export * from "babylonjs/Materials/multiMaterial";
  68536. export * from "babylonjs/Materials/PBR/index";
  68537. export * from "babylonjs/Materials/pushMaterial";
  68538. export * from "babylonjs/Materials/shaderMaterial";
  68539. export * from "babylonjs/Materials/standardMaterial";
  68540. export * from "babylonjs/Materials/Textures/index";
  68541. export * from "babylonjs/Materials/uniformBuffer";
  68542. export * from "babylonjs/Materials/materialFlags";
  68543. export * from "babylonjs/Materials/Node/index";
  68544. export * from "babylonjs/Materials/effectRenderer";
  68545. export * from "babylonjs/Materials/shadowDepthWrapper";
  68546. }
  68547. declare module "babylonjs/Maths/index" {
  68548. export * from "babylonjs/Maths/math.scalar";
  68549. export * from "babylonjs/Maths/math";
  68550. export * from "babylonjs/Maths/sphericalPolynomial";
  68551. }
  68552. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68553. import { IDisposable } from "babylonjs/scene";
  68554. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68555. /**
  68556. * Configuration for Draco compression
  68557. */
  68558. export interface IDracoCompressionConfiguration {
  68559. /**
  68560. * Configuration for the decoder.
  68561. */
  68562. decoder: {
  68563. /**
  68564. * The url to the WebAssembly module.
  68565. */
  68566. wasmUrl?: string;
  68567. /**
  68568. * The url to the WebAssembly binary.
  68569. */
  68570. wasmBinaryUrl?: string;
  68571. /**
  68572. * The url to the fallback JavaScript module.
  68573. */
  68574. fallbackUrl?: string;
  68575. };
  68576. }
  68577. /**
  68578. * Draco compression (https://google.github.io/draco/)
  68579. *
  68580. * This class wraps the Draco module.
  68581. *
  68582. * **Encoder**
  68583. *
  68584. * The encoder is not currently implemented.
  68585. *
  68586. * **Decoder**
  68587. *
  68588. * 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.
  68589. *
  68590. * To update the configuration, use the following code:
  68591. * ```javascript
  68592. * DracoCompression.Configuration = {
  68593. * decoder: {
  68594. * wasmUrl: "<url to the WebAssembly library>",
  68595. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68596. * fallbackUrl: "<url to the fallback JavaScript library>",
  68597. * }
  68598. * };
  68599. * ```
  68600. *
  68601. * 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.
  68602. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68603. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68604. *
  68605. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68606. * ```javascript
  68607. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68608. * ```
  68609. *
  68610. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68611. */
  68612. export class DracoCompression implements IDisposable {
  68613. private _workerPoolPromise?;
  68614. private _decoderModulePromise?;
  68615. /**
  68616. * The configuration. Defaults to the following urls:
  68617. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68618. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68619. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68620. */
  68621. static Configuration: IDracoCompressionConfiguration;
  68622. /**
  68623. * Returns true if the decoder configuration is available.
  68624. */
  68625. static get DecoderAvailable(): boolean;
  68626. /**
  68627. * Default number of workers to create when creating the draco compression object.
  68628. */
  68629. static DefaultNumWorkers: number;
  68630. private static GetDefaultNumWorkers;
  68631. private static _Default;
  68632. /**
  68633. * Default instance for the draco compression object.
  68634. */
  68635. static get Default(): DracoCompression;
  68636. /**
  68637. * Constructor
  68638. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68639. */
  68640. constructor(numWorkers?: number);
  68641. /**
  68642. * Stop all async operations and release resources.
  68643. */
  68644. dispose(): void;
  68645. /**
  68646. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68647. * @returns a promise that resolves when ready
  68648. */
  68649. whenReadyAsync(): Promise<void>;
  68650. /**
  68651. * Decode Draco compressed mesh data to vertex data.
  68652. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68653. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68654. * @returns A promise that resolves with the decoded vertex data
  68655. */
  68656. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68657. [kind: string]: number;
  68658. }): Promise<VertexData>;
  68659. }
  68660. }
  68661. declare module "babylonjs/Meshes/Compression/index" {
  68662. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68663. }
  68664. declare module "babylonjs/Meshes/csg" {
  68665. import { Nullable } from "babylonjs/types";
  68666. import { Scene } from "babylonjs/scene";
  68667. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68668. import { Mesh } from "babylonjs/Meshes/mesh";
  68669. import { Material } from "babylonjs/Materials/material";
  68670. /**
  68671. * Class for building Constructive Solid Geometry
  68672. */
  68673. export class CSG {
  68674. private polygons;
  68675. /**
  68676. * The world matrix
  68677. */
  68678. matrix: Matrix;
  68679. /**
  68680. * Stores the position
  68681. */
  68682. position: Vector3;
  68683. /**
  68684. * Stores the rotation
  68685. */
  68686. rotation: Vector3;
  68687. /**
  68688. * Stores the rotation quaternion
  68689. */
  68690. rotationQuaternion: Nullable<Quaternion>;
  68691. /**
  68692. * Stores the scaling vector
  68693. */
  68694. scaling: Vector3;
  68695. /**
  68696. * Convert the Mesh to CSG
  68697. * @param mesh The Mesh to convert to CSG
  68698. * @returns A new CSG from the Mesh
  68699. */
  68700. static FromMesh(mesh: Mesh): CSG;
  68701. /**
  68702. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68703. * @param polygons Polygons used to construct a CSG solid
  68704. */
  68705. private static FromPolygons;
  68706. /**
  68707. * Clones, or makes a deep copy, of the CSG
  68708. * @returns A new CSG
  68709. */
  68710. clone(): CSG;
  68711. /**
  68712. * Unions this CSG with another CSG
  68713. * @param csg The CSG to union against this CSG
  68714. * @returns The unioned CSG
  68715. */
  68716. union(csg: CSG): CSG;
  68717. /**
  68718. * Unions this CSG with another CSG in place
  68719. * @param csg The CSG to union against this CSG
  68720. */
  68721. unionInPlace(csg: CSG): void;
  68722. /**
  68723. * Subtracts this CSG with another CSG
  68724. * @param csg The CSG to subtract against this CSG
  68725. * @returns A new CSG
  68726. */
  68727. subtract(csg: CSG): CSG;
  68728. /**
  68729. * Subtracts this CSG with another CSG in place
  68730. * @param csg The CSG to subtact against this CSG
  68731. */
  68732. subtractInPlace(csg: CSG): void;
  68733. /**
  68734. * Intersect this CSG with another CSG
  68735. * @param csg The CSG to intersect against this CSG
  68736. * @returns A new CSG
  68737. */
  68738. intersect(csg: CSG): CSG;
  68739. /**
  68740. * Intersects this CSG with another CSG in place
  68741. * @param csg The CSG to intersect against this CSG
  68742. */
  68743. intersectInPlace(csg: CSG): void;
  68744. /**
  68745. * Return a new CSG solid with solid and empty space switched. This solid is
  68746. * not modified.
  68747. * @returns A new CSG solid with solid and empty space switched
  68748. */
  68749. inverse(): CSG;
  68750. /**
  68751. * Inverses the CSG in place
  68752. */
  68753. inverseInPlace(): void;
  68754. /**
  68755. * This is used to keep meshes transformations so they can be restored
  68756. * when we build back a Babylon Mesh
  68757. * NB : All CSG operations are performed in world coordinates
  68758. * @param csg The CSG to copy the transform attributes from
  68759. * @returns This CSG
  68760. */
  68761. copyTransformAttributes(csg: CSG): CSG;
  68762. /**
  68763. * Build Raw mesh from CSG
  68764. * Coordinates here are in world space
  68765. * @param name The name of the mesh geometry
  68766. * @param scene The Scene
  68767. * @param keepSubMeshes Specifies if the submeshes should be kept
  68768. * @returns A new Mesh
  68769. */
  68770. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68771. /**
  68772. * Build Mesh from CSG taking material and transforms into account
  68773. * @param name The name of the Mesh
  68774. * @param material The material of the Mesh
  68775. * @param scene The Scene
  68776. * @param keepSubMeshes Specifies if submeshes should be kept
  68777. * @returns The new Mesh
  68778. */
  68779. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68780. }
  68781. }
  68782. declare module "babylonjs/Meshes/trailMesh" {
  68783. import { Mesh } from "babylonjs/Meshes/mesh";
  68784. import { Scene } from "babylonjs/scene";
  68785. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68786. /**
  68787. * Class used to create a trail following a mesh
  68788. */
  68789. export class TrailMesh extends Mesh {
  68790. private _generator;
  68791. private _autoStart;
  68792. private _running;
  68793. private _diameter;
  68794. private _length;
  68795. private _sectionPolygonPointsCount;
  68796. private _sectionVectors;
  68797. private _sectionNormalVectors;
  68798. private _beforeRenderObserver;
  68799. /**
  68800. * @constructor
  68801. * @param name The value used by scene.getMeshByName() to do a lookup.
  68802. * @param generator The mesh or transform node to generate a trail.
  68803. * @param scene The scene to add this mesh to.
  68804. * @param diameter Diameter of trailing mesh. Default is 1.
  68805. * @param length Length of trailing mesh. Default is 60.
  68806. * @param autoStart Automatically start trailing mesh. Default true.
  68807. */
  68808. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  68809. /**
  68810. * "TrailMesh"
  68811. * @returns "TrailMesh"
  68812. */
  68813. getClassName(): string;
  68814. private _createMesh;
  68815. /**
  68816. * Start trailing mesh.
  68817. */
  68818. start(): void;
  68819. /**
  68820. * Stop trailing mesh.
  68821. */
  68822. stop(): void;
  68823. /**
  68824. * Update trailing mesh geometry.
  68825. */
  68826. update(): void;
  68827. /**
  68828. * Returns a new TrailMesh object.
  68829. * @param name is a string, the name given to the new mesh
  68830. * @param newGenerator use new generator object for cloned trail mesh
  68831. * @returns a new mesh
  68832. */
  68833. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  68834. /**
  68835. * Serializes this trail mesh
  68836. * @param serializationObject object to write serialization to
  68837. */
  68838. serialize(serializationObject: any): void;
  68839. /**
  68840. * Parses a serialized trail mesh
  68841. * @param parsedMesh the serialized mesh
  68842. * @param scene the scene to create the trail mesh in
  68843. * @returns the created trail mesh
  68844. */
  68845. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  68846. }
  68847. }
  68848. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  68849. import { Nullable } from "babylonjs/types";
  68850. import { Scene } from "babylonjs/scene";
  68851. import { Vector4 } from "babylonjs/Maths/math.vector";
  68852. import { Color4 } from "babylonjs/Maths/math.color";
  68853. import { Mesh } from "babylonjs/Meshes/mesh";
  68854. /**
  68855. * Class containing static functions to help procedurally build meshes
  68856. */
  68857. export class TiledBoxBuilder {
  68858. /**
  68859. * Creates a box mesh
  68860. * 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)
  68861. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  68862. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68863. * * 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
  68864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  68865. * @param name defines the name of the mesh
  68866. * @param options defines the options used to create the mesh
  68867. * @param scene defines the hosting scene
  68868. * @returns the box mesh
  68869. */
  68870. static CreateTiledBox(name: string, options: {
  68871. pattern?: number;
  68872. width?: number;
  68873. height?: number;
  68874. depth?: number;
  68875. tileSize?: number;
  68876. tileWidth?: number;
  68877. tileHeight?: number;
  68878. alignHorizontal?: number;
  68879. alignVertical?: number;
  68880. faceUV?: Vector4[];
  68881. faceColors?: Color4[];
  68882. sideOrientation?: number;
  68883. updatable?: boolean;
  68884. }, scene?: Nullable<Scene>): Mesh;
  68885. }
  68886. }
  68887. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  68888. import { Vector4 } from "babylonjs/Maths/math.vector";
  68889. import { Mesh } from "babylonjs/Meshes/mesh";
  68890. /**
  68891. * Class containing static functions to help procedurally build meshes
  68892. */
  68893. export class TorusKnotBuilder {
  68894. /**
  68895. * Creates a torus knot mesh
  68896. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  68897. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  68898. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  68899. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  68900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  68901. * * 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
  68902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  68903. * @param name defines the name of the mesh
  68904. * @param options defines the options used to create the mesh
  68905. * @param scene defines the hosting scene
  68906. * @returns the torus knot mesh
  68907. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  68908. */
  68909. static CreateTorusKnot(name: string, options: {
  68910. radius?: number;
  68911. tube?: number;
  68912. radialSegments?: number;
  68913. tubularSegments?: number;
  68914. p?: number;
  68915. q?: number;
  68916. updatable?: boolean;
  68917. sideOrientation?: number;
  68918. frontUVs?: Vector4;
  68919. backUVs?: Vector4;
  68920. }, scene: any): Mesh;
  68921. }
  68922. }
  68923. declare module "babylonjs/Meshes/polygonMesh" {
  68924. import { Scene } from "babylonjs/scene";
  68925. import { Vector2 } from "babylonjs/Maths/math.vector";
  68926. import { Mesh } from "babylonjs/Meshes/mesh";
  68927. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68928. import { Path2 } from "babylonjs/Maths/math.path";
  68929. /**
  68930. * Polygon
  68931. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  68932. */
  68933. export class Polygon {
  68934. /**
  68935. * Creates a rectangle
  68936. * @param xmin bottom X coord
  68937. * @param ymin bottom Y coord
  68938. * @param xmax top X coord
  68939. * @param ymax top Y coord
  68940. * @returns points that make the resulting rectation
  68941. */
  68942. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  68943. /**
  68944. * Creates a circle
  68945. * @param radius radius of circle
  68946. * @param cx scale in x
  68947. * @param cy scale in y
  68948. * @param numberOfSides number of sides that make up the circle
  68949. * @returns points that make the resulting circle
  68950. */
  68951. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  68952. /**
  68953. * Creates a polygon from input string
  68954. * @param input Input polygon data
  68955. * @returns the parsed points
  68956. */
  68957. static Parse(input: string): Vector2[];
  68958. /**
  68959. * Starts building a polygon from x and y coordinates
  68960. * @param x x coordinate
  68961. * @param y y coordinate
  68962. * @returns the started path2
  68963. */
  68964. static StartingAt(x: number, y: number): Path2;
  68965. }
  68966. /**
  68967. * Builds a polygon
  68968. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  68969. */
  68970. export class PolygonMeshBuilder {
  68971. private _points;
  68972. private _outlinepoints;
  68973. private _holes;
  68974. private _name;
  68975. private _scene;
  68976. private _epoints;
  68977. private _eholes;
  68978. private _addToepoint;
  68979. /**
  68980. * Babylon reference to the earcut plugin.
  68981. */
  68982. bjsEarcut: any;
  68983. /**
  68984. * Creates a PolygonMeshBuilder
  68985. * @param name name of the builder
  68986. * @param contours Path of the polygon
  68987. * @param scene scene to add to when creating the mesh
  68988. * @param earcutInjection can be used to inject your own earcut reference
  68989. */
  68990. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  68991. /**
  68992. * Adds a whole within the polygon
  68993. * @param hole Array of points defining the hole
  68994. * @returns this
  68995. */
  68996. addHole(hole: Vector2[]): PolygonMeshBuilder;
  68997. /**
  68998. * Creates the polygon
  68999. * @param updatable If the mesh should be updatable
  69000. * @param depth The depth of the mesh created
  69001. * @returns the created mesh
  69002. */
  69003. build(updatable?: boolean, depth?: number): Mesh;
  69004. /**
  69005. * Creates the polygon
  69006. * @param depth The depth of the mesh created
  69007. * @returns the created VertexData
  69008. */
  69009. buildVertexData(depth?: number): VertexData;
  69010. /**
  69011. * Adds a side to the polygon
  69012. * @param positions points that make the polygon
  69013. * @param normals normals of the polygon
  69014. * @param uvs uvs of the polygon
  69015. * @param indices indices of the polygon
  69016. * @param bounds bounds of the polygon
  69017. * @param points points of the polygon
  69018. * @param depth depth of the polygon
  69019. * @param flip flip of the polygon
  69020. */
  69021. private addSide;
  69022. }
  69023. }
  69024. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69025. import { Scene } from "babylonjs/scene";
  69026. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69027. import { Color4 } from "babylonjs/Maths/math.color";
  69028. import { Mesh } from "babylonjs/Meshes/mesh";
  69029. import { Nullable } from "babylonjs/types";
  69030. /**
  69031. * Class containing static functions to help procedurally build meshes
  69032. */
  69033. export class PolygonBuilder {
  69034. /**
  69035. * Creates a polygon mesh
  69036. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69037. * * 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
  69038. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69040. * * 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)
  69041. * * Remember you can only change the shape positions, not their number when updating a polygon
  69042. * @param name defines the name of the mesh
  69043. * @param options defines the options used to create the mesh
  69044. * @param scene defines the hosting scene
  69045. * @param earcutInjection can be used to inject your own earcut reference
  69046. * @returns the polygon mesh
  69047. */
  69048. static CreatePolygon(name: string, options: {
  69049. shape: Vector3[];
  69050. holes?: Vector3[][];
  69051. depth?: number;
  69052. faceUV?: Vector4[];
  69053. faceColors?: Color4[];
  69054. updatable?: boolean;
  69055. sideOrientation?: number;
  69056. frontUVs?: Vector4;
  69057. backUVs?: Vector4;
  69058. wrap?: boolean;
  69059. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69060. /**
  69061. * Creates an extruded polygon mesh, with depth in the Y direction.
  69062. * * 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)
  69063. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69064. * @param name defines the name of the mesh
  69065. * @param options defines the options used to create the mesh
  69066. * @param scene defines the hosting scene
  69067. * @param earcutInjection can be used to inject your own earcut reference
  69068. * @returns the polygon mesh
  69069. */
  69070. static ExtrudePolygon(name: string, options: {
  69071. shape: Vector3[];
  69072. holes?: Vector3[][];
  69073. depth?: number;
  69074. faceUV?: Vector4[];
  69075. faceColors?: Color4[];
  69076. updatable?: boolean;
  69077. sideOrientation?: number;
  69078. frontUVs?: Vector4;
  69079. backUVs?: Vector4;
  69080. wrap?: boolean;
  69081. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69082. }
  69083. }
  69084. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69085. import { Scene } from "babylonjs/scene";
  69086. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69087. import { Mesh } from "babylonjs/Meshes/mesh";
  69088. import { Nullable } from "babylonjs/types";
  69089. /**
  69090. * Class containing static functions to help procedurally build meshes
  69091. */
  69092. export class LatheBuilder {
  69093. /**
  69094. * Creates lathe mesh.
  69095. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69096. * * 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
  69097. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69098. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69099. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69100. * * 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
  69101. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69102. * * 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
  69103. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69104. * * 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
  69105. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69107. * @param name defines the name of the mesh
  69108. * @param options defines the options used to create the mesh
  69109. * @param scene defines the hosting scene
  69110. * @returns the lathe mesh
  69111. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69112. */
  69113. static CreateLathe(name: string, options: {
  69114. shape: Vector3[];
  69115. radius?: number;
  69116. tessellation?: number;
  69117. clip?: number;
  69118. arc?: number;
  69119. closed?: boolean;
  69120. updatable?: boolean;
  69121. sideOrientation?: number;
  69122. frontUVs?: Vector4;
  69123. backUVs?: Vector4;
  69124. cap?: number;
  69125. invertUV?: boolean;
  69126. }, scene?: Nullable<Scene>): Mesh;
  69127. }
  69128. }
  69129. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69130. import { Nullable } from "babylonjs/types";
  69131. import { Scene } from "babylonjs/scene";
  69132. import { Vector4 } from "babylonjs/Maths/math.vector";
  69133. import { Mesh } from "babylonjs/Meshes/mesh";
  69134. /**
  69135. * Class containing static functions to help procedurally build meshes
  69136. */
  69137. export class TiledPlaneBuilder {
  69138. /**
  69139. * Creates a tiled plane mesh
  69140. * * The parameter `pattern` will, depending on value, do nothing or
  69141. * * * flip (reflect about central vertical) alternate tiles across and up
  69142. * * * flip every tile on alternate rows
  69143. * * * rotate (180 degs) alternate tiles across and up
  69144. * * * rotate every tile on alternate rows
  69145. * * * flip and rotate alternate tiles across and up
  69146. * * * flip and rotate every tile on alternate rows
  69147. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69148. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69149. * * 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
  69150. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69151. * * 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)
  69152. * * 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)
  69153. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69154. * @param name defines the name of the mesh
  69155. * @param options defines the options used to create the mesh
  69156. * @param scene defines the hosting scene
  69157. * @returns the box mesh
  69158. */
  69159. static CreateTiledPlane(name: string, options: {
  69160. pattern?: number;
  69161. tileSize?: number;
  69162. tileWidth?: number;
  69163. tileHeight?: number;
  69164. size?: number;
  69165. width?: number;
  69166. height?: number;
  69167. alignHorizontal?: number;
  69168. alignVertical?: number;
  69169. sideOrientation?: number;
  69170. frontUVs?: Vector4;
  69171. backUVs?: Vector4;
  69172. updatable?: boolean;
  69173. }, scene?: Nullable<Scene>): Mesh;
  69174. }
  69175. }
  69176. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69177. import { Nullable } from "babylonjs/types";
  69178. import { Scene } from "babylonjs/scene";
  69179. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69180. import { Mesh } from "babylonjs/Meshes/mesh";
  69181. /**
  69182. * Class containing static functions to help procedurally build meshes
  69183. */
  69184. export class TubeBuilder {
  69185. /**
  69186. * Creates a tube mesh.
  69187. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69188. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69189. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69190. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69191. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69192. * * 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)
  69193. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69194. * * 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
  69195. * * 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
  69196. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69197. * * 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
  69198. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69199. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69200. * @param name defines the name of the mesh
  69201. * @param options defines the options used to create the mesh
  69202. * @param scene defines the hosting scene
  69203. * @returns the tube mesh
  69204. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69205. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69206. */
  69207. static CreateTube(name: string, options: {
  69208. path: Vector3[];
  69209. radius?: number;
  69210. tessellation?: number;
  69211. radiusFunction?: {
  69212. (i: number, distance: number): number;
  69213. };
  69214. cap?: number;
  69215. arc?: number;
  69216. updatable?: boolean;
  69217. sideOrientation?: number;
  69218. frontUVs?: Vector4;
  69219. backUVs?: Vector4;
  69220. instance?: Mesh;
  69221. invertUV?: boolean;
  69222. }, scene?: Nullable<Scene>): Mesh;
  69223. }
  69224. }
  69225. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69226. import { Scene } from "babylonjs/scene";
  69227. import { Vector4 } from "babylonjs/Maths/math.vector";
  69228. import { Mesh } from "babylonjs/Meshes/mesh";
  69229. import { Nullable } from "babylonjs/types";
  69230. /**
  69231. * Class containing static functions to help procedurally build meshes
  69232. */
  69233. export class IcoSphereBuilder {
  69234. /**
  69235. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69236. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69237. * * 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`)
  69238. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69239. * * 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
  69240. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69241. * * 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
  69242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69243. * @param name defines the name of the mesh
  69244. * @param options defines the options used to create the mesh
  69245. * @param scene defines the hosting scene
  69246. * @returns the icosahedron mesh
  69247. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69248. */
  69249. static CreateIcoSphere(name: string, options: {
  69250. radius?: number;
  69251. radiusX?: number;
  69252. radiusY?: number;
  69253. radiusZ?: number;
  69254. flat?: boolean;
  69255. subdivisions?: number;
  69256. sideOrientation?: number;
  69257. frontUVs?: Vector4;
  69258. backUVs?: Vector4;
  69259. updatable?: boolean;
  69260. }, scene?: Nullable<Scene>): Mesh;
  69261. }
  69262. }
  69263. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69264. import { Vector3 } from "babylonjs/Maths/math.vector";
  69265. import { Mesh } from "babylonjs/Meshes/mesh";
  69266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69267. /**
  69268. * Class containing static functions to help procedurally build meshes
  69269. */
  69270. export class DecalBuilder {
  69271. /**
  69272. * Creates a decal mesh.
  69273. * 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
  69274. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69275. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69276. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69277. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69278. * @param name defines the name of the mesh
  69279. * @param sourceMesh defines the mesh where the decal must be applied
  69280. * @param options defines the options used to create the mesh
  69281. * @param scene defines the hosting scene
  69282. * @returns the decal mesh
  69283. * @see https://doc.babylonjs.com/how_to/decals
  69284. */
  69285. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69286. position?: Vector3;
  69287. normal?: Vector3;
  69288. size?: Vector3;
  69289. angle?: number;
  69290. }): Mesh;
  69291. }
  69292. }
  69293. declare module "babylonjs/Meshes/meshBuilder" {
  69294. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69295. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69296. import { Nullable } from "babylonjs/types";
  69297. import { Scene } from "babylonjs/scene";
  69298. import { Mesh } from "babylonjs/Meshes/mesh";
  69299. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69300. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69302. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69303. import { Plane } from "babylonjs/Maths/math.plane";
  69304. /**
  69305. * Class containing static functions to help procedurally build meshes
  69306. */
  69307. export class MeshBuilder {
  69308. /**
  69309. * Creates a box mesh
  69310. * * The parameter `size` sets the size (float) of each box side (default 1)
  69311. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69312. * * 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)
  69313. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69314. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69315. * * 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
  69316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69317. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69318. * @param name defines the name of the mesh
  69319. * @param options defines the options used to create the mesh
  69320. * @param scene defines the hosting scene
  69321. * @returns the box mesh
  69322. */
  69323. static CreateBox(name: string, options: {
  69324. size?: number;
  69325. width?: number;
  69326. height?: number;
  69327. depth?: number;
  69328. faceUV?: Vector4[];
  69329. faceColors?: Color4[];
  69330. sideOrientation?: number;
  69331. frontUVs?: Vector4;
  69332. backUVs?: Vector4;
  69333. wrap?: boolean;
  69334. topBaseAt?: number;
  69335. bottomBaseAt?: number;
  69336. updatable?: boolean;
  69337. }, scene?: Nullable<Scene>): Mesh;
  69338. /**
  69339. * Creates a tiled box mesh
  69340. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69342. * @param name defines the name of the mesh
  69343. * @param options defines the options used to create the mesh
  69344. * @param scene defines the hosting scene
  69345. * @returns the tiled box mesh
  69346. */
  69347. static CreateTiledBox(name: string, options: {
  69348. pattern?: number;
  69349. size?: number;
  69350. width?: number;
  69351. height?: number;
  69352. depth: number;
  69353. tileSize?: number;
  69354. tileWidth?: number;
  69355. tileHeight?: number;
  69356. faceUV?: Vector4[];
  69357. faceColors?: Color4[];
  69358. alignHorizontal?: number;
  69359. alignVertical?: number;
  69360. sideOrientation?: number;
  69361. updatable?: boolean;
  69362. }, scene?: Nullable<Scene>): Mesh;
  69363. /**
  69364. * Creates a sphere mesh
  69365. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69366. * * 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`)
  69367. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69368. * * 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
  69369. * * 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)
  69370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69371. * * 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
  69372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69373. * @param name defines the name of the mesh
  69374. * @param options defines the options used to create the mesh
  69375. * @param scene defines the hosting scene
  69376. * @returns the sphere mesh
  69377. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69378. */
  69379. static CreateSphere(name: string, options: {
  69380. segments?: number;
  69381. diameter?: number;
  69382. diameterX?: number;
  69383. diameterY?: number;
  69384. diameterZ?: number;
  69385. arc?: number;
  69386. slice?: number;
  69387. sideOrientation?: number;
  69388. frontUVs?: Vector4;
  69389. backUVs?: Vector4;
  69390. updatable?: boolean;
  69391. }, scene?: Nullable<Scene>): Mesh;
  69392. /**
  69393. * Creates a plane polygonal mesh. By default, this is a disc
  69394. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69395. * * 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
  69396. * * 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
  69397. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69398. * * 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
  69399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69400. * @param name defines the name of the mesh
  69401. * @param options defines the options used to create the mesh
  69402. * @param scene defines the hosting scene
  69403. * @returns the plane polygonal mesh
  69404. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69405. */
  69406. static CreateDisc(name: string, options: {
  69407. radius?: number;
  69408. tessellation?: number;
  69409. arc?: number;
  69410. updatable?: boolean;
  69411. sideOrientation?: number;
  69412. frontUVs?: Vector4;
  69413. backUVs?: Vector4;
  69414. }, scene?: Nullable<Scene>): Mesh;
  69415. /**
  69416. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69417. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69418. * * 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`)
  69419. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69420. * * 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
  69421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69422. * * 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
  69423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69424. * @param name defines the name of the mesh
  69425. * @param options defines the options used to create the mesh
  69426. * @param scene defines the hosting scene
  69427. * @returns the icosahedron mesh
  69428. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69429. */
  69430. static CreateIcoSphere(name: string, options: {
  69431. radius?: number;
  69432. radiusX?: number;
  69433. radiusY?: number;
  69434. radiusZ?: number;
  69435. flat?: boolean;
  69436. subdivisions?: number;
  69437. sideOrientation?: number;
  69438. frontUVs?: Vector4;
  69439. backUVs?: Vector4;
  69440. updatable?: boolean;
  69441. }, scene?: Nullable<Scene>): Mesh;
  69442. /**
  69443. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69444. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69445. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69446. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69447. * * 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
  69448. * * 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
  69449. * * 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
  69450. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69451. * * 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
  69452. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69453. * * 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
  69454. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69455. * * 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
  69456. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69458. * @param name defines the name of the mesh
  69459. * @param options defines the options used to create the mesh
  69460. * @param scene defines the hosting scene
  69461. * @returns the ribbon mesh
  69462. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69463. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69464. */
  69465. static CreateRibbon(name: string, options: {
  69466. pathArray: Vector3[][];
  69467. closeArray?: boolean;
  69468. closePath?: boolean;
  69469. offset?: number;
  69470. updatable?: boolean;
  69471. sideOrientation?: number;
  69472. frontUVs?: Vector4;
  69473. backUVs?: Vector4;
  69474. instance?: Mesh;
  69475. invertUV?: boolean;
  69476. uvs?: Vector2[];
  69477. colors?: Color4[];
  69478. }, scene?: Nullable<Scene>): Mesh;
  69479. /**
  69480. * Creates a cylinder or a cone mesh
  69481. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69482. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69483. * * 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.
  69484. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69485. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69486. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69487. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69488. * * 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).
  69489. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69490. * * 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).
  69491. * * 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
  69492. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69493. * * 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
  69494. * * 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.
  69495. * * If `enclose` is false, a ring surface is one element.
  69496. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69497. * * 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
  69498. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69499. * * 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
  69500. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69501. * @param name defines the name of the mesh
  69502. * @param options defines the options used to create the mesh
  69503. * @param scene defines the hosting scene
  69504. * @returns the cylinder mesh
  69505. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69506. */
  69507. static CreateCylinder(name: string, options: {
  69508. height?: number;
  69509. diameterTop?: number;
  69510. diameterBottom?: number;
  69511. diameter?: number;
  69512. tessellation?: number;
  69513. subdivisions?: number;
  69514. arc?: number;
  69515. faceColors?: Color4[];
  69516. faceUV?: Vector4[];
  69517. updatable?: boolean;
  69518. hasRings?: boolean;
  69519. enclose?: boolean;
  69520. cap?: number;
  69521. sideOrientation?: number;
  69522. frontUVs?: Vector4;
  69523. backUVs?: Vector4;
  69524. }, scene?: Nullable<Scene>): Mesh;
  69525. /**
  69526. * Creates a torus mesh
  69527. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69528. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69529. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  69530. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69531. * * 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
  69532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69533. * @param name defines the name of the mesh
  69534. * @param options defines the options used to create the mesh
  69535. * @param scene defines the hosting scene
  69536. * @returns the torus mesh
  69537. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69538. */
  69539. static CreateTorus(name: string, options: {
  69540. diameter?: number;
  69541. thickness?: number;
  69542. tessellation?: number;
  69543. updatable?: boolean;
  69544. sideOrientation?: number;
  69545. frontUVs?: Vector4;
  69546. backUVs?: Vector4;
  69547. }, scene?: Nullable<Scene>): Mesh;
  69548. /**
  69549. * Creates a torus knot mesh
  69550. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69551. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69552. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69553. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69554. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69555. * * 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
  69556. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69557. * @param name defines the name of the mesh
  69558. * @param options defines the options used to create the mesh
  69559. * @param scene defines the hosting scene
  69560. * @returns the torus knot mesh
  69561. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69562. */
  69563. static CreateTorusKnot(name: string, options: {
  69564. radius?: number;
  69565. tube?: number;
  69566. radialSegments?: number;
  69567. tubularSegments?: number;
  69568. p?: number;
  69569. q?: number;
  69570. updatable?: boolean;
  69571. sideOrientation?: number;
  69572. frontUVs?: Vector4;
  69573. backUVs?: Vector4;
  69574. }, scene?: Nullable<Scene>): Mesh;
  69575. /**
  69576. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69577. * * 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
  69578. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69579. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69580. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69581. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69582. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69583. * * 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
  69584. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69585. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69586. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69587. * @param name defines the name of the new line system
  69588. * @param options defines the options used to create the line system
  69589. * @param scene defines the hosting scene
  69590. * @returns a new line system mesh
  69591. */
  69592. static CreateLineSystem(name: string, options: {
  69593. lines: Vector3[][];
  69594. updatable?: boolean;
  69595. instance?: Nullable<LinesMesh>;
  69596. colors?: Nullable<Color4[][]>;
  69597. useVertexAlpha?: boolean;
  69598. }, scene: Nullable<Scene>): LinesMesh;
  69599. /**
  69600. * Creates a line mesh
  69601. * 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
  69602. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69603. * * The parameter `points` is an array successive Vector3
  69604. * * 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
  69605. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69606. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69607. * * When updating an instance, remember that only point positions can change, not the number of points
  69608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69609. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69610. * @param name defines the name of the new line system
  69611. * @param options defines the options used to create the line system
  69612. * @param scene defines the hosting scene
  69613. * @returns a new line mesh
  69614. */
  69615. static CreateLines(name: string, options: {
  69616. points: Vector3[];
  69617. updatable?: boolean;
  69618. instance?: Nullable<LinesMesh>;
  69619. colors?: Color4[];
  69620. useVertexAlpha?: boolean;
  69621. }, scene?: Nullable<Scene>): LinesMesh;
  69622. /**
  69623. * Creates a dashed line mesh
  69624. * * 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
  69625. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69626. * * The parameter `points` is an array successive Vector3
  69627. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69628. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69629. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69630. * * 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
  69631. * * When updating an instance, remember that only point positions can change, not the number of points
  69632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69633. * @param name defines the name of the mesh
  69634. * @param options defines the options used to create the mesh
  69635. * @param scene defines the hosting scene
  69636. * @returns the dashed line mesh
  69637. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69638. */
  69639. static CreateDashedLines(name: string, options: {
  69640. points: Vector3[];
  69641. dashSize?: number;
  69642. gapSize?: number;
  69643. dashNb?: number;
  69644. updatable?: boolean;
  69645. instance?: LinesMesh;
  69646. }, scene?: Nullable<Scene>): LinesMesh;
  69647. /**
  69648. * 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.
  69649. * * 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.
  69650. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69651. * * 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.
  69652. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69653. * * 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
  69654. * * 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
  69655. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69656. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69657. * * 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
  69658. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69659. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69660. * @param name defines the name of the mesh
  69661. * @param options defines the options used to create the mesh
  69662. * @param scene defines the hosting scene
  69663. * @returns the extruded shape mesh
  69664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69665. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69666. */
  69667. static ExtrudeShape(name: string, options: {
  69668. shape: Vector3[];
  69669. path: Vector3[];
  69670. scale?: number;
  69671. rotation?: number;
  69672. cap?: number;
  69673. updatable?: boolean;
  69674. sideOrientation?: number;
  69675. frontUVs?: Vector4;
  69676. backUVs?: Vector4;
  69677. instance?: Mesh;
  69678. invertUV?: boolean;
  69679. }, scene?: Nullable<Scene>): Mesh;
  69680. /**
  69681. * Creates an custom extruded shape mesh.
  69682. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69683. * * 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.
  69684. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69685. * * 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
  69686. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69687. * * 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
  69688. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69689. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69690. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69691. * * 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
  69692. * * 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
  69693. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69694. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69695. * * 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
  69696. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69697. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69698. * @param name defines the name of the mesh
  69699. * @param options defines the options used to create the mesh
  69700. * @param scene defines the hosting scene
  69701. * @returns the custom extruded shape mesh
  69702. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69703. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69704. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69705. */
  69706. static ExtrudeShapeCustom(name: string, options: {
  69707. shape: Vector3[];
  69708. path: Vector3[];
  69709. scaleFunction?: any;
  69710. rotationFunction?: any;
  69711. ribbonCloseArray?: boolean;
  69712. ribbonClosePath?: boolean;
  69713. cap?: number;
  69714. updatable?: boolean;
  69715. sideOrientation?: number;
  69716. frontUVs?: Vector4;
  69717. backUVs?: Vector4;
  69718. instance?: Mesh;
  69719. invertUV?: boolean;
  69720. }, scene?: Nullable<Scene>): Mesh;
  69721. /**
  69722. * Creates lathe mesh.
  69723. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69724. * * 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
  69725. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69726. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69727. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69728. * * 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
  69729. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69730. * * 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
  69731. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69732. * * 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
  69733. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69735. * @param name defines the name of the mesh
  69736. * @param options defines the options used to create the mesh
  69737. * @param scene defines the hosting scene
  69738. * @returns the lathe mesh
  69739. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69740. */
  69741. static CreateLathe(name: string, options: {
  69742. shape: Vector3[];
  69743. radius?: number;
  69744. tessellation?: number;
  69745. clip?: number;
  69746. arc?: number;
  69747. closed?: boolean;
  69748. updatable?: boolean;
  69749. sideOrientation?: number;
  69750. frontUVs?: Vector4;
  69751. backUVs?: Vector4;
  69752. cap?: number;
  69753. invertUV?: boolean;
  69754. }, scene?: Nullable<Scene>): Mesh;
  69755. /**
  69756. * Creates a tiled plane mesh
  69757. * * You can set a limited pattern arrangement with the tiles
  69758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69759. * * 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
  69760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69761. * @param name defines the name of the mesh
  69762. * @param options defines the options used to create the mesh
  69763. * @param scene defines the hosting scene
  69764. * @returns the plane mesh
  69765. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69766. */
  69767. static CreateTiledPlane(name: string, options: {
  69768. pattern?: number;
  69769. tileSize?: number;
  69770. tileWidth?: number;
  69771. tileHeight?: number;
  69772. size?: number;
  69773. width?: number;
  69774. height?: number;
  69775. alignHorizontal?: number;
  69776. alignVertical?: number;
  69777. sideOrientation?: number;
  69778. frontUVs?: Vector4;
  69779. backUVs?: Vector4;
  69780. updatable?: boolean;
  69781. }, scene?: Nullable<Scene>): Mesh;
  69782. /**
  69783. * Creates a plane mesh
  69784. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69785. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69786. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69788. * * 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
  69789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69790. * @param name defines the name of the mesh
  69791. * @param options defines the options used to create the mesh
  69792. * @param scene defines the hosting scene
  69793. * @returns the plane mesh
  69794. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69795. */
  69796. static CreatePlane(name: string, options: {
  69797. size?: number;
  69798. width?: number;
  69799. height?: number;
  69800. sideOrientation?: number;
  69801. frontUVs?: Vector4;
  69802. backUVs?: Vector4;
  69803. updatable?: boolean;
  69804. sourcePlane?: Plane;
  69805. }, scene?: Nullable<Scene>): Mesh;
  69806. /**
  69807. * Creates a ground mesh
  69808. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  69809. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  69810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69811. * @param name defines the name of the mesh
  69812. * @param options defines the options used to create the mesh
  69813. * @param scene defines the hosting scene
  69814. * @returns the ground mesh
  69815. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  69816. */
  69817. static CreateGround(name: string, options: {
  69818. width?: number;
  69819. height?: number;
  69820. subdivisions?: number;
  69821. subdivisionsX?: number;
  69822. subdivisionsY?: number;
  69823. updatable?: boolean;
  69824. }, scene?: Nullable<Scene>): Mesh;
  69825. /**
  69826. * Creates a tiled ground mesh
  69827. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  69828. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  69829. * * 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
  69830. * * 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
  69831. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69832. * @param name defines the name of the mesh
  69833. * @param options defines the options used to create the mesh
  69834. * @param scene defines the hosting scene
  69835. * @returns the tiled ground mesh
  69836. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  69837. */
  69838. static CreateTiledGround(name: string, options: {
  69839. xmin: number;
  69840. zmin: number;
  69841. xmax: number;
  69842. zmax: number;
  69843. subdivisions?: {
  69844. w: number;
  69845. h: number;
  69846. };
  69847. precision?: {
  69848. w: number;
  69849. h: number;
  69850. };
  69851. updatable?: boolean;
  69852. }, scene?: Nullable<Scene>): Mesh;
  69853. /**
  69854. * Creates a ground mesh from a height map
  69855. * * The parameter `url` sets the URL of the height map image resource.
  69856. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  69857. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  69858. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  69859. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  69860. * * 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.
  69861. * * 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).
  69862. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  69863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69864. * @param name defines the name of the mesh
  69865. * @param url defines the url to the height map
  69866. * @param options defines the options used to create the mesh
  69867. * @param scene defines the hosting scene
  69868. * @returns the ground mesh
  69869. * @see https://doc.babylonjs.com/babylon101/height_map
  69870. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  69871. */
  69872. static CreateGroundFromHeightMap(name: string, url: string, options: {
  69873. width?: number;
  69874. height?: number;
  69875. subdivisions?: number;
  69876. minHeight?: number;
  69877. maxHeight?: number;
  69878. colorFilter?: Color3;
  69879. alphaFilter?: number;
  69880. updatable?: boolean;
  69881. onReady?: (mesh: GroundMesh) => void;
  69882. }, scene?: Nullable<Scene>): GroundMesh;
  69883. /**
  69884. * Creates a polygon mesh
  69885. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69886. * * 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
  69887. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69889. * * 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)
  69890. * * Remember you can only change the shape positions, not their number when updating a polygon
  69891. * @param name defines the name of the mesh
  69892. * @param options defines the options used to create the mesh
  69893. * @param scene defines the hosting scene
  69894. * @param earcutInjection can be used to inject your own earcut reference
  69895. * @returns the polygon mesh
  69896. */
  69897. static CreatePolygon(name: string, options: {
  69898. shape: Vector3[];
  69899. holes?: Vector3[][];
  69900. depth?: number;
  69901. faceUV?: Vector4[];
  69902. faceColors?: Color4[];
  69903. updatable?: boolean;
  69904. sideOrientation?: number;
  69905. frontUVs?: Vector4;
  69906. backUVs?: Vector4;
  69907. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69908. /**
  69909. * Creates an extruded polygon mesh, with depth in the Y direction.
  69910. * * 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)
  69911. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69912. * @param name defines the name of the mesh
  69913. * @param options defines the options used to create the mesh
  69914. * @param scene defines the hosting scene
  69915. * @param earcutInjection can be used to inject your own earcut reference
  69916. * @returns the polygon mesh
  69917. */
  69918. static ExtrudePolygon(name: string, options: {
  69919. shape: Vector3[];
  69920. holes?: Vector3[][];
  69921. depth?: number;
  69922. faceUV?: Vector4[];
  69923. faceColors?: Color4[];
  69924. updatable?: boolean;
  69925. sideOrientation?: number;
  69926. frontUVs?: Vector4;
  69927. backUVs?: Vector4;
  69928. wrap?: boolean;
  69929. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69930. /**
  69931. * Creates a tube mesh.
  69932. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69933. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69934. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69935. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69936. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69937. * * 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)
  69938. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69939. * * 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
  69940. * * 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
  69941. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69942. * * 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
  69943. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69945. * @param name defines the name of the mesh
  69946. * @param options defines the options used to create the mesh
  69947. * @param scene defines the hosting scene
  69948. * @returns the tube mesh
  69949. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69950. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69951. */
  69952. static CreateTube(name: string, options: {
  69953. path: Vector3[];
  69954. radius?: number;
  69955. tessellation?: number;
  69956. radiusFunction?: {
  69957. (i: number, distance: number): number;
  69958. };
  69959. cap?: number;
  69960. arc?: number;
  69961. updatable?: boolean;
  69962. sideOrientation?: number;
  69963. frontUVs?: Vector4;
  69964. backUVs?: Vector4;
  69965. instance?: Mesh;
  69966. invertUV?: boolean;
  69967. }, scene?: Nullable<Scene>): Mesh;
  69968. /**
  69969. * Creates a polyhedron mesh
  69970. * * 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
  69971. * * The parameter `size` (positive float, default 1) sets the polygon size
  69972. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  69973. * * 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`
  69974. * * 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
  69975. * * 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)`)
  69976. * * 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
  69977. * * 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
  69978. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69979. * * 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
  69980. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69981. * @param name defines the name of the mesh
  69982. * @param options defines the options used to create the mesh
  69983. * @param scene defines the hosting scene
  69984. * @returns the polyhedron mesh
  69985. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  69986. */
  69987. static CreatePolyhedron(name: string, options: {
  69988. type?: number;
  69989. size?: number;
  69990. sizeX?: number;
  69991. sizeY?: number;
  69992. sizeZ?: number;
  69993. custom?: any;
  69994. faceUV?: Vector4[];
  69995. faceColors?: Color4[];
  69996. flat?: boolean;
  69997. updatable?: boolean;
  69998. sideOrientation?: number;
  69999. frontUVs?: Vector4;
  70000. backUVs?: Vector4;
  70001. }, scene?: Nullable<Scene>): Mesh;
  70002. /**
  70003. * Creates a decal mesh.
  70004. * 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
  70005. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70006. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70007. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70008. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70009. * @param name defines the name of the mesh
  70010. * @param sourceMesh defines the mesh where the decal must be applied
  70011. * @param options defines the options used to create the mesh
  70012. * @param scene defines the hosting scene
  70013. * @returns the decal mesh
  70014. * @see https://doc.babylonjs.com/how_to/decals
  70015. */
  70016. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70017. position?: Vector3;
  70018. normal?: Vector3;
  70019. size?: Vector3;
  70020. angle?: number;
  70021. }): Mesh;
  70022. /**
  70023. * Creates a Capsule Mesh
  70024. * @param name defines the name of the mesh.
  70025. * @param options the constructors options used to shape the mesh.
  70026. * @param scene defines the scene the mesh is scoped to.
  70027. * @returns the capsule mesh
  70028. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70029. */
  70030. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70031. }
  70032. }
  70033. declare module "babylonjs/Meshes/meshSimplification" {
  70034. import { Mesh } from "babylonjs/Meshes/mesh";
  70035. /**
  70036. * A simplifier interface for future simplification implementations
  70037. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70038. */
  70039. export interface ISimplifier {
  70040. /**
  70041. * Simplification of a given mesh according to the given settings.
  70042. * Since this requires computation, it is assumed that the function runs async.
  70043. * @param settings The settings of the simplification, including quality and distance
  70044. * @param successCallback A callback that will be called after the mesh was simplified.
  70045. * @param errorCallback in case of an error, this callback will be called. optional.
  70046. */
  70047. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70048. }
  70049. /**
  70050. * Expected simplification settings.
  70051. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70052. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70053. */
  70054. export interface ISimplificationSettings {
  70055. /**
  70056. * Gets or sets the expected quality
  70057. */
  70058. quality: number;
  70059. /**
  70060. * Gets or sets the distance when this optimized version should be used
  70061. */
  70062. distance: number;
  70063. /**
  70064. * Gets an already optimized mesh
  70065. */
  70066. optimizeMesh?: boolean;
  70067. }
  70068. /**
  70069. * Class used to specify simplification options
  70070. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70071. */
  70072. export class SimplificationSettings implements ISimplificationSettings {
  70073. /** expected quality */
  70074. quality: number;
  70075. /** distance when this optimized version should be used */
  70076. distance: number;
  70077. /** already optimized mesh */
  70078. optimizeMesh?: boolean | undefined;
  70079. /**
  70080. * Creates a SimplificationSettings
  70081. * @param quality expected quality
  70082. * @param distance distance when this optimized version should be used
  70083. * @param optimizeMesh already optimized mesh
  70084. */
  70085. constructor(
  70086. /** expected quality */
  70087. quality: number,
  70088. /** distance when this optimized version should be used */
  70089. distance: number,
  70090. /** already optimized mesh */
  70091. optimizeMesh?: boolean | undefined);
  70092. }
  70093. /**
  70094. * Interface used to define a simplification task
  70095. */
  70096. export interface ISimplificationTask {
  70097. /**
  70098. * Array of settings
  70099. */
  70100. settings: Array<ISimplificationSettings>;
  70101. /**
  70102. * Simplification type
  70103. */
  70104. simplificationType: SimplificationType;
  70105. /**
  70106. * Mesh to simplify
  70107. */
  70108. mesh: Mesh;
  70109. /**
  70110. * Callback called on success
  70111. */
  70112. successCallback?: () => void;
  70113. /**
  70114. * Defines if parallel processing can be used
  70115. */
  70116. parallelProcessing: boolean;
  70117. }
  70118. /**
  70119. * Queue used to order the simplification tasks
  70120. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70121. */
  70122. export class SimplificationQueue {
  70123. private _simplificationArray;
  70124. /**
  70125. * Gets a boolean indicating that the process is still running
  70126. */
  70127. running: boolean;
  70128. /**
  70129. * Creates a new queue
  70130. */
  70131. constructor();
  70132. /**
  70133. * Adds a new simplification task
  70134. * @param task defines a task to add
  70135. */
  70136. addTask(task: ISimplificationTask): void;
  70137. /**
  70138. * Execute next task
  70139. */
  70140. executeNext(): void;
  70141. /**
  70142. * Execute a simplification task
  70143. * @param task defines the task to run
  70144. */
  70145. runSimplification(task: ISimplificationTask): void;
  70146. private getSimplifier;
  70147. }
  70148. /**
  70149. * The implemented types of simplification
  70150. * At the moment only Quadratic Error Decimation is implemented
  70151. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70152. */
  70153. export enum SimplificationType {
  70154. /** Quadratic error decimation */
  70155. QUADRATIC = 0
  70156. }
  70157. /**
  70158. * An implementation of the Quadratic Error simplification algorithm.
  70159. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70160. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70161. * @author RaananW
  70162. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70163. */
  70164. export class QuadraticErrorSimplification implements ISimplifier {
  70165. private _mesh;
  70166. private triangles;
  70167. private vertices;
  70168. private references;
  70169. private _reconstructedMesh;
  70170. /** Gets or sets the number pf sync interations */
  70171. syncIterations: number;
  70172. /** Gets or sets the aggressiveness of the simplifier */
  70173. aggressiveness: number;
  70174. /** Gets or sets the number of allowed iterations for decimation */
  70175. decimationIterations: number;
  70176. /** Gets or sets the espilon to use for bounding box computation */
  70177. boundingBoxEpsilon: number;
  70178. /**
  70179. * Creates a new QuadraticErrorSimplification
  70180. * @param _mesh defines the target mesh
  70181. */
  70182. constructor(_mesh: Mesh);
  70183. /**
  70184. * Simplification of a given mesh according to the given settings.
  70185. * Since this requires computation, it is assumed that the function runs async.
  70186. * @param settings The settings of the simplification, including quality and distance
  70187. * @param successCallback A callback that will be called after the mesh was simplified.
  70188. */
  70189. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70190. private runDecimation;
  70191. private initWithMesh;
  70192. private init;
  70193. private reconstructMesh;
  70194. private initDecimatedMesh;
  70195. private isFlipped;
  70196. private updateTriangles;
  70197. private identifyBorder;
  70198. private updateMesh;
  70199. private vertexError;
  70200. private calculateError;
  70201. }
  70202. }
  70203. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70204. import { Scene } from "babylonjs/scene";
  70205. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70206. import { ISceneComponent } from "babylonjs/sceneComponent";
  70207. module "babylonjs/scene" {
  70208. interface Scene {
  70209. /** @hidden (Backing field) */
  70210. _simplificationQueue: SimplificationQueue;
  70211. /**
  70212. * Gets or sets the simplification queue attached to the scene
  70213. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70214. */
  70215. simplificationQueue: SimplificationQueue;
  70216. }
  70217. }
  70218. module "babylonjs/Meshes/mesh" {
  70219. interface Mesh {
  70220. /**
  70221. * Simplify the mesh according to the given array of settings.
  70222. * Function will return immediately and will simplify async
  70223. * @param settings a collection of simplification settings
  70224. * @param parallelProcessing should all levels calculate parallel or one after the other
  70225. * @param simplificationType the type of simplification to run
  70226. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70227. * @returns the current mesh
  70228. */
  70229. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70230. }
  70231. }
  70232. /**
  70233. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70234. * created in a scene
  70235. */
  70236. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70237. /**
  70238. * The component name helpfull to identify the component in the list of scene components.
  70239. */
  70240. readonly name: string;
  70241. /**
  70242. * The scene the component belongs to.
  70243. */
  70244. scene: Scene;
  70245. /**
  70246. * Creates a new instance of the component for the given scene
  70247. * @param scene Defines the scene to register the component in
  70248. */
  70249. constructor(scene: Scene);
  70250. /**
  70251. * Registers the component in a given scene
  70252. */
  70253. register(): void;
  70254. /**
  70255. * Rebuilds the elements related to this component in case of
  70256. * context lost for instance.
  70257. */
  70258. rebuild(): void;
  70259. /**
  70260. * Disposes the component and the associated ressources
  70261. */
  70262. dispose(): void;
  70263. private _beforeCameraUpdate;
  70264. }
  70265. }
  70266. declare module "babylonjs/Meshes/Builders/index" {
  70267. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70268. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70269. export * from "babylonjs/Meshes/Builders/discBuilder";
  70270. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70271. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70272. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70273. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70274. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70275. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70276. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70277. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70278. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70279. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70280. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70281. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70282. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70283. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70284. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70285. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70286. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70287. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70288. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70289. }
  70290. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70291. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70292. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70293. import { Matrix } from "babylonjs/Maths/math.vector";
  70294. module "babylonjs/Meshes/mesh" {
  70295. interface Mesh {
  70296. /**
  70297. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70298. */
  70299. thinInstanceEnablePicking: boolean;
  70300. /**
  70301. * Creates a new thin instance
  70302. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70303. * @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
  70304. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70305. */
  70306. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70307. /**
  70308. * Adds the transformation (matrix) of the current mesh as a thin instance
  70309. * @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
  70310. * @returns the thin instance index number
  70311. */
  70312. thinInstanceAddSelf(refresh: boolean): number;
  70313. /**
  70314. * Registers a custom attribute to be used with thin instances
  70315. * @param kind name of the attribute
  70316. * @param stride size in floats of the attribute
  70317. */
  70318. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70319. /**
  70320. * Sets the matrix of a thin instance
  70321. * @param index index of the thin instance
  70322. * @param matrix matrix to set
  70323. * @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
  70324. */
  70325. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70326. /**
  70327. * Sets the value of a custom attribute for a thin instance
  70328. * @param kind name of the attribute
  70329. * @param index index of the thin instance
  70330. * @param value value to set
  70331. * @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
  70332. */
  70333. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70334. /**
  70335. * 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.
  70336. */
  70337. thinInstanceCount: number;
  70338. /**
  70339. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70340. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70341. * @param buffer buffer to set
  70342. * @param stride size in floats of each value of the buffer
  70343. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70344. */
  70345. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70346. /**
  70347. * Gets the list of world matrices
  70348. * @return an array containing all the world matrices from the thin instances
  70349. */
  70350. thinInstanceGetWorldMatrices(): Matrix[];
  70351. /**
  70352. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70353. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70354. */
  70355. thinInstanceBufferUpdated(kind: string): void;
  70356. /**
  70357. * Applies a partial update to a buffer directly on the GPU
  70358. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  70359. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70360. * @param data the data to set in the GPU buffer
  70361. * @param offset the offset in the GPU buffer where to update the data
  70362. */
  70363. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70364. /**
  70365. * Refreshes the bounding info, taking into account all the thin instances defined
  70366. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70367. */
  70368. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70369. /** @hidden */
  70370. _thinInstanceInitializeUserStorage(): void;
  70371. /** @hidden */
  70372. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70373. /** @hidden */
  70374. _userThinInstanceBuffersStorage: {
  70375. data: {
  70376. [key: string]: Float32Array;
  70377. };
  70378. sizes: {
  70379. [key: string]: number;
  70380. };
  70381. vertexBuffers: {
  70382. [key: string]: Nullable<VertexBuffer>;
  70383. };
  70384. strides: {
  70385. [key: string]: number;
  70386. };
  70387. };
  70388. }
  70389. }
  70390. }
  70391. declare module "babylonjs/Meshes/index" {
  70392. export * from "babylonjs/Meshes/abstractMesh";
  70393. export * from "babylonjs/Meshes/buffer";
  70394. export * from "babylonjs/Meshes/Compression/index";
  70395. export * from "babylonjs/Meshes/csg";
  70396. export * from "babylonjs/Meshes/geometry";
  70397. export * from "babylonjs/Meshes/groundMesh";
  70398. export * from "babylonjs/Meshes/trailMesh";
  70399. export * from "babylonjs/Meshes/instancedMesh";
  70400. export * from "babylonjs/Meshes/linesMesh";
  70401. export * from "babylonjs/Meshes/mesh";
  70402. export * from "babylonjs/Meshes/mesh.vertexData";
  70403. export * from "babylonjs/Meshes/meshBuilder";
  70404. export * from "babylonjs/Meshes/meshSimplification";
  70405. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70406. export * from "babylonjs/Meshes/polygonMesh";
  70407. export * from "babylonjs/Meshes/subMesh";
  70408. export * from "babylonjs/Meshes/meshLODLevel";
  70409. export * from "babylonjs/Meshes/transformNode";
  70410. export * from "babylonjs/Meshes/Builders/index";
  70411. export * from "babylonjs/Meshes/dataBuffer";
  70412. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70413. import "babylonjs/Meshes/thinInstanceMesh";
  70414. export * from "babylonjs/Meshes/thinInstanceMesh";
  70415. }
  70416. declare module "babylonjs/Morph/index" {
  70417. export * from "babylonjs/Morph/morphTarget";
  70418. export * from "babylonjs/Morph/morphTargetManager";
  70419. }
  70420. declare module "babylonjs/Navigation/INavigationEngine" {
  70421. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70422. import { Vector3 } from "babylonjs/Maths/math";
  70423. import { Mesh } from "babylonjs/Meshes/mesh";
  70424. import { Scene } from "babylonjs/scene";
  70425. /**
  70426. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70427. */
  70428. export interface INavigationEnginePlugin {
  70429. /**
  70430. * plugin name
  70431. */
  70432. name: string;
  70433. /**
  70434. * Creates a navigation mesh
  70435. * @param meshes array of all the geometry used to compute the navigatio mesh
  70436. * @param parameters bunch of parameters used to filter geometry
  70437. */
  70438. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70439. /**
  70440. * Create a navigation mesh debug mesh
  70441. * @param scene is where the mesh will be added
  70442. * @returns debug display mesh
  70443. */
  70444. createDebugNavMesh(scene: Scene): Mesh;
  70445. /**
  70446. * Get a navigation mesh constrained position, closest to the parameter position
  70447. * @param position world position
  70448. * @returns the closest point to position constrained by the navigation mesh
  70449. */
  70450. getClosestPoint(position: Vector3): Vector3;
  70451. /**
  70452. * Get a navigation mesh constrained position, closest to the parameter position
  70453. * @param position world position
  70454. * @param result output the closest point to position constrained by the navigation mesh
  70455. */
  70456. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70457. /**
  70458. * Get a navigation mesh constrained position, within a particular radius
  70459. * @param position world position
  70460. * @param maxRadius the maximum distance to the constrained world position
  70461. * @returns the closest point to position constrained by the navigation mesh
  70462. */
  70463. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70464. /**
  70465. * Get a navigation mesh constrained position, within a particular radius
  70466. * @param position world position
  70467. * @param maxRadius the maximum distance to the constrained world position
  70468. * @param result output the closest point to position constrained by the navigation mesh
  70469. */
  70470. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70471. /**
  70472. * Compute the final position from a segment made of destination-position
  70473. * @param position world position
  70474. * @param destination world position
  70475. * @returns the resulting point along the navmesh
  70476. */
  70477. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70478. /**
  70479. * Compute the final position from a segment made of destination-position
  70480. * @param position world position
  70481. * @param destination world position
  70482. * @param result output the resulting point along the navmesh
  70483. */
  70484. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70485. /**
  70486. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70487. * @param start world position
  70488. * @param end world position
  70489. * @returns array containing world position composing the path
  70490. */
  70491. computePath(start: Vector3, end: Vector3): Vector3[];
  70492. /**
  70493. * If this plugin is supported
  70494. * @returns true if plugin is supported
  70495. */
  70496. isSupported(): boolean;
  70497. /**
  70498. * Create a new Crowd so you can add agents
  70499. * @param maxAgents the maximum agent count in the crowd
  70500. * @param maxAgentRadius the maximum radius an agent can have
  70501. * @param scene to attach the crowd to
  70502. * @returns the crowd you can add agents to
  70503. */
  70504. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70505. /**
  70506. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70507. * The queries will try to find a solution within those bounds
  70508. * default is (1,1,1)
  70509. * @param extent x,y,z value that define the extent around the queries point of reference
  70510. */
  70511. setDefaultQueryExtent(extent: Vector3): void;
  70512. /**
  70513. * Get the Bounding box extent specified by setDefaultQueryExtent
  70514. * @returns the box extent values
  70515. */
  70516. getDefaultQueryExtent(): Vector3;
  70517. /**
  70518. * build the navmesh from a previously saved state using getNavmeshData
  70519. * @param data the Uint8Array returned by getNavmeshData
  70520. */
  70521. buildFromNavmeshData(data: Uint8Array): void;
  70522. /**
  70523. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70524. * @returns data the Uint8Array that can be saved and reused
  70525. */
  70526. getNavmeshData(): Uint8Array;
  70527. /**
  70528. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70529. * @param result output the box extent values
  70530. */
  70531. getDefaultQueryExtentToRef(result: Vector3): void;
  70532. /**
  70533. * Release all resources
  70534. */
  70535. dispose(): void;
  70536. }
  70537. /**
  70538. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70539. */
  70540. export interface ICrowd {
  70541. /**
  70542. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70543. * You can attach anything to that node. The node position is updated in the scene update tick.
  70544. * @param pos world position that will be constrained by the navigation mesh
  70545. * @param parameters agent parameters
  70546. * @param transform hooked to the agent that will be update by the scene
  70547. * @returns agent index
  70548. */
  70549. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70550. /**
  70551. * Returns the agent position in world space
  70552. * @param index agent index returned by addAgent
  70553. * @returns world space position
  70554. */
  70555. getAgentPosition(index: number): Vector3;
  70556. /**
  70557. * Gets the agent position result in world space
  70558. * @param index agent index returned by addAgent
  70559. * @param result output world space position
  70560. */
  70561. getAgentPositionToRef(index: number, result: Vector3): void;
  70562. /**
  70563. * Gets the agent velocity in world space
  70564. * @param index agent index returned by addAgent
  70565. * @returns world space velocity
  70566. */
  70567. getAgentVelocity(index: number): Vector3;
  70568. /**
  70569. * Gets the agent velocity result in world space
  70570. * @param index agent index returned by addAgent
  70571. * @param result output world space velocity
  70572. */
  70573. getAgentVelocityToRef(index: number, result: Vector3): void;
  70574. /**
  70575. * remove a particular agent previously created
  70576. * @param index agent index returned by addAgent
  70577. */
  70578. removeAgent(index: number): void;
  70579. /**
  70580. * get the list of all agents attached to this crowd
  70581. * @returns list of agent indices
  70582. */
  70583. getAgents(): number[];
  70584. /**
  70585. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70586. * @param deltaTime in seconds
  70587. */
  70588. update(deltaTime: number): void;
  70589. /**
  70590. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70591. * @param index agent index returned by addAgent
  70592. * @param destination targeted world position
  70593. */
  70594. agentGoto(index: number, destination: Vector3): void;
  70595. /**
  70596. * Teleport the agent to a new position
  70597. * @param index agent index returned by addAgent
  70598. * @param destination targeted world position
  70599. */
  70600. agentTeleport(index: number, destination: Vector3): void;
  70601. /**
  70602. * Update agent parameters
  70603. * @param index agent index returned by addAgent
  70604. * @param parameters agent parameters
  70605. */
  70606. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70607. /**
  70608. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70609. * The queries will try to find a solution within those bounds
  70610. * default is (1,1,1)
  70611. * @param extent x,y,z value that define the extent around the queries point of reference
  70612. */
  70613. setDefaultQueryExtent(extent: Vector3): void;
  70614. /**
  70615. * Get the Bounding box extent specified by setDefaultQueryExtent
  70616. * @returns the box extent values
  70617. */
  70618. getDefaultQueryExtent(): Vector3;
  70619. /**
  70620. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70621. * @param result output the box extent values
  70622. */
  70623. getDefaultQueryExtentToRef(result: Vector3): void;
  70624. /**
  70625. * Release all resources
  70626. */
  70627. dispose(): void;
  70628. }
  70629. /**
  70630. * Configures an agent
  70631. */
  70632. export interface IAgentParameters {
  70633. /**
  70634. * Agent radius. [Limit: >= 0]
  70635. */
  70636. radius: number;
  70637. /**
  70638. * Agent height. [Limit: > 0]
  70639. */
  70640. height: number;
  70641. /**
  70642. * Maximum allowed acceleration. [Limit: >= 0]
  70643. */
  70644. maxAcceleration: number;
  70645. /**
  70646. * Maximum allowed speed. [Limit: >= 0]
  70647. */
  70648. maxSpeed: number;
  70649. /**
  70650. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70651. */
  70652. collisionQueryRange: number;
  70653. /**
  70654. * The path visibility optimization range. [Limit: > 0]
  70655. */
  70656. pathOptimizationRange: number;
  70657. /**
  70658. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70659. */
  70660. separationWeight: number;
  70661. }
  70662. /**
  70663. * Configures the navigation mesh creation
  70664. */
  70665. export interface INavMeshParameters {
  70666. /**
  70667. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70668. */
  70669. cs: number;
  70670. /**
  70671. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70672. */
  70673. ch: number;
  70674. /**
  70675. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70676. */
  70677. walkableSlopeAngle: number;
  70678. /**
  70679. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70680. * be considered walkable. [Limit: >= 3] [Units: vx]
  70681. */
  70682. walkableHeight: number;
  70683. /**
  70684. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70685. */
  70686. walkableClimb: number;
  70687. /**
  70688. * The distance to erode/shrink the walkable area of the heightfield away from
  70689. * obstructions. [Limit: >=0] [Units: vx]
  70690. */
  70691. walkableRadius: number;
  70692. /**
  70693. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70694. */
  70695. maxEdgeLen: number;
  70696. /**
  70697. * The maximum distance a simplfied contour's border edges should deviate
  70698. * the original raw contour. [Limit: >=0] [Units: vx]
  70699. */
  70700. maxSimplificationError: number;
  70701. /**
  70702. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70703. */
  70704. minRegionArea: number;
  70705. /**
  70706. * Any regions with a span count smaller than this value will, if possible,
  70707. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70708. */
  70709. mergeRegionArea: number;
  70710. /**
  70711. * The maximum number of vertices allowed for polygons generated during the
  70712. * contour to polygon conversion process. [Limit: >= 3]
  70713. */
  70714. maxVertsPerPoly: number;
  70715. /**
  70716. * Sets the sampling distance to use when generating the detail mesh.
  70717. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70718. */
  70719. detailSampleDist: number;
  70720. /**
  70721. * The maximum distance the detail mesh surface should deviate from heightfield
  70722. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70723. */
  70724. detailSampleMaxError: number;
  70725. }
  70726. }
  70727. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70728. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70729. import { Mesh } from "babylonjs/Meshes/mesh";
  70730. import { Scene } from "babylonjs/scene";
  70731. import { Vector3 } from "babylonjs/Maths/math";
  70732. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70733. /**
  70734. * RecastJS navigation plugin
  70735. */
  70736. export class RecastJSPlugin implements INavigationEnginePlugin {
  70737. /**
  70738. * Reference to the Recast library
  70739. */
  70740. bjsRECAST: any;
  70741. /**
  70742. * plugin name
  70743. */
  70744. name: string;
  70745. /**
  70746. * the first navmesh created. We might extend this to support multiple navmeshes
  70747. */
  70748. navMesh: any;
  70749. /**
  70750. * Initializes the recastJS plugin
  70751. * @param recastInjection can be used to inject your own recast reference
  70752. */
  70753. constructor(recastInjection?: any);
  70754. /**
  70755. * Creates a navigation mesh
  70756. * @param meshes array of all the geometry used to compute the navigatio mesh
  70757. * @param parameters bunch of parameters used to filter geometry
  70758. */
  70759. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70760. /**
  70761. * Create a navigation mesh debug mesh
  70762. * @param scene is where the mesh will be added
  70763. * @returns debug display mesh
  70764. */
  70765. createDebugNavMesh(scene: Scene): Mesh;
  70766. /**
  70767. * Get a navigation mesh constrained position, closest to the parameter position
  70768. * @param position world position
  70769. * @returns the closest point to position constrained by the navigation mesh
  70770. */
  70771. getClosestPoint(position: Vector3): Vector3;
  70772. /**
  70773. * Get a navigation mesh constrained position, closest to the parameter position
  70774. * @param position world position
  70775. * @param result output the closest point to position constrained by the navigation mesh
  70776. */
  70777. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70778. /**
  70779. * Get a navigation mesh constrained position, within a particular radius
  70780. * @param position world position
  70781. * @param maxRadius the maximum distance to the constrained world position
  70782. * @returns the closest point to position constrained by the navigation mesh
  70783. */
  70784. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70785. /**
  70786. * Get a navigation mesh constrained position, within a particular radius
  70787. * @param position world position
  70788. * @param maxRadius the maximum distance to the constrained world position
  70789. * @param result output the closest point to position constrained by the navigation mesh
  70790. */
  70791. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70792. /**
  70793. * Compute the final position from a segment made of destination-position
  70794. * @param position world position
  70795. * @param destination world position
  70796. * @returns the resulting point along the navmesh
  70797. */
  70798. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70799. /**
  70800. * Compute the final position from a segment made of destination-position
  70801. * @param position world position
  70802. * @param destination world position
  70803. * @param result output the resulting point along the navmesh
  70804. */
  70805. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70806. /**
  70807. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70808. * @param start world position
  70809. * @param end world position
  70810. * @returns array containing world position composing the path
  70811. */
  70812. computePath(start: Vector3, end: Vector3): Vector3[];
  70813. /**
  70814. * Create a new Crowd so you can add agents
  70815. * @param maxAgents the maximum agent count in the crowd
  70816. * @param maxAgentRadius the maximum radius an agent can have
  70817. * @param scene to attach the crowd to
  70818. * @returns the crowd you can add agents to
  70819. */
  70820. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70821. /**
  70822. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70823. * The queries will try to find a solution within those bounds
  70824. * default is (1,1,1)
  70825. * @param extent x,y,z value that define the extent around the queries point of reference
  70826. */
  70827. setDefaultQueryExtent(extent: Vector3): void;
  70828. /**
  70829. * Get the Bounding box extent specified by setDefaultQueryExtent
  70830. * @returns the box extent values
  70831. */
  70832. getDefaultQueryExtent(): Vector3;
  70833. /**
  70834. * build the navmesh from a previously saved state using getNavmeshData
  70835. * @param data the Uint8Array returned by getNavmeshData
  70836. */
  70837. buildFromNavmeshData(data: Uint8Array): void;
  70838. /**
  70839. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70840. * @returns data the Uint8Array that can be saved and reused
  70841. */
  70842. getNavmeshData(): Uint8Array;
  70843. /**
  70844. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70845. * @param result output the box extent values
  70846. */
  70847. getDefaultQueryExtentToRef(result: Vector3): void;
  70848. /**
  70849. * Disposes
  70850. */
  70851. dispose(): void;
  70852. /**
  70853. * If this plugin is supported
  70854. * @returns true if plugin is supported
  70855. */
  70856. isSupported(): boolean;
  70857. }
  70858. /**
  70859. * Recast detour crowd implementation
  70860. */
  70861. export class RecastJSCrowd implements ICrowd {
  70862. /**
  70863. * Recast/detour plugin
  70864. */
  70865. bjsRECASTPlugin: RecastJSPlugin;
  70866. /**
  70867. * Link to the detour crowd
  70868. */
  70869. recastCrowd: any;
  70870. /**
  70871. * One transform per agent
  70872. */
  70873. transforms: TransformNode[];
  70874. /**
  70875. * All agents created
  70876. */
  70877. agents: number[];
  70878. /**
  70879. * Link to the scene is kept to unregister the crowd from the scene
  70880. */
  70881. private _scene;
  70882. /**
  70883. * Observer for crowd updates
  70884. */
  70885. private _onBeforeAnimationsObserver;
  70886. /**
  70887. * Constructor
  70888. * @param plugin recastJS plugin
  70889. * @param maxAgents the maximum agent count in the crowd
  70890. * @param maxAgentRadius the maximum radius an agent can have
  70891. * @param scene to attach the crowd to
  70892. * @returns the crowd you can add agents to
  70893. */
  70894. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  70895. /**
  70896. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70897. * You can attach anything to that node. The node position is updated in the scene update tick.
  70898. * @param pos world position that will be constrained by the navigation mesh
  70899. * @param parameters agent parameters
  70900. * @param transform hooked to the agent that will be update by the scene
  70901. * @returns agent index
  70902. */
  70903. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70904. /**
  70905. * Returns the agent position in world space
  70906. * @param index agent index returned by addAgent
  70907. * @returns world space position
  70908. */
  70909. getAgentPosition(index: number): Vector3;
  70910. /**
  70911. * Returns the agent position result in world space
  70912. * @param index agent index returned by addAgent
  70913. * @param result output world space position
  70914. */
  70915. getAgentPositionToRef(index: number, result: Vector3): void;
  70916. /**
  70917. * Returns the agent velocity in world space
  70918. * @param index agent index returned by addAgent
  70919. * @returns world space velocity
  70920. */
  70921. getAgentVelocity(index: number): Vector3;
  70922. /**
  70923. * Returns the agent velocity result in world space
  70924. * @param index agent index returned by addAgent
  70925. * @param result output world space velocity
  70926. */
  70927. getAgentVelocityToRef(index: number, result: Vector3): void;
  70928. /**
  70929. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70930. * @param index agent index returned by addAgent
  70931. * @param destination targeted world position
  70932. */
  70933. agentGoto(index: number, destination: Vector3): void;
  70934. /**
  70935. * Teleport the agent to a new position
  70936. * @param index agent index returned by addAgent
  70937. * @param destination targeted world position
  70938. */
  70939. agentTeleport(index: number, destination: Vector3): void;
  70940. /**
  70941. * Update agent parameters
  70942. * @param index agent index returned by addAgent
  70943. * @param parameters agent parameters
  70944. */
  70945. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70946. /**
  70947. * remove a particular agent previously created
  70948. * @param index agent index returned by addAgent
  70949. */
  70950. removeAgent(index: number): void;
  70951. /**
  70952. * get the list of all agents attached to this crowd
  70953. * @returns list of agent indices
  70954. */
  70955. getAgents(): number[];
  70956. /**
  70957. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70958. * @param deltaTime in seconds
  70959. */
  70960. update(deltaTime: number): void;
  70961. /**
  70962. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70963. * The queries will try to find a solution within those bounds
  70964. * default is (1,1,1)
  70965. * @param extent x,y,z value that define the extent around the queries point of reference
  70966. */
  70967. setDefaultQueryExtent(extent: Vector3): void;
  70968. /**
  70969. * Get the Bounding box extent specified by setDefaultQueryExtent
  70970. * @returns the box extent values
  70971. */
  70972. getDefaultQueryExtent(): Vector3;
  70973. /**
  70974. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70975. * @param result output the box extent values
  70976. */
  70977. getDefaultQueryExtentToRef(result: Vector3): void;
  70978. /**
  70979. * Release all resources
  70980. */
  70981. dispose(): void;
  70982. }
  70983. }
  70984. declare module "babylonjs/Navigation/Plugins/index" {
  70985. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  70986. }
  70987. declare module "babylonjs/Navigation/index" {
  70988. export * from "babylonjs/Navigation/INavigationEngine";
  70989. export * from "babylonjs/Navigation/Plugins/index";
  70990. }
  70991. declare module "babylonjs/Offline/database" {
  70992. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  70993. /**
  70994. * Class used to enable access to IndexedDB
  70995. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  70996. */
  70997. export class Database implements IOfflineProvider {
  70998. private _callbackManifestChecked;
  70999. private _currentSceneUrl;
  71000. private _db;
  71001. private _enableSceneOffline;
  71002. private _enableTexturesOffline;
  71003. private _manifestVersionFound;
  71004. private _mustUpdateRessources;
  71005. private _hasReachedQuota;
  71006. private _isSupported;
  71007. private _idbFactory;
  71008. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71009. private static IsUASupportingBlobStorage;
  71010. /**
  71011. * Gets a boolean indicating if Database storate is enabled (off by default)
  71012. */
  71013. static IDBStorageEnabled: boolean;
  71014. /**
  71015. * Gets a boolean indicating if scene must be saved in the database
  71016. */
  71017. get enableSceneOffline(): boolean;
  71018. /**
  71019. * Gets a boolean indicating if textures must be saved in the database
  71020. */
  71021. get enableTexturesOffline(): boolean;
  71022. /**
  71023. * Creates a new Database
  71024. * @param urlToScene defines the url to load the scene
  71025. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71026. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71027. */
  71028. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71029. private static _ParseURL;
  71030. private static _ReturnFullUrlLocation;
  71031. private _checkManifestFile;
  71032. /**
  71033. * Open the database and make it available
  71034. * @param successCallback defines the callback to call on success
  71035. * @param errorCallback defines the callback to call on error
  71036. */
  71037. open(successCallback: () => void, errorCallback: () => void): void;
  71038. /**
  71039. * Loads an image from the database
  71040. * @param url defines the url to load from
  71041. * @param image defines the target DOM image
  71042. */
  71043. loadImage(url: string, image: HTMLImageElement): void;
  71044. private _loadImageFromDBAsync;
  71045. private _saveImageIntoDBAsync;
  71046. private _checkVersionFromDB;
  71047. private _loadVersionFromDBAsync;
  71048. private _saveVersionIntoDBAsync;
  71049. /**
  71050. * Loads a file from database
  71051. * @param url defines the URL to load from
  71052. * @param sceneLoaded defines a callback to call on success
  71053. * @param progressCallBack defines a callback to call when progress changed
  71054. * @param errorCallback defines a callback to call on error
  71055. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71056. */
  71057. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71058. private _loadFileAsync;
  71059. private _saveFileAsync;
  71060. /**
  71061. * Validates if xhr data is correct
  71062. * @param xhr defines the request to validate
  71063. * @param dataType defines the expected data type
  71064. * @returns true if data is correct
  71065. */
  71066. private static _ValidateXHRData;
  71067. }
  71068. }
  71069. declare module "babylonjs/Offline/index" {
  71070. export * from "babylonjs/Offline/database";
  71071. export * from "babylonjs/Offline/IOfflineProvider";
  71072. }
  71073. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71074. /** @hidden */
  71075. export var gpuUpdateParticlesPixelShader: {
  71076. name: string;
  71077. shader: string;
  71078. };
  71079. }
  71080. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71081. /** @hidden */
  71082. export var gpuUpdateParticlesVertexShader: {
  71083. name: string;
  71084. shader: string;
  71085. };
  71086. }
  71087. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71088. /** @hidden */
  71089. export var clipPlaneFragmentDeclaration2: {
  71090. name: string;
  71091. shader: string;
  71092. };
  71093. }
  71094. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71095. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71096. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71097. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71098. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71099. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71100. /** @hidden */
  71101. export var gpuRenderParticlesPixelShader: {
  71102. name: string;
  71103. shader: string;
  71104. };
  71105. }
  71106. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71107. /** @hidden */
  71108. export var clipPlaneVertexDeclaration2: {
  71109. name: string;
  71110. shader: string;
  71111. };
  71112. }
  71113. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71114. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71115. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71116. /** @hidden */
  71117. export var gpuRenderParticlesVertexShader: {
  71118. name: string;
  71119. shader: string;
  71120. };
  71121. }
  71122. declare module "babylonjs/Particles/gpuParticleSystem" {
  71123. import { Nullable } from "babylonjs/types";
  71124. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71125. import { Observable } from "babylonjs/Misc/observable";
  71126. import { Matrix } from "babylonjs/Maths/math.vector";
  71127. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71128. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71129. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71130. import { IDisposable } from "babylonjs/scene";
  71131. import { Effect } from "babylonjs/Materials/effect";
  71132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71133. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71134. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71135. import { Scene } from "babylonjs/scene";
  71136. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71137. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71138. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71139. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71140. /**
  71141. * This represents a GPU particle system in Babylon
  71142. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71143. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71144. */
  71145. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71146. /**
  71147. * The layer mask we are rendering the particles through.
  71148. */
  71149. layerMask: number;
  71150. private _capacity;
  71151. private _activeCount;
  71152. private _currentActiveCount;
  71153. private _accumulatedCount;
  71154. private _renderEffect;
  71155. private _updateEffect;
  71156. private _buffer0;
  71157. private _buffer1;
  71158. private _spriteBuffer;
  71159. private _updateVAO;
  71160. private _renderVAO;
  71161. private _targetIndex;
  71162. private _sourceBuffer;
  71163. private _targetBuffer;
  71164. private _currentRenderId;
  71165. private _started;
  71166. private _stopped;
  71167. private _timeDelta;
  71168. private _randomTexture;
  71169. private _randomTexture2;
  71170. private _attributesStrideSize;
  71171. private _updateEffectOptions;
  71172. private _randomTextureSize;
  71173. private _actualFrame;
  71174. private _customEffect;
  71175. private readonly _rawTextureWidth;
  71176. /**
  71177. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71178. */
  71179. static get IsSupported(): boolean;
  71180. /**
  71181. * An event triggered when the system is disposed.
  71182. */
  71183. onDisposeObservable: Observable<IParticleSystem>;
  71184. /**
  71185. * Gets the maximum number of particles active at the same time.
  71186. * @returns The max number of active particles.
  71187. */
  71188. getCapacity(): number;
  71189. /**
  71190. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71191. * to override the particles.
  71192. */
  71193. forceDepthWrite: boolean;
  71194. /**
  71195. * Gets or set the number of active particles
  71196. */
  71197. get activeParticleCount(): number;
  71198. set activeParticleCount(value: number);
  71199. private _preWarmDone;
  71200. /**
  71201. * Specifies if the particles are updated in emitter local space or world space.
  71202. */
  71203. isLocal: boolean;
  71204. /** Gets or sets a matrix to use to compute projection */
  71205. defaultProjectionMatrix: Matrix;
  71206. /**
  71207. * Is this system ready to be used/rendered
  71208. * @return true if the system is ready
  71209. */
  71210. isReady(): boolean;
  71211. /**
  71212. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71213. * @returns True if it has been started, otherwise false.
  71214. */
  71215. isStarted(): boolean;
  71216. /**
  71217. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71218. * @returns True if it has been stopped, otherwise false.
  71219. */
  71220. isStopped(): boolean;
  71221. /**
  71222. * Gets a boolean indicating that the system is stopping
  71223. * @returns true if the system is currently stopping
  71224. */
  71225. isStopping(): boolean;
  71226. /**
  71227. * Gets the number of particles active at the same time.
  71228. * @returns The number of active particles.
  71229. */
  71230. getActiveCount(): number;
  71231. /**
  71232. * Starts the particle system and begins to emit
  71233. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71234. */
  71235. start(delay?: number): void;
  71236. /**
  71237. * Stops the particle system.
  71238. */
  71239. stop(): void;
  71240. /**
  71241. * Remove all active particles
  71242. */
  71243. reset(): void;
  71244. /**
  71245. * Returns the string "GPUParticleSystem"
  71246. * @returns a string containing the class name
  71247. */
  71248. getClassName(): string;
  71249. /**
  71250. * Gets the custom effect used to render the particles
  71251. * @param blendMode Blend mode for which the effect should be retrieved
  71252. * @returns The effect
  71253. */
  71254. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71255. /**
  71256. * Sets the custom effect used to render the particles
  71257. * @param effect The effect to set
  71258. * @param blendMode Blend mode for which the effect should be set
  71259. */
  71260. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71261. /** @hidden */
  71262. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71263. /**
  71264. * Observable that will be called just before the particles are drawn
  71265. */
  71266. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71267. /**
  71268. * Gets the name of the particle vertex shader
  71269. */
  71270. get vertexShaderName(): string;
  71271. private _colorGradientsTexture;
  71272. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71273. /**
  71274. * Adds a new color gradient
  71275. * @param gradient defines the gradient to use (between 0 and 1)
  71276. * @param color1 defines the color to affect to the specified gradient
  71277. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71278. * @returns the current particle system
  71279. */
  71280. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71281. private _refreshColorGradient;
  71282. /** Force the system to rebuild all gradients that need to be resync */
  71283. forceRefreshGradients(): void;
  71284. /**
  71285. * Remove a specific color gradient
  71286. * @param gradient defines the gradient to remove
  71287. * @returns the current particle system
  71288. */
  71289. removeColorGradient(gradient: number): GPUParticleSystem;
  71290. private _angularSpeedGradientsTexture;
  71291. private _sizeGradientsTexture;
  71292. private _velocityGradientsTexture;
  71293. private _limitVelocityGradientsTexture;
  71294. private _dragGradientsTexture;
  71295. private _addFactorGradient;
  71296. /**
  71297. * Adds a new size gradient
  71298. * @param gradient defines the gradient to use (between 0 and 1)
  71299. * @param factor defines the size factor to affect to the specified gradient
  71300. * @returns the current particle system
  71301. */
  71302. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71303. /**
  71304. * Remove a specific size gradient
  71305. * @param gradient defines the gradient to remove
  71306. * @returns the current particle system
  71307. */
  71308. removeSizeGradient(gradient: number): GPUParticleSystem;
  71309. private _refreshFactorGradient;
  71310. /**
  71311. * Adds a new angular speed gradient
  71312. * @param gradient defines the gradient to use (between 0 and 1)
  71313. * @param factor defines the angular speed to affect to the specified gradient
  71314. * @returns the current particle system
  71315. */
  71316. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71317. /**
  71318. * Remove a specific angular speed gradient
  71319. * @param gradient defines the gradient to remove
  71320. * @returns the current particle system
  71321. */
  71322. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71323. /**
  71324. * Adds a new velocity gradient
  71325. * @param gradient defines the gradient to use (between 0 and 1)
  71326. * @param factor defines the velocity to affect to the specified gradient
  71327. * @returns the current particle system
  71328. */
  71329. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71330. /**
  71331. * Remove a specific velocity gradient
  71332. * @param gradient defines the gradient to remove
  71333. * @returns the current particle system
  71334. */
  71335. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71336. /**
  71337. * Adds a new limit velocity gradient
  71338. * @param gradient defines the gradient to use (between 0 and 1)
  71339. * @param factor defines the limit velocity value to affect to the specified gradient
  71340. * @returns the current particle system
  71341. */
  71342. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71343. /**
  71344. * Remove a specific limit velocity gradient
  71345. * @param gradient defines the gradient to remove
  71346. * @returns the current particle system
  71347. */
  71348. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71349. /**
  71350. * Adds a new drag gradient
  71351. * @param gradient defines the gradient to use (between 0 and 1)
  71352. * @param factor defines the drag value to affect to the specified gradient
  71353. * @returns the current particle system
  71354. */
  71355. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71356. /**
  71357. * Remove a specific drag gradient
  71358. * @param gradient defines the gradient to remove
  71359. * @returns the current particle system
  71360. */
  71361. removeDragGradient(gradient: number): GPUParticleSystem;
  71362. /**
  71363. * Not supported by GPUParticleSystem
  71364. * @param gradient defines the gradient to use (between 0 and 1)
  71365. * @param factor defines the emit rate value to affect to the specified gradient
  71366. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71367. * @returns the current particle system
  71368. */
  71369. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71370. /**
  71371. * Not supported by GPUParticleSystem
  71372. * @param gradient defines the gradient to remove
  71373. * @returns the current particle system
  71374. */
  71375. removeEmitRateGradient(gradient: number): IParticleSystem;
  71376. /**
  71377. * Not supported by GPUParticleSystem
  71378. * @param gradient defines the gradient to use (between 0 and 1)
  71379. * @param factor defines the start size value to affect to the specified gradient
  71380. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71381. * @returns the current particle system
  71382. */
  71383. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71384. /**
  71385. * Not supported by GPUParticleSystem
  71386. * @param gradient defines the gradient to remove
  71387. * @returns the current particle system
  71388. */
  71389. removeStartSizeGradient(gradient: number): IParticleSystem;
  71390. /**
  71391. * Not supported by GPUParticleSystem
  71392. * @param gradient defines the gradient to use (between 0 and 1)
  71393. * @param min defines the color remap minimal range
  71394. * @param max defines the color remap maximal range
  71395. * @returns the current particle system
  71396. */
  71397. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71398. /**
  71399. * Not supported by GPUParticleSystem
  71400. * @param gradient defines the gradient to remove
  71401. * @returns the current particle system
  71402. */
  71403. removeColorRemapGradient(): IParticleSystem;
  71404. /**
  71405. * Not supported by GPUParticleSystem
  71406. * @param gradient defines the gradient to use (between 0 and 1)
  71407. * @param min defines the alpha remap minimal range
  71408. * @param max defines the alpha remap maximal range
  71409. * @returns the current particle system
  71410. */
  71411. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71412. /**
  71413. * Not supported by GPUParticleSystem
  71414. * @param gradient defines the gradient to remove
  71415. * @returns the current particle system
  71416. */
  71417. removeAlphaRemapGradient(): IParticleSystem;
  71418. /**
  71419. * Not supported by GPUParticleSystem
  71420. * @param gradient defines the gradient to use (between 0 and 1)
  71421. * @param color defines the color to affect to the specified gradient
  71422. * @returns the current particle system
  71423. */
  71424. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71425. /**
  71426. * Not supported by GPUParticleSystem
  71427. * @param gradient defines the gradient to remove
  71428. * @returns the current particle system
  71429. */
  71430. removeRampGradient(): IParticleSystem;
  71431. /**
  71432. * Not supported by GPUParticleSystem
  71433. * @returns the list of ramp gradients
  71434. */
  71435. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71436. /**
  71437. * Not supported by GPUParticleSystem
  71438. * Gets or sets a boolean indicating that ramp gradients must be used
  71439. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71440. */
  71441. get useRampGradients(): boolean;
  71442. set useRampGradients(value: boolean);
  71443. /**
  71444. * Not supported by GPUParticleSystem
  71445. * @param gradient defines the gradient to use (between 0 and 1)
  71446. * @param factor defines the life time factor to affect to the specified gradient
  71447. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71448. * @returns the current particle system
  71449. */
  71450. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71451. /**
  71452. * Not supported by GPUParticleSystem
  71453. * @param gradient defines the gradient to remove
  71454. * @returns the current particle system
  71455. */
  71456. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71457. /**
  71458. * Instantiates a GPU particle system.
  71459. * 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.
  71460. * @param name The name of the particle system
  71461. * @param options The options used to create the system
  71462. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71463. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71464. * @param customEffect a custom effect used to change the way particles are rendered by default
  71465. */
  71466. constructor(name: string, options: Partial<{
  71467. capacity: number;
  71468. randomTextureSize: number;
  71469. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71470. protected _reset(): void;
  71471. private _createUpdateVAO;
  71472. private _createRenderVAO;
  71473. private _initialize;
  71474. /** @hidden */
  71475. _recreateUpdateEffect(): void;
  71476. private _getEffect;
  71477. /**
  71478. * Fill the defines array according to the current settings of the particle system
  71479. * @param defines Array to be updated
  71480. * @param blendMode blend mode to take into account when updating the array
  71481. */
  71482. fillDefines(defines: Array<string>, blendMode?: number): void;
  71483. /**
  71484. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71485. * @param uniforms Uniforms array to fill
  71486. * @param attributes Attributes array to fill
  71487. * @param samplers Samplers array to fill
  71488. */
  71489. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71490. /** @hidden */
  71491. _recreateRenderEffect(): Effect;
  71492. /**
  71493. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71494. * @param preWarm defines if we are in the pre-warmimg phase
  71495. */
  71496. animate(preWarm?: boolean): void;
  71497. private _createFactorGradientTexture;
  71498. private _createSizeGradientTexture;
  71499. private _createAngularSpeedGradientTexture;
  71500. private _createVelocityGradientTexture;
  71501. private _createLimitVelocityGradientTexture;
  71502. private _createDragGradientTexture;
  71503. private _createColorGradientTexture;
  71504. /**
  71505. * Renders the particle system in its current state
  71506. * @param preWarm defines if the system should only update the particles but not render them
  71507. * @returns the current number of particles
  71508. */
  71509. render(preWarm?: boolean): number;
  71510. /**
  71511. * Rebuilds the particle system
  71512. */
  71513. rebuild(): void;
  71514. private _releaseBuffers;
  71515. private _releaseVAOs;
  71516. /**
  71517. * Disposes the particle system and free the associated resources
  71518. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71519. */
  71520. dispose(disposeTexture?: boolean): void;
  71521. /**
  71522. * Clones the particle system.
  71523. * @param name The name of the cloned object
  71524. * @param newEmitter The new emitter to use
  71525. * @returns the cloned particle system
  71526. */
  71527. clone(name: string, newEmitter: any): GPUParticleSystem;
  71528. /**
  71529. * Serializes the particle system to a JSON object
  71530. * @param serializeTexture defines if the texture must be serialized as well
  71531. * @returns the JSON object
  71532. */
  71533. serialize(serializeTexture?: boolean): any;
  71534. /**
  71535. * Parses a JSON object to create a GPU particle system.
  71536. * @param parsedParticleSystem The JSON object to parse
  71537. * @param sceneOrEngine The scene or the engine to create the particle system in
  71538. * @param rootUrl The root url to use to load external dependencies like texture
  71539. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71540. * @returns the parsed GPU particle system
  71541. */
  71542. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71543. }
  71544. }
  71545. declare module "babylonjs/Particles/particleSystemSet" {
  71546. import { Nullable } from "babylonjs/types";
  71547. import { Color3 } from "babylonjs/Maths/math.color";
  71548. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71550. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71551. import { Scene, IDisposable } from "babylonjs/scene";
  71552. /**
  71553. * Represents a set of particle systems working together to create a specific effect
  71554. */
  71555. export class ParticleSystemSet implements IDisposable {
  71556. /**
  71557. * Gets or sets base Assets URL
  71558. */
  71559. static BaseAssetsUrl: string;
  71560. private _emitterCreationOptions;
  71561. private _emitterNode;
  71562. /**
  71563. * Gets the particle system list
  71564. */
  71565. systems: IParticleSystem[];
  71566. /**
  71567. * Gets the emitter node used with this set
  71568. */
  71569. get emitterNode(): Nullable<TransformNode>;
  71570. /**
  71571. * Creates a new emitter mesh as a sphere
  71572. * @param options defines the options used to create the sphere
  71573. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71574. * @param scene defines the hosting scene
  71575. */
  71576. setEmitterAsSphere(options: {
  71577. diameter: number;
  71578. segments: number;
  71579. color: Color3;
  71580. }, renderingGroupId: number, scene: Scene): void;
  71581. /**
  71582. * Starts all particle systems of the set
  71583. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71584. */
  71585. start(emitter?: AbstractMesh): void;
  71586. /**
  71587. * Release all associated resources
  71588. */
  71589. dispose(): void;
  71590. /**
  71591. * Serialize the set into a JSON compatible object
  71592. * @param serializeTexture defines if the texture must be serialized as well
  71593. * @returns a JSON compatible representation of the set
  71594. */
  71595. serialize(serializeTexture?: boolean): any;
  71596. /**
  71597. * Parse a new ParticleSystemSet from a serialized source
  71598. * @param data defines a JSON compatible representation of the set
  71599. * @param scene defines the hosting scene
  71600. * @param gpu defines if we want GPU particles or CPU particles
  71601. * @returns a new ParticleSystemSet
  71602. */
  71603. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71604. }
  71605. }
  71606. declare module "babylonjs/Particles/particleHelper" {
  71607. import { Nullable } from "babylonjs/types";
  71608. import { Scene } from "babylonjs/scene";
  71609. import { Vector3 } from "babylonjs/Maths/math.vector";
  71610. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71611. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71612. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71613. /**
  71614. * This class is made for on one-liner static method to help creating particle system set.
  71615. */
  71616. export class ParticleHelper {
  71617. /**
  71618. * Gets or sets base Assets URL
  71619. */
  71620. static BaseAssetsUrl: string;
  71621. /** Define the Url to load snippets */
  71622. static SnippetUrl: string;
  71623. /**
  71624. * Create a default particle system that you can tweak
  71625. * @param emitter defines the emitter to use
  71626. * @param capacity defines the system capacity (default is 500 particles)
  71627. * @param scene defines the hosting scene
  71628. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71629. * @returns the new Particle system
  71630. */
  71631. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71632. /**
  71633. * This is the main static method (one-liner) of this helper to create different particle systems
  71634. * @param type This string represents the type to the particle system to create
  71635. * @param scene The scene where the particle system should live
  71636. * @param gpu If the system will use gpu
  71637. * @returns the ParticleSystemSet created
  71638. */
  71639. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71640. /**
  71641. * Static function used to export a particle system to a ParticleSystemSet variable.
  71642. * Please note that the emitter shape is not exported
  71643. * @param systems defines the particle systems to export
  71644. * @returns the created particle system set
  71645. */
  71646. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71647. /**
  71648. * Creates a particle system from a snippet saved in a remote file
  71649. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71650. * @param url defines the url to load from
  71651. * @param scene defines the hosting scene
  71652. * @param gpu If the system will use gpu
  71653. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71654. * @returns a promise that will resolve to the new particle system
  71655. */
  71656. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71657. /**
  71658. * Creates a particle system from a snippet saved by the particle system editor
  71659. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71660. * @param scene defines the hosting scene
  71661. * @param gpu If the system will use gpu
  71662. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71663. * @returns a promise that will resolve to the new particle system
  71664. */
  71665. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71666. }
  71667. }
  71668. declare module "babylonjs/Particles/particleSystemComponent" {
  71669. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71670. import { Effect } from "babylonjs/Materials/effect";
  71671. import "babylonjs/Shaders/particles.vertex";
  71672. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71673. module "babylonjs/Engines/engine" {
  71674. interface Engine {
  71675. /**
  71676. * Create an effect to use with particle systems.
  71677. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71678. * the particle system for which you want to create a custom effect in the last parameter
  71679. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71680. * @param uniformsNames defines a list of attribute names
  71681. * @param samplers defines an array of string used to represent textures
  71682. * @param defines defines the string containing the defines to use to compile the shaders
  71683. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71684. * @param onCompiled defines a function to call when the effect creation is successful
  71685. * @param onError defines a function to call when the effect creation has failed
  71686. * @param particleSystem the particle system you want to create the effect for
  71687. * @returns the new Effect
  71688. */
  71689. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71690. }
  71691. }
  71692. module "babylonjs/Meshes/mesh" {
  71693. interface Mesh {
  71694. /**
  71695. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71696. * @returns an array of IParticleSystem
  71697. */
  71698. getEmittedParticleSystems(): IParticleSystem[];
  71699. /**
  71700. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71701. * @returns an array of IParticleSystem
  71702. */
  71703. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71704. }
  71705. }
  71706. }
  71707. declare module "babylonjs/Particles/pointsCloudSystem" {
  71708. import { Color4 } from "babylonjs/Maths/math";
  71709. import { Mesh } from "babylonjs/Meshes/mesh";
  71710. import { Scene, IDisposable } from "babylonjs/scene";
  71711. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71712. /** Defines the 4 color options */
  71713. export enum PointColor {
  71714. /** color value */
  71715. Color = 2,
  71716. /** uv value */
  71717. UV = 1,
  71718. /** random value */
  71719. Random = 0,
  71720. /** stated value */
  71721. Stated = 3
  71722. }
  71723. /**
  71724. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71725. * 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.
  71726. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71727. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71728. *
  71729. * Full documentation here : TO BE ENTERED
  71730. */
  71731. export class PointsCloudSystem implements IDisposable {
  71732. /**
  71733. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71734. * Example : var p = SPS.particles[i];
  71735. */
  71736. particles: CloudPoint[];
  71737. /**
  71738. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71739. */
  71740. nbParticles: number;
  71741. /**
  71742. * This a counter for your own usage. It's not set by any SPS functions.
  71743. */
  71744. counter: number;
  71745. /**
  71746. * The PCS name. This name is also given to the underlying mesh.
  71747. */
  71748. name: string;
  71749. /**
  71750. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71751. */
  71752. mesh: Mesh;
  71753. /**
  71754. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71755. * Please read :
  71756. */
  71757. vars: any;
  71758. /**
  71759. * @hidden
  71760. */
  71761. _size: number;
  71762. private _scene;
  71763. private _promises;
  71764. private _positions;
  71765. private _indices;
  71766. private _normals;
  71767. private _colors;
  71768. private _uvs;
  71769. private _indices32;
  71770. private _positions32;
  71771. private _colors32;
  71772. private _uvs32;
  71773. private _updatable;
  71774. private _isVisibilityBoxLocked;
  71775. private _alwaysVisible;
  71776. private _groups;
  71777. private _groupCounter;
  71778. private _computeParticleColor;
  71779. private _computeParticleTexture;
  71780. private _computeParticleRotation;
  71781. private _computeBoundingBox;
  71782. private _isReady;
  71783. /**
  71784. * Creates a PCS (Points Cloud System) object
  71785. * @param name (String) is the PCS name, this will be the underlying mesh name
  71786. * @param pointSize (number) is the size for each point
  71787. * @param scene (Scene) is the scene in which the PCS is added
  71788. * @param options defines the options of the PCS e.g.
  71789. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71790. */
  71791. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71792. updatable?: boolean;
  71793. });
  71794. /**
  71795. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71796. * If no points were added to the PCS, the returned mesh is just a single point.
  71797. * @returns a promise for the created mesh
  71798. */
  71799. buildMeshAsync(): Promise<Mesh>;
  71800. /**
  71801. * @hidden
  71802. */
  71803. private _buildMesh;
  71804. private _addParticle;
  71805. private _randomUnitVector;
  71806. private _getColorIndicesForCoord;
  71807. private _setPointsColorOrUV;
  71808. private _colorFromTexture;
  71809. private _calculateDensity;
  71810. /**
  71811. * Adds points to the PCS in random positions within a unit sphere
  71812. * @param nb (positive integer) the number of particles to be created from this model
  71813. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  71814. * @returns the number of groups in the system
  71815. */
  71816. addPoints(nb: number, pointFunction?: any): number;
  71817. /**
  71818. * Adds points to the PCS from the surface of the model shape
  71819. * @param mesh is any Mesh object that will be used as a surface model for the points
  71820. * @param nb (positive integer) the number of particles to be created from this model
  71821. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71822. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71823. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71824. * @returns the number of groups in the system
  71825. */
  71826. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71827. /**
  71828. * Adds points to the PCS inside the model shape
  71829. * @param mesh is any Mesh object that will be used as a surface model for the points
  71830. * @param nb (positive integer) the number of particles to be created from this model
  71831. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  71832. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  71833. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  71834. * @returns the number of groups in the system
  71835. */
  71836. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  71837. /**
  71838. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  71839. * This method calls `updateParticle()` for each particle of the SPS.
  71840. * For an animated SPS, it is usually called within the render loop.
  71841. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  71842. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  71843. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  71844. * @returns the PCS.
  71845. */
  71846. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  71847. /**
  71848. * Disposes the PCS.
  71849. */
  71850. dispose(): void;
  71851. /**
  71852. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  71853. * doc :
  71854. * @returns the PCS.
  71855. */
  71856. refreshVisibleSize(): PointsCloudSystem;
  71857. /**
  71858. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  71859. * @param size the size (float) of the visibility box
  71860. * note : this doesn't lock the PCS mesh bounding box.
  71861. * doc :
  71862. */
  71863. setVisibilityBox(size: number): void;
  71864. /**
  71865. * Gets whether the PCS is always visible or not
  71866. * doc :
  71867. */
  71868. get isAlwaysVisible(): boolean;
  71869. /**
  71870. * Sets the PCS as always visible or not
  71871. * doc :
  71872. */
  71873. set isAlwaysVisible(val: boolean);
  71874. /**
  71875. * Tells to `setParticles()` to compute the particle rotations or not
  71876. * Default value : false. The PCS is faster when it's set to false
  71877. * Note : particle rotations are only applied to parent particles
  71878. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  71879. */
  71880. set computeParticleRotation(val: boolean);
  71881. /**
  71882. * Tells to `setParticles()` to compute the particle colors or not.
  71883. * Default value : true. The PCS is faster when it's set to false.
  71884. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71885. */
  71886. set computeParticleColor(val: boolean);
  71887. set computeParticleTexture(val: boolean);
  71888. /**
  71889. * Gets if `setParticles()` computes the particle colors or not.
  71890. * Default value : false. The PCS is faster when it's set to false.
  71891. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  71892. */
  71893. get computeParticleColor(): boolean;
  71894. /**
  71895. * Gets if `setParticles()` computes the particle textures or not.
  71896. * Default value : false. The PCS is faster when it's set to false.
  71897. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  71898. */
  71899. get computeParticleTexture(): boolean;
  71900. /**
  71901. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  71902. */
  71903. set computeBoundingBox(val: boolean);
  71904. /**
  71905. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  71906. */
  71907. get computeBoundingBox(): boolean;
  71908. /**
  71909. * This function does nothing. It may be overwritten to set all the particle first values.
  71910. * The PCS doesn't call this function, you may have to call it by your own.
  71911. * doc :
  71912. */
  71913. initParticles(): void;
  71914. /**
  71915. * This function does nothing. It may be overwritten to recycle a particle
  71916. * The PCS doesn't call this function, you can to call it
  71917. * doc :
  71918. * @param particle The particle to recycle
  71919. * @returns the recycled particle
  71920. */
  71921. recycleParticle(particle: CloudPoint): CloudPoint;
  71922. /**
  71923. * Updates a particle : this function should be overwritten by the user.
  71924. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  71925. * doc :
  71926. * @example : just set a particle position or velocity and recycle conditions
  71927. * @param particle The particle to update
  71928. * @returns the updated particle
  71929. */
  71930. updateParticle(particle: CloudPoint): CloudPoint;
  71931. /**
  71932. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  71933. * This does nothing and may be overwritten by the user.
  71934. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71935. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71936. * @param update the boolean update value actually passed to setParticles()
  71937. */
  71938. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71939. /**
  71940. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  71941. * This will be passed three parameters.
  71942. * This does nothing and may be overwritten by the user.
  71943. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  71944. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  71945. * @param update the boolean update value actually passed to setParticles()
  71946. */
  71947. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  71948. }
  71949. }
  71950. declare module "babylonjs/Particles/cloudPoint" {
  71951. import { Nullable } from "babylonjs/types";
  71952. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  71953. import { Mesh } from "babylonjs/Meshes/mesh";
  71954. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  71955. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  71956. /**
  71957. * Represents one particle of a points cloud system.
  71958. */
  71959. export class CloudPoint {
  71960. /**
  71961. * particle global index
  71962. */
  71963. idx: number;
  71964. /**
  71965. * The color of the particle
  71966. */
  71967. color: Nullable<Color4>;
  71968. /**
  71969. * The world space position of the particle.
  71970. */
  71971. position: Vector3;
  71972. /**
  71973. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  71974. */
  71975. rotation: Vector3;
  71976. /**
  71977. * The world space rotation quaternion of the particle.
  71978. */
  71979. rotationQuaternion: Nullable<Quaternion>;
  71980. /**
  71981. * The uv of the particle.
  71982. */
  71983. uv: Nullable<Vector2>;
  71984. /**
  71985. * The current speed of the particle.
  71986. */
  71987. velocity: Vector3;
  71988. /**
  71989. * The pivot point in the particle local space.
  71990. */
  71991. pivot: Vector3;
  71992. /**
  71993. * Must the particle be translated from its pivot point in its local space ?
  71994. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  71995. * Default : false
  71996. */
  71997. translateFromPivot: boolean;
  71998. /**
  71999. * Index of this particle in the global "positions" array (Internal use)
  72000. * @hidden
  72001. */
  72002. _pos: number;
  72003. /**
  72004. * @hidden Index of this particle in the global "indices" array (Internal use)
  72005. */
  72006. _ind: number;
  72007. /**
  72008. * Group this particle belongs to
  72009. */
  72010. _group: PointsGroup;
  72011. /**
  72012. * Group id of this particle
  72013. */
  72014. groupId: number;
  72015. /**
  72016. * Index of the particle in its group id (Internal use)
  72017. */
  72018. idxInGroup: number;
  72019. /**
  72020. * @hidden Particle BoundingInfo object (Internal use)
  72021. */
  72022. _boundingInfo: BoundingInfo;
  72023. /**
  72024. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72025. */
  72026. _pcs: PointsCloudSystem;
  72027. /**
  72028. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72029. */
  72030. _stillInvisible: boolean;
  72031. /**
  72032. * @hidden Last computed particle rotation matrix
  72033. */
  72034. _rotationMatrix: number[];
  72035. /**
  72036. * Parent particle Id, if any.
  72037. * Default null.
  72038. */
  72039. parentId: Nullable<number>;
  72040. /**
  72041. * @hidden Internal global position in the PCS.
  72042. */
  72043. _globalPosition: Vector3;
  72044. /**
  72045. * Creates a Point Cloud object.
  72046. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72047. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72048. * @param group (PointsGroup) is the group the particle belongs to
  72049. * @param groupId (integer) is the group identifier in the PCS.
  72050. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72051. * @param pcs defines the PCS it is associated to
  72052. */
  72053. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72054. /**
  72055. * get point size
  72056. */
  72057. get size(): Vector3;
  72058. /**
  72059. * Set point size
  72060. */
  72061. set size(scale: Vector3);
  72062. /**
  72063. * Legacy support, changed quaternion to rotationQuaternion
  72064. */
  72065. get quaternion(): Nullable<Quaternion>;
  72066. /**
  72067. * Legacy support, changed quaternion to rotationQuaternion
  72068. */
  72069. set quaternion(q: Nullable<Quaternion>);
  72070. /**
  72071. * Returns a boolean. True if the particle intersects a mesh, else false
  72072. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72073. * @param target is the object (point or mesh) what the intersection is computed against
  72074. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72075. * @returns true if it intersects
  72076. */
  72077. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72078. /**
  72079. * get the rotation matrix of the particle
  72080. * @hidden
  72081. */
  72082. getRotationMatrix(m: Matrix): void;
  72083. }
  72084. /**
  72085. * Represents a group of points in a points cloud system
  72086. * * PCS internal tool, don't use it manually.
  72087. */
  72088. export class PointsGroup {
  72089. /**
  72090. * The group id
  72091. * @hidden
  72092. */
  72093. groupID: number;
  72094. /**
  72095. * image data for group (internal use)
  72096. * @hidden
  72097. */
  72098. _groupImageData: Nullable<ArrayBufferView>;
  72099. /**
  72100. * Image Width (internal use)
  72101. * @hidden
  72102. */
  72103. _groupImgWidth: number;
  72104. /**
  72105. * Image Height (internal use)
  72106. * @hidden
  72107. */
  72108. _groupImgHeight: number;
  72109. /**
  72110. * Custom position function (internal use)
  72111. * @hidden
  72112. */
  72113. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72114. /**
  72115. * density per facet for surface points
  72116. * @hidden
  72117. */
  72118. _groupDensity: number[];
  72119. /**
  72120. * Only when points are colored by texture carries pointer to texture list array
  72121. * @hidden
  72122. */
  72123. _textureNb: number;
  72124. /**
  72125. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72126. * PCS internal tool, don't use it manually.
  72127. * @hidden
  72128. */
  72129. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72130. }
  72131. }
  72132. declare module "babylonjs/Particles/index" {
  72133. export * from "babylonjs/Particles/baseParticleSystem";
  72134. export * from "babylonjs/Particles/EmitterTypes/index";
  72135. export * from "babylonjs/Particles/gpuParticleSystem";
  72136. export * from "babylonjs/Particles/IParticleSystem";
  72137. export * from "babylonjs/Particles/particle";
  72138. export * from "babylonjs/Particles/particleHelper";
  72139. export * from "babylonjs/Particles/particleSystem";
  72140. import "babylonjs/Particles/particleSystemComponent";
  72141. export * from "babylonjs/Particles/particleSystemComponent";
  72142. export * from "babylonjs/Particles/particleSystemSet";
  72143. export * from "babylonjs/Particles/solidParticle";
  72144. export * from "babylonjs/Particles/solidParticleSystem";
  72145. export * from "babylonjs/Particles/cloudPoint";
  72146. export * from "babylonjs/Particles/pointsCloudSystem";
  72147. export * from "babylonjs/Particles/subEmitter";
  72148. }
  72149. declare module "babylonjs/Physics/physicsEngineComponent" {
  72150. import { Nullable } from "babylonjs/types";
  72151. import { Observable, Observer } from "babylonjs/Misc/observable";
  72152. import { Vector3 } from "babylonjs/Maths/math.vector";
  72153. import { Mesh } from "babylonjs/Meshes/mesh";
  72154. import { ISceneComponent } from "babylonjs/sceneComponent";
  72155. import { Scene } from "babylonjs/scene";
  72156. import { Node } from "babylonjs/node";
  72157. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72158. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72159. module "babylonjs/scene" {
  72160. interface Scene {
  72161. /** @hidden (Backing field) */
  72162. _physicsEngine: Nullable<IPhysicsEngine>;
  72163. /** @hidden */
  72164. _physicsTimeAccumulator: number;
  72165. /**
  72166. * Gets the current physics engine
  72167. * @returns a IPhysicsEngine or null if none attached
  72168. */
  72169. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72170. /**
  72171. * Enables physics to the current scene
  72172. * @param gravity defines the scene's gravity for the physics engine
  72173. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72174. * @return a boolean indicating if the physics engine was initialized
  72175. */
  72176. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72177. /**
  72178. * Disables and disposes the physics engine associated with the scene
  72179. */
  72180. disablePhysicsEngine(): void;
  72181. /**
  72182. * Gets a boolean indicating if there is an active physics engine
  72183. * @returns a boolean indicating if there is an active physics engine
  72184. */
  72185. isPhysicsEnabled(): boolean;
  72186. /**
  72187. * Deletes a physics compound impostor
  72188. * @param compound defines the compound to delete
  72189. */
  72190. deleteCompoundImpostor(compound: any): void;
  72191. /**
  72192. * An event triggered when physic simulation is about to be run
  72193. */
  72194. onBeforePhysicsObservable: Observable<Scene>;
  72195. /**
  72196. * An event triggered when physic simulation has been done
  72197. */
  72198. onAfterPhysicsObservable: Observable<Scene>;
  72199. }
  72200. }
  72201. module "babylonjs/Meshes/abstractMesh" {
  72202. interface AbstractMesh {
  72203. /** @hidden */
  72204. _physicsImpostor: Nullable<PhysicsImpostor>;
  72205. /**
  72206. * Gets or sets impostor used for physic simulation
  72207. * @see https://doc.babylonjs.com/features/physics_engine
  72208. */
  72209. physicsImpostor: Nullable<PhysicsImpostor>;
  72210. /**
  72211. * Gets the current physics impostor
  72212. * @see https://doc.babylonjs.com/features/physics_engine
  72213. * @returns a physics impostor or null
  72214. */
  72215. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72216. /** Apply a physic impulse to the mesh
  72217. * @param force defines the force to apply
  72218. * @param contactPoint defines where to apply the force
  72219. * @returns the current mesh
  72220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72221. */
  72222. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72223. /**
  72224. * Creates a physic joint between two meshes
  72225. * @param otherMesh defines the other mesh to use
  72226. * @param pivot1 defines the pivot to use on this mesh
  72227. * @param pivot2 defines the pivot to use on the other mesh
  72228. * @param options defines additional options (can be plugin dependent)
  72229. * @returns the current mesh
  72230. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72231. */
  72232. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72233. /** @hidden */
  72234. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72235. }
  72236. }
  72237. /**
  72238. * Defines the physics engine scene component responsible to manage a physics engine
  72239. */
  72240. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72241. /**
  72242. * The component name helpful to identify the component in the list of scene components.
  72243. */
  72244. readonly name: string;
  72245. /**
  72246. * The scene the component belongs to.
  72247. */
  72248. scene: Scene;
  72249. /**
  72250. * Creates a new instance of the component for the given scene
  72251. * @param scene Defines the scene to register the component in
  72252. */
  72253. constructor(scene: Scene);
  72254. /**
  72255. * Registers the component in a given scene
  72256. */
  72257. register(): void;
  72258. /**
  72259. * Rebuilds the elements related to this component in case of
  72260. * context lost for instance.
  72261. */
  72262. rebuild(): void;
  72263. /**
  72264. * Disposes the component and the associated ressources
  72265. */
  72266. dispose(): void;
  72267. }
  72268. }
  72269. declare module "babylonjs/Physics/physicsHelper" {
  72270. import { Nullable } from "babylonjs/types";
  72271. import { Vector3 } from "babylonjs/Maths/math.vector";
  72272. import { Mesh } from "babylonjs/Meshes/mesh";
  72273. import { Scene } from "babylonjs/scene";
  72274. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72275. /**
  72276. * A helper for physics simulations
  72277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72278. */
  72279. export class PhysicsHelper {
  72280. private _scene;
  72281. private _physicsEngine;
  72282. /**
  72283. * Initializes the Physics helper
  72284. * @param scene Babylon.js scene
  72285. */
  72286. constructor(scene: Scene);
  72287. /**
  72288. * Applies a radial explosion impulse
  72289. * @param origin the origin of the explosion
  72290. * @param radiusOrEventOptions the radius or the options of radial explosion
  72291. * @param strength the explosion strength
  72292. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72293. * @returns A physics radial explosion event, or null
  72294. */
  72295. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72296. /**
  72297. * Applies a radial explosion force
  72298. * @param origin the origin of the explosion
  72299. * @param radiusOrEventOptions the radius or the options of radial explosion
  72300. * @param strength the explosion strength
  72301. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72302. * @returns A physics radial explosion event, or null
  72303. */
  72304. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72305. /**
  72306. * Creates a gravitational field
  72307. * @param origin the origin of the explosion
  72308. * @param radiusOrEventOptions the radius or the options of radial explosion
  72309. * @param strength the explosion strength
  72310. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72311. * @returns A physics gravitational field event, or null
  72312. */
  72313. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72314. /**
  72315. * Creates a physics updraft event
  72316. * @param origin the origin of the updraft
  72317. * @param radiusOrEventOptions the radius or the options of the updraft
  72318. * @param strength the strength of the updraft
  72319. * @param height the height of the updraft
  72320. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72321. * @returns A physics updraft event, or null
  72322. */
  72323. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72324. /**
  72325. * Creates a physics vortex event
  72326. * @param origin the of the vortex
  72327. * @param radiusOrEventOptions the radius or the options of the vortex
  72328. * @param strength the strength of the vortex
  72329. * @param height the height of the vortex
  72330. * @returns a Physics vortex event, or null
  72331. * A physics vortex event or null
  72332. */
  72333. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72334. }
  72335. /**
  72336. * Represents a physics radial explosion event
  72337. */
  72338. class PhysicsRadialExplosionEvent {
  72339. private _scene;
  72340. private _options;
  72341. private _sphere;
  72342. private _dataFetched;
  72343. /**
  72344. * Initializes a radial explosioin event
  72345. * @param _scene BabylonJS scene
  72346. * @param _options The options for the vortex event
  72347. */
  72348. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72349. /**
  72350. * Returns the data related to the radial explosion event (sphere).
  72351. * @returns The radial explosion event data
  72352. */
  72353. getData(): PhysicsRadialExplosionEventData;
  72354. /**
  72355. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72356. * @param impostor A physics imposter
  72357. * @param origin the origin of the explosion
  72358. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72359. */
  72360. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72361. /**
  72362. * Triggers affecterd impostors callbacks
  72363. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72364. */
  72365. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72366. /**
  72367. * Disposes the sphere.
  72368. * @param force Specifies if the sphere should be disposed by force
  72369. */
  72370. dispose(force?: boolean): void;
  72371. /*** Helpers ***/
  72372. private _prepareSphere;
  72373. private _intersectsWithSphere;
  72374. }
  72375. /**
  72376. * Represents a gravitational field event
  72377. */
  72378. class PhysicsGravitationalFieldEvent {
  72379. private _physicsHelper;
  72380. private _scene;
  72381. private _origin;
  72382. private _options;
  72383. private _tickCallback;
  72384. private _sphere;
  72385. private _dataFetched;
  72386. /**
  72387. * Initializes the physics gravitational field event
  72388. * @param _physicsHelper A physics helper
  72389. * @param _scene BabylonJS scene
  72390. * @param _origin The origin position of the gravitational field event
  72391. * @param _options The options for the vortex event
  72392. */
  72393. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72394. /**
  72395. * Returns the data related to the gravitational field event (sphere).
  72396. * @returns A gravitational field event
  72397. */
  72398. getData(): PhysicsGravitationalFieldEventData;
  72399. /**
  72400. * Enables the gravitational field.
  72401. */
  72402. enable(): void;
  72403. /**
  72404. * Disables the gravitational field.
  72405. */
  72406. disable(): void;
  72407. /**
  72408. * Disposes the sphere.
  72409. * @param force The force to dispose from the gravitational field event
  72410. */
  72411. dispose(force?: boolean): void;
  72412. private _tick;
  72413. }
  72414. /**
  72415. * Represents a physics updraft event
  72416. */
  72417. class PhysicsUpdraftEvent {
  72418. private _scene;
  72419. private _origin;
  72420. private _options;
  72421. private _physicsEngine;
  72422. private _originTop;
  72423. private _originDirection;
  72424. private _tickCallback;
  72425. private _cylinder;
  72426. private _cylinderPosition;
  72427. private _dataFetched;
  72428. /**
  72429. * Initializes the physics updraft event
  72430. * @param _scene BabylonJS scene
  72431. * @param _origin The origin position of the updraft
  72432. * @param _options The options for the updraft event
  72433. */
  72434. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72435. /**
  72436. * Returns the data related to the updraft event (cylinder).
  72437. * @returns A physics updraft event
  72438. */
  72439. getData(): PhysicsUpdraftEventData;
  72440. /**
  72441. * Enables the updraft.
  72442. */
  72443. enable(): void;
  72444. /**
  72445. * Disables the updraft.
  72446. */
  72447. disable(): void;
  72448. /**
  72449. * Disposes the cylinder.
  72450. * @param force Specifies if the updraft should be disposed by force
  72451. */
  72452. dispose(force?: boolean): void;
  72453. private getImpostorHitData;
  72454. private _tick;
  72455. /*** Helpers ***/
  72456. private _prepareCylinder;
  72457. private _intersectsWithCylinder;
  72458. }
  72459. /**
  72460. * Represents a physics vortex event
  72461. */
  72462. class PhysicsVortexEvent {
  72463. private _scene;
  72464. private _origin;
  72465. private _options;
  72466. private _physicsEngine;
  72467. private _originTop;
  72468. private _tickCallback;
  72469. private _cylinder;
  72470. private _cylinderPosition;
  72471. private _dataFetched;
  72472. /**
  72473. * Initializes the physics vortex event
  72474. * @param _scene The BabylonJS scene
  72475. * @param _origin The origin position of the vortex
  72476. * @param _options The options for the vortex event
  72477. */
  72478. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72479. /**
  72480. * Returns the data related to the vortex event (cylinder).
  72481. * @returns The physics vortex event data
  72482. */
  72483. getData(): PhysicsVortexEventData;
  72484. /**
  72485. * Enables the vortex.
  72486. */
  72487. enable(): void;
  72488. /**
  72489. * Disables the cortex.
  72490. */
  72491. disable(): void;
  72492. /**
  72493. * Disposes the sphere.
  72494. * @param force
  72495. */
  72496. dispose(force?: boolean): void;
  72497. private getImpostorHitData;
  72498. private _tick;
  72499. /*** Helpers ***/
  72500. private _prepareCylinder;
  72501. private _intersectsWithCylinder;
  72502. }
  72503. /**
  72504. * Options fot the radial explosion event
  72505. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72506. */
  72507. export class PhysicsRadialExplosionEventOptions {
  72508. /**
  72509. * The radius of the sphere for the radial explosion.
  72510. */
  72511. radius: number;
  72512. /**
  72513. * The strenth of the explosion.
  72514. */
  72515. strength: number;
  72516. /**
  72517. * The strenght of the force in correspondence to the distance of the affected object
  72518. */
  72519. falloff: PhysicsRadialImpulseFalloff;
  72520. /**
  72521. * Sphere options for the radial explosion.
  72522. */
  72523. sphere: {
  72524. segments: number;
  72525. diameter: number;
  72526. };
  72527. /**
  72528. * Sphere options for the radial explosion.
  72529. */
  72530. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72531. }
  72532. /**
  72533. * Options fot the updraft event
  72534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72535. */
  72536. export class PhysicsUpdraftEventOptions {
  72537. /**
  72538. * The radius of the cylinder for the vortex
  72539. */
  72540. radius: number;
  72541. /**
  72542. * The strenth of the updraft.
  72543. */
  72544. strength: number;
  72545. /**
  72546. * The height of the cylinder for the updraft.
  72547. */
  72548. height: number;
  72549. /**
  72550. * The mode for the the updraft.
  72551. */
  72552. updraftMode: PhysicsUpdraftMode;
  72553. }
  72554. /**
  72555. * Options fot the vortex event
  72556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72557. */
  72558. export class PhysicsVortexEventOptions {
  72559. /**
  72560. * The radius of the cylinder for the vortex
  72561. */
  72562. radius: number;
  72563. /**
  72564. * The strenth of the vortex.
  72565. */
  72566. strength: number;
  72567. /**
  72568. * The height of the cylinder for the vortex.
  72569. */
  72570. height: number;
  72571. /**
  72572. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72573. */
  72574. centripetalForceThreshold: number;
  72575. /**
  72576. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72577. */
  72578. centripetalForceMultiplier: number;
  72579. /**
  72580. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72581. */
  72582. centrifugalForceMultiplier: number;
  72583. /**
  72584. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72585. */
  72586. updraftForceMultiplier: number;
  72587. }
  72588. /**
  72589. * The strenght of the force in correspondence to the distance of the affected object
  72590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72591. */
  72592. export enum PhysicsRadialImpulseFalloff {
  72593. /** Defines that impulse is constant in strength across it's whole radius */
  72594. Constant = 0,
  72595. /** Defines that impulse gets weaker if it's further from the origin */
  72596. Linear = 1
  72597. }
  72598. /**
  72599. * The strength of the force in correspondence to the distance of the affected object
  72600. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72601. */
  72602. export enum PhysicsUpdraftMode {
  72603. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72604. Center = 0,
  72605. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72606. Perpendicular = 1
  72607. }
  72608. /**
  72609. * Interface for a physics hit data
  72610. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72611. */
  72612. export interface PhysicsHitData {
  72613. /**
  72614. * The force applied at the contact point
  72615. */
  72616. force: Vector3;
  72617. /**
  72618. * The contact point
  72619. */
  72620. contactPoint: Vector3;
  72621. /**
  72622. * The distance from the origin to the contact point
  72623. */
  72624. distanceFromOrigin: number;
  72625. }
  72626. /**
  72627. * Interface for radial explosion event data
  72628. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72629. */
  72630. export interface PhysicsRadialExplosionEventData {
  72631. /**
  72632. * A sphere used for the radial explosion event
  72633. */
  72634. sphere: Mesh;
  72635. }
  72636. /**
  72637. * Interface for gravitational field event data
  72638. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72639. */
  72640. export interface PhysicsGravitationalFieldEventData {
  72641. /**
  72642. * A sphere mesh used for the gravitational field event
  72643. */
  72644. sphere: Mesh;
  72645. }
  72646. /**
  72647. * Interface for updraft event data
  72648. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72649. */
  72650. export interface PhysicsUpdraftEventData {
  72651. /**
  72652. * A cylinder used for the updraft event
  72653. */
  72654. cylinder: Mesh;
  72655. }
  72656. /**
  72657. * Interface for vortex event data
  72658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72659. */
  72660. export interface PhysicsVortexEventData {
  72661. /**
  72662. * A cylinder used for the vortex event
  72663. */
  72664. cylinder: Mesh;
  72665. }
  72666. /**
  72667. * Interface for an affected physics impostor
  72668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72669. */
  72670. export interface PhysicsAffectedImpostorWithData {
  72671. /**
  72672. * The impostor affected by the effect
  72673. */
  72674. impostor: PhysicsImpostor;
  72675. /**
  72676. * The data about the hit/horce from the explosion
  72677. */
  72678. hitData: PhysicsHitData;
  72679. }
  72680. }
  72681. declare module "babylonjs/Physics/Plugins/index" {
  72682. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72683. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72684. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72685. }
  72686. declare module "babylonjs/Physics/index" {
  72687. export * from "babylonjs/Physics/IPhysicsEngine";
  72688. export * from "babylonjs/Physics/physicsEngine";
  72689. export * from "babylonjs/Physics/physicsEngineComponent";
  72690. export * from "babylonjs/Physics/physicsHelper";
  72691. export * from "babylonjs/Physics/physicsImpostor";
  72692. export * from "babylonjs/Physics/physicsJoint";
  72693. export * from "babylonjs/Physics/Plugins/index";
  72694. }
  72695. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72696. /** @hidden */
  72697. export var blackAndWhitePixelShader: {
  72698. name: string;
  72699. shader: string;
  72700. };
  72701. }
  72702. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72703. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72704. import { Camera } from "babylonjs/Cameras/camera";
  72705. import { Engine } from "babylonjs/Engines/engine";
  72706. import "babylonjs/Shaders/blackAndWhite.fragment";
  72707. import { Nullable } from "babylonjs/types";
  72708. import { Scene } from "babylonjs/scene";
  72709. /**
  72710. * Post process used to render in black and white
  72711. */
  72712. export class BlackAndWhitePostProcess extends PostProcess {
  72713. /**
  72714. * Linear about to convert he result to black and white (default: 1)
  72715. */
  72716. degree: number;
  72717. /**
  72718. * Gets a string identifying the name of the class
  72719. * @returns "BlackAndWhitePostProcess" string
  72720. */
  72721. getClassName(): string;
  72722. /**
  72723. * Creates a black and white post process
  72724. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72725. * @param name The name of the effect.
  72726. * @param options The required width/height ratio to downsize to before computing the render pass.
  72727. * @param camera The camera to apply the render pass to.
  72728. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72729. * @param engine The engine which the post process will be applied. (default: current engine)
  72730. * @param reusable If the post process can be reused on the same frame. (default: false)
  72731. */
  72732. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72733. /** @hidden */
  72734. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72735. }
  72736. }
  72737. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72738. import { Nullable } from "babylonjs/types";
  72739. import { Camera } from "babylonjs/Cameras/camera";
  72740. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72741. import { Engine } from "babylonjs/Engines/engine";
  72742. /**
  72743. * This represents a set of one or more post processes in Babylon.
  72744. * A post process can be used to apply a shader to a texture after it is rendered.
  72745. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72746. */
  72747. export class PostProcessRenderEffect {
  72748. private _postProcesses;
  72749. private _getPostProcesses;
  72750. private _singleInstance;
  72751. private _cameras;
  72752. private _indicesForCamera;
  72753. /**
  72754. * Name of the effect
  72755. * @hidden
  72756. */
  72757. _name: string;
  72758. /**
  72759. * Instantiates a post process render effect.
  72760. * A post process can be used to apply a shader to a texture after it is rendered.
  72761. * @param engine The engine the effect is tied to
  72762. * @param name The name of the effect
  72763. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72764. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72765. */
  72766. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72767. /**
  72768. * Checks if all the post processes in the effect are supported.
  72769. */
  72770. get isSupported(): boolean;
  72771. /**
  72772. * Updates the current state of the effect
  72773. * @hidden
  72774. */
  72775. _update(): void;
  72776. /**
  72777. * Attaches the effect on cameras
  72778. * @param cameras The camera to attach to.
  72779. * @hidden
  72780. */
  72781. _attachCameras(cameras: Camera): void;
  72782. /**
  72783. * Attaches the effect on cameras
  72784. * @param cameras The camera to attach to.
  72785. * @hidden
  72786. */
  72787. _attachCameras(cameras: Camera[]): void;
  72788. /**
  72789. * Detaches the effect on cameras
  72790. * @param cameras The camera to detatch from.
  72791. * @hidden
  72792. */
  72793. _detachCameras(cameras: Camera): void;
  72794. /**
  72795. * Detatches the effect on cameras
  72796. * @param cameras The camera to detatch from.
  72797. * @hidden
  72798. */
  72799. _detachCameras(cameras: Camera[]): void;
  72800. /**
  72801. * Enables the effect on given cameras
  72802. * @param cameras The camera to enable.
  72803. * @hidden
  72804. */
  72805. _enable(cameras: Camera): void;
  72806. /**
  72807. * Enables the effect on given cameras
  72808. * @param cameras The camera to enable.
  72809. * @hidden
  72810. */
  72811. _enable(cameras: Nullable<Camera[]>): void;
  72812. /**
  72813. * Disables the effect on the given cameras
  72814. * @param cameras The camera to disable.
  72815. * @hidden
  72816. */
  72817. _disable(cameras: Camera): void;
  72818. /**
  72819. * Disables the effect on the given cameras
  72820. * @param cameras The camera to disable.
  72821. * @hidden
  72822. */
  72823. _disable(cameras: Nullable<Camera[]>): void;
  72824. /**
  72825. * Gets a list of the post processes contained in the effect.
  72826. * @param camera The camera to get the post processes on.
  72827. * @returns The list of the post processes in the effect.
  72828. */
  72829. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  72830. }
  72831. }
  72832. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  72833. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  72834. /** @hidden */
  72835. export var extractHighlightsPixelShader: {
  72836. name: string;
  72837. shader: string;
  72838. };
  72839. }
  72840. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  72841. import { Nullable } from "babylonjs/types";
  72842. import { Camera } from "babylonjs/Cameras/camera";
  72843. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72844. import { Engine } from "babylonjs/Engines/engine";
  72845. import "babylonjs/Shaders/extractHighlights.fragment";
  72846. /**
  72847. * 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.
  72848. */
  72849. export class ExtractHighlightsPostProcess extends PostProcess {
  72850. /**
  72851. * The luminance threshold, pixels below this value will be set to black.
  72852. */
  72853. threshold: number;
  72854. /** @hidden */
  72855. _exposure: number;
  72856. /**
  72857. * Post process which has the input texture to be used when performing highlight extraction
  72858. * @hidden
  72859. */
  72860. _inputPostProcess: Nullable<PostProcess>;
  72861. /**
  72862. * Gets a string identifying the name of the class
  72863. * @returns "ExtractHighlightsPostProcess" string
  72864. */
  72865. getClassName(): string;
  72866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72867. }
  72868. }
  72869. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  72870. /** @hidden */
  72871. export var bloomMergePixelShader: {
  72872. name: string;
  72873. shader: string;
  72874. };
  72875. }
  72876. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  72877. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72878. import { Nullable } from "babylonjs/types";
  72879. import { Engine } from "babylonjs/Engines/engine";
  72880. import { Camera } from "babylonjs/Cameras/camera";
  72881. import "babylonjs/Shaders/bloomMerge.fragment";
  72882. /**
  72883. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  72884. */
  72885. export class BloomMergePostProcess extends PostProcess {
  72886. /** Weight of the bloom to be added to the original input. */
  72887. weight: number;
  72888. /**
  72889. * Gets a string identifying the name of the class
  72890. * @returns "BloomMergePostProcess" string
  72891. */
  72892. getClassName(): string;
  72893. /**
  72894. * Creates a new instance of @see BloomMergePostProcess
  72895. * @param name The name of the effect.
  72896. * @param originalFromInput Post process which's input will be used for the merge.
  72897. * @param blurred Blurred highlights post process which's output will be used.
  72898. * @param weight Weight of the bloom to be added to the original input.
  72899. * @param options The required width/height ratio to downsize to before computing the render pass.
  72900. * @param camera The camera to apply the render pass to.
  72901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72902. * @param engine The engine which the post process will be applied. (default: current engine)
  72903. * @param reusable If the post process can be reused on the same frame. (default: false)
  72904. * @param textureType Type of textures used when performing the post process. (default: 0)
  72905. * @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)
  72906. */
  72907. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  72908. /** Weight of the bloom to be added to the original input. */
  72909. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72910. }
  72911. }
  72912. declare module "babylonjs/PostProcesses/bloomEffect" {
  72913. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  72914. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72915. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  72916. import { Camera } from "babylonjs/Cameras/camera";
  72917. import { Scene } from "babylonjs/scene";
  72918. /**
  72919. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  72920. */
  72921. export class BloomEffect extends PostProcessRenderEffect {
  72922. private bloomScale;
  72923. /**
  72924. * @hidden Internal
  72925. */
  72926. _effects: Array<PostProcess>;
  72927. /**
  72928. * @hidden Internal
  72929. */
  72930. _downscale: ExtractHighlightsPostProcess;
  72931. private _blurX;
  72932. private _blurY;
  72933. private _merge;
  72934. /**
  72935. * The luminance threshold to find bright areas of the image to bloom.
  72936. */
  72937. get threshold(): number;
  72938. set threshold(value: number);
  72939. /**
  72940. * The strength of the bloom.
  72941. */
  72942. get weight(): number;
  72943. set weight(value: number);
  72944. /**
  72945. * Specifies the size of the bloom blur kernel, relative to the final output size
  72946. */
  72947. get kernel(): number;
  72948. set kernel(value: number);
  72949. /**
  72950. * Creates a new instance of @see BloomEffect
  72951. * @param scene The scene the effect belongs to.
  72952. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  72953. * @param bloomKernel The size of the kernel to be used when applying the blur.
  72954. * @param bloomWeight The the strength of bloom.
  72955. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  72956. * @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)
  72957. */
  72958. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  72959. /**
  72960. * Disposes each of the internal effects for a given camera.
  72961. * @param camera The camera to dispose the effect on.
  72962. */
  72963. disposeEffects(camera: Camera): void;
  72964. /**
  72965. * @hidden Internal
  72966. */
  72967. _updateEffects(): void;
  72968. /**
  72969. * Internal
  72970. * @returns if all the contained post processes are ready.
  72971. * @hidden
  72972. */
  72973. _isReady(): boolean;
  72974. }
  72975. }
  72976. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  72977. /** @hidden */
  72978. export var chromaticAberrationPixelShader: {
  72979. name: string;
  72980. shader: string;
  72981. };
  72982. }
  72983. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  72984. import { Vector2 } from "babylonjs/Maths/math.vector";
  72985. import { Nullable } from "babylonjs/types";
  72986. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72987. import { Camera } from "babylonjs/Cameras/camera";
  72988. import { Engine } from "babylonjs/Engines/engine";
  72989. import "babylonjs/Shaders/chromaticAberration.fragment";
  72990. import { Scene } from "babylonjs/scene";
  72991. /**
  72992. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  72993. */
  72994. export class ChromaticAberrationPostProcess extends PostProcess {
  72995. /**
  72996. * The amount of seperation of rgb channels (default: 30)
  72997. */
  72998. aberrationAmount: number;
  72999. /**
  73000. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73001. */
  73002. radialIntensity: number;
  73003. /**
  73004. * 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))
  73005. */
  73006. direction: Vector2;
  73007. /**
  73008. * 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))
  73009. */
  73010. centerPosition: Vector2;
  73011. /** The width of the screen to apply the effect on */
  73012. screenWidth: number;
  73013. /** The height of the screen to apply the effect on */
  73014. screenHeight: number;
  73015. /**
  73016. * Gets a string identifying the name of the class
  73017. * @returns "ChromaticAberrationPostProcess" string
  73018. */
  73019. getClassName(): string;
  73020. /**
  73021. * Creates a new instance ChromaticAberrationPostProcess
  73022. * @param name The name of the effect.
  73023. * @param screenWidth The width of the screen to apply the effect on.
  73024. * @param screenHeight The height of the screen to apply the effect on.
  73025. * @param options The required width/height ratio to downsize to before computing the render pass.
  73026. * @param camera The camera to apply the render pass to.
  73027. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73028. * @param engine The engine which the post process will be applied. (default: current engine)
  73029. * @param reusable If the post process can be reused on the same frame. (default: false)
  73030. * @param textureType Type of textures used when performing the post process. (default: 0)
  73031. * @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)
  73032. */
  73033. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73034. /** @hidden */
  73035. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73036. }
  73037. }
  73038. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73039. /** @hidden */
  73040. export var circleOfConfusionPixelShader: {
  73041. name: string;
  73042. shader: string;
  73043. };
  73044. }
  73045. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73046. import { Nullable } from "babylonjs/types";
  73047. import { Engine } from "babylonjs/Engines/engine";
  73048. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73049. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73050. import { Camera } from "babylonjs/Cameras/camera";
  73051. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73052. /**
  73053. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73054. */
  73055. export class CircleOfConfusionPostProcess extends PostProcess {
  73056. /**
  73057. * 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.
  73058. */
  73059. lensSize: number;
  73060. /**
  73061. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73062. */
  73063. fStop: number;
  73064. /**
  73065. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73066. */
  73067. focusDistance: number;
  73068. /**
  73069. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73070. */
  73071. focalLength: number;
  73072. /**
  73073. * Gets a string identifying the name of the class
  73074. * @returns "CircleOfConfusionPostProcess" string
  73075. */
  73076. getClassName(): string;
  73077. private _depthTexture;
  73078. /**
  73079. * Creates a new instance CircleOfConfusionPostProcess
  73080. * @param name The name of the effect.
  73081. * @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.
  73082. * @param options The required width/height ratio to downsize to before computing the render pass.
  73083. * @param camera The camera to apply the render pass to.
  73084. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73085. * @param engine The engine which the post process will be applied. (default: current engine)
  73086. * @param reusable If the post process can be reused on the same frame. (default: false)
  73087. * @param textureType Type of textures used when performing the post process. (default: 0)
  73088. * @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)
  73089. */
  73090. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73091. /**
  73092. * 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.
  73093. */
  73094. set depthTexture(value: RenderTargetTexture);
  73095. }
  73096. }
  73097. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73098. /** @hidden */
  73099. export var colorCorrectionPixelShader: {
  73100. name: string;
  73101. shader: string;
  73102. };
  73103. }
  73104. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73105. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73106. import { Engine } from "babylonjs/Engines/engine";
  73107. import { Camera } from "babylonjs/Cameras/camera";
  73108. import "babylonjs/Shaders/colorCorrection.fragment";
  73109. import { Nullable } from "babylonjs/types";
  73110. import { Scene } from "babylonjs/scene";
  73111. /**
  73112. *
  73113. * This post-process allows the modification of rendered colors by using
  73114. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73115. *
  73116. * The object needs to be provided an url to a texture containing the color
  73117. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73118. * Use an image editing software to tweak the LUT to match your needs.
  73119. *
  73120. * For an example of a color LUT, see here:
  73121. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73122. * For explanations on color grading, see here:
  73123. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73124. *
  73125. */
  73126. export class ColorCorrectionPostProcess extends PostProcess {
  73127. private _colorTableTexture;
  73128. /**
  73129. * Gets the color table url used to create the LUT texture
  73130. */
  73131. colorTableUrl: string;
  73132. /**
  73133. * Gets a string identifying the name of the class
  73134. * @returns "ColorCorrectionPostProcess" string
  73135. */
  73136. getClassName(): string;
  73137. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73138. /** @hidden */
  73139. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73140. }
  73141. }
  73142. declare module "babylonjs/Shaders/convolution.fragment" {
  73143. /** @hidden */
  73144. export var convolutionPixelShader: {
  73145. name: string;
  73146. shader: string;
  73147. };
  73148. }
  73149. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73150. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73151. import { Nullable } from "babylonjs/types";
  73152. import { Camera } from "babylonjs/Cameras/camera";
  73153. import { Engine } from "babylonjs/Engines/engine";
  73154. import "babylonjs/Shaders/convolution.fragment";
  73155. import { Scene } from "babylonjs/scene";
  73156. /**
  73157. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73158. * input texture to perform effects such as edge detection or sharpening
  73159. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73160. */
  73161. export class ConvolutionPostProcess extends PostProcess {
  73162. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73163. kernel: number[];
  73164. /**
  73165. * Gets a string identifying the name of the class
  73166. * @returns "ConvolutionPostProcess" string
  73167. */
  73168. getClassName(): string;
  73169. /**
  73170. * Creates a new instance ConvolutionPostProcess
  73171. * @param name The name of the effect.
  73172. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73173. * @param options The required width/height ratio to downsize to before computing the render pass.
  73174. * @param camera The camera to apply the render pass to.
  73175. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73176. * @param engine The engine which the post process will be applied. (default: current engine)
  73177. * @param reusable If the post process can be reused on the same frame. (default: false)
  73178. * @param textureType Type of textures used when performing the post process. (default: 0)
  73179. */
  73180. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73181. /** @hidden */
  73182. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73183. /**
  73184. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73185. */
  73186. static EdgeDetect0Kernel: number[];
  73187. /**
  73188. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73189. */
  73190. static EdgeDetect1Kernel: number[];
  73191. /**
  73192. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73193. */
  73194. static EdgeDetect2Kernel: number[];
  73195. /**
  73196. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73197. */
  73198. static SharpenKernel: number[];
  73199. /**
  73200. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73201. */
  73202. static EmbossKernel: number[];
  73203. /**
  73204. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73205. */
  73206. static GaussianKernel: number[];
  73207. }
  73208. }
  73209. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73210. import { Nullable } from "babylonjs/types";
  73211. import { Vector2 } from "babylonjs/Maths/math.vector";
  73212. import { Camera } from "babylonjs/Cameras/camera";
  73213. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73214. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73215. import { Engine } from "babylonjs/Engines/engine";
  73216. import { Scene } from "babylonjs/scene";
  73217. /**
  73218. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73219. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73220. * based on samples that have a large difference in distance than the center pixel.
  73221. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73222. */
  73223. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73224. /**
  73225. * The direction the blur should be applied
  73226. */
  73227. direction: Vector2;
  73228. /**
  73229. * Gets a string identifying the name of the class
  73230. * @returns "DepthOfFieldBlurPostProcess" string
  73231. */
  73232. getClassName(): string;
  73233. /**
  73234. * Creates a new instance CircleOfConfusionPostProcess
  73235. * @param name The name of the effect.
  73236. * @param scene The scene the effect belongs to.
  73237. * @param direction The direction the blur should be applied.
  73238. * @param kernel The size of the kernel used to blur.
  73239. * @param options The required width/height ratio to downsize to before computing the render pass.
  73240. * @param camera The camera to apply the render pass to.
  73241. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73242. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73243. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73244. * @param engine The engine which the post process will be applied. (default: current engine)
  73245. * @param reusable If the post process can be reused on the same frame. (default: false)
  73246. * @param textureType Type of textures used when performing the post process. (default: 0)
  73247. * @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)
  73248. */
  73249. 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);
  73250. }
  73251. }
  73252. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73253. /** @hidden */
  73254. export var depthOfFieldMergePixelShader: {
  73255. name: string;
  73256. shader: string;
  73257. };
  73258. }
  73259. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73260. import { Nullable } from "babylonjs/types";
  73261. import { Camera } from "babylonjs/Cameras/camera";
  73262. import { Effect } from "babylonjs/Materials/effect";
  73263. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73264. import { Engine } from "babylonjs/Engines/engine";
  73265. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73266. /**
  73267. * Options to be set when merging outputs from the default pipeline.
  73268. */
  73269. export class DepthOfFieldMergePostProcessOptions {
  73270. /**
  73271. * The original image to merge on top of
  73272. */
  73273. originalFromInput: PostProcess;
  73274. /**
  73275. * Parameters to perform the merge of the depth of field effect
  73276. */
  73277. depthOfField?: {
  73278. circleOfConfusion: PostProcess;
  73279. blurSteps: Array<PostProcess>;
  73280. };
  73281. /**
  73282. * Parameters to perform the merge of bloom effect
  73283. */
  73284. bloom?: {
  73285. blurred: PostProcess;
  73286. weight: number;
  73287. };
  73288. }
  73289. /**
  73290. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73291. */
  73292. export class DepthOfFieldMergePostProcess extends PostProcess {
  73293. private blurSteps;
  73294. /**
  73295. * Gets a string identifying the name of the class
  73296. * @returns "DepthOfFieldMergePostProcess" string
  73297. */
  73298. getClassName(): string;
  73299. /**
  73300. * Creates a new instance of DepthOfFieldMergePostProcess
  73301. * @param name The name of the effect.
  73302. * @param originalFromInput Post process which's input will be used for the merge.
  73303. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73304. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73305. * @param options The required width/height ratio to downsize to before computing the render pass.
  73306. * @param camera The camera to apply the render pass to.
  73307. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73308. * @param engine The engine which the post process will be applied. (default: current engine)
  73309. * @param reusable If the post process can be reused on the same frame. (default: false)
  73310. * @param textureType Type of textures used when performing the post process. (default: 0)
  73311. * @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)
  73312. */
  73313. 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);
  73314. /**
  73315. * Updates the effect with the current post process compile time values and recompiles the shader.
  73316. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73317. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73318. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73319. * @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
  73320. * @param onCompiled Called when the shader has been compiled.
  73321. * @param onError Called if there is an error when compiling a shader.
  73322. */
  73323. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73324. }
  73325. }
  73326. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73327. import { Nullable } from "babylonjs/types";
  73328. import { Camera } from "babylonjs/Cameras/camera";
  73329. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73330. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73331. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73332. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73333. import { Scene } from "babylonjs/scene";
  73334. /**
  73335. * Specifies the level of max blur that should be applied when using the depth of field effect
  73336. */
  73337. export enum DepthOfFieldEffectBlurLevel {
  73338. /**
  73339. * Subtle blur
  73340. */
  73341. Low = 0,
  73342. /**
  73343. * Medium blur
  73344. */
  73345. Medium = 1,
  73346. /**
  73347. * Large blur
  73348. */
  73349. High = 2
  73350. }
  73351. /**
  73352. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73353. */
  73354. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73355. private _circleOfConfusion;
  73356. /**
  73357. * @hidden Internal, blurs from high to low
  73358. */
  73359. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73360. private _depthOfFieldBlurY;
  73361. private _dofMerge;
  73362. /**
  73363. * @hidden Internal post processes in depth of field effect
  73364. */
  73365. _effects: Array<PostProcess>;
  73366. /**
  73367. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73368. */
  73369. set focalLength(value: number);
  73370. get focalLength(): number;
  73371. /**
  73372. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73373. */
  73374. set fStop(value: number);
  73375. get fStop(): number;
  73376. /**
  73377. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73378. */
  73379. set focusDistance(value: number);
  73380. get focusDistance(): number;
  73381. /**
  73382. * 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.
  73383. */
  73384. set lensSize(value: number);
  73385. get lensSize(): number;
  73386. /**
  73387. * Creates a new instance DepthOfFieldEffect
  73388. * @param scene The scene the effect belongs to.
  73389. * @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.
  73390. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73391. * @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)
  73392. */
  73393. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73394. /**
  73395. * Get the current class name of the current effet
  73396. * @returns "DepthOfFieldEffect"
  73397. */
  73398. getClassName(): string;
  73399. /**
  73400. * 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.
  73401. */
  73402. set depthTexture(value: RenderTargetTexture);
  73403. /**
  73404. * Disposes each of the internal effects for a given camera.
  73405. * @param camera The camera to dispose the effect on.
  73406. */
  73407. disposeEffects(camera: Camera): void;
  73408. /**
  73409. * @hidden Internal
  73410. */
  73411. _updateEffects(): void;
  73412. /**
  73413. * Internal
  73414. * @returns if all the contained post processes are ready.
  73415. * @hidden
  73416. */
  73417. _isReady(): boolean;
  73418. }
  73419. }
  73420. declare module "babylonjs/Shaders/displayPass.fragment" {
  73421. /** @hidden */
  73422. export var displayPassPixelShader: {
  73423. name: string;
  73424. shader: string;
  73425. };
  73426. }
  73427. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73428. import { Nullable } from "babylonjs/types";
  73429. import { Camera } from "babylonjs/Cameras/camera";
  73430. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73431. import { Engine } from "babylonjs/Engines/engine";
  73432. import "babylonjs/Shaders/displayPass.fragment";
  73433. import { Scene } from "babylonjs/scene";
  73434. /**
  73435. * DisplayPassPostProcess which produces an output the same as it's input
  73436. */
  73437. export class DisplayPassPostProcess extends PostProcess {
  73438. /**
  73439. * Gets a string identifying the name of the class
  73440. * @returns "DisplayPassPostProcess" string
  73441. */
  73442. getClassName(): string;
  73443. /**
  73444. * Creates the DisplayPassPostProcess
  73445. * @param name The name of the effect.
  73446. * @param options The required width/height ratio to downsize to before computing the render pass.
  73447. * @param camera The camera to apply the render pass to.
  73448. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73449. * @param engine The engine which the post process will be applied. (default: current engine)
  73450. * @param reusable If the post process can be reused on the same frame. (default: false)
  73451. */
  73452. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73453. /** @hidden */
  73454. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73455. }
  73456. }
  73457. declare module "babylonjs/Shaders/filter.fragment" {
  73458. /** @hidden */
  73459. export var filterPixelShader: {
  73460. name: string;
  73461. shader: string;
  73462. };
  73463. }
  73464. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73465. import { Nullable } from "babylonjs/types";
  73466. import { Matrix } from "babylonjs/Maths/math.vector";
  73467. import { Camera } from "babylonjs/Cameras/camera";
  73468. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73469. import { Engine } from "babylonjs/Engines/engine";
  73470. import "babylonjs/Shaders/filter.fragment";
  73471. import { Scene } from "babylonjs/scene";
  73472. /**
  73473. * Applies a kernel filter to the image
  73474. */
  73475. export class FilterPostProcess extends PostProcess {
  73476. /** The matrix to be applied to the image */
  73477. kernelMatrix: Matrix;
  73478. /**
  73479. * Gets a string identifying the name of the class
  73480. * @returns "FilterPostProcess" string
  73481. */
  73482. getClassName(): string;
  73483. /**
  73484. *
  73485. * @param name The name of the effect.
  73486. * @param kernelMatrix The matrix to be applied to the image
  73487. * @param options The required width/height ratio to downsize to before computing the render pass.
  73488. * @param camera The camera to apply the render pass to.
  73489. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73490. * @param engine The engine which the post process will be applied. (default: current engine)
  73491. * @param reusable If the post process can be reused on the same frame. (default: false)
  73492. */
  73493. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73494. /** @hidden */
  73495. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73496. }
  73497. }
  73498. declare module "babylonjs/Shaders/fxaa.fragment" {
  73499. /** @hidden */
  73500. export var fxaaPixelShader: {
  73501. name: string;
  73502. shader: string;
  73503. };
  73504. }
  73505. declare module "babylonjs/Shaders/fxaa.vertex" {
  73506. /** @hidden */
  73507. export var fxaaVertexShader: {
  73508. name: string;
  73509. shader: string;
  73510. };
  73511. }
  73512. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73513. import { Nullable } from "babylonjs/types";
  73514. import { Camera } from "babylonjs/Cameras/camera";
  73515. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73516. import { Engine } from "babylonjs/Engines/engine";
  73517. import "babylonjs/Shaders/fxaa.fragment";
  73518. import "babylonjs/Shaders/fxaa.vertex";
  73519. import { Scene } from "babylonjs/scene";
  73520. /**
  73521. * Fxaa post process
  73522. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73523. */
  73524. export class FxaaPostProcess extends PostProcess {
  73525. /**
  73526. * Gets a string identifying the name of the class
  73527. * @returns "FxaaPostProcess" string
  73528. */
  73529. getClassName(): string;
  73530. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73531. private _getDefines;
  73532. /** @hidden */
  73533. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73534. }
  73535. }
  73536. declare module "babylonjs/Shaders/grain.fragment" {
  73537. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73538. /** @hidden */
  73539. export var grainPixelShader: {
  73540. name: string;
  73541. shader: string;
  73542. };
  73543. }
  73544. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73545. import { Nullable } from "babylonjs/types";
  73546. import { Camera } from "babylonjs/Cameras/camera";
  73547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73548. import { Engine } from "babylonjs/Engines/engine";
  73549. import "babylonjs/Shaders/grain.fragment";
  73550. import { Scene } from "babylonjs/scene";
  73551. /**
  73552. * The GrainPostProcess adds noise to the image at mid luminance levels
  73553. */
  73554. export class GrainPostProcess extends PostProcess {
  73555. /**
  73556. * The intensity of the grain added (default: 30)
  73557. */
  73558. intensity: number;
  73559. /**
  73560. * If the grain should be randomized on every frame
  73561. */
  73562. animated: boolean;
  73563. /**
  73564. * Gets a string identifying the name of the class
  73565. * @returns "GrainPostProcess" string
  73566. */
  73567. getClassName(): string;
  73568. /**
  73569. * Creates a new instance of @see GrainPostProcess
  73570. * @param name The name of the effect.
  73571. * @param options The required width/height ratio to downsize to before computing the render pass.
  73572. * @param camera The camera to apply the render pass to.
  73573. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73574. * @param engine The engine which the post process will be applied. (default: current engine)
  73575. * @param reusable If the post process can be reused on the same frame. (default: false)
  73576. * @param textureType Type of textures used when performing the post process. (default: 0)
  73577. * @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)
  73578. */
  73579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73580. /** @hidden */
  73581. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73582. }
  73583. }
  73584. declare module "babylonjs/Shaders/highlights.fragment" {
  73585. /** @hidden */
  73586. export var highlightsPixelShader: {
  73587. name: string;
  73588. shader: string;
  73589. };
  73590. }
  73591. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73592. import { Nullable } from "babylonjs/types";
  73593. import { Camera } from "babylonjs/Cameras/camera";
  73594. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73595. import { Engine } from "babylonjs/Engines/engine";
  73596. import "babylonjs/Shaders/highlights.fragment";
  73597. /**
  73598. * Extracts highlights from the image
  73599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73600. */
  73601. export class HighlightsPostProcess extends PostProcess {
  73602. /**
  73603. * Gets a string identifying the name of the class
  73604. * @returns "HighlightsPostProcess" string
  73605. */
  73606. getClassName(): string;
  73607. /**
  73608. * Extracts highlights from the image
  73609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73610. * @param name The name of the effect.
  73611. * @param options The required width/height ratio to downsize to before computing the render pass.
  73612. * @param camera The camera to apply the render pass to.
  73613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73614. * @param engine The engine which the post process will be applied. (default: current engine)
  73615. * @param reusable If the post process can be reused on the same frame. (default: false)
  73616. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73617. */
  73618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73619. }
  73620. }
  73621. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73622. /** @hidden */
  73623. export var mrtFragmentDeclaration: {
  73624. name: string;
  73625. shader: string;
  73626. };
  73627. }
  73628. declare module "babylonjs/Shaders/geometry.fragment" {
  73629. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73630. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73631. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73632. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73633. /** @hidden */
  73634. export var geometryPixelShader: {
  73635. name: string;
  73636. shader: string;
  73637. };
  73638. }
  73639. declare module "babylonjs/Shaders/geometry.vertex" {
  73640. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73641. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73642. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73643. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73644. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73645. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73646. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73647. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73648. /** @hidden */
  73649. export var geometryVertexShader: {
  73650. name: string;
  73651. shader: string;
  73652. };
  73653. }
  73654. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73655. import { Matrix } from "babylonjs/Maths/math.vector";
  73656. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73657. import { Mesh } from "babylonjs/Meshes/mesh";
  73658. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73659. import { Effect } from "babylonjs/Materials/effect";
  73660. import { Scene } from "babylonjs/scene";
  73661. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73662. import "babylonjs/Shaders/geometry.fragment";
  73663. import "babylonjs/Shaders/geometry.vertex";
  73664. /** @hidden */
  73665. interface ISavedTransformationMatrix {
  73666. world: Matrix;
  73667. viewProjection: Matrix;
  73668. }
  73669. /**
  73670. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73671. */
  73672. export class GeometryBufferRenderer {
  73673. /**
  73674. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73675. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73676. */
  73677. static readonly POSITION_TEXTURE_TYPE: number;
  73678. /**
  73679. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73680. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73681. */
  73682. static readonly VELOCITY_TEXTURE_TYPE: number;
  73683. /**
  73684. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73685. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73686. */
  73687. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73688. /**
  73689. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73690. * in order to compute objects velocities when enableVelocity is set to "true"
  73691. * @hidden
  73692. */
  73693. _previousTransformationMatrices: {
  73694. [index: number]: ISavedTransformationMatrix;
  73695. };
  73696. /**
  73697. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73698. * in order to compute objects velocities when enableVelocity is set to "true"
  73699. * @hidden
  73700. */
  73701. _previousBonesTransformationMatrices: {
  73702. [index: number]: Float32Array;
  73703. };
  73704. /**
  73705. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73706. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73707. */
  73708. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73709. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73710. renderTransparentMeshes: boolean;
  73711. private _scene;
  73712. private _resizeObserver;
  73713. private _multiRenderTarget;
  73714. private _ratio;
  73715. private _enablePosition;
  73716. private _enableVelocity;
  73717. private _enableReflectivity;
  73718. private _positionIndex;
  73719. private _velocityIndex;
  73720. private _reflectivityIndex;
  73721. protected _effect: Effect;
  73722. protected _cachedDefines: string;
  73723. /**
  73724. * Set the render list (meshes to be rendered) used in the G buffer.
  73725. */
  73726. set renderList(meshes: Mesh[]);
  73727. /**
  73728. * Gets wether or not G buffer are supported by the running hardware.
  73729. * This requires draw buffer supports
  73730. */
  73731. get isSupported(): boolean;
  73732. /**
  73733. * Returns the index of the given texture type in the G-Buffer textures array
  73734. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73735. * @returns the index of the given texture type in the G-Buffer textures array
  73736. */
  73737. getTextureIndex(textureType: number): number;
  73738. /**
  73739. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73740. */
  73741. get enablePosition(): boolean;
  73742. /**
  73743. * Sets whether or not objects positions are enabled for the G buffer.
  73744. */
  73745. set enablePosition(enable: boolean);
  73746. /**
  73747. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73748. */
  73749. get enableVelocity(): boolean;
  73750. /**
  73751. * Sets wether or not objects velocities are enabled for the G buffer.
  73752. */
  73753. set enableVelocity(enable: boolean);
  73754. /**
  73755. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73756. */
  73757. get enableReflectivity(): boolean;
  73758. /**
  73759. * Sets wether or not objects roughness are enabled for the G buffer.
  73760. */
  73761. set enableReflectivity(enable: boolean);
  73762. /**
  73763. * Gets the scene associated with the buffer.
  73764. */
  73765. get scene(): Scene;
  73766. /**
  73767. * Gets the ratio used by the buffer during its creation.
  73768. * How big is the buffer related to the main canvas.
  73769. */
  73770. get ratio(): number;
  73771. /** @hidden */
  73772. static _SceneComponentInitialization: (scene: Scene) => void;
  73773. /**
  73774. * Creates a new G Buffer for the scene
  73775. * @param scene The scene the buffer belongs to
  73776. * @param ratio How big is the buffer related to the main canvas.
  73777. */
  73778. constructor(scene: Scene, ratio?: number);
  73779. /**
  73780. * Checks wether everything is ready to render a submesh to the G buffer.
  73781. * @param subMesh the submesh to check readiness for
  73782. * @param useInstances is the mesh drawn using instance or not
  73783. * @returns true if ready otherwise false
  73784. */
  73785. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73786. /**
  73787. * Gets the current underlying G Buffer.
  73788. * @returns the buffer
  73789. */
  73790. getGBuffer(): MultiRenderTarget;
  73791. /**
  73792. * Gets the number of samples used to render the buffer (anti aliasing).
  73793. */
  73794. get samples(): number;
  73795. /**
  73796. * Sets the number of samples used to render the buffer (anti aliasing).
  73797. */
  73798. set samples(value: number);
  73799. /**
  73800. * Disposes the renderer and frees up associated resources.
  73801. */
  73802. dispose(): void;
  73803. protected _createRenderTargets(): void;
  73804. private _copyBonesTransformationMatrices;
  73805. }
  73806. }
  73807. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  73808. import { Nullable } from "babylonjs/types";
  73809. import { Scene } from "babylonjs/scene";
  73810. import { ISceneComponent } from "babylonjs/sceneComponent";
  73811. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  73812. module "babylonjs/scene" {
  73813. interface Scene {
  73814. /** @hidden (Backing field) */
  73815. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73816. /**
  73817. * Gets or Sets the current geometry buffer associated to the scene.
  73818. */
  73819. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  73820. /**
  73821. * Enables a GeometryBufferRender and associates it with the scene
  73822. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  73823. * @returns the GeometryBufferRenderer
  73824. */
  73825. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  73826. /**
  73827. * Disables the GeometryBufferRender associated with the scene
  73828. */
  73829. disableGeometryBufferRenderer(): void;
  73830. }
  73831. }
  73832. /**
  73833. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  73834. * in several rendering techniques.
  73835. */
  73836. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  73837. /**
  73838. * The component name helpful to identify the component in the list of scene components.
  73839. */
  73840. readonly name: string;
  73841. /**
  73842. * The scene the component belongs to.
  73843. */
  73844. scene: Scene;
  73845. /**
  73846. * Creates a new instance of the component for the given scene
  73847. * @param scene Defines the scene to register the component in
  73848. */
  73849. constructor(scene: Scene);
  73850. /**
  73851. * Registers the component in a given scene
  73852. */
  73853. register(): void;
  73854. /**
  73855. * Rebuilds the elements related to this component in case of
  73856. * context lost for instance.
  73857. */
  73858. rebuild(): void;
  73859. /**
  73860. * Disposes the component and the associated ressources
  73861. */
  73862. dispose(): void;
  73863. private _gatherRenderTargets;
  73864. }
  73865. }
  73866. declare module "babylonjs/Shaders/motionBlur.fragment" {
  73867. /** @hidden */
  73868. export var motionBlurPixelShader: {
  73869. name: string;
  73870. shader: string;
  73871. };
  73872. }
  73873. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  73874. import { Nullable } from "babylonjs/types";
  73875. import { Camera } from "babylonjs/Cameras/camera";
  73876. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73877. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73878. import "babylonjs/Animations/animatable";
  73879. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  73880. import "babylonjs/Shaders/motionBlur.fragment";
  73881. import { Engine } from "babylonjs/Engines/engine";
  73882. import { Scene } from "babylonjs/scene";
  73883. /**
  73884. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  73885. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  73886. * As an example, all you have to do is to create the post-process:
  73887. * var mb = new BABYLON.MotionBlurPostProcess(
  73888. * 'mb', // The name of the effect.
  73889. * scene, // The scene containing the objects to blur according to their velocity.
  73890. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  73891. * camera // The camera to apply the render pass to.
  73892. * );
  73893. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  73894. */
  73895. export class MotionBlurPostProcess extends PostProcess {
  73896. /**
  73897. * Defines how much the image is blurred by the movement. Default value is equal to 1
  73898. */
  73899. motionStrength: number;
  73900. /**
  73901. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  73902. */
  73903. get motionBlurSamples(): number;
  73904. /**
  73905. * Sets the number of iterations to be used for motion blur quality
  73906. */
  73907. set motionBlurSamples(samples: number);
  73908. private _motionBlurSamples;
  73909. private _geometryBufferRenderer;
  73910. /**
  73911. * Gets a string identifying the name of the class
  73912. * @returns "MotionBlurPostProcess" string
  73913. */
  73914. getClassName(): string;
  73915. /**
  73916. * Creates a new instance MotionBlurPostProcess
  73917. * @param name The name of the effect.
  73918. * @param scene The scene containing the objects to blur according to their velocity.
  73919. * @param options The required width/height ratio to downsize to before computing the render pass.
  73920. * @param camera The camera to apply the render pass to.
  73921. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73922. * @param engine The engine which the post process will be applied. (default: current engine)
  73923. * @param reusable If the post process can be reused on the same frame. (default: false)
  73924. * @param textureType Type of textures used when performing the post process. (default: 0)
  73925. * @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)
  73926. */
  73927. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73928. /**
  73929. * Excludes the given skinned mesh from computing bones velocities.
  73930. * 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.
  73931. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  73932. */
  73933. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73934. /**
  73935. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  73936. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  73937. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  73938. */
  73939. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  73940. /**
  73941. * Disposes the post process.
  73942. * @param camera The camera to dispose the post process on.
  73943. */
  73944. dispose(camera?: Camera): void;
  73945. /** @hidden */
  73946. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  73947. }
  73948. }
  73949. declare module "babylonjs/Shaders/refraction.fragment" {
  73950. /** @hidden */
  73951. export var refractionPixelShader: {
  73952. name: string;
  73953. shader: string;
  73954. };
  73955. }
  73956. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  73957. import { Color3 } from "babylonjs/Maths/math.color";
  73958. import { Camera } from "babylonjs/Cameras/camera";
  73959. import { Texture } from "babylonjs/Materials/Textures/texture";
  73960. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73961. import { Engine } from "babylonjs/Engines/engine";
  73962. import "babylonjs/Shaders/refraction.fragment";
  73963. import { Scene } from "babylonjs/scene";
  73964. /**
  73965. * Post process which applies a refractin texture
  73966. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73967. */
  73968. export class RefractionPostProcess extends PostProcess {
  73969. private _refTexture;
  73970. private _ownRefractionTexture;
  73971. /** the base color of the refraction (used to taint the rendering) */
  73972. color: Color3;
  73973. /** simulated refraction depth */
  73974. depth: number;
  73975. /** the coefficient of the base color (0 to remove base color tainting) */
  73976. colorLevel: number;
  73977. /** Gets the url used to load the refraction texture */
  73978. refractionTextureUrl: string;
  73979. /**
  73980. * Gets or sets the refraction texture
  73981. * Please note that you are responsible for disposing the texture if you set it manually
  73982. */
  73983. get refractionTexture(): Texture;
  73984. set refractionTexture(value: Texture);
  73985. /**
  73986. * Gets a string identifying the name of the class
  73987. * @returns "RefractionPostProcess" string
  73988. */
  73989. getClassName(): string;
  73990. /**
  73991. * Initializes the RefractionPostProcess
  73992. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  73993. * @param name The name of the effect.
  73994. * @param refractionTextureUrl Url of the refraction texture to use
  73995. * @param color the base color of the refraction (used to taint the rendering)
  73996. * @param depth simulated refraction depth
  73997. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  73998. * @param camera The camera to apply the render pass to.
  73999. * @param options The required width/height ratio to downsize to before computing the render pass.
  74000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74001. * @param engine The engine which the post process will be applied. (default: current engine)
  74002. * @param reusable If the post process can be reused on the same frame. (default: false)
  74003. */
  74004. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74005. /**
  74006. * Disposes of the post process
  74007. * @param camera Camera to dispose post process on
  74008. */
  74009. dispose(camera: Camera): void;
  74010. /** @hidden */
  74011. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74012. }
  74013. }
  74014. declare module "babylonjs/Shaders/sharpen.fragment" {
  74015. /** @hidden */
  74016. export var sharpenPixelShader: {
  74017. name: string;
  74018. shader: string;
  74019. };
  74020. }
  74021. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74022. import { Nullable } from "babylonjs/types";
  74023. import { Camera } from "babylonjs/Cameras/camera";
  74024. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74025. import "babylonjs/Shaders/sharpen.fragment";
  74026. import { Engine } from "babylonjs/Engines/engine";
  74027. import { Scene } from "babylonjs/scene";
  74028. /**
  74029. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74030. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74031. */
  74032. export class SharpenPostProcess extends PostProcess {
  74033. /**
  74034. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74035. */
  74036. colorAmount: number;
  74037. /**
  74038. * How much sharpness should be applied (default: 0.3)
  74039. */
  74040. edgeAmount: number;
  74041. /**
  74042. * Gets a string identifying the name of the class
  74043. * @returns "SharpenPostProcess" string
  74044. */
  74045. getClassName(): string;
  74046. /**
  74047. * Creates a new instance ConvolutionPostProcess
  74048. * @param name The name of the effect.
  74049. * @param options The required width/height ratio to downsize to before computing the render pass.
  74050. * @param camera The camera to apply the render pass to.
  74051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74052. * @param engine The engine which the post process will be applied. (default: current engine)
  74053. * @param reusable If the post process can be reused on the same frame. (default: false)
  74054. * @param textureType Type of textures used when performing the post process. (default: 0)
  74055. * @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)
  74056. */
  74057. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74058. /** @hidden */
  74059. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74060. }
  74061. }
  74062. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74063. import { Nullable } from "babylonjs/types";
  74064. import { Camera } from "babylonjs/Cameras/camera";
  74065. import { Engine } from "babylonjs/Engines/engine";
  74066. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74067. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74068. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74069. /**
  74070. * PostProcessRenderPipeline
  74071. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74072. */
  74073. export class PostProcessRenderPipeline {
  74074. private engine;
  74075. private _renderEffects;
  74076. private _renderEffectsForIsolatedPass;
  74077. /**
  74078. * List of inspectable custom properties (used by the Inspector)
  74079. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74080. */
  74081. inspectableCustomProperties: IInspectable[];
  74082. /**
  74083. * @hidden
  74084. */
  74085. protected _cameras: Camera[];
  74086. /** @hidden */
  74087. _name: string;
  74088. /**
  74089. * Gets pipeline name
  74090. */
  74091. get name(): string;
  74092. /** Gets the list of attached cameras */
  74093. get cameras(): Camera[];
  74094. /**
  74095. * Initializes a PostProcessRenderPipeline
  74096. * @param engine engine to add the pipeline to
  74097. * @param name name of the pipeline
  74098. */
  74099. constructor(engine: Engine, name: string);
  74100. /**
  74101. * Gets the class name
  74102. * @returns "PostProcessRenderPipeline"
  74103. */
  74104. getClassName(): string;
  74105. /**
  74106. * If all the render effects in the pipeline are supported
  74107. */
  74108. get isSupported(): boolean;
  74109. /**
  74110. * Adds an effect to the pipeline
  74111. * @param renderEffect the effect to add
  74112. */
  74113. addEffect(renderEffect: PostProcessRenderEffect): void;
  74114. /** @hidden */
  74115. _rebuild(): void;
  74116. /** @hidden */
  74117. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74118. /** @hidden */
  74119. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74120. /** @hidden */
  74121. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74122. /** @hidden */
  74123. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74124. /** @hidden */
  74125. _attachCameras(cameras: Camera, unique: boolean): void;
  74126. /** @hidden */
  74127. _attachCameras(cameras: Camera[], unique: boolean): void;
  74128. /** @hidden */
  74129. _detachCameras(cameras: Camera): void;
  74130. /** @hidden */
  74131. _detachCameras(cameras: Nullable<Camera[]>): void;
  74132. /** @hidden */
  74133. _update(): void;
  74134. /** @hidden */
  74135. _reset(): void;
  74136. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74137. /**
  74138. * Sets the required values to the prepass renderer.
  74139. * @param prePassRenderer defines the prepass renderer to setup.
  74140. * @returns true if the pre pass is needed.
  74141. */
  74142. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74143. /**
  74144. * Disposes of the pipeline
  74145. */
  74146. dispose(): void;
  74147. }
  74148. }
  74149. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74150. import { Camera } from "babylonjs/Cameras/camera";
  74151. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74152. /**
  74153. * PostProcessRenderPipelineManager class
  74154. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74155. */
  74156. export class PostProcessRenderPipelineManager {
  74157. private _renderPipelines;
  74158. /**
  74159. * Initializes a PostProcessRenderPipelineManager
  74160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74161. */
  74162. constructor();
  74163. /**
  74164. * Gets the list of supported render pipelines
  74165. */
  74166. get supportedPipelines(): PostProcessRenderPipeline[];
  74167. /**
  74168. * Adds a pipeline to the manager
  74169. * @param renderPipeline The pipeline to add
  74170. */
  74171. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74172. /**
  74173. * Attaches a camera to the pipeline
  74174. * @param renderPipelineName The name of the pipeline to attach to
  74175. * @param cameras the camera to attach
  74176. * @param unique if the camera can be attached multiple times to the pipeline
  74177. */
  74178. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74179. /**
  74180. * Detaches a camera from the pipeline
  74181. * @param renderPipelineName The name of the pipeline to detach from
  74182. * @param cameras the camera to detach
  74183. */
  74184. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74185. /**
  74186. * Enables an effect by name on a pipeline
  74187. * @param renderPipelineName the name of the pipeline to enable the effect in
  74188. * @param renderEffectName the name of the effect to enable
  74189. * @param cameras the cameras that the effect should be enabled on
  74190. */
  74191. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74192. /**
  74193. * Disables an effect by name on a pipeline
  74194. * @param renderPipelineName the name of the pipeline to disable the effect in
  74195. * @param renderEffectName the name of the effect to disable
  74196. * @param cameras the cameras that the effect should be disabled on
  74197. */
  74198. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74199. /**
  74200. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74201. */
  74202. update(): void;
  74203. /** @hidden */
  74204. _rebuild(): void;
  74205. /**
  74206. * Disposes of the manager and pipelines
  74207. */
  74208. dispose(): void;
  74209. }
  74210. }
  74211. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74212. import { ISceneComponent } from "babylonjs/sceneComponent";
  74213. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74214. import { Scene } from "babylonjs/scene";
  74215. module "babylonjs/scene" {
  74216. interface Scene {
  74217. /** @hidden (Backing field) */
  74218. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74219. /**
  74220. * Gets the postprocess render pipeline manager
  74221. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74222. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74223. */
  74224. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74225. }
  74226. }
  74227. /**
  74228. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74229. */
  74230. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74231. /**
  74232. * The component name helpfull to identify the component in the list of scene components.
  74233. */
  74234. readonly name: string;
  74235. /**
  74236. * The scene the component belongs to.
  74237. */
  74238. scene: Scene;
  74239. /**
  74240. * Creates a new instance of the component for the given scene
  74241. * @param scene Defines the scene to register the component in
  74242. */
  74243. constructor(scene: Scene);
  74244. /**
  74245. * Registers the component in a given scene
  74246. */
  74247. register(): void;
  74248. /**
  74249. * Rebuilds the elements related to this component in case of
  74250. * context lost for instance.
  74251. */
  74252. rebuild(): void;
  74253. /**
  74254. * Disposes the component and the associated ressources
  74255. */
  74256. dispose(): void;
  74257. private _gatherRenderTargets;
  74258. }
  74259. }
  74260. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74261. import { Nullable } from "babylonjs/types";
  74262. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74263. import { Camera } from "babylonjs/Cameras/camera";
  74264. import { IDisposable } from "babylonjs/scene";
  74265. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74266. import { Scene } from "babylonjs/scene";
  74267. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74268. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74269. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74270. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74271. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74272. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74273. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74274. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74275. import { Animation } from "babylonjs/Animations/animation";
  74276. /**
  74277. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74278. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74279. */
  74280. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74281. private _scene;
  74282. private _camerasToBeAttached;
  74283. /**
  74284. * ID of the sharpen post process,
  74285. */
  74286. private readonly SharpenPostProcessId;
  74287. /**
  74288. * @ignore
  74289. * ID of the image processing post process;
  74290. */
  74291. readonly ImageProcessingPostProcessId: string;
  74292. /**
  74293. * @ignore
  74294. * ID of the Fast Approximate Anti-Aliasing post process;
  74295. */
  74296. readonly FxaaPostProcessId: string;
  74297. /**
  74298. * ID of the chromatic aberration post process,
  74299. */
  74300. private readonly ChromaticAberrationPostProcessId;
  74301. /**
  74302. * ID of the grain post process
  74303. */
  74304. private readonly GrainPostProcessId;
  74305. /**
  74306. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74307. */
  74308. sharpen: SharpenPostProcess;
  74309. private _sharpenEffect;
  74310. private bloom;
  74311. /**
  74312. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74313. */
  74314. depthOfField: DepthOfFieldEffect;
  74315. /**
  74316. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74317. */
  74318. fxaa: FxaaPostProcess;
  74319. /**
  74320. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74321. */
  74322. imageProcessing: ImageProcessingPostProcess;
  74323. /**
  74324. * Chromatic aberration post process which will shift rgb colors in the image
  74325. */
  74326. chromaticAberration: ChromaticAberrationPostProcess;
  74327. private _chromaticAberrationEffect;
  74328. /**
  74329. * Grain post process which add noise to the image
  74330. */
  74331. grain: GrainPostProcess;
  74332. private _grainEffect;
  74333. /**
  74334. * Glow post process which adds a glow to emissive areas of the image
  74335. */
  74336. private _glowLayer;
  74337. /**
  74338. * Animations which can be used to tweak settings over a period of time
  74339. */
  74340. animations: Animation[];
  74341. private _imageProcessingConfigurationObserver;
  74342. private _sharpenEnabled;
  74343. private _bloomEnabled;
  74344. private _depthOfFieldEnabled;
  74345. private _depthOfFieldBlurLevel;
  74346. private _fxaaEnabled;
  74347. private _imageProcessingEnabled;
  74348. private _defaultPipelineTextureType;
  74349. private _bloomScale;
  74350. private _chromaticAberrationEnabled;
  74351. private _grainEnabled;
  74352. private _buildAllowed;
  74353. /**
  74354. * Gets active scene
  74355. */
  74356. get scene(): Scene;
  74357. /**
  74358. * Enable or disable the sharpen process from the pipeline
  74359. */
  74360. set sharpenEnabled(enabled: boolean);
  74361. get sharpenEnabled(): boolean;
  74362. private _resizeObserver;
  74363. private _hardwareScaleLevel;
  74364. private _bloomKernel;
  74365. /**
  74366. * Specifies the size of the bloom blur kernel, relative to the final output size
  74367. */
  74368. get bloomKernel(): number;
  74369. set bloomKernel(value: number);
  74370. /**
  74371. * Specifies the weight of the bloom in the final rendering
  74372. */
  74373. private _bloomWeight;
  74374. /**
  74375. * Specifies the luma threshold for the area that will be blurred by the bloom
  74376. */
  74377. private _bloomThreshold;
  74378. private _hdr;
  74379. /**
  74380. * The strength of the bloom.
  74381. */
  74382. set bloomWeight(value: number);
  74383. get bloomWeight(): number;
  74384. /**
  74385. * The strength of the bloom.
  74386. */
  74387. set bloomThreshold(value: number);
  74388. get bloomThreshold(): number;
  74389. /**
  74390. * The scale of the bloom, lower value will provide better performance.
  74391. */
  74392. set bloomScale(value: number);
  74393. get bloomScale(): number;
  74394. /**
  74395. * Enable or disable the bloom from the pipeline
  74396. */
  74397. set bloomEnabled(enabled: boolean);
  74398. get bloomEnabled(): boolean;
  74399. private _rebuildBloom;
  74400. /**
  74401. * If the depth of field is enabled.
  74402. */
  74403. get depthOfFieldEnabled(): boolean;
  74404. set depthOfFieldEnabled(enabled: boolean);
  74405. /**
  74406. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74407. */
  74408. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74409. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74410. /**
  74411. * If the anti aliasing is enabled.
  74412. */
  74413. set fxaaEnabled(enabled: boolean);
  74414. get fxaaEnabled(): boolean;
  74415. private _samples;
  74416. /**
  74417. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74418. */
  74419. set samples(sampleCount: number);
  74420. get samples(): number;
  74421. /**
  74422. * If image processing is enabled.
  74423. */
  74424. set imageProcessingEnabled(enabled: boolean);
  74425. get imageProcessingEnabled(): boolean;
  74426. /**
  74427. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74428. */
  74429. set glowLayerEnabled(enabled: boolean);
  74430. get glowLayerEnabled(): boolean;
  74431. /**
  74432. * Gets the glow layer (or null if not defined)
  74433. */
  74434. get glowLayer(): Nullable<GlowLayer>;
  74435. /**
  74436. * Enable or disable the chromaticAberration process from the pipeline
  74437. */
  74438. set chromaticAberrationEnabled(enabled: boolean);
  74439. get chromaticAberrationEnabled(): boolean;
  74440. /**
  74441. * Enable or disable the grain process from the pipeline
  74442. */
  74443. set grainEnabled(enabled: boolean);
  74444. get grainEnabled(): boolean;
  74445. /**
  74446. * @constructor
  74447. * @param name - The rendering pipeline name (default: "")
  74448. * @param hdr - If high dynamic range textures should be used (default: true)
  74449. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74450. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74451. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74452. */
  74453. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74454. /**
  74455. * Get the class name
  74456. * @returns "DefaultRenderingPipeline"
  74457. */
  74458. getClassName(): string;
  74459. /**
  74460. * Force the compilation of the entire pipeline.
  74461. */
  74462. prepare(): void;
  74463. private _hasCleared;
  74464. private _prevPostProcess;
  74465. private _prevPrevPostProcess;
  74466. private _setAutoClearAndTextureSharing;
  74467. private _depthOfFieldSceneObserver;
  74468. private _buildPipeline;
  74469. private _disposePostProcesses;
  74470. /**
  74471. * Adds a camera to the pipeline
  74472. * @param camera the camera to be added
  74473. */
  74474. addCamera(camera: Camera): void;
  74475. /**
  74476. * Removes a camera from the pipeline
  74477. * @param camera the camera to remove
  74478. */
  74479. removeCamera(camera: Camera): void;
  74480. /**
  74481. * Dispose of the pipeline and stop all post processes
  74482. */
  74483. dispose(): void;
  74484. /**
  74485. * Serialize the rendering pipeline (Used when exporting)
  74486. * @returns the serialized object
  74487. */
  74488. serialize(): any;
  74489. /**
  74490. * Parse the serialized pipeline
  74491. * @param source Source pipeline.
  74492. * @param scene The scene to load the pipeline to.
  74493. * @param rootUrl The URL of the serialized pipeline.
  74494. * @returns An instantiated pipeline from the serialized object.
  74495. */
  74496. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74497. }
  74498. }
  74499. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74500. /** @hidden */
  74501. export var lensHighlightsPixelShader: {
  74502. name: string;
  74503. shader: string;
  74504. };
  74505. }
  74506. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74507. /** @hidden */
  74508. export var depthOfFieldPixelShader: {
  74509. name: string;
  74510. shader: string;
  74511. };
  74512. }
  74513. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74514. import { Camera } from "babylonjs/Cameras/camera";
  74515. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74516. import { Scene } from "babylonjs/scene";
  74517. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74518. import "babylonjs/Shaders/chromaticAberration.fragment";
  74519. import "babylonjs/Shaders/lensHighlights.fragment";
  74520. import "babylonjs/Shaders/depthOfField.fragment";
  74521. /**
  74522. * BABYLON.JS Chromatic Aberration GLSL Shader
  74523. * Author: Olivier Guyot
  74524. * Separates very slightly R, G and B colors on the edges of the screen
  74525. * Inspired by Francois Tarlier & Martins Upitis
  74526. */
  74527. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74528. /**
  74529. * @ignore
  74530. * The chromatic aberration PostProcess id in the pipeline
  74531. */
  74532. LensChromaticAberrationEffect: string;
  74533. /**
  74534. * @ignore
  74535. * The highlights enhancing PostProcess id in the pipeline
  74536. */
  74537. HighlightsEnhancingEffect: string;
  74538. /**
  74539. * @ignore
  74540. * The depth-of-field PostProcess id in the pipeline
  74541. */
  74542. LensDepthOfFieldEffect: string;
  74543. private _scene;
  74544. private _depthTexture;
  74545. private _grainTexture;
  74546. private _chromaticAberrationPostProcess;
  74547. private _highlightsPostProcess;
  74548. private _depthOfFieldPostProcess;
  74549. private _edgeBlur;
  74550. private _grainAmount;
  74551. private _chromaticAberration;
  74552. private _distortion;
  74553. private _highlightsGain;
  74554. private _highlightsThreshold;
  74555. private _dofDistance;
  74556. private _dofAperture;
  74557. private _dofDarken;
  74558. private _dofPentagon;
  74559. private _blurNoise;
  74560. /**
  74561. * @constructor
  74562. *
  74563. * Effect parameters are as follow:
  74564. * {
  74565. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74566. * edge_blur: number; // from 0 to x (1 for realism)
  74567. * distortion: number; // from 0 to x (1 for realism)
  74568. * grain_amount: number; // from 0 to 1
  74569. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74570. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74571. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74572. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74573. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74574. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74575. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74576. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74577. * }
  74578. * Note: if an effect parameter is unset, effect is disabled
  74579. *
  74580. * @param name The rendering pipeline name
  74581. * @param parameters - An object containing all parameters (see above)
  74582. * @param scene The scene linked to this pipeline
  74583. * @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)
  74584. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74585. */
  74586. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74587. /**
  74588. * Get the class name
  74589. * @returns "LensRenderingPipeline"
  74590. */
  74591. getClassName(): string;
  74592. /**
  74593. * Gets associated scene
  74594. */
  74595. get scene(): Scene;
  74596. /**
  74597. * Gets or sets the edge blur
  74598. */
  74599. get edgeBlur(): number;
  74600. set edgeBlur(value: number);
  74601. /**
  74602. * Gets or sets the grain amount
  74603. */
  74604. get grainAmount(): number;
  74605. set grainAmount(value: number);
  74606. /**
  74607. * Gets or sets the chromatic aberration amount
  74608. */
  74609. get chromaticAberration(): number;
  74610. set chromaticAberration(value: number);
  74611. /**
  74612. * Gets or sets the depth of field aperture
  74613. */
  74614. get dofAperture(): number;
  74615. set dofAperture(value: number);
  74616. /**
  74617. * Gets or sets the edge distortion
  74618. */
  74619. get edgeDistortion(): number;
  74620. set edgeDistortion(value: number);
  74621. /**
  74622. * Gets or sets the depth of field distortion
  74623. */
  74624. get dofDistortion(): number;
  74625. set dofDistortion(value: number);
  74626. /**
  74627. * Gets or sets the darken out of focus amount
  74628. */
  74629. get darkenOutOfFocus(): number;
  74630. set darkenOutOfFocus(value: number);
  74631. /**
  74632. * Gets or sets a boolean indicating if blur noise is enabled
  74633. */
  74634. get blurNoise(): boolean;
  74635. set blurNoise(value: boolean);
  74636. /**
  74637. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74638. */
  74639. get pentagonBokeh(): boolean;
  74640. set pentagonBokeh(value: boolean);
  74641. /**
  74642. * Gets or sets the highlight grain amount
  74643. */
  74644. get highlightsGain(): number;
  74645. set highlightsGain(value: number);
  74646. /**
  74647. * Gets or sets the highlight threshold
  74648. */
  74649. get highlightsThreshold(): number;
  74650. set highlightsThreshold(value: number);
  74651. /**
  74652. * Sets the amount of blur at the edges
  74653. * @param amount blur amount
  74654. */
  74655. setEdgeBlur(amount: number): void;
  74656. /**
  74657. * Sets edge blur to 0
  74658. */
  74659. disableEdgeBlur(): void;
  74660. /**
  74661. * Sets the amout of grain
  74662. * @param amount Amount of grain
  74663. */
  74664. setGrainAmount(amount: number): void;
  74665. /**
  74666. * Set grain amount to 0
  74667. */
  74668. disableGrain(): void;
  74669. /**
  74670. * Sets the chromatic aberration amount
  74671. * @param amount amount of chromatic aberration
  74672. */
  74673. setChromaticAberration(amount: number): void;
  74674. /**
  74675. * Sets chromatic aberration amount to 0
  74676. */
  74677. disableChromaticAberration(): void;
  74678. /**
  74679. * Sets the EdgeDistortion amount
  74680. * @param amount amount of EdgeDistortion
  74681. */
  74682. setEdgeDistortion(amount: number): void;
  74683. /**
  74684. * Sets edge distortion to 0
  74685. */
  74686. disableEdgeDistortion(): void;
  74687. /**
  74688. * Sets the FocusDistance amount
  74689. * @param amount amount of FocusDistance
  74690. */
  74691. setFocusDistance(amount: number): void;
  74692. /**
  74693. * Disables depth of field
  74694. */
  74695. disableDepthOfField(): void;
  74696. /**
  74697. * Sets the Aperture amount
  74698. * @param amount amount of Aperture
  74699. */
  74700. setAperture(amount: number): void;
  74701. /**
  74702. * Sets the DarkenOutOfFocus amount
  74703. * @param amount amount of DarkenOutOfFocus
  74704. */
  74705. setDarkenOutOfFocus(amount: number): void;
  74706. private _pentagonBokehIsEnabled;
  74707. /**
  74708. * Creates a pentagon bokeh effect
  74709. */
  74710. enablePentagonBokeh(): void;
  74711. /**
  74712. * Disables the pentagon bokeh effect
  74713. */
  74714. disablePentagonBokeh(): void;
  74715. /**
  74716. * Enables noise blur
  74717. */
  74718. enableNoiseBlur(): void;
  74719. /**
  74720. * Disables noise blur
  74721. */
  74722. disableNoiseBlur(): void;
  74723. /**
  74724. * Sets the HighlightsGain amount
  74725. * @param amount amount of HighlightsGain
  74726. */
  74727. setHighlightsGain(amount: number): void;
  74728. /**
  74729. * Sets the HighlightsThreshold amount
  74730. * @param amount amount of HighlightsThreshold
  74731. */
  74732. setHighlightsThreshold(amount: number): void;
  74733. /**
  74734. * Disables highlights
  74735. */
  74736. disableHighlights(): void;
  74737. /**
  74738. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74739. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74740. */
  74741. dispose(disableDepthRender?: boolean): void;
  74742. private _createChromaticAberrationPostProcess;
  74743. private _createHighlightsPostProcess;
  74744. private _createDepthOfFieldPostProcess;
  74745. private _createGrainTexture;
  74746. }
  74747. }
  74748. declare module "babylonjs/Rendering/ssao2Configuration" {
  74749. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74750. /**
  74751. * Contains all parameters needed for the prepass to perform
  74752. * screen space subsurface scattering
  74753. */
  74754. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74755. /**
  74756. * Is subsurface enabled
  74757. */
  74758. enabled: boolean;
  74759. /**
  74760. * Name of the configuration
  74761. */
  74762. name: string;
  74763. /**
  74764. * Textures that should be present in the MRT for this effect to work
  74765. */
  74766. readonly texturesRequired: number[];
  74767. /**
  74768. * Builds a ssao2 configuration object
  74769. * @param scene The scene
  74770. */
  74771. constructor();
  74772. /**
  74773. * Disposes the configuration
  74774. */
  74775. dispose(): void;
  74776. }
  74777. }
  74778. declare module "babylonjs/Shaders/ssao2.fragment" {
  74779. /** @hidden */
  74780. export var ssao2PixelShader: {
  74781. name: string;
  74782. shader: string;
  74783. };
  74784. }
  74785. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  74786. /** @hidden */
  74787. export var ssaoCombinePixelShader: {
  74788. name: string;
  74789. shader: string;
  74790. };
  74791. }
  74792. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  74793. import { Camera } from "babylonjs/Cameras/camera";
  74794. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74795. import { Scene } from "babylonjs/scene";
  74796. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74797. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74798. import "babylonjs/Shaders/ssao2.fragment";
  74799. import "babylonjs/Shaders/ssaoCombine.fragment";
  74800. /**
  74801. * Render pipeline to produce ssao effect
  74802. */
  74803. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  74804. /**
  74805. * @ignore
  74806. * The PassPostProcess id in the pipeline that contains the original scene color
  74807. */
  74808. SSAOOriginalSceneColorEffect: string;
  74809. /**
  74810. * @ignore
  74811. * The SSAO PostProcess id in the pipeline
  74812. */
  74813. SSAORenderEffect: string;
  74814. /**
  74815. * @ignore
  74816. * The horizontal blur PostProcess id in the pipeline
  74817. */
  74818. SSAOBlurHRenderEffect: string;
  74819. /**
  74820. * @ignore
  74821. * The vertical blur PostProcess id in the pipeline
  74822. */
  74823. SSAOBlurVRenderEffect: string;
  74824. /**
  74825. * @ignore
  74826. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74827. */
  74828. SSAOCombineRenderEffect: string;
  74829. /**
  74830. * The output strength of the SSAO post-process. Default value is 1.0.
  74831. */
  74832. totalStrength: number;
  74833. /**
  74834. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  74835. */
  74836. maxZ: number;
  74837. /**
  74838. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  74839. */
  74840. minZAspect: number;
  74841. private _samples;
  74842. /**
  74843. * Number of samples used for the SSAO calculations. Default value is 8
  74844. */
  74845. set samples(n: number);
  74846. get samples(): number;
  74847. private _textureSamples;
  74848. /**
  74849. * Number of samples to use for antialiasing
  74850. */
  74851. set textureSamples(n: number);
  74852. get textureSamples(): number;
  74853. /**
  74854. * Force rendering the geometry through geometry buffer
  74855. */
  74856. private _forceGeometryBuffer;
  74857. /**
  74858. * Ratio object used for SSAO ratio and blur ratio
  74859. */
  74860. private _ratio;
  74861. /**
  74862. * Dynamically generated sphere sampler.
  74863. */
  74864. private _sampleSphere;
  74865. private _ssao2PrePassConfiguration;
  74866. /**
  74867. * Blur filter offsets
  74868. */
  74869. private _samplerOffsets;
  74870. private _expensiveBlur;
  74871. /**
  74872. * If bilateral blur should be used
  74873. */
  74874. set expensiveBlur(b: boolean);
  74875. get expensiveBlur(): boolean;
  74876. /**
  74877. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  74878. */
  74879. radius: number;
  74880. /**
  74881. * The base color of the SSAO post-process
  74882. * The final result is "base + ssao" between [0, 1]
  74883. */
  74884. base: number;
  74885. /**
  74886. * Support test.
  74887. */
  74888. static get IsSupported(): boolean;
  74889. private _scene;
  74890. private _randomTexture;
  74891. private _originalColorPostProcess;
  74892. private _ssaoPostProcess;
  74893. private _blurHPostProcess;
  74894. private _blurVPostProcess;
  74895. private _ssaoCombinePostProcess;
  74896. private _prePassRenderer;
  74897. /**
  74898. * Gets active scene
  74899. */
  74900. get scene(): Scene;
  74901. /**
  74902. * @constructor
  74903. * @param name The rendering pipeline name
  74904. * @param scene The scene linked to this pipeline
  74905. * @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 }
  74906. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74907. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  74908. */
  74909. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  74910. /**
  74911. * Get the class name
  74912. * @returns "SSAO2RenderingPipeline"
  74913. */
  74914. getClassName(): string;
  74915. /**
  74916. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  74917. */
  74918. dispose(disableGeometryBufferRenderer?: boolean): void;
  74919. private _createBlurPostProcess;
  74920. /** @hidden */
  74921. _rebuild(): void;
  74922. private _bits;
  74923. private _radicalInverse_VdC;
  74924. private _hammersley;
  74925. private _hemisphereSample_uniform;
  74926. private _generateHemisphere;
  74927. private _getDefinesForSSAO;
  74928. private _createSSAOPostProcess;
  74929. private _createSSAOCombinePostProcess;
  74930. private _createRandomTexture;
  74931. /**
  74932. * Serialize the rendering pipeline (Used when exporting)
  74933. * @returns the serialized object
  74934. */
  74935. serialize(): any;
  74936. /**
  74937. * Parse the serialized pipeline
  74938. * @param source Source pipeline.
  74939. * @param scene The scene to load the pipeline to.
  74940. * @param rootUrl The URL of the serialized pipeline.
  74941. * @returns An instantiated pipeline from the serialized object.
  74942. */
  74943. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  74944. /**
  74945. * Sets the required values to the prepass renderer.
  74946. * @param prePassRenderer defines the prepass renderer to setup
  74947. * @returns true if the pre pass is needed.
  74948. */
  74949. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74950. }
  74951. }
  74952. declare module "babylonjs/Shaders/ssao.fragment" {
  74953. /** @hidden */
  74954. export var ssaoPixelShader: {
  74955. name: string;
  74956. shader: string;
  74957. };
  74958. }
  74959. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  74960. import { Camera } from "babylonjs/Cameras/camera";
  74961. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74962. import { Scene } from "babylonjs/scene";
  74963. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74964. import "babylonjs/Shaders/ssao.fragment";
  74965. import "babylonjs/Shaders/ssaoCombine.fragment";
  74966. /**
  74967. * Render pipeline to produce ssao effect
  74968. */
  74969. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  74970. /**
  74971. * @ignore
  74972. * The PassPostProcess id in the pipeline that contains the original scene color
  74973. */
  74974. SSAOOriginalSceneColorEffect: string;
  74975. /**
  74976. * @ignore
  74977. * The SSAO PostProcess id in the pipeline
  74978. */
  74979. SSAORenderEffect: string;
  74980. /**
  74981. * @ignore
  74982. * The horizontal blur PostProcess id in the pipeline
  74983. */
  74984. SSAOBlurHRenderEffect: string;
  74985. /**
  74986. * @ignore
  74987. * The vertical blur PostProcess id in the pipeline
  74988. */
  74989. SSAOBlurVRenderEffect: string;
  74990. /**
  74991. * @ignore
  74992. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  74993. */
  74994. SSAOCombineRenderEffect: string;
  74995. /**
  74996. * The output strength of the SSAO post-process. Default value is 1.0.
  74997. */
  74998. totalStrength: number;
  74999. /**
  75000. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75001. */
  75002. radius: number;
  75003. /**
  75004. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75005. * Must not be equal to fallOff and superior to fallOff.
  75006. * Default value is 0.0075
  75007. */
  75008. area: number;
  75009. /**
  75010. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75011. * Must not be equal to area and inferior to area.
  75012. * Default value is 0.000001
  75013. */
  75014. fallOff: number;
  75015. /**
  75016. * The base color of the SSAO post-process
  75017. * The final result is "base + ssao" between [0, 1]
  75018. */
  75019. base: number;
  75020. private _scene;
  75021. private _depthTexture;
  75022. private _randomTexture;
  75023. private _originalColorPostProcess;
  75024. private _ssaoPostProcess;
  75025. private _blurHPostProcess;
  75026. private _blurVPostProcess;
  75027. private _ssaoCombinePostProcess;
  75028. private _firstUpdate;
  75029. /**
  75030. * Gets active scene
  75031. */
  75032. get scene(): Scene;
  75033. /**
  75034. * @constructor
  75035. * @param name - The rendering pipeline name
  75036. * @param scene - The scene linked to this pipeline
  75037. * @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 }
  75038. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75039. */
  75040. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75041. /**
  75042. * Get the class name
  75043. * @returns "SSAORenderingPipeline"
  75044. */
  75045. getClassName(): string;
  75046. /**
  75047. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75048. */
  75049. dispose(disableDepthRender?: boolean): void;
  75050. private _createBlurPostProcess;
  75051. /** @hidden */
  75052. _rebuild(): void;
  75053. private _createSSAOPostProcess;
  75054. private _createSSAOCombinePostProcess;
  75055. private _createRandomTexture;
  75056. }
  75057. }
  75058. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75059. /** @hidden */
  75060. export var screenSpaceReflectionPixelShader: {
  75061. name: string;
  75062. shader: string;
  75063. };
  75064. }
  75065. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75066. import { Nullable } from "babylonjs/types";
  75067. import { Camera } from "babylonjs/Cameras/camera";
  75068. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75069. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75070. import { Engine } from "babylonjs/Engines/engine";
  75071. import { Scene } from "babylonjs/scene";
  75072. /**
  75073. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75074. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75075. */
  75076. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75077. /**
  75078. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75079. */
  75080. threshold: number;
  75081. /**
  75082. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75083. */
  75084. strength: number;
  75085. /**
  75086. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75087. */
  75088. reflectionSpecularFalloffExponent: number;
  75089. /**
  75090. * 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]
  75091. */
  75092. step: number;
  75093. /**
  75094. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75095. */
  75096. roughnessFactor: number;
  75097. private _geometryBufferRenderer;
  75098. private _enableSmoothReflections;
  75099. private _reflectionSamples;
  75100. private _smoothSteps;
  75101. /**
  75102. * Gets a string identifying the name of the class
  75103. * @returns "ScreenSpaceReflectionPostProcess" string
  75104. */
  75105. getClassName(): string;
  75106. /**
  75107. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75108. * @param name The name of the effect.
  75109. * @param scene The scene containing the objects to calculate reflections.
  75110. * @param options The required width/height ratio to downsize to before computing the render pass.
  75111. * @param camera The camera to apply the render pass to.
  75112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75113. * @param engine The engine which the post process will be applied. (default: current engine)
  75114. * @param reusable If the post process can be reused on the same frame. (default: false)
  75115. * @param textureType Type of textures used when performing the post process. (default: 0)
  75116. * @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)
  75117. */
  75118. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75119. /**
  75120. * Gets wether or not smoothing reflections is enabled.
  75121. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75122. */
  75123. get enableSmoothReflections(): boolean;
  75124. /**
  75125. * Sets wether or not smoothing reflections is enabled.
  75126. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75127. */
  75128. set enableSmoothReflections(enabled: boolean);
  75129. /**
  75130. * Gets the number of samples taken while computing reflections. More samples count is high,
  75131. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75132. */
  75133. get reflectionSamples(): number;
  75134. /**
  75135. * Sets the number of samples taken while computing reflections. More samples count is high,
  75136. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75137. */
  75138. set reflectionSamples(samples: number);
  75139. /**
  75140. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75141. * more the post-process will require GPU power and can generate a drop in FPS.
  75142. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75143. */
  75144. get smoothSteps(): number;
  75145. set smoothSteps(steps: number);
  75146. private _updateEffectDefines;
  75147. /** @hidden */
  75148. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75149. }
  75150. }
  75151. declare module "babylonjs/Shaders/standard.fragment" {
  75152. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75153. /** @hidden */
  75154. export var standardPixelShader: {
  75155. name: string;
  75156. shader: string;
  75157. };
  75158. }
  75159. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75160. import { Nullable } from "babylonjs/types";
  75161. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75162. import { Camera } from "babylonjs/Cameras/camera";
  75163. import { Texture } from "babylonjs/Materials/Textures/texture";
  75164. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75165. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75166. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75167. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75168. import { IDisposable } from "babylonjs/scene";
  75169. import { SpotLight } from "babylonjs/Lights/spotLight";
  75170. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75171. import { Scene } from "babylonjs/scene";
  75172. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75173. import { Animation } from "babylonjs/Animations/animation";
  75174. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75175. import "babylonjs/Shaders/standard.fragment";
  75176. /**
  75177. * Standard rendering pipeline
  75178. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75179. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75180. */
  75181. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75182. /**
  75183. * Public members
  75184. */
  75185. /**
  75186. * Post-process which contains the original scene color before the pipeline applies all the effects
  75187. */
  75188. originalPostProcess: Nullable<PostProcess>;
  75189. /**
  75190. * Post-process used to down scale an image x4
  75191. */
  75192. downSampleX4PostProcess: Nullable<PostProcess>;
  75193. /**
  75194. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75195. */
  75196. brightPassPostProcess: Nullable<PostProcess>;
  75197. /**
  75198. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75199. */
  75200. blurHPostProcesses: PostProcess[];
  75201. /**
  75202. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75203. */
  75204. blurVPostProcesses: PostProcess[];
  75205. /**
  75206. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75207. */
  75208. textureAdderPostProcess: Nullable<PostProcess>;
  75209. /**
  75210. * Post-process used to create volumetric lighting effect
  75211. */
  75212. volumetricLightPostProcess: Nullable<PostProcess>;
  75213. /**
  75214. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75215. */
  75216. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75217. /**
  75218. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75219. */
  75220. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75221. /**
  75222. * Post-process used to merge the volumetric light effect and the real scene color
  75223. */
  75224. volumetricLightMergePostProces: Nullable<PostProcess>;
  75225. /**
  75226. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75227. */
  75228. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75229. /**
  75230. * Base post-process used to calculate the average luminance of the final image for HDR
  75231. */
  75232. luminancePostProcess: Nullable<PostProcess>;
  75233. /**
  75234. * Post-processes used to create down sample post-processes in order to get
  75235. * the average luminance of the final image for HDR
  75236. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75237. */
  75238. luminanceDownSamplePostProcesses: PostProcess[];
  75239. /**
  75240. * Post-process used to create a HDR effect (light adaptation)
  75241. */
  75242. hdrPostProcess: Nullable<PostProcess>;
  75243. /**
  75244. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75245. */
  75246. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75247. /**
  75248. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75249. */
  75250. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75251. /**
  75252. * Post-process used to merge the final HDR post-process and the real scene color
  75253. */
  75254. hdrFinalPostProcess: Nullable<PostProcess>;
  75255. /**
  75256. * Post-process used to create a lens flare effect
  75257. */
  75258. lensFlarePostProcess: Nullable<PostProcess>;
  75259. /**
  75260. * Post-process that merges the result of the lens flare post-process and the real scene color
  75261. */
  75262. lensFlareComposePostProcess: Nullable<PostProcess>;
  75263. /**
  75264. * Post-process used to create a motion blur effect
  75265. */
  75266. motionBlurPostProcess: Nullable<PostProcess>;
  75267. /**
  75268. * Post-process used to create a depth of field effect
  75269. */
  75270. depthOfFieldPostProcess: Nullable<PostProcess>;
  75271. /**
  75272. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75273. */
  75274. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75275. /**
  75276. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75277. */
  75278. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75279. /**
  75280. * Represents the brightness threshold in order to configure the illuminated surfaces
  75281. */
  75282. brightThreshold: number;
  75283. /**
  75284. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75285. */
  75286. blurWidth: number;
  75287. /**
  75288. * Sets if the blur for highlighted surfaces must be only horizontal
  75289. */
  75290. horizontalBlur: boolean;
  75291. /**
  75292. * Gets the overall exposure used by the pipeline
  75293. */
  75294. get exposure(): number;
  75295. /**
  75296. * Sets the overall exposure used by the pipeline
  75297. */
  75298. set exposure(value: number);
  75299. /**
  75300. * Texture used typically to simulate "dirty" on camera lens
  75301. */
  75302. lensTexture: Nullable<Texture>;
  75303. /**
  75304. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75305. */
  75306. volumetricLightCoefficient: number;
  75307. /**
  75308. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75309. */
  75310. volumetricLightPower: number;
  75311. /**
  75312. * Used the set the blur intensity to smooth the volumetric lights
  75313. */
  75314. volumetricLightBlurScale: number;
  75315. /**
  75316. * Light (spot or directional) used to generate the volumetric lights rays
  75317. * The source light must have a shadow generate so the pipeline can get its
  75318. * depth map
  75319. */
  75320. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75321. /**
  75322. * For eye adaptation, represents the minimum luminance the eye can see
  75323. */
  75324. hdrMinimumLuminance: number;
  75325. /**
  75326. * For eye adaptation, represents the decrease luminance speed
  75327. */
  75328. hdrDecreaseRate: number;
  75329. /**
  75330. * For eye adaptation, represents the increase luminance speed
  75331. */
  75332. hdrIncreaseRate: number;
  75333. /**
  75334. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75335. */
  75336. get hdrAutoExposure(): boolean;
  75337. /**
  75338. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75339. */
  75340. set hdrAutoExposure(value: boolean);
  75341. /**
  75342. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75343. */
  75344. lensColorTexture: Nullable<Texture>;
  75345. /**
  75346. * The overall strengh for the lens flare effect
  75347. */
  75348. lensFlareStrength: number;
  75349. /**
  75350. * Dispersion coefficient for lens flare ghosts
  75351. */
  75352. lensFlareGhostDispersal: number;
  75353. /**
  75354. * Main lens flare halo width
  75355. */
  75356. lensFlareHaloWidth: number;
  75357. /**
  75358. * Based on the lens distortion effect, defines how much the lens flare result
  75359. * is distorted
  75360. */
  75361. lensFlareDistortionStrength: number;
  75362. /**
  75363. * Configures the blur intensity used for for lens flare (halo)
  75364. */
  75365. lensFlareBlurWidth: number;
  75366. /**
  75367. * Lens star texture must be used to simulate rays on the flares and is available
  75368. * in the documentation
  75369. */
  75370. lensStarTexture: Nullable<Texture>;
  75371. /**
  75372. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75373. * flare effect by taking account of the dirt texture
  75374. */
  75375. lensFlareDirtTexture: Nullable<Texture>;
  75376. /**
  75377. * Represents the focal length for the depth of field effect
  75378. */
  75379. depthOfFieldDistance: number;
  75380. /**
  75381. * Represents the blur intensity for the blurred part of the depth of field effect
  75382. */
  75383. depthOfFieldBlurWidth: number;
  75384. /**
  75385. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75386. */
  75387. get motionStrength(): number;
  75388. /**
  75389. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75390. */
  75391. set motionStrength(strength: number);
  75392. /**
  75393. * Gets wether or not the motion blur post-process is object based or screen based.
  75394. */
  75395. get objectBasedMotionBlur(): boolean;
  75396. /**
  75397. * Sets wether or not the motion blur post-process should be object based or screen based
  75398. */
  75399. set objectBasedMotionBlur(value: boolean);
  75400. /**
  75401. * List of animations for the pipeline (IAnimatable implementation)
  75402. */
  75403. animations: Animation[];
  75404. /**
  75405. * Private members
  75406. */
  75407. private _scene;
  75408. private _currentDepthOfFieldSource;
  75409. private _basePostProcess;
  75410. private _fixedExposure;
  75411. private _currentExposure;
  75412. private _hdrAutoExposure;
  75413. private _hdrCurrentLuminance;
  75414. private _motionStrength;
  75415. private _isObjectBasedMotionBlur;
  75416. private _floatTextureType;
  75417. private _camerasToBeAttached;
  75418. private _ratio;
  75419. private _bloomEnabled;
  75420. private _depthOfFieldEnabled;
  75421. private _vlsEnabled;
  75422. private _lensFlareEnabled;
  75423. private _hdrEnabled;
  75424. private _motionBlurEnabled;
  75425. private _fxaaEnabled;
  75426. private _screenSpaceReflectionsEnabled;
  75427. private _motionBlurSamples;
  75428. private _volumetricLightStepsCount;
  75429. private _samples;
  75430. /**
  75431. * @ignore
  75432. * Specifies if the bloom pipeline is enabled
  75433. */
  75434. get BloomEnabled(): boolean;
  75435. set BloomEnabled(enabled: boolean);
  75436. /**
  75437. * @ignore
  75438. * Specifies if the depth of field pipeline is enabed
  75439. */
  75440. get DepthOfFieldEnabled(): boolean;
  75441. set DepthOfFieldEnabled(enabled: boolean);
  75442. /**
  75443. * @ignore
  75444. * Specifies if the lens flare pipeline is enabed
  75445. */
  75446. get LensFlareEnabled(): boolean;
  75447. set LensFlareEnabled(enabled: boolean);
  75448. /**
  75449. * @ignore
  75450. * Specifies if the HDR pipeline is enabled
  75451. */
  75452. get HDREnabled(): boolean;
  75453. set HDREnabled(enabled: boolean);
  75454. /**
  75455. * @ignore
  75456. * Specifies if the volumetric lights scattering effect is enabled
  75457. */
  75458. get VLSEnabled(): boolean;
  75459. set VLSEnabled(enabled: boolean);
  75460. /**
  75461. * @ignore
  75462. * Specifies if the motion blur effect is enabled
  75463. */
  75464. get MotionBlurEnabled(): boolean;
  75465. set MotionBlurEnabled(enabled: boolean);
  75466. /**
  75467. * Specifies if anti-aliasing is enabled
  75468. */
  75469. get fxaaEnabled(): boolean;
  75470. set fxaaEnabled(enabled: boolean);
  75471. /**
  75472. * Specifies if screen space reflections are enabled.
  75473. */
  75474. get screenSpaceReflectionsEnabled(): boolean;
  75475. set screenSpaceReflectionsEnabled(enabled: boolean);
  75476. /**
  75477. * Specifies the number of steps used to calculate the volumetric lights
  75478. * Typically in interval [50, 200]
  75479. */
  75480. get volumetricLightStepsCount(): number;
  75481. set volumetricLightStepsCount(count: number);
  75482. /**
  75483. * Specifies the number of samples used for the motion blur effect
  75484. * Typically in interval [16, 64]
  75485. */
  75486. get motionBlurSamples(): number;
  75487. set motionBlurSamples(samples: number);
  75488. /**
  75489. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75490. */
  75491. get samples(): number;
  75492. set samples(sampleCount: number);
  75493. /**
  75494. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75495. * @constructor
  75496. * @param name The rendering pipeline name
  75497. * @param scene The scene linked to this pipeline
  75498. * @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)
  75499. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75500. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75501. */
  75502. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75503. private _buildPipeline;
  75504. private _createDownSampleX4PostProcess;
  75505. private _createBrightPassPostProcess;
  75506. private _createBlurPostProcesses;
  75507. private _createTextureAdderPostProcess;
  75508. private _createVolumetricLightPostProcess;
  75509. private _createLuminancePostProcesses;
  75510. private _createHdrPostProcess;
  75511. private _createLensFlarePostProcess;
  75512. private _createDepthOfFieldPostProcess;
  75513. private _createMotionBlurPostProcess;
  75514. private _getDepthTexture;
  75515. private _disposePostProcesses;
  75516. /**
  75517. * Dispose of the pipeline and stop all post processes
  75518. */
  75519. dispose(): void;
  75520. /**
  75521. * Serialize the rendering pipeline (Used when exporting)
  75522. * @returns the serialized object
  75523. */
  75524. serialize(): any;
  75525. /**
  75526. * Parse the serialized pipeline
  75527. * @param source Source pipeline.
  75528. * @param scene The scene to load the pipeline to.
  75529. * @param rootUrl The URL of the serialized pipeline.
  75530. * @returns An instantiated pipeline from the serialized object.
  75531. */
  75532. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75533. /**
  75534. * Luminance steps
  75535. */
  75536. static LuminanceSteps: number;
  75537. }
  75538. }
  75539. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75540. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75541. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75542. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75543. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75544. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75545. }
  75546. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75547. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75548. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75549. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75550. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75551. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75552. }
  75553. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75554. /** @hidden */
  75555. export var stereoscopicInterlacePixelShader: {
  75556. name: string;
  75557. shader: string;
  75558. };
  75559. }
  75560. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75561. import { Camera } from "babylonjs/Cameras/camera";
  75562. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75563. import { Engine } from "babylonjs/Engines/engine";
  75564. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75565. /**
  75566. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75567. */
  75568. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75569. private _stepSize;
  75570. private _passedProcess;
  75571. /**
  75572. * Gets a string identifying the name of the class
  75573. * @returns "StereoscopicInterlacePostProcessI" string
  75574. */
  75575. getClassName(): string;
  75576. /**
  75577. * Initializes a StereoscopicInterlacePostProcessI
  75578. * @param name The name of the effect.
  75579. * @param rigCameras The rig cameras to be appled to the post process
  75580. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75581. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75582. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75583. * @param engine The engine which the post process will be applied. (default: current engine)
  75584. * @param reusable If the post process can be reused on the same frame. (default: false)
  75585. */
  75586. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75587. }
  75588. /**
  75589. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75590. */
  75591. export class StereoscopicInterlacePostProcess extends PostProcess {
  75592. private _stepSize;
  75593. private _passedProcess;
  75594. /**
  75595. * Gets a string identifying the name of the class
  75596. * @returns "StereoscopicInterlacePostProcess" string
  75597. */
  75598. getClassName(): string;
  75599. /**
  75600. * Initializes a StereoscopicInterlacePostProcess
  75601. * @param name The name of the effect.
  75602. * @param rigCameras The rig cameras to be appled to the post process
  75603. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75604. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75605. * @param engine The engine which the post process will be applied. (default: current engine)
  75606. * @param reusable If the post process can be reused on the same frame. (default: false)
  75607. */
  75608. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75609. }
  75610. }
  75611. declare module "babylonjs/Shaders/tonemap.fragment" {
  75612. /** @hidden */
  75613. export var tonemapPixelShader: {
  75614. name: string;
  75615. shader: string;
  75616. };
  75617. }
  75618. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75619. import { Camera } from "babylonjs/Cameras/camera";
  75620. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75621. import "babylonjs/Shaders/tonemap.fragment";
  75622. import { Engine } from "babylonjs/Engines/engine";
  75623. /** Defines operator used for tonemapping */
  75624. export enum TonemappingOperator {
  75625. /** Hable */
  75626. Hable = 0,
  75627. /** Reinhard */
  75628. Reinhard = 1,
  75629. /** HejiDawson */
  75630. HejiDawson = 2,
  75631. /** Photographic */
  75632. Photographic = 3
  75633. }
  75634. /**
  75635. * Defines a post process to apply tone mapping
  75636. */
  75637. export class TonemapPostProcess extends PostProcess {
  75638. private _operator;
  75639. /** Defines the required exposure adjustement */
  75640. exposureAdjustment: number;
  75641. /**
  75642. * Gets a string identifying the name of the class
  75643. * @returns "TonemapPostProcess" string
  75644. */
  75645. getClassName(): string;
  75646. /**
  75647. * Creates a new TonemapPostProcess
  75648. * @param name defines the name of the postprocess
  75649. * @param _operator defines the operator to use
  75650. * @param exposureAdjustment defines the required exposure adjustement
  75651. * @param camera defines the camera to use (can be null)
  75652. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75653. * @param engine defines the hosting engine (can be ignore if camera is set)
  75654. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75655. */
  75656. constructor(name: string, _operator: TonemappingOperator,
  75657. /** Defines the required exposure adjustement */
  75658. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75659. }
  75660. }
  75661. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75662. /** @hidden */
  75663. export var volumetricLightScatteringPixelShader: {
  75664. name: string;
  75665. shader: string;
  75666. };
  75667. }
  75668. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75669. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75670. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75671. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75672. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75673. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75674. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75675. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75676. /** @hidden */
  75677. export var volumetricLightScatteringPassVertexShader: {
  75678. name: string;
  75679. shader: string;
  75680. };
  75681. }
  75682. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75683. /** @hidden */
  75684. export var volumetricLightScatteringPassPixelShader: {
  75685. name: string;
  75686. shader: string;
  75687. };
  75688. }
  75689. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75690. import { Vector3 } from "babylonjs/Maths/math.vector";
  75691. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75692. import { Mesh } from "babylonjs/Meshes/mesh";
  75693. import { Camera } from "babylonjs/Cameras/camera";
  75694. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75695. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75696. import { Scene } from "babylonjs/scene";
  75697. import "babylonjs/Meshes/Builders/planeBuilder";
  75698. import "babylonjs/Shaders/depth.vertex";
  75699. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75700. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75701. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75702. import { Engine } from "babylonjs/Engines/engine";
  75703. /**
  75704. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75705. */
  75706. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75707. private _volumetricLightScatteringPass;
  75708. private _volumetricLightScatteringRTT;
  75709. private _viewPort;
  75710. private _screenCoordinates;
  75711. private _cachedDefines;
  75712. /**
  75713. * If not undefined, the mesh position is computed from the attached node position
  75714. */
  75715. attachedNode: {
  75716. position: Vector3;
  75717. };
  75718. /**
  75719. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75720. */
  75721. customMeshPosition: Vector3;
  75722. /**
  75723. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75724. */
  75725. useCustomMeshPosition: boolean;
  75726. /**
  75727. * If the post-process should inverse the light scattering direction
  75728. */
  75729. invert: boolean;
  75730. /**
  75731. * The internal mesh used by the post-process
  75732. */
  75733. mesh: Mesh;
  75734. /**
  75735. * @hidden
  75736. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75737. */
  75738. get useDiffuseColor(): boolean;
  75739. set useDiffuseColor(useDiffuseColor: boolean);
  75740. /**
  75741. * Array containing the excluded meshes not rendered in the internal pass
  75742. */
  75743. excludedMeshes: AbstractMesh[];
  75744. /**
  75745. * Controls the overall intensity of the post-process
  75746. */
  75747. exposure: number;
  75748. /**
  75749. * Dissipates each sample's contribution in range [0, 1]
  75750. */
  75751. decay: number;
  75752. /**
  75753. * Controls the overall intensity of each sample
  75754. */
  75755. weight: number;
  75756. /**
  75757. * Controls the density of each sample
  75758. */
  75759. density: number;
  75760. /**
  75761. * @constructor
  75762. * @param name The post-process name
  75763. * @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)
  75764. * @param camera The camera that the post-process will be attached to
  75765. * @param mesh The mesh used to create the light scattering
  75766. * @param samples The post-process quality, default 100
  75767. * @param samplingModeThe post-process filtering mode
  75768. * @param engine The babylon engine
  75769. * @param reusable If the post-process is reusable
  75770. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  75771. */
  75772. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  75773. /**
  75774. * Returns the string "VolumetricLightScatteringPostProcess"
  75775. * @returns "VolumetricLightScatteringPostProcess"
  75776. */
  75777. getClassName(): string;
  75778. private _isReady;
  75779. /**
  75780. * Sets the new light position for light scattering effect
  75781. * @param position The new custom light position
  75782. */
  75783. setCustomMeshPosition(position: Vector3): void;
  75784. /**
  75785. * Returns the light position for light scattering effect
  75786. * @return Vector3 The custom light position
  75787. */
  75788. getCustomMeshPosition(): Vector3;
  75789. /**
  75790. * Disposes the internal assets and detaches the post-process from the camera
  75791. */
  75792. dispose(camera: Camera): void;
  75793. /**
  75794. * Returns the render target texture used by the post-process
  75795. * @return the render target texture used by the post-process
  75796. */
  75797. getPass(): RenderTargetTexture;
  75798. private _meshExcluded;
  75799. private _createPass;
  75800. private _updateMeshScreenCoordinates;
  75801. /**
  75802. * Creates a default mesh for the Volumeric Light Scattering post-process
  75803. * @param name The mesh name
  75804. * @param scene The scene where to create the mesh
  75805. * @return the default mesh
  75806. */
  75807. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  75808. }
  75809. }
  75810. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  75811. /** @hidden */
  75812. export var screenSpaceCurvaturePixelShader: {
  75813. name: string;
  75814. shader: string;
  75815. };
  75816. }
  75817. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  75818. import { Nullable } from "babylonjs/types";
  75819. import { Camera } from "babylonjs/Cameras/camera";
  75820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75821. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  75822. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  75823. import { Engine } from "babylonjs/Engines/engine";
  75824. import { Scene } from "babylonjs/scene";
  75825. /**
  75826. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  75827. */
  75828. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  75829. /**
  75830. * Defines how much ridge the curvature effect displays.
  75831. */
  75832. ridge: number;
  75833. /**
  75834. * Defines how much valley the curvature effect displays.
  75835. */
  75836. valley: number;
  75837. private _geometryBufferRenderer;
  75838. /**
  75839. * Gets a string identifying the name of the class
  75840. * @returns "ScreenSpaceCurvaturePostProcess" string
  75841. */
  75842. getClassName(): string;
  75843. /**
  75844. * Creates a new instance ScreenSpaceCurvaturePostProcess
  75845. * @param name The name of the effect.
  75846. * @param scene The scene containing the objects to blur according to their velocity.
  75847. * @param options The required width/height ratio to downsize to before computing the render pass.
  75848. * @param camera The camera to apply the render pass to.
  75849. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75850. * @param engine The engine which the post process will be applied. (default: current engine)
  75851. * @param reusable If the post process can be reused on the same frame. (default: false)
  75852. * @param textureType Type of textures used when performing the post process. (default: 0)
  75853. * @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)
  75854. */
  75855. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  75856. /**
  75857. * Support test.
  75858. */
  75859. static get IsSupported(): boolean;
  75860. /** @hidden */
  75861. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  75862. }
  75863. }
  75864. declare module "babylonjs/PostProcesses/index" {
  75865. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  75866. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  75867. export * from "babylonjs/PostProcesses/bloomEffect";
  75868. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  75869. export * from "babylonjs/PostProcesses/blurPostProcess";
  75870. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  75871. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  75872. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  75873. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  75874. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  75875. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  75876. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  75877. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  75878. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  75879. export * from "babylonjs/PostProcesses/filterPostProcess";
  75880. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  75881. export * from "babylonjs/PostProcesses/grainPostProcess";
  75882. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  75883. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  75884. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  75885. export * from "babylonjs/PostProcesses/passPostProcess";
  75886. export * from "babylonjs/PostProcesses/postProcess";
  75887. export * from "babylonjs/PostProcesses/postProcessManager";
  75888. export * from "babylonjs/PostProcesses/refractionPostProcess";
  75889. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  75890. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  75891. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  75892. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  75893. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  75894. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  75895. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  75896. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75897. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  75898. }
  75899. declare module "babylonjs/Probes/index" {
  75900. export * from "babylonjs/Probes/reflectionProbe";
  75901. }
  75902. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  75903. import { Scene } from "babylonjs/scene";
  75904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75905. import { SmartArray } from "babylonjs/Misc/smartArray";
  75906. import { ISceneComponent } from "babylonjs/sceneComponent";
  75907. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  75908. import "babylonjs/Meshes/Builders/boxBuilder";
  75909. import "babylonjs/Shaders/color.fragment";
  75910. import "babylonjs/Shaders/color.vertex";
  75911. import { Color3 } from "babylonjs/Maths/math.color";
  75912. import { Observable } from "babylonjs/Misc/observable";
  75913. module "babylonjs/scene" {
  75914. interface Scene {
  75915. /** @hidden (Backing field) */
  75916. _boundingBoxRenderer: BoundingBoxRenderer;
  75917. /** @hidden (Backing field) */
  75918. _forceShowBoundingBoxes: boolean;
  75919. /**
  75920. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  75921. */
  75922. forceShowBoundingBoxes: boolean;
  75923. /**
  75924. * Gets the bounding box renderer associated with the scene
  75925. * @returns a BoundingBoxRenderer
  75926. */
  75927. getBoundingBoxRenderer(): BoundingBoxRenderer;
  75928. }
  75929. }
  75930. module "babylonjs/Meshes/abstractMesh" {
  75931. interface AbstractMesh {
  75932. /** @hidden (Backing field) */
  75933. _showBoundingBox: boolean;
  75934. /**
  75935. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  75936. */
  75937. showBoundingBox: boolean;
  75938. }
  75939. }
  75940. /**
  75941. * Component responsible of rendering the bounding box of the meshes in a scene.
  75942. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  75943. */
  75944. export class BoundingBoxRenderer implements ISceneComponent {
  75945. /**
  75946. * The component name helpfull to identify the component in the list of scene components.
  75947. */
  75948. readonly name: string;
  75949. /**
  75950. * The scene the component belongs to.
  75951. */
  75952. scene: Scene;
  75953. /**
  75954. * Color of the bounding box lines placed in front of an object
  75955. */
  75956. frontColor: Color3;
  75957. /**
  75958. * Color of the bounding box lines placed behind an object
  75959. */
  75960. backColor: Color3;
  75961. /**
  75962. * Defines if the renderer should show the back lines or not
  75963. */
  75964. showBackLines: boolean;
  75965. /**
  75966. * Observable raised before rendering a bounding box
  75967. */
  75968. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  75969. /**
  75970. * Observable raised after rendering a bounding box
  75971. */
  75972. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  75973. /**
  75974. * @hidden
  75975. */
  75976. renderList: SmartArray<BoundingBox>;
  75977. private _colorShader;
  75978. private _vertexBuffers;
  75979. private _indexBuffer;
  75980. private _fillIndexBuffer;
  75981. private _fillIndexData;
  75982. /**
  75983. * Instantiates a new bounding box renderer in a scene.
  75984. * @param scene the scene the renderer renders in
  75985. */
  75986. constructor(scene: Scene);
  75987. /**
  75988. * Registers the component in a given scene
  75989. */
  75990. register(): void;
  75991. private _evaluateSubMesh;
  75992. private _activeMesh;
  75993. private _prepareRessources;
  75994. private _createIndexBuffer;
  75995. /**
  75996. * Rebuilds the elements related to this component in case of
  75997. * context lost for instance.
  75998. */
  75999. rebuild(): void;
  76000. /**
  76001. * @hidden
  76002. */
  76003. reset(): void;
  76004. /**
  76005. * Render the bounding boxes of a specific rendering group
  76006. * @param renderingGroupId defines the rendering group to render
  76007. */
  76008. render(renderingGroupId: number): void;
  76009. /**
  76010. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76011. * @param mesh Define the mesh to render the occlusion bounding box for
  76012. */
  76013. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76014. /**
  76015. * Dispose and release the resources attached to this renderer.
  76016. */
  76017. dispose(): void;
  76018. }
  76019. }
  76020. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76021. import { Nullable } from "babylonjs/types";
  76022. import { Scene } from "babylonjs/scene";
  76023. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76024. import { Camera } from "babylonjs/Cameras/camera";
  76025. import { ISceneComponent } from "babylonjs/sceneComponent";
  76026. module "babylonjs/scene" {
  76027. interface Scene {
  76028. /** @hidden (Backing field) */
  76029. _depthRenderer: {
  76030. [id: string]: DepthRenderer;
  76031. };
  76032. /**
  76033. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76034. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76035. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76036. * @returns the created depth renderer
  76037. */
  76038. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  76039. /**
  76040. * Disables a depth renderer for a given camera
  76041. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76042. */
  76043. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76044. }
  76045. }
  76046. /**
  76047. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76048. * in several rendering techniques.
  76049. */
  76050. export class DepthRendererSceneComponent implements ISceneComponent {
  76051. /**
  76052. * The component name helpfull to identify the component in the list of scene components.
  76053. */
  76054. readonly name: string;
  76055. /**
  76056. * The scene the component belongs to.
  76057. */
  76058. scene: Scene;
  76059. /**
  76060. * Creates a new instance of the component for the given scene
  76061. * @param scene Defines the scene to register the component in
  76062. */
  76063. constructor(scene: Scene);
  76064. /**
  76065. * Registers the component in a given scene
  76066. */
  76067. register(): void;
  76068. /**
  76069. * Rebuilds the elements related to this component in case of
  76070. * context lost for instance.
  76071. */
  76072. rebuild(): void;
  76073. /**
  76074. * Disposes the component and the associated ressources
  76075. */
  76076. dispose(): void;
  76077. private _gatherRenderTargets;
  76078. private _gatherActiveCameraRenderTargets;
  76079. }
  76080. }
  76081. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76082. import { Nullable } from "babylonjs/types";
  76083. import { Scene } from "babylonjs/scene";
  76084. import { ISceneComponent } from "babylonjs/sceneComponent";
  76085. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76086. module "babylonjs/abstractScene" {
  76087. interface AbstractScene {
  76088. /** @hidden (Backing field) */
  76089. _prePassRenderer: Nullable<PrePassRenderer>;
  76090. /**
  76091. * Gets or Sets the current prepass renderer associated to the scene.
  76092. */
  76093. prePassRenderer: Nullable<PrePassRenderer>;
  76094. /**
  76095. * Enables the prepass and associates it with the scene
  76096. * @returns the PrePassRenderer
  76097. */
  76098. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76099. /**
  76100. * Disables the prepass associated with the scene
  76101. */
  76102. disablePrePassRenderer(): void;
  76103. }
  76104. }
  76105. /**
  76106. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76107. * in several rendering techniques.
  76108. */
  76109. export class PrePassRendererSceneComponent implements ISceneComponent {
  76110. /**
  76111. * The component name helpful to identify the component in the list of scene components.
  76112. */
  76113. readonly name: string;
  76114. /**
  76115. * The scene the component belongs to.
  76116. */
  76117. scene: Scene;
  76118. /**
  76119. * Creates a new instance of the component for the given scene
  76120. * @param scene Defines the scene to register the component in
  76121. */
  76122. constructor(scene: Scene);
  76123. /**
  76124. * Registers the component in a given scene
  76125. */
  76126. register(): void;
  76127. private _beforeCameraDraw;
  76128. private _afterCameraDraw;
  76129. private _beforeClearStage;
  76130. /**
  76131. * Rebuilds the elements related to this component in case of
  76132. * context lost for instance.
  76133. */
  76134. rebuild(): void;
  76135. /**
  76136. * Disposes the component and the associated ressources
  76137. */
  76138. dispose(): void;
  76139. }
  76140. }
  76141. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76142. /** @hidden */
  76143. export var fibonacci: {
  76144. name: string;
  76145. shader: string;
  76146. };
  76147. }
  76148. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76149. /** @hidden */
  76150. export var diffusionProfile: {
  76151. name: string;
  76152. shader: string;
  76153. };
  76154. }
  76155. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76156. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76157. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76158. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76159. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76160. /** @hidden */
  76161. export var subSurfaceScatteringPixelShader: {
  76162. name: string;
  76163. shader: string;
  76164. };
  76165. }
  76166. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76167. import { Nullable } from "babylonjs/types";
  76168. import { Camera } from "babylonjs/Cameras/camera";
  76169. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76170. import { Engine } from "babylonjs/Engines/engine";
  76171. import { Scene } from "babylonjs/scene";
  76172. import "babylonjs/Shaders/imageProcessing.fragment";
  76173. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76174. import "babylonjs/Shaders/postprocess.vertex";
  76175. /**
  76176. * Sub surface scattering post process
  76177. */
  76178. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76179. /**
  76180. * Gets a string identifying the name of the class
  76181. * @returns "SubSurfaceScatteringPostProcess" string
  76182. */
  76183. getClassName(): string;
  76184. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76185. }
  76186. }
  76187. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76188. import { Scene } from "babylonjs/scene";
  76189. import { Color3 } from "babylonjs/Maths/math.color";
  76190. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76191. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76192. /**
  76193. * Contains all parameters needed for the prepass to perform
  76194. * screen space subsurface scattering
  76195. */
  76196. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76197. /** @hidden */
  76198. static _SceneComponentInitialization: (scene: Scene) => void;
  76199. private _ssDiffusionS;
  76200. private _ssFilterRadii;
  76201. private _ssDiffusionD;
  76202. /**
  76203. * Post process to attach for screen space subsurface scattering
  76204. */
  76205. postProcess: SubSurfaceScatteringPostProcess;
  76206. /**
  76207. * Diffusion profile color for subsurface scattering
  76208. */
  76209. get ssDiffusionS(): number[];
  76210. /**
  76211. * Diffusion profile max color channel value for subsurface scattering
  76212. */
  76213. get ssDiffusionD(): number[];
  76214. /**
  76215. * Diffusion profile filter radius for subsurface scattering
  76216. */
  76217. get ssFilterRadii(): number[];
  76218. /**
  76219. * Is subsurface enabled
  76220. */
  76221. enabled: boolean;
  76222. /**
  76223. * Name of the configuration
  76224. */
  76225. name: string;
  76226. /**
  76227. * Diffusion profile colors for subsurface scattering
  76228. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76229. * See ...
  76230. * Note that you can only store up to 5 of them
  76231. */
  76232. ssDiffusionProfileColors: Color3[];
  76233. /**
  76234. * Defines the ratio real world => scene units.
  76235. * Used for subsurface scattering
  76236. */
  76237. metersPerUnit: number;
  76238. /**
  76239. * Textures that should be present in the MRT for this effect to work
  76240. */
  76241. readonly texturesRequired: number[];
  76242. private _scene;
  76243. /**
  76244. * Builds a subsurface configuration object
  76245. * @param scene The scene
  76246. */
  76247. constructor(scene: Scene);
  76248. /**
  76249. * Adds a new diffusion profile.
  76250. * Useful for more realistic subsurface scattering on diverse materials.
  76251. * @param color The color of the diffusion profile. Should be the average color of the material.
  76252. * @return The index of the diffusion profile for the material subsurface configuration
  76253. */
  76254. addDiffusionProfile(color: Color3): number;
  76255. /**
  76256. * Creates the sss post process
  76257. * @return The created post process
  76258. */
  76259. createPostProcess(): SubSurfaceScatteringPostProcess;
  76260. /**
  76261. * Deletes all diffusion profiles.
  76262. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76263. */
  76264. clearAllDiffusionProfiles(): void;
  76265. /**
  76266. * Disposes this object
  76267. */
  76268. dispose(): void;
  76269. /**
  76270. * @hidden
  76271. * https://zero-radiance.github.io/post/sampling-diffusion/
  76272. *
  76273. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76274. * ------------------------------------------------------------------------------------
  76275. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76276. * PDF[r, phi, s] = r * R[r, phi, s]
  76277. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76278. * ------------------------------------------------------------------------------------
  76279. * We importance sample the color channel with the widest scattering distance.
  76280. */
  76281. getDiffusionProfileParameters(color: Color3): number;
  76282. /**
  76283. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76284. * 'u' is the random number (the value of the CDF): [0, 1).
  76285. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76286. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76287. */
  76288. private _sampleBurleyDiffusionProfile;
  76289. }
  76290. }
  76291. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76292. import { Nullable } from "babylonjs/types";
  76293. import { Scene } from "babylonjs/scene";
  76294. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76295. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76296. import { AbstractScene } from "babylonjs/abstractScene";
  76297. module "babylonjs/abstractScene" {
  76298. interface AbstractScene {
  76299. /** @hidden (Backing field) */
  76300. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76301. /**
  76302. * Gets or Sets the current prepass renderer associated to the scene.
  76303. */
  76304. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76305. /**
  76306. * Enables the subsurface effect for prepass
  76307. * @returns the SubSurfaceConfiguration
  76308. */
  76309. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76310. /**
  76311. * Disables the subsurface effect for prepass
  76312. */
  76313. disableSubSurfaceForPrePass(): void;
  76314. }
  76315. }
  76316. /**
  76317. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76318. * in several rendering techniques.
  76319. */
  76320. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76321. /**
  76322. * The component name helpful to identify the component in the list of scene components.
  76323. */
  76324. readonly name: string;
  76325. /**
  76326. * The scene the component belongs to.
  76327. */
  76328. scene: Scene;
  76329. /**
  76330. * Creates a new instance of the component for the given scene
  76331. * @param scene Defines the scene to register the component in
  76332. */
  76333. constructor(scene: Scene);
  76334. /**
  76335. * Registers the component in a given scene
  76336. */
  76337. register(): void;
  76338. /**
  76339. * Serializes the component data to the specified json object
  76340. * @param serializationObject The object to serialize to
  76341. */
  76342. serialize(serializationObject: any): void;
  76343. /**
  76344. * Adds all the elements from the container to the scene
  76345. * @param container the container holding the elements
  76346. */
  76347. addFromContainer(container: AbstractScene): void;
  76348. /**
  76349. * Removes all the elements in the container from the scene
  76350. * @param container contains the elements to remove
  76351. * @param dispose if the removed element should be disposed (default: false)
  76352. */
  76353. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76354. /**
  76355. * Rebuilds the elements related to this component in case of
  76356. * context lost for instance.
  76357. */
  76358. rebuild(): void;
  76359. /**
  76360. * Disposes the component and the associated ressources
  76361. */
  76362. dispose(): void;
  76363. }
  76364. }
  76365. declare module "babylonjs/Shaders/outline.fragment" {
  76366. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76367. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76368. /** @hidden */
  76369. export var outlinePixelShader: {
  76370. name: string;
  76371. shader: string;
  76372. };
  76373. }
  76374. declare module "babylonjs/Shaders/outline.vertex" {
  76375. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76376. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76378. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76381. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76382. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76383. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76384. /** @hidden */
  76385. export var outlineVertexShader: {
  76386. name: string;
  76387. shader: string;
  76388. };
  76389. }
  76390. declare module "babylonjs/Rendering/outlineRenderer" {
  76391. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76392. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76393. import { Scene } from "babylonjs/scene";
  76394. import { ISceneComponent } from "babylonjs/sceneComponent";
  76395. import "babylonjs/Shaders/outline.fragment";
  76396. import "babylonjs/Shaders/outline.vertex";
  76397. module "babylonjs/scene" {
  76398. interface Scene {
  76399. /** @hidden */
  76400. _outlineRenderer: OutlineRenderer;
  76401. /**
  76402. * Gets the outline renderer associated with the scene
  76403. * @returns a OutlineRenderer
  76404. */
  76405. getOutlineRenderer(): OutlineRenderer;
  76406. }
  76407. }
  76408. module "babylonjs/Meshes/abstractMesh" {
  76409. interface AbstractMesh {
  76410. /** @hidden (Backing field) */
  76411. _renderOutline: boolean;
  76412. /**
  76413. * Gets or sets a boolean indicating if the outline must be rendered as well
  76414. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76415. */
  76416. renderOutline: boolean;
  76417. /** @hidden (Backing field) */
  76418. _renderOverlay: boolean;
  76419. /**
  76420. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76421. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76422. */
  76423. renderOverlay: boolean;
  76424. }
  76425. }
  76426. /**
  76427. * This class is responsible to draw bothe outline/overlay of meshes.
  76428. * It should not be used directly but through the available method on mesh.
  76429. */
  76430. export class OutlineRenderer implements ISceneComponent {
  76431. /**
  76432. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76433. */
  76434. private static _StencilReference;
  76435. /**
  76436. * The name of the component. Each component must have a unique name.
  76437. */
  76438. name: string;
  76439. /**
  76440. * The scene the component belongs to.
  76441. */
  76442. scene: Scene;
  76443. /**
  76444. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76445. */
  76446. zOffset: number;
  76447. private _engine;
  76448. private _effect;
  76449. private _cachedDefines;
  76450. private _savedDepthWrite;
  76451. /**
  76452. * Instantiates a new outline renderer. (There could be only one per scene).
  76453. * @param scene Defines the scene it belongs to
  76454. */
  76455. constructor(scene: Scene);
  76456. /**
  76457. * Register the component to one instance of a scene.
  76458. */
  76459. register(): void;
  76460. /**
  76461. * Rebuilds the elements related to this component in case of
  76462. * context lost for instance.
  76463. */
  76464. rebuild(): void;
  76465. /**
  76466. * Disposes the component and the associated ressources.
  76467. */
  76468. dispose(): void;
  76469. /**
  76470. * Renders the outline in the canvas.
  76471. * @param subMesh Defines the sumesh to render
  76472. * @param batch Defines the batch of meshes in case of instances
  76473. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76474. */
  76475. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76476. /**
  76477. * Returns whether or not the outline renderer is ready for a given submesh.
  76478. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76479. * @param subMesh Defines the submesh to check readyness for
  76480. * @param useInstances Defines wheter wee are trying to render instances or not
  76481. * @returns true if ready otherwise false
  76482. */
  76483. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76484. private _beforeRenderingMesh;
  76485. private _afterRenderingMesh;
  76486. }
  76487. }
  76488. declare module "babylonjs/Rendering/index" {
  76489. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76490. export * from "babylonjs/Rendering/depthRenderer";
  76491. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76492. export * from "babylonjs/Rendering/edgesRenderer";
  76493. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76494. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76495. export * from "babylonjs/Rendering/prePassRenderer";
  76496. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76497. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76498. export * from "babylonjs/Rendering/outlineRenderer";
  76499. export * from "babylonjs/Rendering/renderingGroup";
  76500. export * from "babylonjs/Rendering/renderingManager";
  76501. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76502. }
  76503. declare module "babylonjs/Sprites/ISprites" {
  76504. /**
  76505. * Defines the basic options interface of a Sprite Frame Source Size.
  76506. */
  76507. export interface ISpriteJSONSpriteSourceSize {
  76508. /**
  76509. * number of the original width of the Frame
  76510. */
  76511. w: number;
  76512. /**
  76513. * number of the original height of the Frame
  76514. */
  76515. h: number;
  76516. }
  76517. /**
  76518. * Defines the basic options interface of a Sprite Frame Data.
  76519. */
  76520. export interface ISpriteJSONSpriteFrameData {
  76521. /**
  76522. * number of the x offset of the Frame
  76523. */
  76524. x: number;
  76525. /**
  76526. * number of the y offset of the Frame
  76527. */
  76528. y: number;
  76529. /**
  76530. * number of the width of the Frame
  76531. */
  76532. w: number;
  76533. /**
  76534. * number of the height of the Frame
  76535. */
  76536. h: number;
  76537. }
  76538. /**
  76539. * Defines the basic options interface of a JSON Sprite.
  76540. */
  76541. export interface ISpriteJSONSprite {
  76542. /**
  76543. * string name of the Frame
  76544. */
  76545. filename: string;
  76546. /**
  76547. * ISpriteJSONSpriteFrame basic object of the frame data
  76548. */
  76549. frame: ISpriteJSONSpriteFrameData;
  76550. /**
  76551. * boolean to flag is the frame was rotated.
  76552. */
  76553. rotated: boolean;
  76554. /**
  76555. * boolean to flag is the frame was trimmed.
  76556. */
  76557. trimmed: boolean;
  76558. /**
  76559. * ISpriteJSONSpriteFrame basic object of the source data
  76560. */
  76561. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76562. /**
  76563. * ISpriteJSONSpriteFrame basic object of the source data
  76564. */
  76565. sourceSize: ISpriteJSONSpriteSourceSize;
  76566. }
  76567. /**
  76568. * Defines the basic options interface of a JSON atlas.
  76569. */
  76570. export interface ISpriteJSONAtlas {
  76571. /**
  76572. * Array of objects that contain the frame data.
  76573. */
  76574. frames: Array<ISpriteJSONSprite>;
  76575. /**
  76576. * object basic object containing the sprite meta data.
  76577. */
  76578. meta?: object;
  76579. }
  76580. }
  76581. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76582. /** @hidden */
  76583. export var spriteMapPixelShader: {
  76584. name: string;
  76585. shader: string;
  76586. };
  76587. }
  76588. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76589. /** @hidden */
  76590. export var spriteMapVertexShader: {
  76591. name: string;
  76592. shader: string;
  76593. };
  76594. }
  76595. declare module "babylonjs/Sprites/spriteMap" {
  76596. import { IDisposable, Scene } from "babylonjs/scene";
  76597. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76598. import { Texture } from "babylonjs/Materials/Textures/texture";
  76599. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76600. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76601. import "babylonjs/Meshes/Builders/planeBuilder";
  76602. import "babylonjs/Shaders/spriteMap.fragment";
  76603. import "babylonjs/Shaders/spriteMap.vertex";
  76604. /**
  76605. * Defines the basic options interface of a SpriteMap
  76606. */
  76607. export interface ISpriteMapOptions {
  76608. /**
  76609. * Vector2 of the number of cells in the grid.
  76610. */
  76611. stageSize?: Vector2;
  76612. /**
  76613. * Vector2 of the size of the output plane in World Units.
  76614. */
  76615. outputSize?: Vector2;
  76616. /**
  76617. * Vector3 of the position of the output plane in World Units.
  76618. */
  76619. outputPosition?: Vector3;
  76620. /**
  76621. * Vector3 of the rotation of the output plane.
  76622. */
  76623. outputRotation?: Vector3;
  76624. /**
  76625. * number of layers that the system will reserve in resources.
  76626. */
  76627. layerCount?: number;
  76628. /**
  76629. * number of max animation frames a single cell will reserve in resources.
  76630. */
  76631. maxAnimationFrames?: number;
  76632. /**
  76633. * number cell index of the base tile when the system compiles.
  76634. */
  76635. baseTile?: number;
  76636. /**
  76637. * boolean flip the sprite after its been repositioned by the framing data.
  76638. */
  76639. flipU?: boolean;
  76640. /**
  76641. * Vector3 scalar of the global RGB values of the SpriteMap.
  76642. */
  76643. colorMultiply?: Vector3;
  76644. }
  76645. /**
  76646. * Defines the IDisposable interface in order to be cleanable from resources.
  76647. */
  76648. export interface ISpriteMap extends IDisposable {
  76649. /**
  76650. * String name of the SpriteMap.
  76651. */
  76652. name: string;
  76653. /**
  76654. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76655. */
  76656. atlasJSON: ISpriteJSONAtlas;
  76657. /**
  76658. * Texture of the SpriteMap.
  76659. */
  76660. spriteSheet: Texture;
  76661. /**
  76662. * The parameters to initialize the SpriteMap with.
  76663. */
  76664. options: ISpriteMapOptions;
  76665. }
  76666. /**
  76667. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76668. */
  76669. export class SpriteMap implements ISpriteMap {
  76670. /** The Name of the spriteMap */
  76671. name: string;
  76672. /** The JSON file with the frame and meta data */
  76673. atlasJSON: ISpriteJSONAtlas;
  76674. /** The systems Sprite Sheet Texture */
  76675. spriteSheet: Texture;
  76676. /** Arguments passed with the Constructor */
  76677. options: ISpriteMapOptions;
  76678. /** Public Sprite Storage array, parsed from atlasJSON */
  76679. sprites: Array<ISpriteJSONSprite>;
  76680. /** Returns the Number of Sprites in the System */
  76681. get spriteCount(): number;
  76682. /** Returns the Position of Output Plane*/
  76683. get position(): Vector3;
  76684. /** Returns the Position of Output Plane*/
  76685. set position(v: Vector3);
  76686. /** Returns the Rotation of Output Plane*/
  76687. get rotation(): Vector3;
  76688. /** Returns the Rotation of Output Plane*/
  76689. set rotation(v: Vector3);
  76690. /** Sets the AnimationMap*/
  76691. get animationMap(): RawTexture;
  76692. /** Sets the AnimationMap*/
  76693. set animationMap(v: RawTexture);
  76694. /** Scene that the SpriteMap was created in */
  76695. private _scene;
  76696. /** Texture Buffer of Float32 that holds tile frame data*/
  76697. private _frameMap;
  76698. /** Texture Buffers of Float32 that holds tileMap data*/
  76699. private _tileMaps;
  76700. /** Texture Buffer of Float32 that holds Animation Data*/
  76701. private _animationMap;
  76702. /** Custom ShaderMaterial Central to the System*/
  76703. private _material;
  76704. /** Custom ShaderMaterial Central to the System*/
  76705. private _output;
  76706. /** Systems Time Ticker*/
  76707. private _time;
  76708. /**
  76709. * Creates a new SpriteMap
  76710. * @param name defines the SpriteMaps Name
  76711. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76712. * @param spriteSheet is the Texture that the Sprites are on.
  76713. * @param options a basic deployment configuration
  76714. * @param scene The Scene that the map is deployed on
  76715. */
  76716. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76717. /**
  76718. * Returns tileID location
  76719. * @returns Vector2 the cell position ID
  76720. */
  76721. getTileID(): Vector2;
  76722. /**
  76723. * Gets the UV location of the mouse over the SpriteMap.
  76724. * @returns Vector2 the UV position of the mouse interaction
  76725. */
  76726. getMousePosition(): Vector2;
  76727. /**
  76728. * Creates the "frame" texture Buffer
  76729. * -------------------------------------
  76730. * Structure of frames
  76731. * "filename": "Falling-Water-2.png",
  76732. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76733. * "rotated": true,
  76734. * "trimmed": true,
  76735. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76736. * "sourceSize": {"w":32,"h":32}
  76737. * @returns RawTexture of the frameMap
  76738. */
  76739. private _createFrameBuffer;
  76740. /**
  76741. * Creates the tileMap texture Buffer
  76742. * @param buffer normally and array of numbers, or a false to generate from scratch
  76743. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76744. * @returns RawTexture of the tileMap
  76745. */
  76746. private _createTileBuffer;
  76747. /**
  76748. * Modifies the data of the tileMaps
  76749. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76750. * @param pos is the iVector2 Coordinates of the Tile
  76751. * @param tile The SpriteIndex of the new Tile
  76752. */
  76753. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76754. /**
  76755. * Creates the animationMap texture Buffer
  76756. * @param buffer normally and array of numbers, or a false to generate from scratch
  76757. * @returns RawTexture of the animationMap
  76758. */
  76759. private _createTileAnimationBuffer;
  76760. /**
  76761. * Modifies the data of the animationMap
  76762. * @param cellID is the Index of the Sprite
  76763. * @param _frame is the target Animation frame
  76764. * @param toCell is the Target Index of the next frame of the animation
  76765. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76766. * @param speed is a global scalar of the time variable on the map.
  76767. */
  76768. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  76769. /**
  76770. * Exports the .tilemaps file
  76771. */
  76772. saveTileMaps(): void;
  76773. /**
  76774. * Imports the .tilemaps file
  76775. * @param url of the .tilemaps file
  76776. */
  76777. loadTileMaps(url: string): void;
  76778. /**
  76779. * Release associated resources
  76780. */
  76781. dispose(): void;
  76782. }
  76783. }
  76784. declare module "babylonjs/Sprites/spritePackedManager" {
  76785. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  76786. import { Scene } from "babylonjs/scene";
  76787. /**
  76788. * Class used to manage multiple sprites of different sizes on the same spritesheet
  76789. * @see https://doc.babylonjs.com/babylon101/sprites
  76790. */
  76791. export class SpritePackedManager extends SpriteManager {
  76792. /** defines the packed manager's name */
  76793. name: string;
  76794. /**
  76795. * Creates a new sprite manager from a packed sprite sheet
  76796. * @param name defines the manager's name
  76797. * @param imgUrl defines the sprite sheet url
  76798. * @param capacity defines the maximum allowed number of sprites
  76799. * @param scene defines the hosting scene
  76800. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  76801. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  76802. * @param samplingMode defines the smapling mode to use with spritesheet
  76803. * @param fromPacked set to true; do not alter
  76804. */
  76805. constructor(
  76806. /** defines the packed manager's name */
  76807. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  76808. }
  76809. }
  76810. declare module "babylonjs/Sprites/index" {
  76811. export * from "babylonjs/Sprites/sprite";
  76812. export * from "babylonjs/Sprites/ISprites";
  76813. export * from "babylonjs/Sprites/spriteManager";
  76814. export * from "babylonjs/Sprites/spriteMap";
  76815. export * from "babylonjs/Sprites/spritePackedManager";
  76816. export * from "babylonjs/Sprites/spriteSceneComponent";
  76817. }
  76818. declare module "babylonjs/States/index" {
  76819. export * from "babylonjs/States/alphaCullingState";
  76820. export * from "babylonjs/States/depthCullingState";
  76821. export * from "babylonjs/States/stencilState";
  76822. }
  76823. declare module "babylonjs/Misc/assetsManager" {
  76824. import { Scene } from "babylonjs/scene";
  76825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  76827. import { Skeleton } from "babylonjs/Bones/skeleton";
  76828. import { Observable } from "babylonjs/Misc/observable";
  76829. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  76830. import { Texture } from "babylonjs/Materials/Textures/texture";
  76831. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  76832. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  76833. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  76834. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  76835. import { AssetContainer } from "babylonjs/assetContainer";
  76836. /**
  76837. * Defines the list of states available for a task inside a AssetsManager
  76838. */
  76839. export enum AssetTaskState {
  76840. /**
  76841. * Initialization
  76842. */
  76843. INIT = 0,
  76844. /**
  76845. * Running
  76846. */
  76847. RUNNING = 1,
  76848. /**
  76849. * Done
  76850. */
  76851. DONE = 2,
  76852. /**
  76853. * Error
  76854. */
  76855. ERROR = 3
  76856. }
  76857. /**
  76858. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  76859. */
  76860. export abstract class AbstractAssetTask {
  76861. /**
  76862. * Task name
  76863. */ name: string;
  76864. /**
  76865. * Callback called when the task is successful
  76866. */
  76867. onSuccess: (task: any) => void;
  76868. /**
  76869. * Callback called when the task is not successful
  76870. */
  76871. onError: (task: any, message?: string, exception?: any) => void;
  76872. /**
  76873. * Creates a new AssetsManager
  76874. * @param name defines the name of the task
  76875. */
  76876. constructor(
  76877. /**
  76878. * Task name
  76879. */ name: string);
  76880. private _isCompleted;
  76881. private _taskState;
  76882. private _errorObject;
  76883. /**
  76884. * Get if the task is completed
  76885. */
  76886. get isCompleted(): boolean;
  76887. /**
  76888. * Gets the current state of the task
  76889. */
  76890. get taskState(): AssetTaskState;
  76891. /**
  76892. * Gets the current error object (if task is in error)
  76893. */
  76894. get errorObject(): {
  76895. message?: string;
  76896. exception?: any;
  76897. };
  76898. /**
  76899. * Internal only
  76900. * @hidden
  76901. */
  76902. _setErrorObject(message?: string, exception?: any): void;
  76903. /**
  76904. * Execute the current task
  76905. * @param scene defines the scene where you want your assets to be loaded
  76906. * @param onSuccess is a callback called when the task is successfully executed
  76907. * @param onError is a callback called if an error occurs
  76908. */
  76909. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76910. /**
  76911. * Execute the current task
  76912. * @param scene defines the scene where you want your assets to be loaded
  76913. * @param onSuccess is a callback called when the task is successfully executed
  76914. * @param onError is a callback called if an error occurs
  76915. */
  76916. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  76917. /**
  76918. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  76919. * This can be used with failed tasks that have the reason for failure fixed.
  76920. */
  76921. reset(): void;
  76922. private onErrorCallback;
  76923. private onDoneCallback;
  76924. }
  76925. /**
  76926. * Define the interface used by progress events raised during assets loading
  76927. */
  76928. export interface IAssetsProgressEvent {
  76929. /**
  76930. * Defines the number of remaining tasks to process
  76931. */
  76932. remainingCount: number;
  76933. /**
  76934. * Defines the total number of tasks
  76935. */
  76936. totalCount: number;
  76937. /**
  76938. * Defines the task that was just processed
  76939. */
  76940. task: AbstractAssetTask;
  76941. }
  76942. /**
  76943. * Class used to share progress information about assets loading
  76944. */
  76945. export class AssetsProgressEvent implements IAssetsProgressEvent {
  76946. /**
  76947. * Defines the number of remaining tasks to process
  76948. */
  76949. remainingCount: number;
  76950. /**
  76951. * Defines the total number of tasks
  76952. */
  76953. totalCount: number;
  76954. /**
  76955. * Defines the task that was just processed
  76956. */
  76957. task: AbstractAssetTask;
  76958. /**
  76959. * Creates a AssetsProgressEvent
  76960. * @param remainingCount defines the number of remaining tasks to process
  76961. * @param totalCount defines the total number of tasks
  76962. * @param task defines the task that was just processed
  76963. */
  76964. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  76965. }
  76966. /**
  76967. * Define a task used by AssetsManager to load assets into a container
  76968. */
  76969. export class ContainerAssetTask extends AbstractAssetTask {
  76970. /**
  76971. * Defines the name of the task
  76972. */
  76973. name: string;
  76974. /**
  76975. * Defines the list of mesh's names you want to load
  76976. */
  76977. meshesNames: any;
  76978. /**
  76979. * Defines the root url to use as a base to load your meshes and associated resources
  76980. */
  76981. rootUrl: string;
  76982. /**
  76983. * Defines the filename or File of the scene to load from
  76984. */
  76985. sceneFilename: string | File;
  76986. /**
  76987. * Get the loaded asset container
  76988. */
  76989. loadedContainer: AssetContainer;
  76990. /**
  76991. * Gets the list of loaded meshes
  76992. */
  76993. loadedMeshes: Array<AbstractMesh>;
  76994. /**
  76995. * Gets the list of loaded particle systems
  76996. */
  76997. loadedParticleSystems: Array<IParticleSystem>;
  76998. /**
  76999. * Gets the list of loaded skeletons
  77000. */
  77001. loadedSkeletons: Array<Skeleton>;
  77002. /**
  77003. * Gets the list of loaded animation groups
  77004. */
  77005. loadedAnimationGroups: Array<AnimationGroup>;
  77006. /**
  77007. * Callback called when the task is successful
  77008. */
  77009. onSuccess: (task: ContainerAssetTask) => void;
  77010. /**
  77011. * Callback called when the task is successful
  77012. */
  77013. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77014. /**
  77015. * Creates a new ContainerAssetTask
  77016. * @param name defines the name of the task
  77017. * @param meshesNames defines the list of mesh's names you want to load
  77018. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77019. * @param sceneFilename defines the filename or File of the scene to load from
  77020. */
  77021. constructor(
  77022. /**
  77023. * Defines the name of the task
  77024. */
  77025. name: string,
  77026. /**
  77027. * Defines the list of mesh's names you want to load
  77028. */
  77029. meshesNames: any,
  77030. /**
  77031. * Defines the root url to use as a base to load your meshes and associated resources
  77032. */
  77033. rootUrl: string,
  77034. /**
  77035. * Defines the filename or File of the scene to load from
  77036. */
  77037. sceneFilename: string | File);
  77038. /**
  77039. * Execute the current task
  77040. * @param scene defines the scene where you want your assets to be loaded
  77041. * @param onSuccess is a callback called when the task is successfully executed
  77042. * @param onError is a callback called if an error occurs
  77043. */
  77044. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77045. }
  77046. /**
  77047. * Define a task used by AssetsManager to load meshes
  77048. */
  77049. export class MeshAssetTask extends AbstractAssetTask {
  77050. /**
  77051. * Defines the name of the task
  77052. */
  77053. name: string;
  77054. /**
  77055. * Defines the list of mesh's names you want to load
  77056. */
  77057. meshesNames: any;
  77058. /**
  77059. * Defines the root url to use as a base to load your meshes and associated resources
  77060. */
  77061. rootUrl: string;
  77062. /**
  77063. * Defines the filename or File of the scene to load from
  77064. */
  77065. sceneFilename: string | File;
  77066. /**
  77067. * Gets the list of loaded meshes
  77068. */
  77069. loadedMeshes: Array<AbstractMesh>;
  77070. /**
  77071. * Gets the list of loaded particle systems
  77072. */
  77073. loadedParticleSystems: Array<IParticleSystem>;
  77074. /**
  77075. * Gets the list of loaded skeletons
  77076. */
  77077. loadedSkeletons: Array<Skeleton>;
  77078. /**
  77079. * Gets the list of loaded animation groups
  77080. */
  77081. loadedAnimationGroups: Array<AnimationGroup>;
  77082. /**
  77083. * Callback called when the task is successful
  77084. */
  77085. onSuccess: (task: MeshAssetTask) => void;
  77086. /**
  77087. * Callback called when the task is successful
  77088. */
  77089. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77090. /**
  77091. * Creates a new MeshAssetTask
  77092. * @param name defines the name of the task
  77093. * @param meshesNames defines the list of mesh's names you want to load
  77094. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77095. * @param sceneFilename defines the filename or File of the scene to load from
  77096. */
  77097. constructor(
  77098. /**
  77099. * Defines the name of the task
  77100. */
  77101. name: string,
  77102. /**
  77103. * Defines the list of mesh's names you want to load
  77104. */
  77105. meshesNames: any,
  77106. /**
  77107. * Defines the root url to use as a base to load your meshes and associated resources
  77108. */
  77109. rootUrl: string,
  77110. /**
  77111. * Defines the filename or File of the scene to load from
  77112. */
  77113. sceneFilename: string | File);
  77114. /**
  77115. * Execute the current task
  77116. * @param scene defines the scene where you want your assets to be loaded
  77117. * @param onSuccess is a callback called when the task is successfully executed
  77118. * @param onError is a callback called if an error occurs
  77119. */
  77120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77121. }
  77122. /**
  77123. * Define a task used by AssetsManager to load text content
  77124. */
  77125. export class TextFileAssetTask extends AbstractAssetTask {
  77126. /**
  77127. * Defines the name of the task
  77128. */
  77129. name: string;
  77130. /**
  77131. * Defines the location of the file to load
  77132. */
  77133. url: string;
  77134. /**
  77135. * Gets the loaded text string
  77136. */
  77137. text: string;
  77138. /**
  77139. * Callback called when the task is successful
  77140. */
  77141. onSuccess: (task: TextFileAssetTask) => void;
  77142. /**
  77143. * Callback called when the task is successful
  77144. */
  77145. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77146. /**
  77147. * Creates a new TextFileAssetTask object
  77148. * @param name defines the name of the task
  77149. * @param url defines the location of the file to load
  77150. */
  77151. constructor(
  77152. /**
  77153. * Defines the name of the task
  77154. */
  77155. name: string,
  77156. /**
  77157. * Defines the location of the file to load
  77158. */
  77159. url: string);
  77160. /**
  77161. * Execute the current task
  77162. * @param scene defines the scene where you want your assets to be loaded
  77163. * @param onSuccess is a callback called when the task is successfully executed
  77164. * @param onError is a callback called if an error occurs
  77165. */
  77166. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77167. }
  77168. /**
  77169. * Define a task used by AssetsManager to load binary data
  77170. */
  77171. export class BinaryFileAssetTask extends AbstractAssetTask {
  77172. /**
  77173. * Defines the name of the task
  77174. */
  77175. name: string;
  77176. /**
  77177. * Defines the location of the file to load
  77178. */
  77179. url: string;
  77180. /**
  77181. * Gets the lodaded data (as an array buffer)
  77182. */
  77183. data: ArrayBuffer;
  77184. /**
  77185. * Callback called when the task is successful
  77186. */
  77187. onSuccess: (task: BinaryFileAssetTask) => void;
  77188. /**
  77189. * Callback called when the task is successful
  77190. */
  77191. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77192. /**
  77193. * Creates a new BinaryFileAssetTask object
  77194. * @param name defines the name of the new task
  77195. * @param url defines the location of the file to load
  77196. */
  77197. constructor(
  77198. /**
  77199. * Defines the name of the task
  77200. */
  77201. name: string,
  77202. /**
  77203. * Defines the location of the file to load
  77204. */
  77205. url: string);
  77206. /**
  77207. * Execute the current task
  77208. * @param scene defines the scene where you want your assets to be loaded
  77209. * @param onSuccess is a callback called when the task is successfully executed
  77210. * @param onError is a callback called if an error occurs
  77211. */
  77212. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77213. }
  77214. /**
  77215. * Define a task used by AssetsManager to load images
  77216. */
  77217. export class ImageAssetTask extends AbstractAssetTask {
  77218. /**
  77219. * Defines the name of the task
  77220. */
  77221. name: string;
  77222. /**
  77223. * Defines the location of the image to load
  77224. */
  77225. url: string;
  77226. /**
  77227. * Gets the loaded images
  77228. */
  77229. image: HTMLImageElement;
  77230. /**
  77231. * Callback called when the task is successful
  77232. */
  77233. onSuccess: (task: ImageAssetTask) => void;
  77234. /**
  77235. * Callback called when the task is successful
  77236. */
  77237. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77238. /**
  77239. * Creates a new ImageAssetTask
  77240. * @param name defines the name of the task
  77241. * @param url defines the location of the image to load
  77242. */
  77243. constructor(
  77244. /**
  77245. * Defines the name of the task
  77246. */
  77247. name: string,
  77248. /**
  77249. * Defines the location of the image to load
  77250. */
  77251. url: string);
  77252. /**
  77253. * Execute the current task
  77254. * @param scene defines the scene where you want your assets to be loaded
  77255. * @param onSuccess is a callback called when the task is successfully executed
  77256. * @param onError is a callback called if an error occurs
  77257. */
  77258. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77259. }
  77260. /**
  77261. * Defines the interface used by texture loading tasks
  77262. */
  77263. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77264. /**
  77265. * Gets the loaded texture
  77266. */
  77267. texture: TEX;
  77268. }
  77269. /**
  77270. * Define a task used by AssetsManager to load 2D textures
  77271. */
  77272. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77273. /**
  77274. * Defines the name of the task
  77275. */
  77276. name: string;
  77277. /**
  77278. * Defines the location of the file to load
  77279. */
  77280. url: string;
  77281. /**
  77282. * Defines if mipmap should not be generated (default is false)
  77283. */
  77284. noMipmap?: boolean | undefined;
  77285. /**
  77286. * Defines if texture must be inverted on Y axis (default is true)
  77287. */
  77288. invertY: boolean;
  77289. /**
  77290. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77291. */
  77292. samplingMode: number;
  77293. /**
  77294. * Gets the loaded texture
  77295. */
  77296. texture: Texture;
  77297. /**
  77298. * Callback called when the task is successful
  77299. */
  77300. onSuccess: (task: TextureAssetTask) => void;
  77301. /**
  77302. * Callback called when the task is successful
  77303. */
  77304. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77305. /**
  77306. * Creates a new TextureAssetTask object
  77307. * @param name defines the name of the task
  77308. * @param url defines the location of the file to load
  77309. * @param noMipmap defines if mipmap should not be generated (default is false)
  77310. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77311. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77312. */
  77313. constructor(
  77314. /**
  77315. * Defines the name of the task
  77316. */
  77317. name: string,
  77318. /**
  77319. * Defines the location of the file to load
  77320. */
  77321. url: string,
  77322. /**
  77323. * Defines if mipmap should not be generated (default is false)
  77324. */
  77325. noMipmap?: boolean | undefined,
  77326. /**
  77327. * Defines if texture must be inverted on Y axis (default is true)
  77328. */
  77329. invertY?: boolean,
  77330. /**
  77331. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77332. */
  77333. samplingMode?: number);
  77334. /**
  77335. * Execute the current task
  77336. * @param scene defines the scene where you want your assets to be loaded
  77337. * @param onSuccess is a callback called when the task is successfully executed
  77338. * @param onError is a callback called if an error occurs
  77339. */
  77340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77341. }
  77342. /**
  77343. * Define a task used by AssetsManager to load cube textures
  77344. */
  77345. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77346. /**
  77347. * Defines the name of the task
  77348. */
  77349. name: string;
  77350. /**
  77351. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77352. */
  77353. url: string;
  77354. /**
  77355. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77356. */
  77357. extensions?: string[] | undefined;
  77358. /**
  77359. * Defines if mipmaps should not be generated (default is false)
  77360. */
  77361. noMipmap?: boolean | undefined;
  77362. /**
  77363. * Defines the explicit list of files (undefined by default)
  77364. */
  77365. files?: string[] | undefined;
  77366. /**
  77367. * Gets the loaded texture
  77368. */
  77369. texture: CubeTexture;
  77370. /**
  77371. * Callback called when the task is successful
  77372. */
  77373. onSuccess: (task: CubeTextureAssetTask) => void;
  77374. /**
  77375. * Callback called when the task is successful
  77376. */
  77377. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77378. /**
  77379. * Creates a new CubeTextureAssetTask
  77380. * @param name defines the name of the task
  77381. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77382. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77383. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77384. * @param files defines the explicit list of files (undefined by default)
  77385. */
  77386. constructor(
  77387. /**
  77388. * Defines the name of the task
  77389. */
  77390. name: string,
  77391. /**
  77392. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77393. */
  77394. url: string,
  77395. /**
  77396. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77397. */
  77398. extensions?: string[] | undefined,
  77399. /**
  77400. * Defines if mipmaps should not be generated (default is false)
  77401. */
  77402. noMipmap?: boolean | undefined,
  77403. /**
  77404. * Defines the explicit list of files (undefined by default)
  77405. */
  77406. files?: string[] | undefined);
  77407. /**
  77408. * Execute the current task
  77409. * @param scene defines the scene where you want your assets to be loaded
  77410. * @param onSuccess is a callback called when the task is successfully executed
  77411. * @param onError is a callback called if an error occurs
  77412. */
  77413. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77414. }
  77415. /**
  77416. * Define a task used by AssetsManager to load HDR cube textures
  77417. */
  77418. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77419. /**
  77420. * Defines the name of the task
  77421. */
  77422. name: string;
  77423. /**
  77424. * Defines the location of the file to load
  77425. */
  77426. url: string;
  77427. /**
  77428. * Defines the desired size (the more it increases the longer the generation will be)
  77429. */
  77430. size: number;
  77431. /**
  77432. * Defines if mipmaps should not be generated (default is false)
  77433. */
  77434. noMipmap: boolean;
  77435. /**
  77436. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77437. */
  77438. generateHarmonics: boolean;
  77439. /**
  77440. * 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)
  77441. */
  77442. gammaSpace: boolean;
  77443. /**
  77444. * Internal Use Only
  77445. */
  77446. reserved: boolean;
  77447. /**
  77448. * Gets the loaded texture
  77449. */
  77450. texture: HDRCubeTexture;
  77451. /**
  77452. * Callback called when the task is successful
  77453. */
  77454. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77455. /**
  77456. * Callback called when the task is successful
  77457. */
  77458. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77459. /**
  77460. * Creates a new HDRCubeTextureAssetTask object
  77461. * @param name defines the name of the task
  77462. * @param url defines the location of the file to load
  77463. * @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.
  77464. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77465. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77466. * @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)
  77467. * @param reserved Internal use only
  77468. */
  77469. constructor(
  77470. /**
  77471. * Defines the name of the task
  77472. */
  77473. name: string,
  77474. /**
  77475. * Defines the location of the file to load
  77476. */
  77477. url: string,
  77478. /**
  77479. * Defines the desired size (the more it increases the longer the generation will be)
  77480. */
  77481. size: number,
  77482. /**
  77483. * Defines if mipmaps should not be generated (default is false)
  77484. */
  77485. noMipmap?: boolean,
  77486. /**
  77487. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77488. */
  77489. generateHarmonics?: boolean,
  77490. /**
  77491. * 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)
  77492. */
  77493. gammaSpace?: boolean,
  77494. /**
  77495. * Internal Use Only
  77496. */
  77497. reserved?: boolean);
  77498. /**
  77499. * Execute the current task
  77500. * @param scene defines the scene where you want your assets to be loaded
  77501. * @param onSuccess is a callback called when the task is successfully executed
  77502. * @param onError is a callback called if an error occurs
  77503. */
  77504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77505. }
  77506. /**
  77507. * Define a task used by AssetsManager to load Equirectangular cube textures
  77508. */
  77509. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77510. /**
  77511. * Defines the name of the task
  77512. */
  77513. name: string;
  77514. /**
  77515. * Defines the location of the file to load
  77516. */
  77517. url: string;
  77518. /**
  77519. * Defines the desired size (the more it increases the longer the generation will be)
  77520. */
  77521. size: number;
  77522. /**
  77523. * Defines if mipmaps should not be generated (default is false)
  77524. */
  77525. noMipmap: boolean;
  77526. /**
  77527. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77528. * but the standard material would require them in Gamma space) (default is true)
  77529. */
  77530. gammaSpace: boolean;
  77531. /**
  77532. * Gets the loaded texture
  77533. */
  77534. texture: EquiRectangularCubeTexture;
  77535. /**
  77536. * Callback called when the task is successful
  77537. */
  77538. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77539. /**
  77540. * Callback called when the task is successful
  77541. */
  77542. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77543. /**
  77544. * Creates a new EquiRectangularCubeTextureAssetTask object
  77545. * @param name defines the name of the task
  77546. * @param url defines the location of the file to load
  77547. * @param size defines the desired size (the more it increases the longer the generation will be)
  77548. * If the size is omitted this implies you are using a preprocessed cubemap.
  77549. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77550. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77551. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77552. * (default is true)
  77553. */
  77554. constructor(
  77555. /**
  77556. * Defines the name of the task
  77557. */
  77558. name: string,
  77559. /**
  77560. * Defines the location of the file to load
  77561. */
  77562. url: string,
  77563. /**
  77564. * Defines the desired size (the more it increases the longer the generation will be)
  77565. */
  77566. size: number,
  77567. /**
  77568. * Defines if mipmaps should not be generated (default is false)
  77569. */
  77570. noMipmap?: boolean,
  77571. /**
  77572. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77573. * but the standard material would require them in Gamma space) (default is true)
  77574. */
  77575. gammaSpace?: boolean);
  77576. /**
  77577. * Execute the current task
  77578. * @param scene defines the scene where you want your assets to be loaded
  77579. * @param onSuccess is a callback called when the task is successfully executed
  77580. * @param onError is a callback called if an error occurs
  77581. */
  77582. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77583. }
  77584. /**
  77585. * This class can be used to easily import assets into a scene
  77586. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77587. */
  77588. export class AssetsManager {
  77589. private _scene;
  77590. private _isLoading;
  77591. protected _tasks: AbstractAssetTask[];
  77592. protected _waitingTasksCount: number;
  77593. protected _totalTasksCount: number;
  77594. /**
  77595. * Callback called when all tasks are processed
  77596. */
  77597. onFinish: (tasks: AbstractAssetTask[]) => void;
  77598. /**
  77599. * Callback called when a task is successful
  77600. */
  77601. onTaskSuccess: (task: AbstractAssetTask) => void;
  77602. /**
  77603. * Callback called when a task had an error
  77604. */
  77605. onTaskError: (task: AbstractAssetTask) => void;
  77606. /**
  77607. * Callback called when a task is done (whatever the result is)
  77608. */
  77609. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77610. /**
  77611. * Observable called when all tasks are processed
  77612. */
  77613. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77614. /**
  77615. * Observable called when a task had an error
  77616. */
  77617. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77618. /**
  77619. * Observable called when all tasks were executed
  77620. */
  77621. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77622. /**
  77623. * Observable called when a task is done (whatever the result is)
  77624. */
  77625. onProgressObservable: Observable<IAssetsProgressEvent>;
  77626. /**
  77627. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77628. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77629. */
  77630. useDefaultLoadingScreen: boolean;
  77631. /**
  77632. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77633. * when all assets have been downloaded.
  77634. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77635. */
  77636. autoHideLoadingUI: boolean;
  77637. /**
  77638. * Creates a new AssetsManager
  77639. * @param scene defines the scene to work on
  77640. */
  77641. constructor(scene: Scene);
  77642. /**
  77643. * Add a ContainerAssetTask to the list of active tasks
  77644. * @param taskName defines the name of the new task
  77645. * @param meshesNames defines the name of meshes to load
  77646. * @param rootUrl defines the root url to use to locate files
  77647. * @param sceneFilename defines the filename of the scene file
  77648. * @returns a new ContainerAssetTask object
  77649. */
  77650. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77651. /**
  77652. * Add a MeshAssetTask to the list of active tasks
  77653. * @param taskName defines the name of the new task
  77654. * @param meshesNames defines the name of meshes to load
  77655. * @param rootUrl defines the root url to use to locate files
  77656. * @param sceneFilename defines the filename of the scene file
  77657. * @returns a new MeshAssetTask object
  77658. */
  77659. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77660. /**
  77661. * Add a TextFileAssetTask to the list of active tasks
  77662. * @param taskName defines the name of the new task
  77663. * @param url defines the url of the file to load
  77664. * @returns a new TextFileAssetTask object
  77665. */
  77666. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77667. /**
  77668. * Add a BinaryFileAssetTask to the list of active tasks
  77669. * @param taskName defines the name of the new task
  77670. * @param url defines the url of the file to load
  77671. * @returns a new BinaryFileAssetTask object
  77672. */
  77673. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77674. /**
  77675. * Add a ImageAssetTask to the list of active tasks
  77676. * @param taskName defines the name of the new task
  77677. * @param url defines the url of the file to load
  77678. * @returns a new ImageAssetTask object
  77679. */
  77680. addImageTask(taskName: string, url: string): ImageAssetTask;
  77681. /**
  77682. * Add a TextureAssetTask to the list of active tasks
  77683. * @param taskName defines the name of the new task
  77684. * @param url defines the url of the file to load
  77685. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77686. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77687. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77688. * @returns a new TextureAssetTask object
  77689. */
  77690. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77691. /**
  77692. * Add a CubeTextureAssetTask to the list of active tasks
  77693. * @param taskName defines the name of the new task
  77694. * @param url defines the url of the file to load
  77695. * @param extensions defines the extension to use to load the cube map (can be null)
  77696. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77697. * @param files defines the list of files to load (can be null)
  77698. * @returns a new CubeTextureAssetTask object
  77699. */
  77700. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77701. /**
  77702. *
  77703. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77704. * @param taskName defines the name of the new task
  77705. * @param url defines the url of the file to load
  77706. * @param size defines the size you want for the cubemap (can be null)
  77707. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77708. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77709. * @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)
  77710. * @param reserved Internal use only
  77711. * @returns a new HDRCubeTextureAssetTask object
  77712. */
  77713. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77714. /**
  77715. *
  77716. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77717. * @param taskName defines the name of the new task
  77718. * @param url defines the url of the file to load
  77719. * @param size defines the size you want for the cubemap (can be null)
  77720. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77721. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77722. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77723. * @returns a new EquiRectangularCubeTextureAssetTask object
  77724. */
  77725. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77726. /**
  77727. * Remove a task from the assets manager.
  77728. * @param task the task to remove
  77729. */
  77730. removeTask(task: AbstractAssetTask): void;
  77731. private _decreaseWaitingTasksCount;
  77732. private _runTask;
  77733. /**
  77734. * Reset the AssetsManager and remove all tasks
  77735. * @return the current instance of the AssetsManager
  77736. */
  77737. reset(): AssetsManager;
  77738. /**
  77739. * Start the loading process
  77740. * @return the current instance of the AssetsManager
  77741. */
  77742. load(): AssetsManager;
  77743. /**
  77744. * Start the loading process as an async operation
  77745. * @return a promise returning the list of failed tasks
  77746. */
  77747. loadAsync(): Promise<void>;
  77748. }
  77749. }
  77750. declare module "babylonjs/Misc/deferred" {
  77751. /**
  77752. * Wrapper class for promise with external resolve and reject.
  77753. */
  77754. export class Deferred<T> {
  77755. /**
  77756. * The promise associated with this deferred object.
  77757. */
  77758. readonly promise: Promise<T>;
  77759. private _resolve;
  77760. private _reject;
  77761. /**
  77762. * The resolve method of the promise associated with this deferred object.
  77763. */
  77764. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77765. /**
  77766. * The reject method of the promise associated with this deferred object.
  77767. */
  77768. get reject(): (reason?: any) => void;
  77769. /**
  77770. * Constructor for this deferred object.
  77771. */
  77772. constructor();
  77773. }
  77774. }
  77775. declare module "babylonjs/Misc/meshExploder" {
  77776. import { Mesh } from "babylonjs/Meshes/mesh";
  77777. /**
  77778. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  77779. */
  77780. export class MeshExploder {
  77781. private _centerMesh;
  77782. private _meshes;
  77783. private _meshesOrigins;
  77784. private _toCenterVectors;
  77785. private _scaledDirection;
  77786. private _newPosition;
  77787. private _centerPosition;
  77788. /**
  77789. * Explodes meshes from a center mesh.
  77790. * @param meshes The meshes to explode.
  77791. * @param centerMesh The mesh to be center of explosion.
  77792. */
  77793. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  77794. private _setCenterMesh;
  77795. /**
  77796. * Get class name
  77797. * @returns "MeshExploder"
  77798. */
  77799. getClassName(): string;
  77800. /**
  77801. * "Exploded meshes"
  77802. * @returns Array of meshes with the centerMesh at index 0.
  77803. */
  77804. getMeshes(): Array<Mesh>;
  77805. /**
  77806. * Explodes meshes giving a specific direction
  77807. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  77808. */
  77809. explode(direction?: number): void;
  77810. }
  77811. }
  77812. declare module "babylonjs/Misc/filesInput" {
  77813. import { Engine } from "babylonjs/Engines/engine";
  77814. import { Scene } from "babylonjs/scene";
  77815. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  77816. import { Nullable } from "babylonjs/types";
  77817. /**
  77818. * Class used to help managing file picking and drag'n'drop
  77819. */
  77820. export class FilesInput {
  77821. /**
  77822. * List of files ready to be loaded
  77823. */
  77824. static get FilesToLoad(): {
  77825. [key: string]: File;
  77826. };
  77827. /**
  77828. * Callback called when a file is processed
  77829. */
  77830. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  77831. private _engine;
  77832. private _currentScene;
  77833. private _sceneLoadedCallback;
  77834. private _progressCallback;
  77835. private _additionalRenderLoopLogicCallback;
  77836. private _textureLoadingCallback;
  77837. private _startingProcessingFilesCallback;
  77838. private _onReloadCallback;
  77839. private _errorCallback;
  77840. private _elementToMonitor;
  77841. private _sceneFileToLoad;
  77842. private _filesToLoad;
  77843. /**
  77844. * Creates a new FilesInput
  77845. * @param engine defines the rendering engine
  77846. * @param scene defines the hosting scene
  77847. * @param sceneLoadedCallback callback called when scene is loaded
  77848. * @param progressCallback callback called to track progress
  77849. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  77850. * @param textureLoadingCallback callback called when a texture is loading
  77851. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  77852. * @param onReloadCallback callback called when a reload is requested
  77853. * @param errorCallback callback call if an error occurs
  77854. */
  77855. 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>);
  77856. private _dragEnterHandler;
  77857. private _dragOverHandler;
  77858. private _dropHandler;
  77859. /**
  77860. * Calls this function to listen to drag'n'drop events on a specific DOM element
  77861. * @param elementToMonitor defines the DOM element to track
  77862. */
  77863. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  77864. /** Gets the current list of files to load */
  77865. get filesToLoad(): File[];
  77866. /**
  77867. * Release all associated resources
  77868. */
  77869. dispose(): void;
  77870. private renderFunction;
  77871. private drag;
  77872. private drop;
  77873. private _traverseFolder;
  77874. private _processFiles;
  77875. /**
  77876. * Load files from a drop event
  77877. * @param event defines the drop event to use as source
  77878. */
  77879. loadFiles(event: any): void;
  77880. private _processReload;
  77881. /**
  77882. * Reload the current scene from the loaded files
  77883. */
  77884. reload(): void;
  77885. }
  77886. }
  77887. declare module "babylonjs/Misc/HighDynamicRange/index" {
  77888. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  77889. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  77890. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  77891. }
  77892. declare module "babylonjs/Misc/sceneOptimizer" {
  77893. import { Scene, IDisposable } from "babylonjs/scene";
  77894. import { Observable } from "babylonjs/Misc/observable";
  77895. /**
  77896. * Defines the root class used to create scene optimization to use with SceneOptimizer
  77897. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77898. */
  77899. export class SceneOptimization {
  77900. /**
  77901. * Defines the priority of this optimization (0 by default which means first in the list)
  77902. */
  77903. priority: number;
  77904. /**
  77905. * Gets a string describing the action executed by the current optimization
  77906. * @returns description string
  77907. */
  77908. getDescription(): string;
  77909. /**
  77910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77911. * @param scene defines the current scene where to apply this optimization
  77912. * @param optimizer defines the current optimizer
  77913. * @returns true if everything that can be done was applied
  77914. */
  77915. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77916. /**
  77917. * Creates the SceneOptimization object
  77918. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77919. * @param desc defines the description associated with the optimization
  77920. */
  77921. constructor(
  77922. /**
  77923. * Defines the priority of this optimization (0 by default which means first in the list)
  77924. */
  77925. priority?: number);
  77926. }
  77927. /**
  77928. * Defines an optimization used to reduce the size of render target textures
  77929. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77930. */
  77931. export class TextureOptimization extends SceneOptimization {
  77932. /**
  77933. * Defines the priority of this optimization (0 by default which means first in the list)
  77934. */
  77935. priority: number;
  77936. /**
  77937. * 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
  77938. */
  77939. maximumSize: number;
  77940. /**
  77941. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77942. */
  77943. step: number;
  77944. /**
  77945. * Gets a string describing the action executed by the current optimization
  77946. * @returns description string
  77947. */
  77948. getDescription(): string;
  77949. /**
  77950. * Creates the TextureOptimization object
  77951. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  77952. * @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
  77953. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77954. */
  77955. constructor(
  77956. /**
  77957. * Defines the priority of this optimization (0 by default which means first in the list)
  77958. */
  77959. priority?: number,
  77960. /**
  77961. * 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
  77962. */
  77963. maximumSize?: number,
  77964. /**
  77965. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  77966. */
  77967. step?: number);
  77968. /**
  77969. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  77970. * @param scene defines the current scene where to apply this optimization
  77971. * @param optimizer defines the current optimizer
  77972. * @returns true if everything that can be done was applied
  77973. */
  77974. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  77975. }
  77976. /**
  77977. * Defines an optimization used to increase or decrease the rendering resolution
  77978. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  77979. */
  77980. export class HardwareScalingOptimization extends SceneOptimization {
  77981. /**
  77982. * Defines the priority of this optimization (0 by default which means first in the list)
  77983. */
  77984. priority: number;
  77985. /**
  77986. * Defines the maximum scale to use (2 by default)
  77987. */
  77988. maximumScale: number;
  77989. /**
  77990. * Defines the step to use between two passes (0.5 by default)
  77991. */
  77992. step: number;
  77993. private _currentScale;
  77994. private _directionOffset;
  77995. /**
  77996. * Gets a string describing the action executed by the current optimization
  77997. * @return description string
  77998. */
  77999. getDescription(): string;
  78000. /**
  78001. * Creates the HardwareScalingOptimization object
  78002. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78003. * @param maximumScale defines the maximum scale to use (2 by default)
  78004. * @param step defines the step to use between two passes (0.5 by default)
  78005. */
  78006. constructor(
  78007. /**
  78008. * Defines the priority of this optimization (0 by default which means first in the list)
  78009. */
  78010. priority?: number,
  78011. /**
  78012. * Defines the maximum scale to use (2 by default)
  78013. */
  78014. maximumScale?: number,
  78015. /**
  78016. * Defines the step to use between two passes (0.5 by default)
  78017. */
  78018. step?: number);
  78019. /**
  78020. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78021. * @param scene defines the current scene where to apply this optimization
  78022. * @param optimizer defines the current optimizer
  78023. * @returns true if everything that can be done was applied
  78024. */
  78025. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78026. }
  78027. /**
  78028. * Defines an optimization used to remove shadows
  78029. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78030. */
  78031. export class ShadowsOptimization extends SceneOptimization {
  78032. /**
  78033. * Gets a string describing the action executed by the current optimization
  78034. * @return description string
  78035. */
  78036. getDescription(): string;
  78037. /**
  78038. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78039. * @param scene defines the current scene where to apply this optimization
  78040. * @param optimizer defines the current optimizer
  78041. * @returns true if everything that can be done was applied
  78042. */
  78043. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78044. }
  78045. /**
  78046. * Defines an optimization used to turn post-processes off
  78047. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78048. */
  78049. export class PostProcessesOptimization extends SceneOptimization {
  78050. /**
  78051. * Gets a string describing the action executed by the current optimization
  78052. * @return description string
  78053. */
  78054. getDescription(): string;
  78055. /**
  78056. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78057. * @param scene defines the current scene where to apply this optimization
  78058. * @param optimizer defines the current optimizer
  78059. * @returns true if everything that can be done was applied
  78060. */
  78061. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78062. }
  78063. /**
  78064. * Defines an optimization used to turn lens flares off
  78065. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78066. */
  78067. export class LensFlaresOptimization extends SceneOptimization {
  78068. /**
  78069. * Gets a string describing the action executed by the current optimization
  78070. * @return description string
  78071. */
  78072. getDescription(): string;
  78073. /**
  78074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78075. * @param scene defines the current scene where to apply this optimization
  78076. * @param optimizer defines the current optimizer
  78077. * @returns true if everything that can be done was applied
  78078. */
  78079. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78080. }
  78081. /**
  78082. * Defines an optimization based on user defined callback.
  78083. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78084. */
  78085. export class CustomOptimization extends SceneOptimization {
  78086. /**
  78087. * Callback called to apply the custom optimization.
  78088. */
  78089. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78090. /**
  78091. * Callback called to get custom description
  78092. */
  78093. onGetDescription: () => string;
  78094. /**
  78095. * Gets a string describing the action executed by the current optimization
  78096. * @returns description string
  78097. */
  78098. getDescription(): string;
  78099. /**
  78100. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78101. * @param scene defines the current scene where to apply this optimization
  78102. * @param optimizer defines the current optimizer
  78103. * @returns true if everything that can be done was applied
  78104. */
  78105. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78106. }
  78107. /**
  78108. * Defines an optimization used to turn particles off
  78109. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78110. */
  78111. export class ParticlesOptimization extends SceneOptimization {
  78112. /**
  78113. * Gets a string describing the action executed by the current optimization
  78114. * @return description string
  78115. */
  78116. getDescription(): string;
  78117. /**
  78118. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78119. * @param scene defines the current scene where to apply this optimization
  78120. * @param optimizer defines the current optimizer
  78121. * @returns true if everything that can be done was applied
  78122. */
  78123. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78124. }
  78125. /**
  78126. * Defines an optimization used to turn render targets off
  78127. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78128. */
  78129. export class RenderTargetsOptimization extends SceneOptimization {
  78130. /**
  78131. * Gets a string describing the action executed by the current optimization
  78132. * @return description string
  78133. */
  78134. getDescription(): string;
  78135. /**
  78136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78137. * @param scene defines the current scene where to apply this optimization
  78138. * @param optimizer defines the current optimizer
  78139. * @returns true if everything that can be done was applied
  78140. */
  78141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78142. }
  78143. /**
  78144. * Defines an optimization used to merge meshes with compatible materials
  78145. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78146. */
  78147. export class MergeMeshesOptimization extends SceneOptimization {
  78148. private static _UpdateSelectionTree;
  78149. /**
  78150. * Gets or sets a boolean which defines if optimization octree has to be updated
  78151. */
  78152. static get UpdateSelectionTree(): boolean;
  78153. /**
  78154. * Gets or sets a boolean which defines if optimization octree has to be updated
  78155. */
  78156. static set UpdateSelectionTree(value: boolean);
  78157. /**
  78158. * Gets a string describing the action executed by the current optimization
  78159. * @return description string
  78160. */
  78161. getDescription(): string;
  78162. private _canBeMerged;
  78163. /**
  78164. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78165. * @param scene defines the current scene where to apply this optimization
  78166. * @param optimizer defines the current optimizer
  78167. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78168. * @returns true if everything that can be done was applied
  78169. */
  78170. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78171. }
  78172. /**
  78173. * Defines a list of options used by SceneOptimizer
  78174. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78175. */
  78176. export class SceneOptimizerOptions {
  78177. /**
  78178. * Defines the target frame rate to reach (60 by default)
  78179. */
  78180. targetFrameRate: number;
  78181. /**
  78182. * Defines the interval between two checkes (2000ms by default)
  78183. */
  78184. trackerDuration: number;
  78185. /**
  78186. * Gets the list of optimizations to apply
  78187. */
  78188. optimizations: SceneOptimization[];
  78189. /**
  78190. * Creates a new list of options used by SceneOptimizer
  78191. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78192. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78193. */
  78194. constructor(
  78195. /**
  78196. * Defines the target frame rate to reach (60 by default)
  78197. */
  78198. targetFrameRate?: number,
  78199. /**
  78200. * Defines the interval between two checkes (2000ms by default)
  78201. */
  78202. trackerDuration?: number);
  78203. /**
  78204. * Add a new optimization
  78205. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78206. * @returns the current SceneOptimizerOptions
  78207. */
  78208. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78209. /**
  78210. * Add a new custom optimization
  78211. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78212. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78213. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78214. * @returns the current SceneOptimizerOptions
  78215. */
  78216. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78217. /**
  78218. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78219. * @param targetFrameRate defines the target frame rate (60 by default)
  78220. * @returns a SceneOptimizerOptions object
  78221. */
  78222. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78223. /**
  78224. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78225. * @param targetFrameRate defines the target frame rate (60 by default)
  78226. * @returns a SceneOptimizerOptions object
  78227. */
  78228. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78229. /**
  78230. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78231. * @param targetFrameRate defines the target frame rate (60 by default)
  78232. * @returns a SceneOptimizerOptions object
  78233. */
  78234. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78235. }
  78236. /**
  78237. * Class used to run optimizations in order to reach a target frame rate
  78238. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78239. */
  78240. export class SceneOptimizer implements IDisposable {
  78241. private _isRunning;
  78242. private _options;
  78243. private _scene;
  78244. private _currentPriorityLevel;
  78245. private _targetFrameRate;
  78246. private _trackerDuration;
  78247. private _currentFrameRate;
  78248. private _sceneDisposeObserver;
  78249. private _improvementMode;
  78250. /**
  78251. * Defines an observable called when the optimizer reaches the target frame rate
  78252. */
  78253. onSuccessObservable: Observable<SceneOptimizer>;
  78254. /**
  78255. * Defines an observable called when the optimizer enables an optimization
  78256. */
  78257. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78258. /**
  78259. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78260. */
  78261. onFailureObservable: Observable<SceneOptimizer>;
  78262. /**
  78263. * Gets a boolean indicating if the optimizer is in improvement mode
  78264. */
  78265. get isInImprovementMode(): boolean;
  78266. /**
  78267. * Gets the current priority level (0 at start)
  78268. */
  78269. get currentPriorityLevel(): number;
  78270. /**
  78271. * Gets the current frame rate checked by the SceneOptimizer
  78272. */
  78273. get currentFrameRate(): number;
  78274. /**
  78275. * Gets or sets the current target frame rate (60 by default)
  78276. */
  78277. get targetFrameRate(): number;
  78278. /**
  78279. * Gets or sets the current target frame rate (60 by default)
  78280. */
  78281. set targetFrameRate(value: number);
  78282. /**
  78283. * Gets or sets the current interval between two checks (every 2000ms by default)
  78284. */
  78285. get trackerDuration(): number;
  78286. /**
  78287. * Gets or sets the current interval between two checks (every 2000ms by default)
  78288. */
  78289. set trackerDuration(value: number);
  78290. /**
  78291. * Gets the list of active optimizations
  78292. */
  78293. get optimizations(): SceneOptimization[];
  78294. /**
  78295. * Creates a new SceneOptimizer
  78296. * @param scene defines the scene to work on
  78297. * @param options defines the options to use with the SceneOptimizer
  78298. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78299. * @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)
  78300. */
  78301. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78302. /**
  78303. * Stops the current optimizer
  78304. */
  78305. stop(): void;
  78306. /**
  78307. * Reset the optimizer to initial step (current priority level = 0)
  78308. */
  78309. reset(): void;
  78310. /**
  78311. * Start the optimizer. By default it will try to reach a specific framerate
  78312. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78313. */
  78314. start(): void;
  78315. private _checkCurrentState;
  78316. /**
  78317. * Release all resources
  78318. */
  78319. dispose(): void;
  78320. /**
  78321. * Helper function to create a SceneOptimizer with one single line of code
  78322. * @param scene defines the scene to work on
  78323. * @param options defines the options to use with the SceneOptimizer
  78324. * @param onSuccess defines a callback to call on success
  78325. * @param onFailure defines a callback to call on failure
  78326. * @returns the new SceneOptimizer object
  78327. */
  78328. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78329. }
  78330. }
  78331. declare module "babylonjs/Misc/sceneSerializer" {
  78332. import { Scene } from "babylonjs/scene";
  78333. /**
  78334. * Class used to serialize a scene into a string
  78335. */
  78336. export class SceneSerializer {
  78337. /**
  78338. * Clear cache used by a previous serialization
  78339. */
  78340. static ClearCache(): void;
  78341. /**
  78342. * Serialize a scene into a JSON compatible object
  78343. * @param scene defines the scene to serialize
  78344. * @returns a JSON compatible object
  78345. */
  78346. static Serialize(scene: Scene): any;
  78347. /**
  78348. * Serialize a mesh into a JSON compatible object
  78349. * @param toSerialize defines the mesh to serialize
  78350. * @param withParents defines if parents must be serialized as well
  78351. * @param withChildren defines if children must be serialized as well
  78352. * @returns a JSON compatible object
  78353. */
  78354. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78355. }
  78356. }
  78357. declare module "babylonjs/Misc/textureTools" {
  78358. import { Texture } from "babylonjs/Materials/Textures/texture";
  78359. /**
  78360. * Class used to host texture specific utilities
  78361. */
  78362. export class TextureTools {
  78363. /**
  78364. * Uses the GPU to create a copy texture rescaled at a given size
  78365. * @param texture Texture to copy from
  78366. * @param width defines the desired width
  78367. * @param height defines the desired height
  78368. * @param useBilinearMode defines if bilinear mode has to be used
  78369. * @return the generated texture
  78370. */
  78371. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78372. }
  78373. }
  78374. declare module "babylonjs/Misc/videoRecorder" {
  78375. import { Nullable } from "babylonjs/types";
  78376. import { Engine } from "babylonjs/Engines/engine";
  78377. /**
  78378. * This represents the different options available for the video capture.
  78379. */
  78380. export interface VideoRecorderOptions {
  78381. /** Defines the mime type of the video. */
  78382. mimeType: string;
  78383. /** Defines the FPS the video should be recorded at. */
  78384. fps: number;
  78385. /** Defines the chunk size for the recording data. */
  78386. recordChunckSize: number;
  78387. /** The audio tracks to attach to the recording. */
  78388. audioTracks?: MediaStreamTrack[];
  78389. }
  78390. /**
  78391. * This can help with recording videos from BabylonJS.
  78392. * This is based on the available WebRTC functionalities of the browser.
  78393. *
  78394. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78395. */
  78396. export class VideoRecorder {
  78397. private static readonly _defaultOptions;
  78398. /**
  78399. * Returns whether or not the VideoRecorder is available in your browser.
  78400. * @param engine Defines the Babylon Engine.
  78401. * @returns true if supported otherwise false.
  78402. */
  78403. static IsSupported(engine: Engine): boolean;
  78404. private readonly _options;
  78405. private _canvas;
  78406. private _mediaRecorder;
  78407. private _recordedChunks;
  78408. private _fileName;
  78409. private _resolve;
  78410. private _reject;
  78411. /**
  78412. * True when a recording is already in progress.
  78413. */
  78414. get isRecording(): boolean;
  78415. /**
  78416. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78417. * @param engine Defines the BabylonJS Engine you wish to record.
  78418. * @param options Defines options that can be used to customize the capture.
  78419. */
  78420. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78421. /**
  78422. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78423. */
  78424. stopRecording(): void;
  78425. /**
  78426. * Starts recording the canvas for a max duration specified in parameters.
  78427. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78428. * If null no automatic download will start and you can rely on the promise to get the data back.
  78429. * @param maxDuration Defines the maximum recording time in seconds.
  78430. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78431. * @return A promise callback at the end of the recording with the video data in Blob.
  78432. */
  78433. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78434. /**
  78435. * Releases internal resources used during the recording.
  78436. */
  78437. dispose(): void;
  78438. private _handleDataAvailable;
  78439. private _handleError;
  78440. private _handleStop;
  78441. }
  78442. }
  78443. declare module "babylonjs/Misc/screenshotTools" {
  78444. import { Camera } from "babylonjs/Cameras/camera";
  78445. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78446. import { Engine } from "babylonjs/Engines/engine";
  78447. /**
  78448. * Class containing a set of static utilities functions for screenshots
  78449. */
  78450. export class ScreenshotTools {
  78451. /**
  78452. * Captures a screenshot of the current rendering
  78453. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78454. * @param engine defines the rendering engine
  78455. * @param camera defines the source camera
  78456. * @param size This parameter can be set to a single number or to an object with the
  78457. * following (optional) properties: precision, width, height. If a single number is passed,
  78458. * it will be used for both width and height. If an object is passed, the screenshot size
  78459. * will be derived from the parameters. The precision property is a multiplier allowing
  78460. * rendering at a higher or lower resolution
  78461. * @param successCallback defines the callback receives a single parameter which contains the
  78462. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78463. * src parameter of an <img> to display it
  78464. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78465. * Check your browser for supported MIME types
  78466. */
  78467. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78468. /**
  78469. * Captures a screenshot of the current rendering
  78470. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78471. * @param engine defines the rendering engine
  78472. * @param camera defines the source camera
  78473. * @param size This parameter can be set to a single number or to an object with the
  78474. * following (optional) properties: precision, width, height. If a single number is passed,
  78475. * it will be used for both width and height. If an object is passed, the screenshot size
  78476. * will be derived from the parameters. The precision property is a multiplier allowing
  78477. * rendering at a higher or lower resolution
  78478. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78479. * Check your browser for supported MIME types
  78480. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78481. * to the src parameter of an <img> to display it
  78482. */
  78483. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78484. /**
  78485. * Generates an image screenshot from the specified camera.
  78486. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78487. * @param engine The engine to use for rendering
  78488. * @param camera The camera to use for rendering
  78489. * @param size This parameter can be set to a single number or to an object with the
  78490. * following (optional) properties: precision, width, height. If a single number is passed,
  78491. * it will be used for both width and height. If an object is passed, the screenshot size
  78492. * will be derived from the parameters. The precision property is a multiplier allowing
  78493. * rendering at a higher or lower resolution
  78494. * @param successCallback The callback receives a single parameter which contains the
  78495. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78496. * src parameter of an <img> to display it
  78497. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78498. * Check your browser for supported MIME types
  78499. * @param samples Texture samples (default: 1)
  78500. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78501. * @param fileName A name for for the downloaded file.
  78502. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78503. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78504. */
  78505. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  78506. /**
  78507. * Generates an image screenshot from the specified camera.
  78508. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78509. * @param engine The engine to use for rendering
  78510. * @param camera The camera to use for rendering
  78511. * @param size This parameter can be set to a single number or to an object with the
  78512. * following (optional) properties: precision, width, height. If a single number is passed,
  78513. * it will be used for both width and height. If an object is passed, the screenshot size
  78514. * will be derived from the parameters. The precision property is a multiplier allowing
  78515. * rendering at a higher or lower resolution
  78516. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78517. * Check your browser for supported MIME types
  78518. * @param samples Texture samples (default: 1)
  78519. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78520. * @param fileName A name for for the downloaded file.
  78521. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78522. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78523. * to the src parameter of an <img> to display it
  78524. */
  78525. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78526. /**
  78527. * Gets height and width for screenshot size
  78528. * @private
  78529. */
  78530. private static _getScreenshotSize;
  78531. }
  78532. }
  78533. declare module "babylonjs/Misc/dataReader" {
  78534. /**
  78535. * Interface for a data buffer
  78536. */
  78537. export interface IDataBuffer {
  78538. /**
  78539. * Reads bytes from the data buffer.
  78540. * @param byteOffset The byte offset to read
  78541. * @param byteLength The byte length to read
  78542. * @returns A promise that resolves when the bytes are read
  78543. */
  78544. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78545. /**
  78546. * The byte length of the buffer.
  78547. */
  78548. readonly byteLength: number;
  78549. }
  78550. /**
  78551. * Utility class for reading from a data buffer
  78552. */
  78553. export class DataReader {
  78554. /**
  78555. * The data buffer associated with this data reader.
  78556. */
  78557. readonly buffer: IDataBuffer;
  78558. /**
  78559. * The current byte offset from the beginning of the data buffer.
  78560. */
  78561. byteOffset: number;
  78562. private _dataView;
  78563. private _dataByteOffset;
  78564. /**
  78565. * Constructor
  78566. * @param buffer The buffer to read
  78567. */
  78568. constructor(buffer: IDataBuffer);
  78569. /**
  78570. * Loads the given byte length.
  78571. * @param byteLength The byte length to load
  78572. * @returns A promise that resolves when the load is complete
  78573. */
  78574. loadAsync(byteLength: number): Promise<void>;
  78575. /**
  78576. * Read a unsigned 32-bit integer from the currently loaded data range.
  78577. * @returns The 32-bit integer read
  78578. */
  78579. readUint32(): number;
  78580. /**
  78581. * Read a byte array from the currently loaded data range.
  78582. * @param byteLength The byte length to read
  78583. * @returns The byte array read
  78584. */
  78585. readUint8Array(byteLength: number): Uint8Array;
  78586. /**
  78587. * Read a string from the currently loaded data range.
  78588. * @param byteLength The byte length to read
  78589. * @returns The string read
  78590. */
  78591. readString(byteLength: number): string;
  78592. /**
  78593. * Skips the given byte length the currently loaded data range.
  78594. * @param byteLength The byte length to skip
  78595. */
  78596. skipBytes(byteLength: number): void;
  78597. }
  78598. }
  78599. declare module "babylonjs/Misc/dataStorage" {
  78600. /**
  78601. * Class for storing data to local storage if available or in-memory storage otherwise
  78602. */
  78603. export class DataStorage {
  78604. private static _Storage;
  78605. private static _GetStorage;
  78606. /**
  78607. * Reads a string from the data storage
  78608. * @param key The key to read
  78609. * @param defaultValue The value if the key doesn't exist
  78610. * @returns The string value
  78611. */
  78612. static ReadString(key: string, defaultValue: string): string;
  78613. /**
  78614. * Writes a string to the data storage
  78615. * @param key The key to write
  78616. * @param value The value to write
  78617. */
  78618. static WriteString(key: string, value: string): void;
  78619. /**
  78620. * Reads a boolean from the data storage
  78621. * @param key The key to read
  78622. * @param defaultValue The value if the key doesn't exist
  78623. * @returns The boolean value
  78624. */
  78625. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78626. /**
  78627. * Writes a boolean to the data storage
  78628. * @param key The key to write
  78629. * @param value The value to write
  78630. */
  78631. static WriteBoolean(key: string, value: boolean): void;
  78632. /**
  78633. * Reads a number from the data storage
  78634. * @param key The key to read
  78635. * @param defaultValue The value if the key doesn't exist
  78636. * @returns The number value
  78637. */
  78638. static ReadNumber(key: string, defaultValue: number): number;
  78639. /**
  78640. * Writes a number to the data storage
  78641. * @param key The key to write
  78642. * @param value The value to write
  78643. */
  78644. static WriteNumber(key: string, value: number): void;
  78645. }
  78646. }
  78647. declare module "babylonjs/Misc/sceneRecorder" {
  78648. import { Scene } from "babylonjs/scene";
  78649. /**
  78650. * Class used to record delta files between 2 scene states
  78651. */
  78652. export class SceneRecorder {
  78653. private _trackedScene;
  78654. private _savedJSON;
  78655. /**
  78656. * Track a given scene. This means the current scene state will be considered the original state
  78657. * @param scene defines the scene to track
  78658. */
  78659. track(scene: Scene): void;
  78660. /**
  78661. * Get the delta between current state and original state
  78662. * @returns a string containing the delta
  78663. */
  78664. getDelta(): any;
  78665. private _compareArray;
  78666. private _compareObjects;
  78667. private _compareCollections;
  78668. private static GetShadowGeneratorById;
  78669. /**
  78670. * Apply a given delta to a given scene
  78671. * @param deltaJSON defines the JSON containing the delta
  78672. * @param scene defines the scene to apply the delta to
  78673. */
  78674. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78675. private static _ApplyPropertiesToEntity;
  78676. private static _ApplyDeltaForEntity;
  78677. }
  78678. }
  78679. declare module "babylonjs/Misc/trajectoryClassifier" {
  78680. import { DeepImmutable, Nullable } from "babylonjs/types";
  78681. import { Vector3 } from "babylonjs/Maths/math.vector";
  78682. /**
  78683. * A 3D trajectory consisting of an order list of vectors describing a
  78684. * path of motion through 3D space.
  78685. */
  78686. export class Trajectory {
  78687. private _points;
  78688. private readonly _segmentLength;
  78689. /**
  78690. * Serialize to JSON.
  78691. * @returns serialized JSON string
  78692. */
  78693. serialize(): string;
  78694. /**
  78695. * Deserialize from JSON.
  78696. * @param json serialized JSON string
  78697. * @returns deserialized Trajectory
  78698. */
  78699. static Deserialize(json: string): Trajectory;
  78700. /**
  78701. * Create a new empty Trajectory.
  78702. * @param segmentLength radius of discretization for Trajectory points
  78703. */
  78704. constructor(segmentLength?: number);
  78705. /**
  78706. * Get the length of the Trajectory.
  78707. * @returns length of the Trajectory
  78708. */
  78709. getLength(): number;
  78710. /**
  78711. * Append a new point to the Trajectory.
  78712. * NOTE: This implementation has many allocations.
  78713. * @param point point to append to the Trajectory
  78714. */
  78715. add(point: DeepImmutable<Vector3>): void;
  78716. /**
  78717. * Create a new Trajectory with a segment length chosen to make it
  78718. * probable that the new Trajectory will have a specified number of
  78719. * segments. This operation is imprecise.
  78720. * @param targetResolution number of segments desired
  78721. * @returns new Trajectory with approximately the requested number of segments
  78722. */
  78723. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78724. /**
  78725. * Convert Trajectory segments into tokenized representation. This
  78726. * representation is an array of numbers where each nth number is the
  78727. * index of the token which is most similar to the nth segment of the
  78728. * Trajectory.
  78729. * @param tokens list of vectors which serve as discrete tokens
  78730. * @returns list of indices of most similar token per segment
  78731. */
  78732. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78733. private static _forwardDir;
  78734. private static _inverseFromVec;
  78735. private static _upDir;
  78736. private static _fromToVec;
  78737. private static _lookMatrix;
  78738. /**
  78739. * Transform the rotation (i.e., direction) of a segment to isolate
  78740. * the relative transformation represented by the segment. This operation
  78741. * may or may not succeed due to singularities in the equations that define
  78742. * motion relativity in this context.
  78743. * @param priorVec the origin of the prior segment
  78744. * @param fromVec the origin of the current segment
  78745. * @param toVec the destination of the current segment
  78746. * @param result reference to output variable
  78747. * @returns whether or not transformation was successful
  78748. */
  78749. private static _transformSegmentDirToRef;
  78750. private static _bestMatch;
  78751. private static _score;
  78752. private static _bestScore;
  78753. /**
  78754. * Determine which token vector is most similar to the
  78755. * segment vector.
  78756. * @param segment segment vector
  78757. * @param tokens token vector list
  78758. * @returns index of the most similar token to the segment
  78759. */
  78760. private static _tokenizeSegment;
  78761. }
  78762. /**
  78763. * Class representing a set of known, named trajectories to which Trajectories can be
  78764. * added and using which Trajectories can be recognized.
  78765. */
  78766. export class TrajectoryClassifier {
  78767. private _maximumAllowableMatchCost;
  78768. private _vector3Alphabet;
  78769. private _levenshteinAlphabet;
  78770. private _nameToDescribedTrajectory;
  78771. /**
  78772. * Serialize to JSON.
  78773. * @returns JSON serialization
  78774. */
  78775. serialize(): string;
  78776. /**
  78777. * Deserialize from JSON.
  78778. * @param json JSON serialization
  78779. * @returns deserialized TrajectorySet
  78780. */
  78781. static Deserialize(json: string): TrajectoryClassifier;
  78782. /**
  78783. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  78784. * VERY naive, need to be generating these things from known
  78785. * sets. Better version later, probably eliminating this one.
  78786. * @returns auto-generated TrajectorySet
  78787. */
  78788. static Generate(): TrajectoryClassifier;
  78789. private constructor();
  78790. /**
  78791. * Add a new Trajectory to the set with a given name.
  78792. * @param trajectory new Trajectory to be added
  78793. * @param classification name to which to add the Trajectory
  78794. */
  78795. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  78796. /**
  78797. * Remove a known named trajectory and all Trajectories associated with it.
  78798. * @param classification name to remove
  78799. * @returns whether anything was removed
  78800. */
  78801. deleteClassification(classification: string): boolean;
  78802. /**
  78803. * Attempt to recognize a Trajectory from among all the classifications
  78804. * already known to the classifier.
  78805. * @param trajectory Trajectory to be recognized
  78806. * @returns classification of Trajectory if recognized, null otherwise
  78807. */
  78808. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  78809. }
  78810. }
  78811. declare module "babylonjs/Misc/index" {
  78812. export * from "babylonjs/Misc/andOrNotEvaluator";
  78813. export * from "babylonjs/Misc/assetsManager";
  78814. export * from "babylonjs/Misc/basis";
  78815. export * from "babylonjs/Misc/dds";
  78816. export * from "babylonjs/Misc/decorators";
  78817. export * from "babylonjs/Misc/deferred";
  78818. export * from "babylonjs/Misc/environmentTextureTools";
  78819. export * from "babylonjs/Misc/meshExploder";
  78820. export * from "babylonjs/Misc/filesInput";
  78821. export * from "babylonjs/Misc/HighDynamicRange/index";
  78822. export * from "babylonjs/Misc/khronosTextureContainer";
  78823. export * from "babylonjs/Misc/observable";
  78824. export * from "babylonjs/Misc/performanceMonitor";
  78825. export * from "babylonjs/Misc/promise";
  78826. export * from "babylonjs/Misc/sceneOptimizer";
  78827. export * from "babylonjs/Misc/sceneSerializer";
  78828. export * from "babylonjs/Misc/smartArray";
  78829. export * from "babylonjs/Misc/stringDictionary";
  78830. export * from "babylonjs/Misc/tags";
  78831. export * from "babylonjs/Misc/textureTools";
  78832. export * from "babylonjs/Misc/tga";
  78833. export * from "babylonjs/Misc/tools";
  78834. export * from "babylonjs/Misc/videoRecorder";
  78835. export * from "babylonjs/Misc/virtualJoystick";
  78836. export * from "babylonjs/Misc/workerPool";
  78837. export * from "babylonjs/Misc/logger";
  78838. export * from "babylonjs/Misc/typeStore";
  78839. export * from "babylonjs/Misc/filesInputStore";
  78840. export * from "babylonjs/Misc/deepCopier";
  78841. export * from "babylonjs/Misc/pivotTools";
  78842. export * from "babylonjs/Misc/precisionDate";
  78843. export * from "babylonjs/Misc/screenshotTools";
  78844. export * from "babylonjs/Misc/typeStore";
  78845. export * from "babylonjs/Misc/webRequest";
  78846. export * from "babylonjs/Misc/iInspectable";
  78847. export * from "babylonjs/Misc/brdfTextureTools";
  78848. export * from "babylonjs/Misc/rgbdTextureTools";
  78849. export * from "babylonjs/Misc/gradients";
  78850. export * from "babylonjs/Misc/perfCounter";
  78851. export * from "babylonjs/Misc/fileRequest";
  78852. export * from "babylonjs/Misc/customAnimationFrameRequester";
  78853. export * from "babylonjs/Misc/retryStrategy";
  78854. export * from "babylonjs/Misc/interfaces/screenshotSize";
  78855. export * from "babylonjs/Misc/canvasGenerator";
  78856. export * from "babylonjs/Misc/fileTools";
  78857. export * from "babylonjs/Misc/stringTools";
  78858. export * from "babylonjs/Misc/dataReader";
  78859. export * from "babylonjs/Misc/minMaxReducer";
  78860. export * from "babylonjs/Misc/depthReducer";
  78861. export * from "babylonjs/Misc/dataStorage";
  78862. export * from "babylonjs/Misc/sceneRecorder";
  78863. export * from "babylonjs/Misc/khronosTextureContainer2";
  78864. export * from "babylonjs/Misc/trajectoryClassifier";
  78865. }
  78866. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  78867. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  78868. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78869. import { Observable } from "babylonjs/Misc/observable";
  78870. import { Matrix } from "babylonjs/Maths/math.vector";
  78871. import { TransformNode } from "babylonjs/Meshes/transformNode";
  78872. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78873. /**
  78874. * An interface for all Hit test features
  78875. */
  78876. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  78877. /**
  78878. * Triggered when new babylon (transformed) hit test results are available
  78879. */
  78880. onHitTestResultObservable: Observable<T[]>;
  78881. }
  78882. /**
  78883. * Options used for hit testing
  78884. */
  78885. export interface IWebXRLegacyHitTestOptions {
  78886. /**
  78887. * Only test when user interacted with the scene. Default - hit test every frame
  78888. */
  78889. testOnPointerDownOnly?: boolean;
  78890. /**
  78891. * The node to use to transform the local results to world coordinates
  78892. */
  78893. worldParentNode?: TransformNode;
  78894. }
  78895. /**
  78896. * Interface defining the babylon result of raycasting/hit-test
  78897. */
  78898. export interface IWebXRLegacyHitResult {
  78899. /**
  78900. * Transformation matrix that can be applied to a node that will put it in the hit point location
  78901. */
  78902. transformationMatrix: Matrix;
  78903. /**
  78904. * The native hit test result
  78905. */
  78906. xrHitResult: XRHitResult | XRHitTestResult;
  78907. }
  78908. /**
  78909. * The currently-working hit-test module.
  78910. * Hit test (or Ray-casting) is used to interact with the real world.
  78911. * For further information read here - https://github.com/immersive-web/hit-test
  78912. */
  78913. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  78914. /**
  78915. * options to use when constructing this feature
  78916. */
  78917. readonly options: IWebXRLegacyHitTestOptions;
  78918. private _direction;
  78919. private _mat;
  78920. private _onSelectEnabled;
  78921. private _origin;
  78922. /**
  78923. * The module's name
  78924. */
  78925. static readonly Name: string;
  78926. /**
  78927. * The (Babylon) version of this module.
  78928. * This is an integer representing the implementation version.
  78929. * This number does not correspond to the WebXR specs version
  78930. */
  78931. static readonly Version: number;
  78932. /**
  78933. * Populated with the last native XR Hit Results
  78934. */
  78935. lastNativeXRHitResults: XRHitResult[];
  78936. /**
  78937. * Triggered when new babylon (transformed) hit test results are available
  78938. */
  78939. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  78940. /**
  78941. * Creates a new instance of the (legacy version) hit test feature
  78942. * @param _xrSessionManager an instance of WebXRSessionManager
  78943. * @param options options to use when constructing this feature
  78944. */
  78945. constructor(_xrSessionManager: WebXRSessionManager,
  78946. /**
  78947. * options to use when constructing this feature
  78948. */
  78949. options?: IWebXRLegacyHitTestOptions);
  78950. /**
  78951. * execute a hit test with an XR Ray
  78952. *
  78953. * @param xrSession a native xrSession that will execute this hit test
  78954. * @param xrRay the ray (position and direction) to use for ray-casting
  78955. * @param referenceSpace native XR reference space to use for the hit-test
  78956. * @param filter filter function that will filter the results
  78957. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78958. */
  78959. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  78960. /**
  78961. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  78962. * @param event the (select) event to use to select with
  78963. * @param referenceSpace the reference space to use for this hit test
  78964. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  78965. */
  78966. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  78967. /**
  78968. * attach this feature
  78969. * Will usually be called by the features manager
  78970. *
  78971. * @returns true if successful.
  78972. */
  78973. attach(): boolean;
  78974. /**
  78975. * detach this feature.
  78976. * Will usually be called by the features manager
  78977. *
  78978. * @returns true if successful.
  78979. */
  78980. detach(): boolean;
  78981. /**
  78982. * Dispose this feature and all of the resources attached
  78983. */
  78984. dispose(): void;
  78985. protected _onXRFrame(frame: XRFrame): void;
  78986. private _onHitTestResults;
  78987. private _onSelect;
  78988. }
  78989. }
  78990. declare module "babylonjs/XR/features/WebXRHitTest" {
  78991. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  78992. import { Observable } from "babylonjs/Misc/observable";
  78993. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  78994. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  78995. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  78996. /**
  78997. * Options used for hit testing (version 2)
  78998. */
  78999. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79000. /**
  79001. * Do not create a permanent hit test. Will usually be used when only
  79002. * transient inputs are needed.
  79003. */
  79004. disablePermanentHitTest?: boolean;
  79005. /**
  79006. * Enable transient (for example touch-based) hit test inspections
  79007. */
  79008. enableTransientHitTest?: boolean;
  79009. /**
  79010. * Offset ray for the permanent hit test
  79011. */
  79012. offsetRay?: Vector3;
  79013. /**
  79014. * Offset ray for the transient hit test
  79015. */
  79016. transientOffsetRay?: Vector3;
  79017. /**
  79018. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79019. */
  79020. useReferenceSpace?: boolean;
  79021. /**
  79022. * Override the default entity type(s) of the hit-test result
  79023. */
  79024. entityTypes?: XRHitTestTrackableType[];
  79025. }
  79026. /**
  79027. * Interface defining the babylon result of hit-test
  79028. */
  79029. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79030. /**
  79031. * The input source that generated this hit test (if transient)
  79032. */
  79033. inputSource?: XRInputSource;
  79034. /**
  79035. * Is this a transient hit test
  79036. */
  79037. isTransient?: boolean;
  79038. /**
  79039. * Position of the hit test result
  79040. */
  79041. position: Vector3;
  79042. /**
  79043. * Rotation of the hit test result
  79044. */
  79045. rotationQuaternion: Quaternion;
  79046. /**
  79047. * The native hit test result
  79048. */
  79049. xrHitResult: XRHitTestResult;
  79050. }
  79051. /**
  79052. * The currently-working hit-test module.
  79053. * Hit test (or Ray-casting) is used to interact with the real world.
  79054. * For further information read here - https://github.com/immersive-web/hit-test
  79055. *
  79056. * Tested on chrome (mobile) 80.
  79057. */
  79058. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79059. /**
  79060. * options to use when constructing this feature
  79061. */
  79062. readonly options: IWebXRHitTestOptions;
  79063. private _tmpMat;
  79064. private _tmpPos;
  79065. private _tmpQuat;
  79066. private _transientXrHitTestSource;
  79067. private _xrHitTestSource;
  79068. private initHitTestSource;
  79069. /**
  79070. * The module's name
  79071. */
  79072. static readonly Name: string;
  79073. /**
  79074. * The (Babylon) version of this module.
  79075. * This is an integer representing the implementation version.
  79076. * This number does not correspond to the WebXR specs version
  79077. */
  79078. static readonly Version: number;
  79079. /**
  79080. * When set to true, each hit test will have its own position/rotation objects
  79081. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79082. * the developers will clone them or copy them as they see fit.
  79083. */
  79084. autoCloneTransformation: boolean;
  79085. /**
  79086. * Triggered when new babylon (transformed) hit test results are available
  79087. * Note - this will be called when results come back from the device. It can be an empty array!!
  79088. */
  79089. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79090. /**
  79091. * Use this to temporarily pause hit test checks.
  79092. */
  79093. paused: boolean;
  79094. /**
  79095. * Creates a new instance of the hit test feature
  79096. * @param _xrSessionManager an instance of WebXRSessionManager
  79097. * @param options options to use when constructing this feature
  79098. */
  79099. constructor(_xrSessionManager: WebXRSessionManager,
  79100. /**
  79101. * options to use when constructing this feature
  79102. */
  79103. options?: IWebXRHitTestOptions);
  79104. /**
  79105. * attach this feature
  79106. * Will usually be called by the features manager
  79107. *
  79108. * @returns true if successful.
  79109. */
  79110. attach(): boolean;
  79111. /**
  79112. * detach this feature.
  79113. * Will usually be called by the features manager
  79114. *
  79115. * @returns true if successful.
  79116. */
  79117. detach(): boolean;
  79118. /**
  79119. * Dispose this feature and all of the resources attached
  79120. */
  79121. dispose(): void;
  79122. protected _onXRFrame(frame: XRFrame): void;
  79123. private _processWebXRHitTestResult;
  79124. }
  79125. }
  79126. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79127. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79128. import { Observable } from "babylonjs/Misc/observable";
  79129. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79130. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79131. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79132. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79133. /**
  79134. * Configuration options of the anchor system
  79135. */
  79136. export interface IWebXRAnchorSystemOptions {
  79137. /**
  79138. * a node that will be used to convert local to world coordinates
  79139. */
  79140. worldParentNode?: TransformNode;
  79141. /**
  79142. * If set to true a reference of the created anchors will be kept until the next session starts
  79143. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79144. */
  79145. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79146. }
  79147. /**
  79148. * A babylon container for an XR Anchor
  79149. */
  79150. export interface IWebXRAnchor {
  79151. /**
  79152. * A babylon-assigned ID for this anchor
  79153. */
  79154. id: number;
  79155. /**
  79156. * Transformation matrix to apply to an object attached to this anchor
  79157. */
  79158. transformationMatrix: Matrix;
  79159. /**
  79160. * The native anchor object
  79161. */
  79162. xrAnchor: XRAnchor;
  79163. /**
  79164. * if defined, this object will be constantly updated by the anchor's position and rotation
  79165. */
  79166. attachedNode?: TransformNode;
  79167. }
  79168. /**
  79169. * An implementation of the anchor system for WebXR.
  79170. * For further information see https://github.com/immersive-web/anchors/
  79171. */
  79172. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79173. private _options;
  79174. private _lastFrameDetected;
  79175. private _trackedAnchors;
  79176. private _referenceSpaceForFrameAnchors;
  79177. private _futureAnchors;
  79178. /**
  79179. * The module's name
  79180. */
  79181. static readonly Name: string;
  79182. /**
  79183. * The (Babylon) version of this module.
  79184. * This is an integer representing the implementation version.
  79185. * This number does not correspond to the WebXR specs version
  79186. */
  79187. static readonly Version: number;
  79188. /**
  79189. * Observers registered here will be executed when a new anchor was added to the session
  79190. */
  79191. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79192. /**
  79193. * Observers registered here will be executed when an anchor was removed from the session
  79194. */
  79195. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79196. /**
  79197. * Observers registered here will be executed when an existing anchor updates
  79198. * This can execute N times every frame
  79199. */
  79200. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79201. /**
  79202. * Set the reference space to use for anchor creation, when not using a hit test.
  79203. * Will default to the session's reference space if not defined
  79204. */
  79205. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79206. /**
  79207. * constructs a new anchor system
  79208. * @param _xrSessionManager an instance of WebXRSessionManager
  79209. * @param _options configuration object for this feature
  79210. */
  79211. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79212. private _tmpVector;
  79213. private _tmpQuaternion;
  79214. private _populateTmpTransformation;
  79215. /**
  79216. * Create a new anchor point using a hit test result at a specific point in the scene
  79217. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79218. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79219. *
  79220. * @param hitTestResult The hit test result to use for this anchor creation
  79221. * @param position an optional position offset for this anchor
  79222. * @param rotationQuaternion an optional rotation offset for this anchor
  79223. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79224. */
  79225. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79226. /**
  79227. * Add a new anchor at a specific position and rotation
  79228. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79229. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79230. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79231. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79232. *
  79233. * @param position the position in which to add an anchor
  79234. * @param rotationQuaternion an optional rotation for the anchor transformation
  79235. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79236. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79237. */
  79238. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79239. /**
  79240. * detach this feature.
  79241. * Will usually be called by the features manager
  79242. *
  79243. * @returns true if successful.
  79244. */
  79245. detach(): boolean;
  79246. /**
  79247. * Dispose this feature and all of the resources attached
  79248. */
  79249. dispose(): void;
  79250. protected _onXRFrame(frame: XRFrame): void;
  79251. /**
  79252. * avoiding using Array.find for global support.
  79253. * @param xrAnchor the plane to find in the array
  79254. */
  79255. private _findIndexInAnchorArray;
  79256. private _updateAnchorWithXRFrame;
  79257. private _createAnchorAtTransformation;
  79258. }
  79259. }
  79260. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79261. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79262. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79263. import { Observable } from "babylonjs/Misc/observable";
  79264. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79265. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79266. /**
  79267. * Options used in the plane detector module
  79268. */
  79269. export interface IWebXRPlaneDetectorOptions {
  79270. /**
  79271. * The node to use to transform the local results to world coordinates
  79272. */
  79273. worldParentNode?: TransformNode;
  79274. /**
  79275. * If set to true a reference of the created planes will be kept until the next session starts
  79276. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79277. */
  79278. doNotRemovePlanesOnSessionEnded?: boolean;
  79279. }
  79280. /**
  79281. * A babylon interface for a WebXR plane.
  79282. * A Plane is actually a polygon, built from N points in space
  79283. *
  79284. * Supported in chrome 79, not supported in canary 81 ATM
  79285. */
  79286. export interface IWebXRPlane {
  79287. /**
  79288. * a babylon-assigned ID for this polygon
  79289. */
  79290. id: number;
  79291. /**
  79292. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79293. */
  79294. polygonDefinition: Array<Vector3>;
  79295. /**
  79296. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79297. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79298. */
  79299. transformationMatrix: Matrix;
  79300. /**
  79301. * the native xr-plane object
  79302. */
  79303. xrPlane: XRPlane;
  79304. }
  79305. /**
  79306. * The plane detector is used to detect planes in the real world when in AR
  79307. * For more information see https://github.com/immersive-web/real-world-geometry/
  79308. */
  79309. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79310. private _options;
  79311. private _detectedPlanes;
  79312. private _enabled;
  79313. private _lastFrameDetected;
  79314. /**
  79315. * The module's name
  79316. */
  79317. static readonly Name: string;
  79318. /**
  79319. * The (Babylon) version of this module.
  79320. * This is an integer representing the implementation version.
  79321. * This number does not correspond to the WebXR specs version
  79322. */
  79323. static readonly Version: number;
  79324. /**
  79325. * Observers registered here will be executed when a new plane was added to the session
  79326. */
  79327. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79328. /**
  79329. * Observers registered here will be executed when a plane is no longer detected in the session
  79330. */
  79331. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79332. /**
  79333. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79334. * This can execute N times every frame
  79335. */
  79336. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79337. /**
  79338. * construct a new Plane Detector
  79339. * @param _xrSessionManager an instance of xr Session manager
  79340. * @param _options configuration to use when constructing this feature
  79341. */
  79342. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79343. /**
  79344. * detach this feature.
  79345. * Will usually be called by the features manager
  79346. *
  79347. * @returns true if successful.
  79348. */
  79349. detach(): boolean;
  79350. /**
  79351. * Dispose this feature and all of the resources attached
  79352. */
  79353. dispose(): void;
  79354. protected _onXRFrame(frame: XRFrame): void;
  79355. private _init;
  79356. private _updatePlaneWithXRPlane;
  79357. /**
  79358. * avoiding using Array.find for global support.
  79359. * @param xrPlane the plane to find in the array
  79360. */
  79361. private findIndexInPlaneArray;
  79362. }
  79363. }
  79364. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79365. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79366. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79367. import { Observable } from "babylonjs/Misc/observable";
  79368. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79369. /**
  79370. * Options interface for the background remover plugin
  79371. */
  79372. export interface IWebXRBackgroundRemoverOptions {
  79373. /**
  79374. * Further background meshes to disable when entering AR
  79375. */
  79376. backgroundMeshes?: AbstractMesh[];
  79377. /**
  79378. * flags to configure the removal of the environment helper.
  79379. * If not set, the entire background will be removed. If set, flags should be set as well.
  79380. */
  79381. environmentHelperRemovalFlags?: {
  79382. /**
  79383. * Should the skybox be removed (default false)
  79384. */
  79385. skyBox?: boolean;
  79386. /**
  79387. * Should the ground be removed (default false)
  79388. */
  79389. ground?: boolean;
  79390. };
  79391. /**
  79392. * don't disable the environment helper
  79393. */
  79394. ignoreEnvironmentHelper?: boolean;
  79395. }
  79396. /**
  79397. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79398. */
  79399. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79400. /**
  79401. * read-only options to be used in this module
  79402. */
  79403. readonly options: IWebXRBackgroundRemoverOptions;
  79404. /**
  79405. * The module's name
  79406. */
  79407. static readonly Name: string;
  79408. /**
  79409. * The (Babylon) version of this module.
  79410. * This is an integer representing the implementation version.
  79411. * This number does not correspond to the WebXR specs version
  79412. */
  79413. static readonly Version: number;
  79414. /**
  79415. * registered observers will be triggered when the background state changes
  79416. */
  79417. onBackgroundStateChangedObservable: Observable<boolean>;
  79418. /**
  79419. * constructs a new background remover module
  79420. * @param _xrSessionManager the session manager for this module
  79421. * @param options read-only options to be used in this module
  79422. */
  79423. constructor(_xrSessionManager: WebXRSessionManager,
  79424. /**
  79425. * read-only options to be used in this module
  79426. */
  79427. options?: IWebXRBackgroundRemoverOptions);
  79428. /**
  79429. * attach this feature
  79430. * Will usually be called by the features manager
  79431. *
  79432. * @returns true if successful.
  79433. */
  79434. attach(): boolean;
  79435. /**
  79436. * detach this feature.
  79437. * Will usually be called by the features manager
  79438. *
  79439. * @returns true if successful.
  79440. */
  79441. detach(): boolean;
  79442. /**
  79443. * Dispose this feature and all of the resources attached
  79444. */
  79445. dispose(): void;
  79446. protected _onXRFrame(_xrFrame: XRFrame): void;
  79447. private _setBackgroundState;
  79448. }
  79449. }
  79450. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79451. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79452. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79453. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79454. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79455. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79456. import { Nullable } from "babylonjs/types";
  79457. /**
  79458. * Options for the controller physics feature
  79459. */
  79460. export class IWebXRControllerPhysicsOptions {
  79461. /**
  79462. * Should the headset get its own impostor
  79463. */
  79464. enableHeadsetImpostor?: boolean;
  79465. /**
  79466. * Optional parameters for the headset impostor
  79467. */
  79468. headsetImpostorParams?: {
  79469. /**
  79470. * The type of impostor to create. Default is sphere
  79471. */
  79472. impostorType: number;
  79473. /**
  79474. * the size of the impostor. Defaults to 10cm
  79475. */
  79476. impostorSize?: number | {
  79477. width: number;
  79478. height: number;
  79479. depth: number;
  79480. };
  79481. /**
  79482. * Friction definitions
  79483. */
  79484. friction?: number;
  79485. /**
  79486. * Restitution
  79487. */
  79488. restitution?: number;
  79489. };
  79490. /**
  79491. * The physics properties of the future impostors
  79492. */
  79493. physicsProperties?: {
  79494. /**
  79495. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79496. * Note that this requires a physics engine that supports mesh impostors!
  79497. */
  79498. useControllerMesh?: boolean;
  79499. /**
  79500. * The type of impostor to create. Default is sphere
  79501. */
  79502. impostorType?: number;
  79503. /**
  79504. * the size of the impostor. Defaults to 10cm
  79505. */
  79506. impostorSize?: number | {
  79507. width: number;
  79508. height: number;
  79509. depth: number;
  79510. };
  79511. /**
  79512. * Friction definitions
  79513. */
  79514. friction?: number;
  79515. /**
  79516. * Restitution
  79517. */
  79518. restitution?: number;
  79519. };
  79520. /**
  79521. * the xr input to use with this pointer selection
  79522. */
  79523. xrInput: WebXRInput;
  79524. }
  79525. /**
  79526. * Add physics impostor to your webxr controllers,
  79527. * including naive calculation of their linear and angular velocity
  79528. */
  79529. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79530. private readonly _options;
  79531. private _attachController;
  79532. private _controllers;
  79533. private _debugMode;
  79534. private _delta;
  79535. private _headsetImpostor?;
  79536. private _headsetMesh?;
  79537. private _lastTimestamp;
  79538. private _tmpQuaternion;
  79539. private _tmpVector;
  79540. /**
  79541. * The module's name
  79542. */
  79543. static readonly Name: string;
  79544. /**
  79545. * The (Babylon) version of this module.
  79546. * This is an integer representing the implementation version.
  79547. * This number does not correspond to the webxr specs version
  79548. */
  79549. static readonly Version: number;
  79550. /**
  79551. * Construct a new Controller Physics Feature
  79552. * @param _xrSessionManager the corresponding xr session manager
  79553. * @param _options options to create this feature with
  79554. */
  79555. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79556. /**
  79557. * @hidden
  79558. * enable debugging - will show console outputs and the impostor mesh
  79559. */
  79560. _enablePhysicsDebug(): void;
  79561. /**
  79562. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79563. * @param xrController the controller to add
  79564. */
  79565. addController(xrController: WebXRInputSource): void;
  79566. /**
  79567. * attach this feature
  79568. * Will usually be called by the features manager
  79569. *
  79570. * @returns true if successful.
  79571. */
  79572. attach(): boolean;
  79573. /**
  79574. * detach this feature.
  79575. * Will usually be called by the features manager
  79576. *
  79577. * @returns true if successful.
  79578. */
  79579. detach(): boolean;
  79580. /**
  79581. * Get the headset impostor, if enabled
  79582. * @returns the impostor
  79583. */
  79584. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79585. /**
  79586. * Get the physics impostor of a specific controller.
  79587. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79588. * @param controller the controller or the controller id of which to get the impostor
  79589. * @returns the impostor or null
  79590. */
  79591. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79592. /**
  79593. * Update the physics properties provided in the constructor
  79594. * @param newProperties the new properties object
  79595. */
  79596. setPhysicsProperties(newProperties: {
  79597. impostorType?: number;
  79598. impostorSize?: number | {
  79599. width: number;
  79600. height: number;
  79601. depth: number;
  79602. };
  79603. friction?: number;
  79604. restitution?: number;
  79605. }): void;
  79606. protected _onXRFrame(_xrFrame: any): void;
  79607. private _detachController;
  79608. }
  79609. }
  79610. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79611. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79612. import { Observable } from "babylonjs/Misc/observable";
  79613. import { Vector3 } from "babylonjs/Maths/math.vector";
  79614. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79615. /**
  79616. * A babylon interface for a "WebXR" feature point.
  79617. * Represents the position and confidence value of a given feature point.
  79618. */
  79619. export interface IWebXRFeaturePoint {
  79620. /**
  79621. * Represents the position of the feature point in world space.
  79622. */
  79623. position: Vector3;
  79624. /**
  79625. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79626. */
  79627. confidenceValue: number;
  79628. }
  79629. /**
  79630. * The feature point system is used to detect feature points from real world geometry.
  79631. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79632. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79633. */
  79634. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79635. private _enabled;
  79636. private _featurePointCloud;
  79637. /**
  79638. * The module's name
  79639. */
  79640. static readonly Name: string;
  79641. /**
  79642. * The (Babylon) version of this module.
  79643. * This is an integer representing the implementation version.
  79644. * This number does not correspond to the WebXR specs version
  79645. */
  79646. static readonly Version: number;
  79647. /**
  79648. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79649. * Will notify the observers about which feature points have been added.
  79650. */
  79651. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79652. /**
  79653. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79654. * Will notify the observers about which feature points have been updated.
  79655. */
  79656. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79657. /**
  79658. * The current feature point cloud maintained across frames.
  79659. */
  79660. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79661. /**
  79662. * construct the feature point system
  79663. * @param _xrSessionManager an instance of xr Session manager
  79664. */
  79665. constructor(_xrSessionManager: WebXRSessionManager);
  79666. /**
  79667. * Detach this feature.
  79668. * Will usually be called by the features manager
  79669. *
  79670. * @returns true if successful.
  79671. */
  79672. detach(): boolean;
  79673. /**
  79674. * Dispose this feature and all of the resources attached
  79675. */
  79676. dispose(): void;
  79677. /**
  79678. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79679. */
  79680. protected _onXRFrame(frame: XRFrame): void;
  79681. /**
  79682. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79683. */
  79684. private _init;
  79685. }
  79686. }
  79687. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79688. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79689. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79691. import { Mesh } from "babylonjs/Meshes/mesh";
  79692. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79693. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79694. import { Nullable } from "babylonjs/types";
  79695. import { IDisposable } from "babylonjs/scene";
  79696. import { Observable } from "babylonjs/Misc/observable";
  79697. /**
  79698. * Configuration interface for the hand tracking feature
  79699. */
  79700. export interface IWebXRHandTrackingOptions {
  79701. /**
  79702. * The xrInput that will be used as source for new hands
  79703. */
  79704. xrInput: WebXRInput;
  79705. /**
  79706. * Configuration object for the joint meshes
  79707. */
  79708. jointMeshes?: {
  79709. /**
  79710. * Should the meshes created be invisible (defaults to false)
  79711. */
  79712. invisible?: boolean;
  79713. /**
  79714. * A source mesh to be used to create instances. Defaults to a sphere.
  79715. * This mesh will be the source for all other (25) meshes.
  79716. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79717. */
  79718. sourceMesh?: Mesh;
  79719. /**
  79720. * Should the source mesh stay visible. Defaults to false
  79721. */
  79722. keepOriginalVisible?: boolean;
  79723. /**
  79724. * Scale factor for all instances (defaults to 2)
  79725. */
  79726. scaleFactor?: number;
  79727. /**
  79728. * Should each instance have its own physics impostor
  79729. */
  79730. enablePhysics?: boolean;
  79731. /**
  79732. * If enabled, override default physics properties
  79733. */
  79734. physicsProps?: {
  79735. friction?: number;
  79736. restitution?: number;
  79737. impostorType?: number;
  79738. };
  79739. /**
  79740. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79741. */
  79742. handMesh?: AbstractMesh;
  79743. };
  79744. }
  79745. /**
  79746. * Parts of the hands divided to writs and finger names
  79747. */
  79748. export const enum HandPart {
  79749. /**
  79750. * HandPart - Wrist
  79751. */
  79752. WRIST = "wrist",
  79753. /**
  79754. * HandPart - The THumb
  79755. */
  79756. THUMB = "thumb",
  79757. /**
  79758. * HandPart - Index finger
  79759. */
  79760. INDEX = "index",
  79761. /**
  79762. * HandPart - Middle finger
  79763. */
  79764. MIDDLE = "middle",
  79765. /**
  79766. * HandPart - Ring finger
  79767. */
  79768. RING = "ring",
  79769. /**
  79770. * HandPart - Little finger
  79771. */
  79772. LITTLE = "little"
  79773. }
  79774. /**
  79775. * Representing a single hand (with its corresponding native XRHand object)
  79776. */
  79777. export class WebXRHand implements IDisposable {
  79778. /** the controller to which the hand correlates */
  79779. readonly xrController: WebXRInputSource;
  79780. /** the meshes to be used to track the hand joints */
  79781. readonly trackedMeshes: AbstractMesh[];
  79782. /**
  79783. * Hand-parts definition (key is HandPart)
  79784. */
  79785. handPartsDefinition: {
  79786. [key: string]: number[];
  79787. };
  79788. /**
  79789. * Populate the HandPartsDefinition object.
  79790. * This is called as a side effect since certain browsers don't have XRHand defined.
  79791. */
  79792. private generateHandPartsDefinition;
  79793. /**
  79794. * Construct a new hand object
  79795. * @param xrController the controller to which the hand correlates
  79796. * @param trackedMeshes the meshes to be used to track the hand joints
  79797. */
  79798. constructor(
  79799. /** the controller to which the hand correlates */
  79800. xrController: WebXRInputSource,
  79801. /** the meshes to be used to track the hand joints */
  79802. trackedMeshes: AbstractMesh[]);
  79803. /**
  79804. * Update this hand from the latest xr frame
  79805. * @param xrFrame xrFrame to update from
  79806. * @param referenceSpace The current viewer reference space
  79807. * @param scaleFactor optional scale factor for the meshes
  79808. */
  79809. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  79810. /**
  79811. * Get meshes of part of the hand
  79812. * @param part the part of hand to get
  79813. * @returns An array of meshes that correlate to the hand part requested
  79814. */
  79815. getHandPartMeshes(part: HandPart): AbstractMesh[];
  79816. /**
  79817. * Dispose this Hand object
  79818. */
  79819. dispose(): void;
  79820. }
  79821. /**
  79822. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  79823. */
  79824. export class WebXRHandTracking extends WebXRAbstractFeature {
  79825. /**
  79826. * options to use when constructing this feature
  79827. */
  79828. readonly options: IWebXRHandTrackingOptions;
  79829. private static _idCounter;
  79830. /**
  79831. * The module's name
  79832. */
  79833. static readonly Name: string;
  79834. /**
  79835. * The (Babylon) version of this module.
  79836. * This is an integer representing the implementation version.
  79837. * This number does not correspond to the WebXR specs version
  79838. */
  79839. static readonly Version: number;
  79840. /**
  79841. * This observable will notify registered observers when a new hand object was added and initialized
  79842. */
  79843. onHandAddedObservable: Observable<WebXRHand>;
  79844. /**
  79845. * This observable will notify its observers right before the hand object is disposed
  79846. */
  79847. onHandRemovedObservable: Observable<WebXRHand>;
  79848. private _hands;
  79849. /**
  79850. * Creates a new instance of the hit test feature
  79851. * @param _xrSessionManager an instance of WebXRSessionManager
  79852. * @param options options to use when constructing this feature
  79853. */
  79854. constructor(_xrSessionManager: WebXRSessionManager,
  79855. /**
  79856. * options to use when constructing this feature
  79857. */
  79858. options: IWebXRHandTrackingOptions);
  79859. /**
  79860. * Check if the needed objects are defined.
  79861. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  79862. */
  79863. isCompatible(): boolean;
  79864. /**
  79865. * attach this feature
  79866. * Will usually be called by the features manager
  79867. *
  79868. * @returns true if successful.
  79869. */
  79870. attach(): boolean;
  79871. /**
  79872. * detach this feature.
  79873. * Will usually be called by the features manager
  79874. *
  79875. * @returns true if successful.
  79876. */
  79877. detach(): boolean;
  79878. /**
  79879. * Dispose this feature and all of the resources attached
  79880. */
  79881. dispose(): void;
  79882. /**
  79883. * Get the hand object according to the controller id
  79884. * @param controllerId the controller id to which we want to get the hand
  79885. * @returns null if not found or the WebXRHand object if found
  79886. */
  79887. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  79888. /**
  79889. * Get a hand object according to the requested handedness
  79890. * @param handedness the handedness to request
  79891. * @returns null if not found or the WebXRHand object if found
  79892. */
  79893. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  79894. protected _onXRFrame(_xrFrame: XRFrame): void;
  79895. private _attachHand;
  79896. private _detachHand;
  79897. }
  79898. }
  79899. declare module "babylonjs/XR/features/index" {
  79900. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  79901. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  79902. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  79903. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  79904. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  79905. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  79906. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  79907. export * from "babylonjs/XR/features/WebXRHitTest";
  79908. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  79909. export * from "babylonjs/XR/features/WebXRHandTracking";
  79910. }
  79911. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  79912. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79913. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79914. import { Scene } from "babylonjs/scene";
  79915. /**
  79916. * The motion controller class for all microsoft mixed reality controllers
  79917. */
  79918. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  79919. protected readonly _mapping: {
  79920. defaultButton: {
  79921. valueNodeName: string;
  79922. unpressedNodeName: string;
  79923. pressedNodeName: string;
  79924. };
  79925. defaultAxis: {
  79926. valueNodeName: string;
  79927. minNodeName: string;
  79928. maxNodeName: string;
  79929. };
  79930. buttons: {
  79931. "xr-standard-trigger": {
  79932. rootNodeName: string;
  79933. componentProperty: string;
  79934. states: string[];
  79935. };
  79936. "xr-standard-squeeze": {
  79937. rootNodeName: string;
  79938. componentProperty: string;
  79939. states: string[];
  79940. };
  79941. "xr-standard-touchpad": {
  79942. rootNodeName: string;
  79943. labelAnchorNodeName: string;
  79944. touchPointNodeName: string;
  79945. };
  79946. "xr-standard-thumbstick": {
  79947. rootNodeName: string;
  79948. componentProperty: string;
  79949. states: string[];
  79950. };
  79951. };
  79952. axes: {
  79953. "xr-standard-touchpad": {
  79954. "x-axis": {
  79955. rootNodeName: string;
  79956. };
  79957. "y-axis": {
  79958. rootNodeName: string;
  79959. };
  79960. };
  79961. "xr-standard-thumbstick": {
  79962. "x-axis": {
  79963. rootNodeName: string;
  79964. };
  79965. "y-axis": {
  79966. rootNodeName: string;
  79967. };
  79968. };
  79969. };
  79970. };
  79971. /**
  79972. * The base url used to load the left and right controller models
  79973. */
  79974. static MODEL_BASE_URL: string;
  79975. /**
  79976. * The name of the left controller model file
  79977. */
  79978. static MODEL_LEFT_FILENAME: string;
  79979. /**
  79980. * The name of the right controller model file
  79981. */
  79982. static MODEL_RIGHT_FILENAME: string;
  79983. profileId: string;
  79984. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  79985. protected _getFilenameAndPath(): {
  79986. filename: string;
  79987. path: string;
  79988. };
  79989. protected _getModelLoadingConstraints(): boolean;
  79990. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  79991. protected _setRootMesh(meshes: AbstractMesh[]): void;
  79992. protected _updateModel(): void;
  79993. }
  79994. }
  79995. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  79996. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  79997. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79998. import { Scene } from "babylonjs/scene";
  79999. /**
  80000. * The motion controller class for oculus touch (quest, rift).
  80001. * This class supports legacy mapping as well the standard xr mapping
  80002. */
  80003. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80004. private _forceLegacyControllers;
  80005. private _modelRootNode;
  80006. /**
  80007. * The base url used to load the left and right controller models
  80008. */
  80009. static MODEL_BASE_URL: string;
  80010. /**
  80011. * The name of the left controller model file
  80012. */
  80013. static MODEL_LEFT_FILENAME: string;
  80014. /**
  80015. * The name of the right controller model file
  80016. */
  80017. static MODEL_RIGHT_FILENAME: string;
  80018. /**
  80019. * Base Url for the Quest controller model.
  80020. */
  80021. static QUEST_MODEL_BASE_URL: string;
  80022. profileId: string;
  80023. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80024. protected _getFilenameAndPath(): {
  80025. filename: string;
  80026. path: string;
  80027. };
  80028. protected _getModelLoadingConstraints(): boolean;
  80029. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80030. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80031. protected _updateModel(): void;
  80032. /**
  80033. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80034. * between the touch and touch 2.
  80035. */
  80036. private _isQuest;
  80037. }
  80038. }
  80039. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80040. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80041. import { Scene } from "babylonjs/scene";
  80042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80043. /**
  80044. * The motion controller class for the standard HTC-Vive controllers
  80045. */
  80046. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80047. private _modelRootNode;
  80048. /**
  80049. * The base url used to load the left and right controller models
  80050. */
  80051. static MODEL_BASE_URL: string;
  80052. /**
  80053. * File name for the controller model.
  80054. */
  80055. static MODEL_FILENAME: string;
  80056. profileId: string;
  80057. /**
  80058. * Create a new Vive motion controller object
  80059. * @param scene the scene to use to create this controller
  80060. * @param gamepadObject the corresponding gamepad object
  80061. * @param handedness the handedness of the controller
  80062. */
  80063. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80064. protected _getFilenameAndPath(): {
  80065. filename: string;
  80066. path: string;
  80067. };
  80068. protected _getModelLoadingConstraints(): boolean;
  80069. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80070. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80071. protected _updateModel(): void;
  80072. }
  80073. }
  80074. declare module "babylonjs/XR/motionController/index" {
  80075. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80076. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80077. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80078. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80079. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80080. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80081. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80082. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80083. }
  80084. declare module "babylonjs/XR/index" {
  80085. export * from "babylonjs/XR/webXRCamera";
  80086. export * from "babylonjs/XR/webXREnterExitUI";
  80087. export * from "babylonjs/XR/webXRExperienceHelper";
  80088. export * from "babylonjs/XR/webXRInput";
  80089. export * from "babylonjs/XR/webXRInputSource";
  80090. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80091. export * from "babylonjs/XR/webXRTypes";
  80092. export * from "babylonjs/XR/webXRSessionManager";
  80093. export * from "babylonjs/XR/webXRDefaultExperience";
  80094. export * from "babylonjs/XR/webXRFeaturesManager";
  80095. export * from "babylonjs/XR/features/index";
  80096. export * from "babylonjs/XR/motionController/index";
  80097. }
  80098. declare module "babylonjs/index" {
  80099. export * from "babylonjs/abstractScene";
  80100. export * from "babylonjs/Actions/index";
  80101. export * from "babylonjs/Animations/index";
  80102. export * from "babylonjs/assetContainer";
  80103. export * from "babylonjs/Audio/index";
  80104. export * from "babylonjs/Behaviors/index";
  80105. export * from "babylonjs/Bones/index";
  80106. export * from "babylonjs/Cameras/index";
  80107. export * from "babylonjs/Collisions/index";
  80108. export * from "babylonjs/Culling/index";
  80109. export * from "babylonjs/Debug/index";
  80110. export * from "babylonjs/DeviceInput/index";
  80111. export * from "babylonjs/Engines/index";
  80112. export * from "babylonjs/Events/index";
  80113. export * from "babylonjs/Gamepads/index";
  80114. export * from "babylonjs/Gizmos/index";
  80115. export * from "babylonjs/Helpers/index";
  80116. export * from "babylonjs/Instrumentation/index";
  80117. export * from "babylonjs/Layers/index";
  80118. export * from "babylonjs/LensFlares/index";
  80119. export * from "babylonjs/Lights/index";
  80120. export * from "babylonjs/Loading/index";
  80121. export * from "babylonjs/Materials/index";
  80122. export * from "babylonjs/Maths/index";
  80123. export * from "babylonjs/Meshes/index";
  80124. export * from "babylonjs/Morph/index";
  80125. export * from "babylonjs/Navigation/index";
  80126. export * from "babylonjs/node";
  80127. export * from "babylonjs/Offline/index";
  80128. export * from "babylonjs/Particles/index";
  80129. export * from "babylonjs/Physics/index";
  80130. export * from "babylonjs/PostProcesses/index";
  80131. export * from "babylonjs/Probes/index";
  80132. export * from "babylonjs/Rendering/index";
  80133. export * from "babylonjs/scene";
  80134. export * from "babylonjs/sceneComponent";
  80135. export * from "babylonjs/Sprites/index";
  80136. export * from "babylonjs/States/index";
  80137. export * from "babylonjs/Misc/index";
  80138. export * from "babylonjs/XR/index";
  80139. export * from "babylonjs/types";
  80140. }
  80141. declare module "babylonjs/Animations/pathCursor" {
  80142. import { Vector3 } from "babylonjs/Maths/math.vector";
  80143. import { Path2 } from "babylonjs/Maths/math.path";
  80144. /**
  80145. * A cursor which tracks a point on a path
  80146. */
  80147. export class PathCursor {
  80148. private path;
  80149. /**
  80150. * Stores path cursor callbacks for when an onchange event is triggered
  80151. */
  80152. private _onchange;
  80153. /**
  80154. * The value of the path cursor
  80155. */
  80156. value: number;
  80157. /**
  80158. * The animation array of the path cursor
  80159. */
  80160. animations: Animation[];
  80161. /**
  80162. * Initializes the path cursor
  80163. * @param path The path to track
  80164. */
  80165. constructor(path: Path2);
  80166. /**
  80167. * Gets the cursor point on the path
  80168. * @returns A point on the path cursor at the cursor location
  80169. */
  80170. getPoint(): Vector3;
  80171. /**
  80172. * Moves the cursor ahead by the step amount
  80173. * @param step The amount to move the cursor forward
  80174. * @returns This path cursor
  80175. */
  80176. moveAhead(step?: number): PathCursor;
  80177. /**
  80178. * Moves the cursor behind by the step amount
  80179. * @param step The amount to move the cursor back
  80180. * @returns This path cursor
  80181. */
  80182. moveBack(step?: number): PathCursor;
  80183. /**
  80184. * Moves the cursor by the step amount
  80185. * If the step amount is greater than one, an exception is thrown
  80186. * @param step The amount to move the cursor
  80187. * @returns This path cursor
  80188. */
  80189. move(step: number): PathCursor;
  80190. /**
  80191. * Ensures that the value is limited between zero and one
  80192. * @returns This path cursor
  80193. */
  80194. private ensureLimits;
  80195. /**
  80196. * Runs onchange callbacks on change (used by the animation engine)
  80197. * @returns This path cursor
  80198. */
  80199. private raiseOnChange;
  80200. /**
  80201. * Executes a function on change
  80202. * @param f A path cursor onchange callback
  80203. * @returns This path cursor
  80204. */
  80205. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80206. }
  80207. }
  80208. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80209. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80210. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80211. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80212. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80213. }
  80214. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80215. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80216. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80217. }
  80218. declare module "babylonjs/Engines/Processors/index" {
  80219. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80220. export * from "babylonjs/Engines/Processors/Expressions/index";
  80221. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80222. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80223. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80224. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80225. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80226. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80227. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80228. }
  80229. declare module "babylonjs/Legacy/legacy" {
  80230. import * as Babylon from "babylonjs/index";
  80231. export * from "babylonjs/index";
  80232. }
  80233. declare module "babylonjs/Shaders/blur.fragment" {
  80234. /** @hidden */
  80235. export var blurPixelShader: {
  80236. name: string;
  80237. shader: string;
  80238. };
  80239. }
  80240. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80241. /** @hidden */
  80242. export var pointCloudVertexDeclaration: {
  80243. name: string;
  80244. shader: string;
  80245. };
  80246. }
  80247. declare module "babylonjs" {
  80248. export * from "babylonjs/Legacy/legacy";
  80249. }
  80250. declare module BABYLON {
  80251. /** Alias type for value that can be null */
  80252. export type Nullable<T> = T | null;
  80253. /**
  80254. * Alias type for number that are floats
  80255. * @ignorenaming
  80256. */
  80257. export type float = number;
  80258. /**
  80259. * Alias type for number that are doubles.
  80260. * @ignorenaming
  80261. */
  80262. export type double = number;
  80263. /**
  80264. * Alias type for number that are integer
  80265. * @ignorenaming
  80266. */
  80267. export type int = number;
  80268. /** Alias type for number array or Float32Array */
  80269. export type FloatArray = number[] | Float32Array;
  80270. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80271. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80272. /**
  80273. * Alias for types that can be used by a Buffer or VertexBuffer.
  80274. */
  80275. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80276. /**
  80277. * Alias type for primitive types
  80278. * @ignorenaming
  80279. */
  80280. type Primitive = undefined | null | boolean | string | number | Function;
  80281. /**
  80282. * Type modifier to make all the properties of an object Readonly
  80283. */
  80284. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80285. /**
  80286. * Type modifier to make all the properties of an object Readonly recursively
  80287. */
  80288. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80289. /**
  80290. * Type modifier to make object properties readonly.
  80291. */
  80292. export type DeepImmutableObject<T> = {
  80293. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80294. };
  80295. /** @hidden */
  80296. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80297. }
  80298. }
  80299. declare module BABYLON {
  80300. /**
  80301. * A class serves as a medium between the observable and its observers
  80302. */
  80303. export class EventState {
  80304. /**
  80305. * Create a new EventState
  80306. * @param mask defines the mask associated with this state
  80307. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80308. * @param target defines the original target of the state
  80309. * @param currentTarget defines the current target of the state
  80310. */
  80311. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80312. /**
  80313. * Initialize the current event state
  80314. * @param mask defines the mask associated with this state
  80315. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80316. * @param target defines the original target of the state
  80317. * @param currentTarget defines the current target of the state
  80318. * @returns the current event state
  80319. */
  80320. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80321. /**
  80322. * An Observer can set this property to true to prevent subsequent observers of being notified
  80323. */
  80324. skipNextObservers: boolean;
  80325. /**
  80326. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80327. */
  80328. mask: number;
  80329. /**
  80330. * The object that originally notified the event
  80331. */
  80332. target?: any;
  80333. /**
  80334. * The current object in the bubbling phase
  80335. */
  80336. currentTarget?: any;
  80337. /**
  80338. * This will be populated with the return value of the last function that was executed.
  80339. * If it is the first function in the callback chain it will be the event data.
  80340. */
  80341. lastReturnValue?: any;
  80342. }
  80343. /**
  80344. * Represent an Observer registered to a given Observable object.
  80345. */
  80346. export class Observer<T> {
  80347. /**
  80348. * Defines the callback to call when the observer is notified
  80349. */
  80350. callback: (eventData: T, eventState: EventState) => void;
  80351. /**
  80352. * Defines the mask of the observer (used to filter notifications)
  80353. */
  80354. mask: number;
  80355. /**
  80356. * Defines the current scope used to restore the JS context
  80357. */
  80358. scope: any;
  80359. /** @hidden */
  80360. _willBeUnregistered: boolean;
  80361. /**
  80362. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80363. */
  80364. unregisterOnNextCall: boolean;
  80365. /**
  80366. * Creates a new observer
  80367. * @param callback defines the callback to call when the observer is notified
  80368. * @param mask defines the mask of the observer (used to filter notifications)
  80369. * @param scope defines the current scope used to restore the JS context
  80370. */
  80371. constructor(
  80372. /**
  80373. * Defines the callback to call when the observer is notified
  80374. */
  80375. callback: (eventData: T, eventState: EventState) => void,
  80376. /**
  80377. * Defines the mask of the observer (used to filter notifications)
  80378. */
  80379. mask: number,
  80380. /**
  80381. * Defines the current scope used to restore the JS context
  80382. */
  80383. scope?: any);
  80384. }
  80385. /**
  80386. * Represent a list of observers registered to multiple Observables object.
  80387. */
  80388. export class MultiObserver<T> {
  80389. private _observers;
  80390. private _observables;
  80391. /**
  80392. * Release associated resources
  80393. */
  80394. dispose(): void;
  80395. /**
  80396. * Raise a callback when one of the observable will notify
  80397. * @param observables defines a list of observables to watch
  80398. * @param callback defines the callback to call on notification
  80399. * @param mask defines the mask used to filter notifications
  80400. * @param scope defines the current scope used to restore the JS context
  80401. * @returns the new MultiObserver
  80402. */
  80403. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80404. }
  80405. /**
  80406. * The Observable class is a simple implementation of the Observable pattern.
  80407. *
  80408. * 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.
  80409. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80410. * 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).
  80411. * 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.
  80412. */
  80413. export class Observable<T> {
  80414. private _observers;
  80415. private _eventState;
  80416. private _onObserverAdded;
  80417. /**
  80418. * Gets the list of observers
  80419. */
  80420. get observers(): Array<Observer<T>>;
  80421. /**
  80422. * Creates a new observable
  80423. * @param onObserverAdded defines a callback to call when a new observer is added
  80424. */
  80425. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80426. /**
  80427. * Create a new Observer with the specified callback
  80428. * @param callback the callback that will be executed for that Observer
  80429. * @param mask the mask used to filter observers
  80430. * @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.
  80431. * @param scope optional scope for the callback to be called from
  80432. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80433. * @returns the new observer created for the callback
  80434. */
  80435. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80436. /**
  80437. * Create a new Observer with the specified callback and unregisters after the next notification
  80438. * @param callback the callback that will be executed for that Observer
  80439. * @returns the new observer created for the callback
  80440. */
  80441. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80442. /**
  80443. * Remove an Observer from the Observable object
  80444. * @param observer the instance of the Observer to remove
  80445. * @returns false if it doesn't belong to this Observable
  80446. */
  80447. remove(observer: Nullable<Observer<T>>): boolean;
  80448. /**
  80449. * Remove a callback from the Observable object
  80450. * @param callback the callback to remove
  80451. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80452. * @returns false if it doesn't belong to this Observable
  80453. */
  80454. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80455. private _deferUnregister;
  80456. private _remove;
  80457. /**
  80458. * Moves the observable to the top of the observer list making it get called first when notified
  80459. * @param observer the observer to move
  80460. */
  80461. makeObserverTopPriority(observer: Observer<T>): void;
  80462. /**
  80463. * Moves the observable to the bottom of the observer list making it get called last when notified
  80464. * @param observer the observer to move
  80465. */
  80466. makeObserverBottomPriority(observer: Observer<T>): void;
  80467. /**
  80468. * Notify all Observers by calling their respective callback with the given data
  80469. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80470. * @param eventData defines the data to send to all observers
  80471. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80472. * @param target defines the original target of the state
  80473. * @param currentTarget defines the current target of the state
  80474. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80475. */
  80476. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80477. /**
  80478. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80479. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80480. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80481. * and it is crucial that all callbacks will be executed.
  80482. * The order of the callbacks is kept, callbacks are not executed parallel.
  80483. *
  80484. * @param eventData The data to be sent to each callback
  80485. * @param mask is used to filter observers defaults to -1
  80486. * @param target defines the callback target (see EventState)
  80487. * @param currentTarget defines he current object in the bubbling phase
  80488. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80489. */
  80490. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80491. /**
  80492. * Notify a specific observer
  80493. * @param observer defines the observer to notify
  80494. * @param eventData defines the data to be sent to each callback
  80495. * @param mask is used to filter observers defaults to -1
  80496. */
  80497. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80498. /**
  80499. * Gets a boolean indicating if the observable has at least one observer
  80500. * @returns true is the Observable has at least one Observer registered
  80501. */
  80502. hasObservers(): boolean;
  80503. /**
  80504. * Clear the list of observers
  80505. */
  80506. clear(): void;
  80507. /**
  80508. * Clone the current observable
  80509. * @returns a new observable
  80510. */
  80511. clone(): Observable<T>;
  80512. /**
  80513. * Does this observable handles observer registered with a given mask
  80514. * @param mask defines the mask to be tested
  80515. * @return whether or not one observer registered with the given mask is handeled
  80516. **/
  80517. hasSpecificMask(mask?: number): boolean;
  80518. }
  80519. }
  80520. declare module BABYLON {
  80521. /**
  80522. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80523. * Babylon.js
  80524. */
  80525. export class DomManagement {
  80526. /**
  80527. * Checks if the window object exists
  80528. * @returns true if the window object exists
  80529. */
  80530. static IsWindowObjectExist(): boolean;
  80531. /**
  80532. * Checks if the navigator object exists
  80533. * @returns true if the navigator object exists
  80534. */
  80535. static IsNavigatorAvailable(): boolean;
  80536. /**
  80537. * Check if the document object exists
  80538. * @returns true if the document object exists
  80539. */
  80540. static IsDocumentAvailable(): boolean;
  80541. /**
  80542. * Extracts text content from a DOM element hierarchy
  80543. * @param element defines the root element
  80544. * @returns a string
  80545. */
  80546. static GetDOMTextContent(element: HTMLElement): string;
  80547. }
  80548. }
  80549. declare module BABYLON {
  80550. /**
  80551. * Logger used througouht the application to allow configuration of
  80552. * the log level required for the messages.
  80553. */
  80554. export class Logger {
  80555. /**
  80556. * No log
  80557. */
  80558. static readonly NoneLogLevel: number;
  80559. /**
  80560. * Only message logs
  80561. */
  80562. static readonly MessageLogLevel: number;
  80563. /**
  80564. * Only warning logs
  80565. */
  80566. static readonly WarningLogLevel: number;
  80567. /**
  80568. * Only error logs
  80569. */
  80570. static readonly ErrorLogLevel: number;
  80571. /**
  80572. * All logs
  80573. */
  80574. static readonly AllLogLevel: number;
  80575. private static _LogCache;
  80576. /**
  80577. * Gets a value indicating the number of loading errors
  80578. * @ignorenaming
  80579. */
  80580. static errorsCount: number;
  80581. /**
  80582. * Callback called when a new log is added
  80583. */
  80584. static OnNewCacheEntry: (entry: string) => void;
  80585. private static _AddLogEntry;
  80586. private static _FormatMessage;
  80587. private static _LogDisabled;
  80588. private static _LogEnabled;
  80589. private static _WarnDisabled;
  80590. private static _WarnEnabled;
  80591. private static _ErrorDisabled;
  80592. private static _ErrorEnabled;
  80593. /**
  80594. * Log a message to the console
  80595. */
  80596. static Log: (message: string) => void;
  80597. /**
  80598. * Write a warning message to the console
  80599. */
  80600. static Warn: (message: string) => void;
  80601. /**
  80602. * Write an error message to the console
  80603. */
  80604. static Error: (message: string) => void;
  80605. /**
  80606. * Gets current log cache (list of logs)
  80607. */
  80608. static get LogCache(): string;
  80609. /**
  80610. * Clears the log cache
  80611. */
  80612. static ClearLogCache(): void;
  80613. /**
  80614. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80615. */
  80616. static set LogLevels(level: number);
  80617. }
  80618. }
  80619. declare module BABYLON {
  80620. /** @hidden */
  80621. export class _TypeStore {
  80622. /** @hidden */
  80623. static RegisteredTypes: {
  80624. [key: string]: Object;
  80625. };
  80626. /** @hidden */
  80627. static GetClass(fqdn: string): any;
  80628. }
  80629. }
  80630. declare module BABYLON {
  80631. /**
  80632. * Helper to manipulate strings
  80633. */
  80634. export class StringTools {
  80635. /**
  80636. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80637. * @param str Source string
  80638. * @param suffix Suffix to search for in the source string
  80639. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80640. */
  80641. static EndsWith(str: string, suffix: string): boolean;
  80642. /**
  80643. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80644. * @param str Source string
  80645. * @param suffix Suffix to search for in the source string
  80646. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80647. */
  80648. static StartsWith(str: string, suffix: string): boolean;
  80649. /**
  80650. * Decodes a buffer into a string
  80651. * @param buffer The buffer to decode
  80652. * @returns The decoded string
  80653. */
  80654. static Decode(buffer: Uint8Array | Uint16Array): string;
  80655. /**
  80656. * Encode a buffer to a base64 string
  80657. * @param buffer defines the buffer to encode
  80658. * @returns the encoded string
  80659. */
  80660. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80661. /**
  80662. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80663. * @param num the number to convert and pad
  80664. * @param length the expected length of the string
  80665. * @returns the padded string
  80666. */
  80667. static PadNumber(num: number, length: number): string;
  80668. }
  80669. }
  80670. declare module BABYLON {
  80671. /**
  80672. * Class containing a set of static utilities functions for deep copy.
  80673. */
  80674. export class DeepCopier {
  80675. /**
  80676. * Tries to copy an object by duplicating every property
  80677. * @param source defines the source object
  80678. * @param destination defines the target object
  80679. * @param doNotCopyList defines a list of properties to avoid
  80680. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80681. */
  80682. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80683. }
  80684. }
  80685. declare module BABYLON {
  80686. /**
  80687. * Class containing a set of static utilities functions for precision date
  80688. */
  80689. export class PrecisionDate {
  80690. /**
  80691. * Gets either window.performance.now() if supported or Date.now() else
  80692. */
  80693. static get Now(): number;
  80694. }
  80695. }
  80696. declare module BABYLON {
  80697. /** @hidden */
  80698. export class _DevTools {
  80699. static WarnImport(name: string): string;
  80700. }
  80701. }
  80702. declare module BABYLON {
  80703. /**
  80704. * Interface used to define the mechanism to get data from the network
  80705. */
  80706. export interface IWebRequest {
  80707. /**
  80708. * Returns client's response url
  80709. */
  80710. responseURL: string;
  80711. /**
  80712. * Returns client's status
  80713. */
  80714. status: number;
  80715. /**
  80716. * Returns client's status as a text
  80717. */
  80718. statusText: string;
  80719. }
  80720. }
  80721. declare module BABYLON {
  80722. /**
  80723. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80724. */
  80725. export class WebRequest implements IWebRequest {
  80726. private _xhr;
  80727. /**
  80728. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80729. * i.e. when loading files, where the server/service expects an Authorization header
  80730. */
  80731. static CustomRequestHeaders: {
  80732. [key: string]: string;
  80733. };
  80734. /**
  80735. * Add callback functions in this array to update all the requests before they get sent to the network
  80736. */
  80737. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80738. private _injectCustomRequestHeaders;
  80739. /**
  80740. * Gets or sets a function to be called when loading progress changes
  80741. */
  80742. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80743. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80744. /**
  80745. * Returns client's state
  80746. */
  80747. get readyState(): number;
  80748. /**
  80749. * Returns client's status
  80750. */
  80751. get status(): number;
  80752. /**
  80753. * Returns client's status as a text
  80754. */
  80755. get statusText(): string;
  80756. /**
  80757. * Returns client's response
  80758. */
  80759. get response(): any;
  80760. /**
  80761. * Returns client's response url
  80762. */
  80763. get responseURL(): string;
  80764. /**
  80765. * Returns client's response as text
  80766. */
  80767. get responseText(): string;
  80768. /**
  80769. * Gets or sets the expected response type
  80770. */
  80771. get responseType(): XMLHttpRequestResponseType;
  80772. set responseType(value: XMLHttpRequestResponseType);
  80773. /** @hidden */
  80774. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  80775. /** @hidden */
  80776. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  80777. /**
  80778. * Cancels any network activity
  80779. */
  80780. abort(): void;
  80781. /**
  80782. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  80783. * @param body defines an optional request body
  80784. */
  80785. send(body?: Document | BodyInit | null): void;
  80786. /**
  80787. * Sets the request method, request URL
  80788. * @param method defines the method to use (GET, POST, etc..)
  80789. * @param url defines the url to connect with
  80790. */
  80791. open(method: string, url: string): void;
  80792. /**
  80793. * Sets the value of a request header.
  80794. * @param name The name of the header whose value is to be set
  80795. * @param value The value to set as the body of the header
  80796. */
  80797. setRequestHeader(name: string, value: string): void;
  80798. /**
  80799. * Get the string containing the text of a particular header's value.
  80800. * @param name The name of the header
  80801. * @returns The string containing the text of the given header name
  80802. */
  80803. getResponseHeader(name: string): Nullable<string>;
  80804. }
  80805. }
  80806. declare module BABYLON {
  80807. /**
  80808. * File request interface
  80809. */
  80810. export interface IFileRequest {
  80811. /**
  80812. * Raised when the request is complete (success or error).
  80813. */
  80814. onCompleteObservable: Observable<IFileRequest>;
  80815. /**
  80816. * Aborts the request for a file.
  80817. */
  80818. abort: () => void;
  80819. }
  80820. }
  80821. declare module BABYLON {
  80822. /**
  80823. * Define options used to create a render target texture
  80824. */
  80825. export class RenderTargetCreationOptions {
  80826. /**
  80827. * Specifies is mipmaps must be generated
  80828. */
  80829. generateMipMaps?: boolean;
  80830. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  80831. generateDepthBuffer?: boolean;
  80832. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  80833. generateStencilBuffer?: boolean;
  80834. /** Defines texture type (int by default) */
  80835. type?: number;
  80836. /** Defines sampling mode (trilinear by default) */
  80837. samplingMode?: number;
  80838. /** Defines format (RGBA by default) */
  80839. format?: number;
  80840. }
  80841. }
  80842. declare module BABYLON {
  80843. /** Defines the cross module used constants to avoid circular dependncies */
  80844. export class Constants {
  80845. /** Defines that alpha blending is disabled */
  80846. static readonly ALPHA_DISABLE: number;
  80847. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  80848. static readonly ALPHA_ADD: number;
  80849. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  80850. static readonly ALPHA_COMBINE: number;
  80851. /** Defines that alpha blending is DEST - SRC * DEST */
  80852. static readonly ALPHA_SUBTRACT: number;
  80853. /** Defines that alpha blending is SRC * DEST */
  80854. static readonly ALPHA_MULTIPLY: number;
  80855. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  80856. static readonly ALPHA_MAXIMIZED: number;
  80857. /** Defines that alpha blending is SRC + DEST */
  80858. static readonly ALPHA_ONEONE: number;
  80859. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  80860. static readonly ALPHA_PREMULTIPLIED: number;
  80861. /**
  80862. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  80863. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  80864. */
  80865. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  80866. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  80867. static readonly ALPHA_INTERPOLATE: number;
  80868. /**
  80869. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  80870. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  80871. */
  80872. static readonly ALPHA_SCREENMODE: number;
  80873. /**
  80874. * Defines that alpha blending is SRC + DST
  80875. * Alpha will be set to SRC ALPHA + DST ALPHA
  80876. */
  80877. static readonly ALPHA_ONEONE_ONEONE: number;
  80878. /**
  80879. * Defines that alpha blending is SRC * DST ALPHA + DST
  80880. * Alpha will be set to 0
  80881. */
  80882. static readonly ALPHA_ALPHATOCOLOR: number;
  80883. /**
  80884. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80885. */
  80886. static readonly ALPHA_REVERSEONEMINUS: number;
  80887. /**
  80888. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  80889. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  80890. */
  80891. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  80892. /**
  80893. * Defines that alpha blending is SRC + DST
  80894. * Alpha will be set to SRC ALPHA
  80895. */
  80896. static readonly ALPHA_ONEONE_ONEZERO: number;
  80897. /**
  80898. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  80899. * Alpha will be set to DST ALPHA
  80900. */
  80901. static readonly ALPHA_EXCLUSION: number;
  80902. /** Defines that alpha blending equation a SUM */
  80903. static readonly ALPHA_EQUATION_ADD: number;
  80904. /** Defines that alpha blending equation a SUBSTRACTION */
  80905. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  80906. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  80907. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  80908. /** Defines that alpha blending equation a MAX operation */
  80909. static readonly ALPHA_EQUATION_MAX: number;
  80910. /** Defines that alpha blending equation a MIN operation */
  80911. static readonly ALPHA_EQUATION_MIN: number;
  80912. /**
  80913. * Defines that alpha blending equation a DARKEN operation:
  80914. * It takes the min of the src and sums the alpha channels.
  80915. */
  80916. static readonly ALPHA_EQUATION_DARKEN: number;
  80917. /** Defines that the ressource is not delayed*/
  80918. static readonly DELAYLOADSTATE_NONE: number;
  80919. /** Defines that the ressource was successfully delay loaded */
  80920. static readonly DELAYLOADSTATE_LOADED: number;
  80921. /** Defines that the ressource is currently delay loading */
  80922. static readonly DELAYLOADSTATE_LOADING: number;
  80923. /** Defines that the ressource is delayed and has not started loading */
  80924. static readonly DELAYLOADSTATE_NOTLOADED: number;
  80925. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  80926. static readonly NEVER: number;
  80927. /** 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 */
  80928. static readonly ALWAYS: number;
  80929. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  80930. static readonly LESS: number;
  80931. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  80932. static readonly EQUAL: number;
  80933. /** 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 */
  80934. static readonly LEQUAL: number;
  80935. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  80936. static readonly GREATER: number;
  80937. /** 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 */
  80938. static readonly GEQUAL: number;
  80939. /** 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 */
  80940. static readonly NOTEQUAL: number;
  80941. /** Passed to stencilOperation to specify that stencil value must be kept */
  80942. static readonly KEEP: number;
  80943. /** Passed to stencilOperation to specify that stencil value must be replaced */
  80944. static readonly REPLACE: number;
  80945. /** Passed to stencilOperation to specify that stencil value must be incremented */
  80946. static readonly INCR: number;
  80947. /** Passed to stencilOperation to specify that stencil value must be decremented */
  80948. static readonly DECR: number;
  80949. /** Passed to stencilOperation to specify that stencil value must be inverted */
  80950. static readonly INVERT: number;
  80951. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  80952. static readonly INCR_WRAP: number;
  80953. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  80954. static readonly DECR_WRAP: number;
  80955. /** Texture is not repeating outside of 0..1 UVs */
  80956. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  80957. /** Texture is repeating outside of 0..1 UVs */
  80958. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  80959. /** Texture is repeating and mirrored */
  80960. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  80961. /** ALPHA */
  80962. static readonly TEXTUREFORMAT_ALPHA: number;
  80963. /** LUMINANCE */
  80964. static readonly TEXTUREFORMAT_LUMINANCE: number;
  80965. /** LUMINANCE_ALPHA */
  80966. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  80967. /** RGB */
  80968. static readonly TEXTUREFORMAT_RGB: number;
  80969. /** RGBA */
  80970. static readonly TEXTUREFORMAT_RGBA: number;
  80971. /** RED */
  80972. static readonly TEXTUREFORMAT_RED: number;
  80973. /** RED (2nd reference) */
  80974. static readonly TEXTUREFORMAT_R: number;
  80975. /** RG */
  80976. static readonly TEXTUREFORMAT_RG: number;
  80977. /** RED_INTEGER */
  80978. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  80979. /** RED_INTEGER (2nd reference) */
  80980. static readonly TEXTUREFORMAT_R_INTEGER: number;
  80981. /** RG_INTEGER */
  80982. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  80983. /** RGB_INTEGER */
  80984. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  80985. /** RGBA_INTEGER */
  80986. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  80987. /** UNSIGNED_BYTE */
  80988. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  80989. /** UNSIGNED_BYTE (2nd reference) */
  80990. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  80991. /** FLOAT */
  80992. static readonly TEXTURETYPE_FLOAT: number;
  80993. /** HALF_FLOAT */
  80994. static readonly TEXTURETYPE_HALF_FLOAT: number;
  80995. /** BYTE */
  80996. static readonly TEXTURETYPE_BYTE: number;
  80997. /** SHORT */
  80998. static readonly TEXTURETYPE_SHORT: number;
  80999. /** UNSIGNED_SHORT */
  81000. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81001. /** INT */
  81002. static readonly TEXTURETYPE_INT: number;
  81003. /** UNSIGNED_INT */
  81004. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81005. /** UNSIGNED_SHORT_4_4_4_4 */
  81006. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81007. /** UNSIGNED_SHORT_5_5_5_1 */
  81008. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81009. /** UNSIGNED_SHORT_5_6_5 */
  81010. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81011. /** UNSIGNED_INT_2_10_10_10_REV */
  81012. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81013. /** UNSIGNED_INT_24_8 */
  81014. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81015. /** UNSIGNED_INT_10F_11F_11F_REV */
  81016. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81017. /** UNSIGNED_INT_5_9_9_9_REV */
  81018. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81019. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81020. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81021. /** nearest is mag = nearest and min = nearest and no mip */
  81022. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81023. /** mag = nearest and min = nearest and mip = none */
  81024. static readonly TEXTURE_NEAREST_NEAREST: number;
  81025. /** Bilinear is mag = linear and min = linear and no mip */
  81026. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81027. /** mag = linear and min = linear and mip = none */
  81028. static readonly TEXTURE_LINEAR_LINEAR: number;
  81029. /** Trilinear is mag = linear and min = linear and mip = linear */
  81030. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81031. /** Trilinear is mag = linear and min = linear and mip = linear */
  81032. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81033. /** mag = nearest and min = nearest and mip = nearest */
  81034. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81035. /** mag = nearest and min = linear and mip = nearest */
  81036. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81037. /** mag = nearest and min = linear and mip = linear */
  81038. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81039. /** mag = nearest and min = linear and mip = none */
  81040. static readonly TEXTURE_NEAREST_LINEAR: number;
  81041. /** nearest is mag = nearest and min = nearest and mip = linear */
  81042. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81043. /** mag = linear and min = nearest and mip = nearest */
  81044. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81045. /** mag = linear and min = nearest and mip = linear */
  81046. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81047. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81048. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81049. /** mag = linear and min = nearest and mip = none */
  81050. static readonly TEXTURE_LINEAR_NEAREST: number;
  81051. /** Explicit coordinates mode */
  81052. static readonly TEXTURE_EXPLICIT_MODE: number;
  81053. /** Spherical coordinates mode */
  81054. static readonly TEXTURE_SPHERICAL_MODE: number;
  81055. /** Planar coordinates mode */
  81056. static readonly TEXTURE_PLANAR_MODE: number;
  81057. /** Cubic coordinates mode */
  81058. static readonly TEXTURE_CUBIC_MODE: number;
  81059. /** Projection coordinates mode */
  81060. static readonly TEXTURE_PROJECTION_MODE: number;
  81061. /** Skybox coordinates mode */
  81062. static readonly TEXTURE_SKYBOX_MODE: number;
  81063. /** Inverse Cubic coordinates mode */
  81064. static readonly TEXTURE_INVCUBIC_MODE: number;
  81065. /** Equirectangular coordinates mode */
  81066. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81067. /** Equirectangular Fixed coordinates mode */
  81068. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81069. /** Equirectangular Fixed Mirrored coordinates mode */
  81070. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81071. /** Offline (baking) quality for texture filtering */
  81072. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81073. /** High quality for texture filtering */
  81074. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81075. /** Medium quality for texture filtering */
  81076. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81077. /** Low quality for texture filtering */
  81078. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81079. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81080. static readonly SCALEMODE_FLOOR: number;
  81081. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81082. static readonly SCALEMODE_NEAREST: number;
  81083. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81084. static readonly SCALEMODE_CEILING: number;
  81085. /**
  81086. * The dirty texture flag value
  81087. */
  81088. static readonly MATERIAL_TextureDirtyFlag: number;
  81089. /**
  81090. * The dirty light flag value
  81091. */
  81092. static readonly MATERIAL_LightDirtyFlag: number;
  81093. /**
  81094. * The dirty fresnel flag value
  81095. */
  81096. static readonly MATERIAL_FresnelDirtyFlag: number;
  81097. /**
  81098. * The dirty attribute flag value
  81099. */
  81100. static readonly MATERIAL_AttributesDirtyFlag: number;
  81101. /**
  81102. * The dirty misc flag value
  81103. */
  81104. static readonly MATERIAL_MiscDirtyFlag: number;
  81105. /**
  81106. * The all dirty flag value
  81107. */
  81108. static readonly MATERIAL_AllDirtyFlag: number;
  81109. /**
  81110. * Returns the triangle fill mode
  81111. */
  81112. static readonly MATERIAL_TriangleFillMode: number;
  81113. /**
  81114. * Returns the wireframe mode
  81115. */
  81116. static readonly MATERIAL_WireFrameFillMode: number;
  81117. /**
  81118. * Returns the point fill mode
  81119. */
  81120. static readonly MATERIAL_PointFillMode: number;
  81121. /**
  81122. * Returns the point list draw mode
  81123. */
  81124. static readonly MATERIAL_PointListDrawMode: number;
  81125. /**
  81126. * Returns the line list draw mode
  81127. */
  81128. static readonly MATERIAL_LineListDrawMode: number;
  81129. /**
  81130. * Returns the line loop draw mode
  81131. */
  81132. static readonly MATERIAL_LineLoopDrawMode: number;
  81133. /**
  81134. * Returns the line strip draw mode
  81135. */
  81136. static readonly MATERIAL_LineStripDrawMode: number;
  81137. /**
  81138. * Returns the triangle strip draw mode
  81139. */
  81140. static readonly MATERIAL_TriangleStripDrawMode: number;
  81141. /**
  81142. * Returns the triangle fan draw mode
  81143. */
  81144. static readonly MATERIAL_TriangleFanDrawMode: number;
  81145. /**
  81146. * Stores the clock-wise side orientation
  81147. */
  81148. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81149. /**
  81150. * Stores the counter clock-wise side orientation
  81151. */
  81152. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81153. /**
  81154. * Nothing
  81155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81156. */
  81157. static readonly ACTION_NothingTrigger: number;
  81158. /**
  81159. * On pick
  81160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81161. */
  81162. static readonly ACTION_OnPickTrigger: number;
  81163. /**
  81164. * On left pick
  81165. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81166. */
  81167. static readonly ACTION_OnLeftPickTrigger: number;
  81168. /**
  81169. * On right pick
  81170. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81171. */
  81172. static readonly ACTION_OnRightPickTrigger: number;
  81173. /**
  81174. * On center pick
  81175. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81176. */
  81177. static readonly ACTION_OnCenterPickTrigger: number;
  81178. /**
  81179. * On pick down
  81180. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81181. */
  81182. static readonly ACTION_OnPickDownTrigger: number;
  81183. /**
  81184. * On double pick
  81185. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81186. */
  81187. static readonly ACTION_OnDoublePickTrigger: number;
  81188. /**
  81189. * On pick up
  81190. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81191. */
  81192. static readonly ACTION_OnPickUpTrigger: number;
  81193. /**
  81194. * On pick out.
  81195. * This trigger will only be raised if you also declared a OnPickDown
  81196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81197. */
  81198. static readonly ACTION_OnPickOutTrigger: number;
  81199. /**
  81200. * On long press
  81201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81202. */
  81203. static readonly ACTION_OnLongPressTrigger: number;
  81204. /**
  81205. * On pointer over
  81206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81207. */
  81208. static readonly ACTION_OnPointerOverTrigger: number;
  81209. /**
  81210. * On pointer out
  81211. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81212. */
  81213. static readonly ACTION_OnPointerOutTrigger: number;
  81214. /**
  81215. * On every frame
  81216. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81217. */
  81218. static readonly ACTION_OnEveryFrameTrigger: number;
  81219. /**
  81220. * On intersection enter
  81221. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81222. */
  81223. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81224. /**
  81225. * On intersection exit
  81226. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81227. */
  81228. static readonly ACTION_OnIntersectionExitTrigger: number;
  81229. /**
  81230. * On key down
  81231. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81232. */
  81233. static readonly ACTION_OnKeyDownTrigger: number;
  81234. /**
  81235. * On key up
  81236. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81237. */
  81238. static readonly ACTION_OnKeyUpTrigger: number;
  81239. /**
  81240. * Billboard mode will only apply to Y axis
  81241. */
  81242. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81243. /**
  81244. * Billboard mode will apply to all axes
  81245. */
  81246. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81247. /**
  81248. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81249. */
  81250. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81251. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81252. * Test order :
  81253. * Is the bounding sphere outside the frustum ?
  81254. * If not, are the bounding box vertices outside the frustum ?
  81255. * It not, then the cullable object is in the frustum.
  81256. */
  81257. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81258. /** Culling strategy : Bounding Sphere Only.
  81259. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81260. * It's also less accurate than the standard because some not visible objects can still be selected.
  81261. * Test : is the bounding sphere outside the frustum ?
  81262. * If not, then the cullable object is in the frustum.
  81263. */
  81264. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81265. /** Culling strategy : Optimistic Inclusion.
  81266. * This in an inclusion test first, then the standard exclusion test.
  81267. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81268. * 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.
  81269. * Anyway, it's as accurate as the standard strategy.
  81270. * Test :
  81271. * Is the cullable object bounding sphere center in the frustum ?
  81272. * If not, apply the default culling strategy.
  81273. */
  81274. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81275. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81276. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81277. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81278. * 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.
  81279. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81280. * Test :
  81281. * Is the cullable object bounding sphere center in the frustum ?
  81282. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81283. */
  81284. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81285. /**
  81286. * No logging while loading
  81287. */
  81288. static readonly SCENELOADER_NO_LOGGING: number;
  81289. /**
  81290. * Minimal logging while loading
  81291. */
  81292. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81293. /**
  81294. * Summary logging while loading
  81295. */
  81296. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81297. /**
  81298. * Detailled logging while loading
  81299. */
  81300. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81301. /**
  81302. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81303. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81304. */
  81305. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81306. /**
  81307. * Constant used to retrieve the position texture index in the textures array in the prepass
  81308. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81309. */
  81310. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81311. /**
  81312. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81313. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81314. */
  81315. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81316. /**
  81317. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81318. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81319. */
  81320. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81321. /**
  81322. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81323. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81324. */
  81325. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81326. /**
  81327. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81328. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81329. */
  81330. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81331. /**
  81332. * Constant used to retrieve albedo index in the textures array in the prepass
  81333. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81334. */
  81335. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81336. }
  81337. }
  81338. declare module BABYLON {
  81339. /**
  81340. * This represents the required contract to create a new type of texture loader.
  81341. */
  81342. export interface IInternalTextureLoader {
  81343. /**
  81344. * Defines wether the loader supports cascade loading the different faces.
  81345. */
  81346. supportCascades: boolean;
  81347. /**
  81348. * This returns if the loader support the current file information.
  81349. * @param extension defines the file extension of the file being loaded
  81350. * @param mimeType defines the optional mime type of the file being loaded
  81351. * @returns true if the loader can load the specified file
  81352. */
  81353. canLoad(extension: string, mimeType?: string): boolean;
  81354. /**
  81355. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81356. * @param data contains the texture data
  81357. * @param texture defines the BabylonJS internal texture
  81358. * @param createPolynomials will be true if polynomials have been requested
  81359. * @param onLoad defines the callback to trigger once the texture is ready
  81360. * @param onError defines the callback to trigger in case of error
  81361. */
  81362. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81363. /**
  81364. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81365. * @param data contains the texture data
  81366. * @param texture defines the BabylonJS internal texture
  81367. * @param callback defines the method to call once ready to upload
  81368. */
  81369. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81370. }
  81371. }
  81372. declare module BABYLON {
  81373. /**
  81374. * Class used to store and describe the pipeline context associated with an effect
  81375. */
  81376. export interface IPipelineContext {
  81377. /**
  81378. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81379. */
  81380. isAsync: boolean;
  81381. /**
  81382. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81383. */
  81384. isReady: boolean;
  81385. /** @hidden */
  81386. _getVertexShaderCode(): string | null;
  81387. /** @hidden */
  81388. _getFragmentShaderCode(): string | null;
  81389. /** @hidden */
  81390. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81391. }
  81392. }
  81393. declare module BABYLON {
  81394. /**
  81395. * Class used to store gfx data (like WebGLBuffer)
  81396. */
  81397. export class DataBuffer {
  81398. /**
  81399. * Gets or sets the number of objects referencing this buffer
  81400. */
  81401. references: number;
  81402. /** Gets or sets the size of the underlying buffer */
  81403. capacity: number;
  81404. /**
  81405. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81406. */
  81407. is32Bits: boolean;
  81408. /**
  81409. * Gets the underlying buffer
  81410. */
  81411. get underlyingResource(): any;
  81412. }
  81413. }
  81414. declare module BABYLON {
  81415. /** @hidden */
  81416. export interface IShaderProcessor {
  81417. attributeProcessor?: (attribute: string) => string;
  81418. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81419. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81420. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81421. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81422. lineProcessor?: (line: string, isFragment: boolean) => string;
  81423. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81424. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81425. }
  81426. }
  81427. declare module BABYLON {
  81428. /** @hidden */
  81429. export interface ProcessingOptions {
  81430. defines: string[];
  81431. indexParameters: any;
  81432. isFragment: boolean;
  81433. shouldUseHighPrecisionShader: boolean;
  81434. supportsUniformBuffers: boolean;
  81435. shadersRepository: string;
  81436. includesShadersStore: {
  81437. [key: string]: string;
  81438. };
  81439. processor?: IShaderProcessor;
  81440. version: string;
  81441. platformName: string;
  81442. lookForClosingBracketForUniformBuffer?: boolean;
  81443. }
  81444. }
  81445. declare module BABYLON {
  81446. /** @hidden */
  81447. export class ShaderCodeNode {
  81448. line: string;
  81449. children: ShaderCodeNode[];
  81450. additionalDefineKey?: string;
  81451. additionalDefineValue?: string;
  81452. isValid(preprocessors: {
  81453. [key: string]: string;
  81454. }): boolean;
  81455. process(preprocessors: {
  81456. [key: string]: string;
  81457. }, options: ProcessingOptions): string;
  81458. }
  81459. }
  81460. declare module BABYLON {
  81461. /** @hidden */
  81462. export class ShaderCodeCursor {
  81463. private _lines;
  81464. lineIndex: number;
  81465. get currentLine(): string;
  81466. get canRead(): boolean;
  81467. set lines(value: string[]);
  81468. }
  81469. }
  81470. declare module BABYLON {
  81471. /** @hidden */
  81472. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81473. process(preprocessors: {
  81474. [key: string]: string;
  81475. }, options: ProcessingOptions): string;
  81476. }
  81477. }
  81478. declare module BABYLON {
  81479. /** @hidden */
  81480. export class ShaderDefineExpression {
  81481. isTrue(preprocessors: {
  81482. [key: string]: string;
  81483. }): boolean;
  81484. private static _OperatorPriority;
  81485. private static _Stack;
  81486. static postfixToInfix(postfix: string[]): string;
  81487. static infixToPostfix(infix: string): string[];
  81488. }
  81489. }
  81490. declare module BABYLON {
  81491. /** @hidden */
  81492. export class ShaderCodeTestNode extends ShaderCodeNode {
  81493. testExpression: ShaderDefineExpression;
  81494. isValid(preprocessors: {
  81495. [key: string]: string;
  81496. }): boolean;
  81497. }
  81498. }
  81499. declare module BABYLON {
  81500. /** @hidden */
  81501. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81502. define: string;
  81503. not: boolean;
  81504. constructor(define: string, not?: boolean);
  81505. isTrue(preprocessors: {
  81506. [key: string]: string;
  81507. }): boolean;
  81508. }
  81509. }
  81510. declare module BABYLON {
  81511. /** @hidden */
  81512. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81513. leftOperand: ShaderDefineExpression;
  81514. rightOperand: ShaderDefineExpression;
  81515. isTrue(preprocessors: {
  81516. [key: string]: string;
  81517. }): boolean;
  81518. }
  81519. }
  81520. declare module BABYLON {
  81521. /** @hidden */
  81522. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81523. leftOperand: ShaderDefineExpression;
  81524. rightOperand: ShaderDefineExpression;
  81525. isTrue(preprocessors: {
  81526. [key: string]: string;
  81527. }): boolean;
  81528. }
  81529. }
  81530. declare module BABYLON {
  81531. /** @hidden */
  81532. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81533. define: string;
  81534. operand: string;
  81535. testValue: string;
  81536. constructor(define: string, operand: string, testValue: string);
  81537. isTrue(preprocessors: {
  81538. [key: string]: string;
  81539. }): boolean;
  81540. }
  81541. }
  81542. declare module BABYLON {
  81543. /**
  81544. * Class used to enable access to offline support
  81545. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81546. */
  81547. export interface IOfflineProvider {
  81548. /**
  81549. * Gets a boolean indicating if scene must be saved in the database
  81550. */
  81551. enableSceneOffline: boolean;
  81552. /**
  81553. * Gets a boolean indicating if textures must be saved in the database
  81554. */
  81555. enableTexturesOffline: boolean;
  81556. /**
  81557. * Open the offline support and make it available
  81558. * @param successCallback defines the callback to call on success
  81559. * @param errorCallback defines the callback to call on error
  81560. */
  81561. open(successCallback: () => void, errorCallback: () => void): void;
  81562. /**
  81563. * Loads an image from the offline support
  81564. * @param url defines the url to load from
  81565. * @param image defines the target DOM image
  81566. */
  81567. loadImage(url: string, image: HTMLImageElement): void;
  81568. /**
  81569. * Loads a file from offline support
  81570. * @param url defines the URL to load from
  81571. * @param sceneLoaded defines a callback to call on success
  81572. * @param progressCallBack defines a callback to call when progress changed
  81573. * @param errorCallback defines a callback to call on error
  81574. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81575. */
  81576. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81577. }
  81578. }
  81579. declare module BABYLON {
  81580. /**
  81581. * Class used to help managing file picking and drag'n'drop
  81582. * File Storage
  81583. */
  81584. export class FilesInputStore {
  81585. /**
  81586. * List of files ready to be loaded
  81587. */
  81588. static FilesToLoad: {
  81589. [key: string]: File;
  81590. };
  81591. }
  81592. }
  81593. declare module BABYLON {
  81594. /**
  81595. * Class used to define a retry strategy when error happens while loading assets
  81596. */
  81597. export class RetryStrategy {
  81598. /**
  81599. * Function used to defines an exponential back off strategy
  81600. * @param maxRetries defines the maximum number of retries (3 by default)
  81601. * @param baseInterval defines the interval between retries
  81602. * @returns the strategy function to use
  81603. */
  81604. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81605. }
  81606. }
  81607. declare module BABYLON {
  81608. /**
  81609. * @ignore
  81610. * Application error to support additional information when loading a file
  81611. */
  81612. export abstract class BaseError extends Error {
  81613. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81614. }
  81615. }
  81616. declare module BABYLON {
  81617. /** @ignore */
  81618. export class LoadFileError extends BaseError {
  81619. request?: WebRequest;
  81620. file?: File;
  81621. /**
  81622. * Creates a new LoadFileError
  81623. * @param message defines the message of the error
  81624. * @param request defines the optional web request
  81625. * @param file defines the optional file
  81626. */
  81627. constructor(message: string, object?: WebRequest | File);
  81628. }
  81629. /** @ignore */
  81630. export class RequestFileError extends BaseError {
  81631. request: WebRequest;
  81632. /**
  81633. * Creates a new LoadFileError
  81634. * @param message defines the message of the error
  81635. * @param request defines the optional web request
  81636. */
  81637. constructor(message: string, request: WebRequest);
  81638. }
  81639. /** @ignore */
  81640. export class ReadFileError extends BaseError {
  81641. file: File;
  81642. /**
  81643. * Creates a new ReadFileError
  81644. * @param message defines the message of the error
  81645. * @param file defines the optional file
  81646. */
  81647. constructor(message: string, file: File);
  81648. }
  81649. /**
  81650. * @hidden
  81651. */
  81652. export class FileTools {
  81653. /**
  81654. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81655. */
  81656. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81657. /**
  81658. * Gets or sets the base URL to use to load assets
  81659. */
  81660. static BaseUrl: string;
  81661. /**
  81662. * Default behaviour for cors in the application.
  81663. * It can be a string if the expected behavior is identical in the entire app.
  81664. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81665. */
  81666. static CorsBehavior: string | ((url: string | string[]) => string);
  81667. /**
  81668. * Gets or sets a function used to pre-process url before using them to load assets
  81669. */
  81670. static PreprocessUrl: (url: string) => string;
  81671. /**
  81672. * Removes unwanted characters from an url
  81673. * @param url defines the url to clean
  81674. * @returns the cleaned url
  81675. */
  81676. private static _CleanUrl;
  81677. /**
  81678. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81679. * @param url define the url we are trying
  81680. * @param element define the dom element where to configure the cors policy
  81681. */
  81682. static SetCorsBehavior(url: string | string[], element: {
  81683. crossOrigin: string | null;
  81684. }): void;
  81685. /**
  81686. * Loads an image as an HTMLImageElement.
  81687. * @param input url string, ArrayBuffer, or Blob to load
  81688. * @param onLoad callback called when the image successfully loads
  81689. * @param onError callback called when the image fails to load
  81690. * @param offlineProvider offline provider for caching
  81691. * @param mimeType optional mime type
  81692. * @returns the HTMLImageElement of the loaded image
  81693. */
  81694. 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>;
  81695. /**
  81696. * Reads a file from a File object
  81697. * @param file defines the file to load
  81698. * @param onSuccess defines the callback to call when data is loaded
  81699. * @param onProgress defines the callback to call during loading process
  81700. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81701. * @param onError defines the callback to call when an error occurs
  81702. * @returns a file request object
  81703. */
  81704. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81705. /**
  81706. * Loads a file from a url
  81707. * @param url url to load
  81708. * @param onSuccess callback called when the file successfully loads
  81709. * @param onProgress callback called while file is loading (if the server supports this mode)
  81710. * @param offlineProvider defines the offline provider for caching
  81711. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81712. * @param onError callback called when the file fails to load
  81713. * @returns a file request object
  81714. */
  81715. 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;
  81716. /**
  81717. * Loads a file
  81718. * @param url url to load
  81719. * @param onSuccess callback called when the file successfully loads
  81720. * @param onProgress callback called while file is loading (if the server supports this mode)
  81721. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81722. * @param onError callback called when the file fails to load
  81723. * @param onOpened callback called when the web request is opened
  81724. * @returns a file request object
  81725. */
  81726. 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;
  81727. /**
  81728. * Checks if the loaded document was accessed via `file:`-Protocol.
  81729. * @returns boolean
  81730. */
  81731. static IsFileURL(): boolean;
  81732. }
  81733. }
  81734. declare module BABYLON {
  81735. /** @hidden */
  81736. export class ShaderProcessor {
  81737. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81738. private static _ProcessPrecision;
  81739. private static _ExtractOperation;
  81740. private static _BuildSubExpression;
  81741. private static _BuildExpression;
  81742. private static _MoveCursorWithinIf;
  81743. private static _MoveCursor;
  81744. private static _EvaluatePreProcessors;
  81745. private static _PreparePreProcessors;
  81746. private static _ProcessShaderConversion;
  81747. private static _ProcessIncludes;
  81748. /**
  81749. * Loads a file from a url
  81750. * @param url url to load
  81751. * @param onSuccess callback called when the file successfully loads
  81752. * @param onProgress callback called while file is loading (if the server supports this mode)
  81753. * @param offlineProvider defines the offline provider for caching
  81754. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81755. * @param onError callback called when the file fails to load
  81756. * @returns a file request object
  81757. * @hidden
  81758. */
  81759. 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;
  81760. }
  81761. }
  81762. declare module BABYLON {
  81763. /**
  81764. * @hidden
  81765. */
  81766. export interface IColor4Like {
  81767. r: float;
  81768. g: float;
  81769. b: float;
  81770. a: float;
  81771. }
  81772. /**
  81773. * @hidden
  81774. */
  81775. export interface IColor3Like {
  81776. r: float;
  81777. g: float;
  81778. b: float;
  81779. }
  81780. /**
  81781. * @hidden
  81782. */
  81783. export interface IVector4Like {
  81784. x: float;
  81785. y: float;
  81786. z: float;
  81787. w: float;
  81788. }
  81789. /**
  81790. * @hidden
  81791. */
  81792. export interface IVector3Like {
  81793. x: float;
  81794. y: float;
  81795. z: float;
  81796. }
  81797. /**
  81798. * @hidden
  81799. */
  81800. export interface IVector2Like {
  81801. x: float;
  81802. y: float;
  81803. }
  81804. /**
  81805. * @hidden
  81806. */
  81807. export interface IMatrixLike {
  81808. toArray(): DeepImmutable<Float32Array | Array<number>>;
  81809. updateFlag: int;
  81810. }
  81811. /**
  81812. * @hidden
  81813. */
  81814. export interface IViewportLike {
  81815. x: float;
  81816. y: float;
  81817. width: float;
  81818. height: float;
  81819. }
  81820. /**
  81821. * @hidden
  81822. */
  81823. export interface IPlaneLike {
  81824. normal: IVector3Like;
  81825. d: float;
  81826. normalize(): void;
  81827. }
  81828. }
  81829. declare module BABYLON {
  81830. /**
  81831. * Interface used to define common properties for effect fallbacks
  81832. */
  81833. export interface IEffectFallbacks {
  81834. /**
  81835. * Removes the defines that should be removed when falling back.
  81836. * @param currentDefines defines the current define statements for the shader.
  81837. * @param effect defines the current effect we try to compile
  81838. * @returns The resulting defines with defines of the current rank removed.
  81839. */
  81840. reduce(currentDefines: string, effect: Effect): string;
  81841. /**
  81842. * Removes the fallback from the bound mesh.
  81843. */
  81844. unBindMesh(): void;
  81845. /**
  81846. * Checks to see if more fallbacks are still availible.
  81847. */
  81848. hasMoreFallbacks: boolean;
  81849. }
  81850. }
  81851. declare module BABYLON {
  81852. /**
  81853. * Class used to evalaute queries containing `and` and `or` operators
  81854. */
  81855. export class AndOrNotEvaluator {
  81856. /**
  81857. * Evaluate a query
  81858. * @param query defines the query to evaluate
  81859. * @param evaluateCallback defines the callback used to filter result
  81860. * @returns true if the query matches
  81861. */
  81862. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  81863. private static _HandleParenthesisContent;
  81864. private static _SimplifyNegation;
  81865. }
  81866. }
  81867. declare module BABYLON {
  81868. /**
  81869. * Class used to store custom tags
  81870. */
  81871. export class Tags {
  81872. /**
  81873. * Adds support for tags on the given object
  81874. * @param obj defines the object to use
  81875. */
  81876. static EnableFor(obj: any): void;
  81877. /**
  81878. * Removes tags support
  81879. * @param obj defines the object to use
  81880. */
  81881. static DisableFor(obj: any): void;
  81882. /**
  81883. * Gets a boolean indicating if the given object has tags
  81884. * @param obj defines the object to use
  81885. * @returns a boolean
  81886. */
  81887. static HasTags(obj: any): boolean;
  81888. /**
  81889. * Gets the tags available on a given object
  81890. * @param obj defines the object to use
  81891. * @param asString defines if the tags must be returned as a string instead of an array of strings
  81892. * @returns the tags
  81893. */
  81894. static GetTags(obj: any, asString?: boolean): any;
  81895. /**
  81896. * Adds tags to an object
  81897. * @param obj defines the object to use
  81898. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  81899. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  81900. */
  81901. static AddTagsTo(obj: any, tagsString: string): void;
  81902. /**
  81903. * @hidden
  81904. */
  81905. static _AddTagTo(obj: any, tag: string): void;
  81906. /**
  81907. * Removes specific tags from a specific object
  81908. * @param obj defines the object to use
  81909. * @param tagsString defines the tags to remove
  81910. */
  81911. static RemoveTagsFrom(obj: any, tagsString: string): void;
  81912. /**
  81913. * @hidden
  81914. */
  81915. static _RemoveTagFrom(obj: any, tag: string): void;
  81916. /**
  81917. * Defines if tags hosted on an object match a given query
  81918. * @param obj defines the object to use
  81919. * @param tagsQuery defines the tag query
  81920. * @returns a boolean
  81921. */
  81922. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  81923. }
  81924. }
  81925. declare module BABYLON {
  81926. /**
  81927. * Scalar computation library
  81928. */
  81929. export class Scalar {
  81930. /**
  81931. * Two pi constants convenient for computation.
  81932. */
  81933. static TwoPi: number;
  81934. /**
  81935. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81936. * @param a number
  81937. * @param b number
  81938. * @param epsilon (default = 1.401298E-45)
  81939. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  81940. */
  81941. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  81942. /**
  81943. * Returns a string : the upper case translation of the number i to hexadecimal.
  81944. * @param i number
  81945. * @returns the upper case translation of the number i to hexadecimal.
  81946. */
  81947. static ToHex(i: number): string;
  81948. /**
  81949. * Returns -1 if value is negative and +1 is value is positive.
  81950. * @param value the value
  81951. * @returns the value itself if it's equal to zero.
  81952. */
  81953. static Sign(value: number): number;
  81954. /**
  81955. * Returns the value itself if it's between min and max.
  81956. * Returns min if the value is lower than min.
  81957. * Returns max if the value is greater than max.
  81958. * @param value the value to clmap
  81959. * @param min the min value to clamp to (default: 0)
  81960. * @param max the max value to clamp to (default: 1)
  81961. * @returns the clamped value
  81962. */
  81963. static Clamp(value: number, min?: number, max?: number): number;
  81964. /**
  81965. * the log2 of value.
  81966. * @param value the value to compute log2 of
  81967. * @returns the log2 of value.
  81968. */
  81969. static Log2(value: number): number;
  81970. /**
  81971. * Loops the value, so that it is never larger than length and never smaller than 0.
  81972. *
  81973. * This is similar to the modulo operator but it works with floating point numbers.
  81974. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  81975. * With t = 5 and length = 2.5, the result would be 0.0.
  81976. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  81977. * @param value the value
  81978. * @param length the length
  81979. * @returns the looped value
  81980. */
  81981. static Repeat(value: number, length: number): number;
  81982. /**
  81983. * Normalize the value between 0.0 and 1.0 using min and max values
  81984. * @param value value to normalize
  81985. * @param min max to normalize between
  81986. * @param max min to normalize between
  81987. * @returns the normalized value
  81988. */
  81989. static Normalize(value: number, min: number, max: number): number;
  81990. /**
  81991. * Denormalize the value from 0.0 and 1.0 using min and max values
  81992. * @param normalized value to denormalize
  81993. * @param min max to denormalize between
  81994. * @param max min to denormalize between
  81995. * @returns the denormalized value
  81996. */
  81997. static Denormalize(normalized: number, min: number, max: number): number;
  81998. /**
  81999. * Calculates the shortest difference between two given angles given in degrees.
  82000. * @param current current angle in degrees
  82001. * @param target target angle in degrees
  82002. * @returns the delta
  82003. */
  82004. static DeltaAngle(current: number, target: number): number;
  82005. /**
  82006. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82007. * @param tx value
  82008. * @param length length
  82009. * @returns The returned value will move back and forth between 0 and length
  82010. */
  82011. static PingPong(tx: number, length: number): number;
  82012. /**
  82013. * Interpolates between min and max with smoothing at the limits.
  82014. *
  82015. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82016. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82017. * @param from from
  82018. * @param to to
  82019. * @param tx value
  82020. * @returns the smooth stepped value
  82021. */
  82022. static SmoothStep(from: number, to: number, tx: number): number;
  82023. /**
  82024. * Moves a value current towards target.
  82025. *
  82026. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82027. * Negative values of maxDelta pushes the value away from target.
  82028. * @param current current value
  82029. * @param target target value
  82030. * @param maxDelta max distance to move
  82031. * @returns resulting value
  82032. */
  82033. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82034. /**
  82035. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82036. *
  82037. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82038. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82039. * @param current current value
  82040. * @param target target value
  82041. * @param maxDelta max distance to move
  82042. * @returns resulting angle
  82043. */
  82044. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82045. /**
  82046. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82047. * @param start start value
  82048. * @param end target value
  82049. * @param amount amount to lerp between
  82050. * @returns the lerped value
  82051. */
  82052. static Lerp(start: number, end: number, amount: number): number;
  82053. /**
  82054. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82055. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82056. * @param start start value
  82057. * @param end target value
  82058. * @param amount amount to lerp between
  82059. * @returns the lerped value
  82060. */
  82061. static LerpAngle(start: number, end: number, amount: number): number;
  82062. /**
  82063. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82064. * @param a start value
  82065. * @param b target value
  82066. * @param value value between a and b
  82067. * @returns the inverseLerp value
  82068. */
  82069. static InverseLerp(a: number, b: number, value: number): number;
  82070. /**
  82071. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82072. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82073. * @param value1 spline value
  82074. * @param tangent1 spline value
  82075. * @param value2 spline value
  82076. * @param tangent2 spline value
  82077. * @param amount input value
  82078. * @returns hermite result
  82079. */
  82080. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82081. /**
  82082. * Returns a random float number between and min and max values
  82083. * @param min min value of random
  82084. * @param max max value of random
  82085. * @returns random value
  82086. */
  82087. static RandomRange(min: number, max: number): number;
  82088. /**
  82089. * This function returns percentage of a number in a given range.
  82090. *
  82091. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82092. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82093. * @param number to convert to percentage
  82094. * @param min min range
  82095. * @param max max range
  82096. * @returns the percentage
  82097. */
  82098. static RangeToPercent(number: number, min: number, max: number): number;
  82099. /**
  82100. * This function returns number that corresponds to the percentage in a given range.
  82101. *
  82102. * PercentToRange(0.34,0,100) will return 34.
  82103. * @param percent to convert to number
  82104. * @param min min range
  82105. * @param max max range
  82106. * @returns the number
  82107. */
  82108. static PercentToRange(percent: number, min: number, max: number): number;
  82109. /**
  82110. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82111. * @param angle The angle to normalize in radian.
  82112. * @return The converted angle.
  82113. */
  82114. static NormalizeRadians(angle: number): number;
  82115. }
  82116. }
  82117. declare module BABYLON {
  82118. /**
  82119. * Constant used to convert a value to gamma space
  82120. * @ignorenaming
  82121. */
  82122. export const ToGammaSpace: number;
  82123. /**
  82124. * Constant used to convert a value to linear space
  82125. * @ignorenaming
  82126. */
  82127. export const ToLinearSpace = 2.2;
  82128. /**
  82129. * Constant used to define the minimal number value in Babylon.js
  82130. * @ignorenaming
  82131. */
  82132. let Epsilon: number;
  82133. }
  82134. declare module BABYLON {
  82135. /**
  82136. * Class used to represent a viewport on screen
  82137. */
  82138. export class Viewport {
  82139. /** viewport left coordinate */
  82140. x: number;
  82141. /** viewport top coordinate */
  82142. y: number;
  82143. /**viewport width */
  82144. width: number;
  82145. /** viewport height */
  82146. height: number;
  82147. /**
  82148. * Creates a Viewport object located at (x, y) and sized (width, height)
  82149. * @param x defines viewport left coordinate
  82150. * @param y defines viewport top coordinate
  82151. * @param width defines the viewport width
  82152. * @param height defines the viewport height
  82153. */
  82154. constructor(
  82155. /** viewport left coordinate */
  82156. x: number,
  82157. /** viewport top coordinate */
  82158. y: number,
  82159. /**viewport width */
  82160. width: number,
  82161. /** viewport height */
  82162. height: number);
  82163. /**
  82164. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82165. * @param renderWidth defines the rendering width
  82166. * @param renderHeight defines the rendering height
  82167. * @returns a new Viewport
  82168. */
  82169. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82170. /**
  82171. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82172. * @param renderWidth defines the rendering width
  82173. * @param renderHeight defines the rendering height
  82174. * @param ref defines the target viewport
  82175. * @returns the current viewport
  82176. */
  82177. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82178. /**
  82179. * Returns a new Viewport copied from the current one
  82180. * @returns a new Viewport
  82181. */
  82182. clone(): Viewport;
  82183. }
  82184. }
  82185. declare module BABYLON {
  82186. /**
  82187. * Class containing a set of static utilities functions for arrays.
  82188. */
  82189. export class ArrayTools {
  82190. /**
  82191. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82192. * @param size the number of element to construct and put in the array
  82193. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82194. * @returns a new array filled with new objects
  82195. */
  82196. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82197. }
  82198. }
  82199. declare module BABYLON {
  82200. /**
  82201. * Represents a plane by the equation ax + by + cz + d = 0
  82202. */
  82203. export class Plane {
  82204. private static _TmpMatrix;
  82205. /**
  82206. * Normal of the plane (a,b,c)
  82207. */
  82208. normal: Vector3;
  82209. /**
  82210. * d component of the plane
  82211. */
  82212. d: number;
  82213. /**
  82214. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82215. * @param a a component of the plane
  82216. * @param b b component of the plane
  82217. * @param c c component of the plane
  82218. * @param d d component of the plane
  82219. */
  82220. constructor(a: number, b: number, c: number, d: number);
  82221. /**
  82222. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82223. */
  82224. asArray(): number[];
  82225. /**
  82226. * @returns a new plane copied from the current Plane.
  82227. */
  82228. clone(): Plane;
  82229. /**
  82230. * @returns the string "Plane".
  82231. */
  82232. getClassName(): string;
  82233. /**
  82234. * @returns the Plane hash code.
  82235. */
  82236. getHashCode(): number;
  82237. /**
  82238. * Normalize the current Plane in place.
  82239. * @returns the updated Plane.
  82240. */
  82241. normalize(): Plane;
  82242. /**
  82243. * Applies a transformation the plane and returns the result
  82244. * @param transformation the transformation matrix to be applied to the plane
  82245. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82246. */
  82247. transform(transformation: DeepImmutable<Matrix>): Plane;
  82248. /**
  82249. * Compute the dot product between the point and the plane normal
  82250. * @param point point to calculate the dot product with
  82251. * @returns the dot product (float) of the point coordinates and the plane normal.
  82252. */
  82253. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82254. /**
  82255. * Updates the current Plane from the plane defined by the three given points.
  82256. * @param point1 one of the points used to contruct the plane
  82257. * @param point2 one of the points used to contruct the plane
  82258. * @param point3 one of the points used to contruct the plane
  82259. * @returns the updated Plane.
  82260. */
  82261. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82262. /**
  82263. * Checks if the plane is facing a given direction
  82264. * @param direction the direction to check if the plane is facing
  82265. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82266. * @returns True is the vector "direction" is the same side than the plane normal.
  82267. */
  82268. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82269. /**
  82270. * Calculates the distance to a point
  82271. * @param point point to calculate distance to
  82272. * @returns the signed distance (float) from the given point to the Plane.
  82273. */
  82274. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82275. /**
  82276. * Creates a plane from an array
  82277. * @param array the array to create a plane from
  82278. * @returns a new Plane from the given array.
  82279. */
  82280. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82281. /**
  82282. * Creates a plane from three points
  82283. * @param point1 point used to create the plane
  82284. * @param point2 point used to create the plane
  82285. * @param point3 point used to create the plane
  82286. * @returns a new Plane defined by the three given points.
  82287. */
  82288. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82289. /**
  82290. * Creates a plane from an origin point and a normal
  82291. * @param origin origin of the plane to be constructed
  82292. * @param normal normal of the plane to be constructed
  82293. * @returns a new Plane the normal vector to this plane at the given origin point.
  82294. * Note : the vector "normal" is updated because normalized.
  82295. */
  82296. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82297. /**
  82298. * Calculates the distance from a plane and a point
  82299. * @param origin origin of the plane to be constructed
  82300. * @param normal normal of the plane to be constructed
  82301. * @param point point to calculate distance to
  82302. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82303. */
  82304. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82305. }
  82306. }
  82307. declare module BABYLON {
  82308. /** @hidden */
  82309. export class PerformanceConfigurator {
  82310. /** @hidden */
  82311. static MatrixUse64Bits: boolean;
  82312. /** @hidden */
  82313. static MatrixTrackPrecisionChange: boolean;
  82314. /** @hidden */
  82315. static MatrixCurrentType: any;
  82316. /** @hidden */
  82317. static MatrixTrackedMatrices: Array<any> | null;
  82318. /** @hidden */
  82319. static SetMatrixPrecision(use64bits: boolean): void;
  82320. }
  82321. }
  82322. declare module BABYLON {
  82323. /**
  82324. * Class representing a vector containing 2 coordinates
  82325. */
  82326. export class Vector2 {
  82327. /** defines the first coordinate */
  82328. x: number;
  82329. /** defines the second coordinate */
  82330. y: number;
  82331. /**
  82332. * Creates a new Vector2 from the given x and y coordinates
  82333. * @param x defines the first coordinate
  82334. * @param y defines the second coordinate
  82335. */
  82336. constructor(
  82337. /** defines the first coordinate */
  82338. x?: number,
  82339. /** defines the second coordinate */
  82340. y?: number);
  82341. /**
  82342. * Gets a string with the Vector2 coordinates
  82343. * @returns a string with the Vector2 coordinates
  82344. */
  82345. toString(): string;
  82346. /**
  82347. * Gets class name
  82348. * @returns the string "Vector2"
  82349. */
  82350. getClassName(): string;
  82351. /**
  82352. * Gets current vector hash code
  82353. * @returns the Vector2 hash code as a number
  82354. */
  82355. getHashCode(): number;
  82356. /**
  82357. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82358. * @param array defines the source array
  82359. * @param index defines the offset in source array
  82360. * @returns the current Vector2
  82361. */
  82362. toArray(array: FloatArray, index?: number): Vector2;
  82363. /**
  82364. * Update the current vector from an array
  82365. * @param array defines the destination array
  82366. * @param index defines the offset in the destination array
  82367. * @returns the current Vector3
  82368. */
  82369. fromArray(array: FloatArray, index?: number): Vector2;
  82370. /**
  82371. * Copy the current vector to an array
  82372. * @returns a new array with 2 elements: the Vector2 coordinates.
  82373. */
  82374. asArray(): number[];
  82375. /**
  82376. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82377. * @param source defines the source Vector2
  82378. * @returns the current updated Vector2
  82379. */
  82380. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82381. /**
  82382. * Sets the Vector2 coordinates with the given floats
  82383. * @param x defines the first coordinate
  82384. * @param y defines the second coordinate
  82385. * @returns the current updated Vector2
  82386. */
  82387. copyFromFloats(x: number, y: number): Vector2;
  82388. /**
  82389. * Sets the Vector2 coordinates with the given floats
  82390. * @param x defines the first coordinate
  82391. * @param y defines the second coordinate
  82392. * @returns the current updated Vector2
  82393. */
  82394. set(x: number, y: number): Vector2;
  82395. /**
  82396. * Add another vector with the current one
  82397. * @param otherVector defines the other vector
  82398. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82399. */
  82400. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82401. /**
  82402. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82403. * @param otherVector defines the other vector
  82404. * @param result defines the target vector
  82405. * @returns the unmodified current Vector2
  82406. */
  82407. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82408. /**
  82409. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82410. * @param otherVector defines the other vector
  82411. * @returns the current updated Vector2
  82412. */
  82413. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82414. /**
  82415. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82416. * @param otherVector defines the other vector
  82417. * @returns a new Vector2
  82418. */
  82419. addVector3(otherVector: Vector3): Vector2;
  82420. /**
  82421. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82422. * @param otherVector defines the other vector
  82423. * @returns a new Vector2
  82424. */
  82425. subtract(otherVector: Vector2): Vector2;
  82426. /**
  82427. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82428. * @param otherVector defines the other vector
  82429. * @param result defines the target vector
  82430. * @returns the unmodified current Vector2
  82431. */
  82432. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82433. /**
  82434. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82435. * @param otherVector defines the other vector
  82436. * @returns the current updated Vector2
  82437. */
  82438. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82439. /**
  82440. * Multiplies in place the current Vector2 coordinates by the given ones
  82441. * @param otherVector defines the other vector
  82442. * @returns the current updated Vector2
  82443. */
  82444. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82445. /**
  82446. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82447. * @param otherVector defines the other vector
  82448. * @returns a new Vector2
  82449. */
  82450. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82451. /**
  82452. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82453. * @param otherVector defines the other vector
  82454. * @param result defines the target vector
  82455. * @returns the unmodified current Vector2
  82456. */
  82457. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82458. /**
  82459. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82460. * @param x defines the first coordinate
  82461. * @param y defines the second coordinate
  82462. * @returns a new Vector2
  82463. */
  82464. multiplyByFloats(x: number, y: number): Vector2;
  82465. /**
  82466. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82467. * @param otherVector defines the other vector
  82468. * @returns a new Vector2
  82469. */
  82470. divide(otherVector: Vector2): Vector2;
  82471. /**
  82472. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82473. * @param otherVector defines the other vector
  82474. * @param result defines the target vector
  82475. * @returns the unmodified current Vector2
  82476. */
  82477. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82478. /**
  82479. * Divides the current Vector2 coordinates by the given ones
  82480. * @param otherVector defines the other vector
  82481. * @returns the current updated Vector2
  82482. */
  82483. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82484. /**
  82485. * Gets a new Vector2 with current Vector2 negated coordinates
  82486. * @returns a new Vector2
  82487. */
  82488. negate(): Vector2;
  82489. /**
  82490. * Negate this vector in place
  82491. * @returns this
  82492. */
  82493. negateInPlace(): Vector2;
  82494. /**
  82495. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82496. * @param result defines the Vector3 object where to store the result
  82497. * @returns the current Vector2
  82498. */
  82499. negateToRef(result: Vector2): Vector2;
  82500. /**
  82501. * Multiply the Vector2 coordinates by scale
  82502. * @param scale defines the scaling factor
  82503. * @returns the current updated Vector2
  82504. */
  82505. scaleInPlace(scale: number): Vector2;
  82506. /**
  82507. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82508. * @param scale defines the scaling factor
  82509. * @returns a new Vector2
  82510. */
  82511. scale(scale: number): Vector2;
  82512. /**
  82513. * Scale the current Vector2 values by a factor to a given Vector2
  82514. * @param scale defines the scale factor
  82515. * @param result defines the Vector2 object where to store the result
  82516. * @returns the unmodified current Vector2
  82517. */
  82518. scaleToRef(scale: number, result: Vector2): Vector2;
  82519. /**
  82520. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82521. * @param scale defines the scale factor
  82522. * @param result defines the Vector2 object where to store the result
  82523. * @returns the unmodified current Vector2
  82524. */
  82525. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82526. /**
  82527. * Gets a boolean if two vectors are equals
  82528. * @param otherVector defines the other vector
  82529. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82530. */
  82531. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82532. /**
  82533. * Gets a boolean if two vectors are equals (using an epsilon value)
  82534. * @param otherVector defines the other vector
  82535. * @param epsilon defines the minimal distance to consider equality
  82536. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82537. */
  82538. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82539. /**
  82540. * Gets a new Vector2 from current Vector2 floored values
  82541. * @returns a new Vector2
  82542. */
  82543. floor(): Vector2;
  82544. /**
  82545. * Gets a new Vector2 from current Vector2 floored values
  82546. * @returns a new Vector2
  82547. */
  82548. fract(): Vector2;
  82549. /**
  82550. * Gets the length of the vector
  82551. * @returns the vector length (float)
  82552. */
  82553. length(): number;
  82554. /**
  82555. * Gets the vector squared length
  82556. * @returns the vector squared length (float)
  82557. */
  82558. lengthSquared(): number;
  82559. /**
  82560. * Normalize the vector
  82561. * @returns the current updated Vector2
  82562. */
  82563. normalize(): Vector2;
  82564. /**
  82565. * Gets a new Vector2 copied from the Vector2
  82566. * @returns a new Vector2
  82567. */
  82568. clone(): Vector2;
  82569. /**
  82570. * Gets a new Vector2(0, 0)
  82571. * @returns a new Vector2
  82572. */
  82573. static Zero(): Vector2;
  82574. /**
  82575. * Gets a new Vector2(1, 1)
  82576. * @returns a new Vector2
  82577. */
  82578. static One(): Vector2;
  82579. /**
  82580. * Gets a new Vector2 set from the given index element of the given array
  82581. * @param array defines the data source
  82582. * @param offset defines the offset in the data source
  82583. * @returns a new Vector2
  82584. */
  82585. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82586. /**
  82587. * Sets "result" from the given index element of the given array
  82588. * @param array defines the data source
  82589. * @param offset defines the offset in the data source
  82590. * @param result defines the target vector
  82591. */
  82592. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82593. /**
  82594. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82595. * @param value1 defines 1st point of control
  82596. * @param value2 defines 2nd point of control
  82597. * @param value3 defines 3rd point of control
  82598. * @param value4 defines 4th point of control
  82599. * @param amount defines the interpolation factor
  82600. * @returns a new Vector2
  82601. */
  82602. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82603. /**
  82604. * 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".
  82605. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82606. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82607. * @param value defines the value to clamp
  82608. * @param min defines the lower limit
  82609. * @param max defines the upper limit
  82610. * @returns a new Vector2
  82611. */
  82612. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82613. /**
  82614. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82615. * @param value1 defines the 1st control point
  82616. * @param tangent1 defines the outgoing tangent
  82617. * @param value2 defines the 2nd control point
  82618. * @param tangent2 defines the incoming tangent
  82619. * @param amount defines the interpolation factor
  82620. * @returns a new Vector2
  82621. */
  82622. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82623. /**
  82624. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82625. * @param start defines the start vector
  82626. * @param end defines the end vector
  82627. * @param amount defines the interpolation factor
  82628. * @returns a new Vector2
  82629. */
  82630. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82631. /**
  82632. * Gets the dot product of the vector "left" and the vector "right"
  82633. * @param left defines first vector
  82634. * @param right defines second vector
  82635. * @returns the dot product (float)
  82636. */
  82637. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82638. /**
  82639. * Returns a new Vector2 equal to the normalized given vector
  82640. * @param vector defines the vector to normalize
  82641. * @returns a new Vector2
  82642. */
  82643. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82644. /**
  82645. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82646. * @param left defines 1st vector
  82647. * @param right defines 2nd vector
  82648. * @returns a new Vector2
  82649. */
  82650. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82651. /**
  82652. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82653. * @param left defines 1st vector
  82654. * @param right defines 2nd vector
  82655. * @returns a new Vector2
  82656. */
  82657. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82658. /**
  82659. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82660. * @param vector defines the vector to transform
  82661. * @param transformation defines the matrix to apply
  82662. * @returns a new Vector2
  82663. */
  82664. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82665. /**
  82666. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82667. * @param vector defines the vector to transform
  82668. * @param transformation defines the matrix to apply
  82669. * @param result defines the target vector
  82670. */
  82671. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82672. /**
  82673. * Determines if a given vector is included in a triangle
  82674. * @param p defines the vector to test
  82675. * @param p0 defines 1st triangle point
  82676. * @param p1 defines 2nd triangle point
  82677. * @param p2 defines 3rd triangle point
  82678. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82679. */
  82680. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82681. /**
  82682. * Gets the distance between the vectors "value1" and "value2"
  82683. * @param value1 defines first vector
  82684. * @param value2 defines second vector
  82685. * @returns the distance between vectors
  82686. */
  82687. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82688. /**
  82689. * Returns the squared distance between the vectors "value1" and "value2"
  82690. * @param value1 defines first vector
  82691. * @param value2 defines second vector
  82692. * @returns the squared distance between vectors
  82693. */
  82694. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82695. /**
  82696. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82697. * @param value1 defines first vector
  82698. * @param value2 defines second vector
  82699. * @returns a new Vector2
  82700. */
  82701. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82702. /**
  82703. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82704. * @param p defines the middle point
  82705. * @param segA defines one point of the segment
  82706. * @param segB defines the other point of the segment
  82707. * @returns the shortest distance
  82708. */
  82709. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82710. }
  82711. /**
  82712. * Class used to store (x,y,z) vector representation
  82713. * A Vector3 is the main object used in 3D geometry
  82714. * It can represent etiher the coordinates of a point the space, either a direction
  82715. * Reminder: js uses a left handed forward facing system
  82716. */
  82717. export class Vector3 {
  82718. private static _UpReadOnly;
  82719. private static _ZeroReadOnly;
  82720. /** @hidden */
  82721. _x: number;
  82722. /** @hidden */
  82723. _y: number;
  82724. /** @hidden */
  82725. _z: number;
  82726. /** @hidden */
  82727. _isDirty: boolean;
  82728. /** Gets or sets the x coordinate */
  82729. get x(): number;
  82730. set x(value: number);
  82731. /** Gets or sets the y coordinate */
  82732. get y(): number;
  82733. set y(value: number);
  82734. /** Gets or sets the z coordinate */
  82735. get z(): number;
  82736. set z(value: number);
  82737. /**
  82738. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82739. * @param x defines the first coordinates (on X axis)
  82740. * @param y defines the second coordinates (on Y axis)
  82741. * @param z defines the third coordinates (on Z axis)
  82742. */
  82743. constructor(x?: number, y?: number, z?: number);
  82744. /**
  82745. * Creates a string representation of the Vector3
  82746. * @returns a string with the Vector3 coordinates.
  82747. */
  82748. toString(): string;
  82749. /**
  82750. * Gets the class name
  82751. * @returns the string "Vector3"
  82752. */
  82753. getClassName(): string;
  82754. /**
  82755. * Creates the Vector3 hash code
  82756. * @returns a number which tends to be unique between Vector3 instances
  82757. */
  82758. getHashCode(): number;
  82759. /**
  82760. * Creates an array containing three elements : the coordinates of the Vector3
  82761. * @returns a new array of numbers
  82762. */
  82763. asArray(): number[];
  82764. /**
  82765. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  82766. * @param array defines the destination array
  82767. * @param index defines the offset in the destination array
  82768. * @returns the current Vector3
  82769. */
  82770. toArray(array: FloatArray, index?: number): Vector3;
  82771. /**
  82772. * Update the current vector from an array
  82773. * @param array defines the destination array
  82774. * @param index defines the offset in the destination array
  82775. * @returns the current Vector3
  82776. */
  82777. fromArray(array: FloatArray, index?: number): Vector3;
  82778. /**
  82779. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  82780. * @returns a new Quaternion object, computed from the Vector3 coordinates
  82781. */
  82782. toQuaternion(): Quaternion;
  82783. /**
  82784. * Adds the given vector to the current Vector3
  82785. * @param otherVector defines the second operand
  82786. * @returns the current updated Vector3
  82787. */
  82788. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82789. /**
  82790. * Adds the given coordinates to the current Vector3
  82791. * @param x defines the x coordinate of the operand
  82792. * @param y defines the y coordinate of the operand
  82793. * @param z defines the z coordinate of the operand
  82794. * @returns the current updated Vector3
  82795. */
  82796. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82797. /**
  82798. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  82799. * @param otherVector defines the second operand
  82800. * @returns the resulting Vector3
  82801. */
  82802. add(otherVector: DeepImmutable<Vector3>): Vector3;
  82803. /**
  82804. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  82805. * @param otherVector defines the second operand
  82806. * @param result defines the Vector3 object where to store the result
  82807. * @returns the current Vector3
  82808. */
  82809. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82810. /**
  82811. * Subtract the given vector from the current Vector3
  82812. * @param otherVector defines the second operand
  82813. * @returns the current updated Vector3
  82814. */
  82815. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82816. /**
  82817. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  82818. * @param otherVector defines the second operand
  82819. * @returns the resulting Vector3
  82820. */
  82821. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  82822. /**
  82823. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  82824. * @param otherVector defines the second operand
  82825. * @param result defines the Vector3 object where to store the result
  82826. * @returns the current Vector3
  82827. */
  82828. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82829. /**
  82830. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  82831. * @param x defines the x coordinate of the operand
  82832. * @param y defines the y coordinate of the operand
  82833. * @param z defines the z coordinate of the operand
  82834. * @returns the resulting Vector3
  82835. */
  82836. subtractFromFloats(x: number, y: number, z: number): Vector3;
  82837. /**
  82838. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  82839. * @param x defines the x coordinate of the operand
  82840. * @param y defines the y coordinate of the operand
  82841. * @param z defines the z coordinate of the operand
  82842. * @param result defines the Vector3 object where to store the result
  82843. * @returns the current Vector3
  82844. */
  82845. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  82846. /**
  82847. * Gets a new Vector3 set with the current Vector3 negated coordinates
  82848. * @returns a new Vector3
  82849. */
  82850. negate(): Vector3;
  82851. /**
  82852. * Negate this vector in place
  82853. * @returns this
  82854. */
  82855. negateInPlace(): Vector3;
  82856. /**
  82857. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  82858. * @param result defines the Vector3 object where to store the result
  82859. * @returns the current Vector3
  82860. */
  82861. negateToRef(result: Vector3): Vector3;
  82862. /**
  82863. * Multiplies the Vector3 coordinates by the float "scale"
  82864. * @param scale defines the multiplier factor
  82865. * @returns the current updated Vector3
  82866. */
  82867. scaleInPlace(scale: number): Vector3;
  82868. /**
  82869. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  82870. * @param scale defines the multiplier factor
  82871. * @returns a new Vector3
  82872. */
  82873. scale(scale: number): Vector3;
  82874. /**
  82875. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  82876. * @param scale defines the multiplier factor
  82877. * @param result defines the Vector3 object where to store the result
  82878. * @returns the current Vector3
  82879. */
  82880. scaleToRef(scale: number, result: Vector3): Vector3;
  82881. /**
  82882. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  82883. * @param scale defines the scale factor
  82884. * @param result defines the Vector3 object where to store the result
  82885. * @returns the unmodified current Vector3
  82886. */
  82887. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  82888. /**
  82889. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82890. * @param origin defines the origin of the projection ray
  82891. * @param plane defines the plane to project to
  82892. * @returns the projected vector3
  82893. */
  82894. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  82895. /**
  82896. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  82897. * @param origin defines the origin of the projection ray
  82898. * @param plane defines the plane to project to
  82899. * @param result defines the Vector3 where to store the result
  82900. */
  82901. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  82902. /**
  82903. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  82904. * @param otherVector defines the second operand
  82905. * @returns true if both vectors are equals
  82906. */
  82907. equals(otherVector: DeepImmutable<Vector3>): boolean;
  82908. /**
  82909. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  82910. * @param otherVector defines the second operand
  82911. * @param epsilon defines the minimal distance to define values as equals
  82912. * @returns true if both vectors are distant less than epsilon
  82913. */
  82914. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  82915. /**
  82916. * Returns true if the current Vector3 coordinates equals the given floats
  82917. * @param x defines the x coordinate of the operand
  82918. * @param y defines the y coordinate of the operand
  82919. * @param z defines the z coordinate of the operand
  82920. * @returns true if both vectors are equals
  82921. */
  82922. equalsToFloats(x: number, y: number, z: number): boolean;
  82923. /**
  82924. * Multiplies the current Vector3 coordinates by the given ones
  82925. * @param otherVector defines the second operand
  82926. * @returns the current updated Vector3
  82927. */
  82928. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  82929. /**
  82930. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  82931. * @param otherVector defines the second operand
  82932. * @returns the new Vector3
  82933. */
  82934. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  82935. /**
  82936. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  82937. * @param otherVector defines the second operand
  82938. * @param result defines the Vector3 object where to store the result
  82939. * @returns the current Vector3
  82940. */
  82941. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82942. /**
  82943. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  82944. * @param x defines the x coordinate of the operand
  82945. * @param y defines the y coordinate of the operand
  82946. * @param z defines the z coordinate of the operand
  82947. * @returns the new Vector3
  82948. */
  82949. multiplyByFloats(x: number, y: number, z: number): Vector3;
  82950. /**
  82951. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  82952. * @param otherVector defines the second operand
  82953. * @returns the new Vector3
  82954. */
  82955. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  82956. /**
  82957. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  82958. * @param otherVector defines the second operand
  82959. * @param result defines the Vector3 object where to store the result
  82960. * @returns the current Vector3
  82961. */
  82962. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  82963. /**
  82964. * Divides the current Vector3 coordinates by the given ones.
  82965. * @param otherVector defines the second operand
  82966. * @returns the current updated Vector3
  82967. */
  82968. divideInPlace(otherVector: Vector3): Vector3;
  82969. /**
  82970. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  82971. * @param other defines the second operand
  82972. * @returns the current updated Vector3
  82973. */
  82974. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82975. /**
  82976. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  82977. * @param other defines the second operand
  82978. * @returns the current updated Vector3
  82979. */
  82980. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  82981. /**
  82982. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  82983. * @param x defines the x coordinate of the operand
  82984. * @param y defines the y coordinate of the operand
  82985. * @param z defines the z coordinate of the operand
  82986. * @returns the current updated Vector3
  82987. */
  82988. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82989. /**
  82990. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  82991. * @param x defines the x coordinate of the operand
  82992. * @param y defines the y coordinate of the operand
  82993. * @param z defines the z coordinate of the operand
  82994. * @returns the current updated Vector3
  82995. */
  82996. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  82997. /**
  82998. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  82999. * Check if is non uniform within a certain amount of decimal places to account for this
  83000. * @param epsilon the amount the values can differ
  83001. * @returns if the the vector is non uniform to a certain number of decimal places
  83002. */
  83003. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83004. /**
  83005. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83006. */
  83007. get isNonUniform(): boolean;
  83008. /**
  83009. * Gets a new Vector3 from current Vector3 floored values
  83010. * @returns a new Vector3
  83011. */
  83012. floor(): Vector3;
  83013. /**
  83014. * Gets a new Vector3 from current Vector3 floored values
  83015. * @returns a new Vector3
  83016. */
  83017. fract(): Vector3;
  83018. /**
  83019. * Gets the length of the Vector3
  83020. * @returns the length of the Vector3
  83021. */
  83022. length(): number;
  83023. /**
  83024. * Gets the squared length of the Vector3
  83025. * @returns squared length of the Vector3
  83026. */
  83027. lengthSquared(): number;
  83028. /**
  83029. * Normalize the current Vector3.
  83030. * Please note that this is an in place operation.
  83031. * @returns the current updated Vector3
  83032. */
  83033. normalize(): Vector3;
  83034. /**
  83035. * Reorders the x y z properties of the vector in place
  83036. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83037. * @returns the current updated vector
  83038. */
  83039. reorderInPlace(order: string): this;
  83040. /**
  83041. * Rotates the vector around 0,0,0 by a quaternion
  83042. * @param quaternion the rotation quaternion
  83043. * @param result vector to store the result
  83044. * @returns the resulting vector
  83045. */
  83046. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83047. /**
  83048. * Rotates a vector around a given point
  83049. * @param quaternion the rotation quaternion
  83050. * @param point the point to rotate around
  83051. * @param result vector to store the result
  83052. * @returns the resulting vector
  83053. */
  83054. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83055. /**
  83056. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83057. * The cross product is then orthogonal to both current and "other"
  83058. * @param other defines the right operand
  83059. * @returns the cross product
  83060. */
  83061. cross(other: Vector3): Vector3;
  83062. /**
  83063. * Normalize the current Vector3 with the given input length.
  83064. * Please note that this is an in place operation.
  83065. * @param len the length of the vector
  83066. * @returns the current updated Vector3
  83067. */
  83068. normalizeFromLength(len: number): Vector3;
  83069. /**
  83070. * Normalize the current Vector3 to a new vector
  83071. * @returns the new Vector3
  83072. */
  83073. normalizeToNew(): Vector3;
  83074. /**
  83075. * Normalize the current Vector3 to the reference
  83076. * @param reference define the Vector3 to update
  83077. * @returns the updated Vector3
  83078. */
  83079. normalizeToRef(reference: Vector3): Vector3;
  83080. /**
  83081. * Creates a new Vector3 copied from the current Vector3
  83082. * @returns the new Vector3
  83083. */
  83084. clone(): Vector3;
  83085. /**
  83086. * Copies the given vector coordinates to the current Vector3 ones
  83087. * @param source defines the source Vector3
  83088. * @returns the current updated Vector3
  83089. */
  83090. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83091. /**
  83092. * Copies the given floats to the current Vector3 coordinates
  83093. * @param x defines the x coordinate of the operand
  83094. * @param y defines the y coordinate of the operand
  83095. * @param z defines the z coordinate of the operand
  83096. * @returns the current updated Vector3
  83097. */
  83098. copyFromFloats(x: number, y: number, z: number): Vector3;
  83099. /**
  83100. * Copies the given floats to the current Vector3 coordinates
  83101. * @param x defines the x coordinate of the operand
  83102. * @param y defines the y coordinate of the operand
  83103. * @param z defines the z coordinate of the operand
  83104. * @returns the current updated Vector3
  83105. */
  83106. set(x: number, y: number, z: number): Vector3;
  83107. /**
  83108. * Copies the given float to the current Vector3 coordinates
  83109. * @param v defines the x, y and z coordinates of the operand
  83110. * @returns the current updated Vector3
  83111. */
  83112. setAll(v: number): Vector3;
  83113. /**
  83114. * Get the clip factor between two vectors
  83115. * @param vector0 defines the first operand
  83116. * @param vector1 defines the second operand
  83117. * @param axis defines the axis to use
  83118. * @param size defines the size along the axis
  83119. * @returns the clip factor
  83120. */
  83121. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83122. /**
  83123. * Get angle between two vectors
  83124. * @param vector0 angle between vector0 and vector1
  83125. * @param vector1 angle between vector0 and vector1
  83126. * @param normal direction of the normal
  83127. * @return the angle between vector0 and vector1
  83128. */
  83129. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83130. /**
  83131. * Returns a new Vector3 set from the index "offset" of the given array
  83132. * @param array defines the source array
  83133. * @param offset defines the offset in the source array
  83134. * @returns the new Vector3
  83135. */
  83136. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83137. /**
  83138. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83139. * @param array defines the source array
  83140. * @param offset defines the offset in the source array
  83141. * @returns the new Vector3
  83142. * @deprecated Please use FromArray instead.
  83143. */
  83144. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83145. /**
  83146. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83147. * @param array defines the source array
  83148. * @param offset defines the offset in the source array
  83149. * @param result defines the Vector3 where to store the result
  83150. */
  83151. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83152. /**
  83153. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83154. * @param array defines the source array
  83155. * @param offset defines the offset in the source array
  83156. * @param result defines the Vector3 where to store the result
  83157. * @deprecated Please use FromArrayToRef instead.
  83158. */
  83159. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83160. /**
  83161. * Sets the given vector "result" with the given floats.
  83162. * @param x defines the x coordinate of the source
  83163. * @param y defines the y coordinate of the source
  83164. * @param z defines the z coordinate of the source
  83165. * @param result defines the Vector3 where to store the result
  83166. */
  83167. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83168. /**
  83169. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83170. * @returns a new empty Vector3
  83171. */
  83172. static Zero(): Vector3;
  83173. /**
  83174. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83175. * @returns a new unit Vector3
  83176. */
  83177. static One(): Vector3;
  83178. /**
  83179. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83180. * @returns a new up Vector3
  83181. */
  83182. static Up(): Vector3;
  83183. /**
  83184. * Gets a up Vector3 that must not be updated
  83185. */
  83186. static get UpReadOnly(): DeepImmutable<Vector3>;
  83187. /**
  83188. * Gets a zero Vector3 that must not be updated
  83189. */
  83190. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83191. /**
  83192. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83193. * @returns a new down Vector3
  83194. */
  83195. static Down(): Vector3;
  83196. /**
  83197. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83198. * @param rightHandedSystem is the scene right-handed (negative z)
  83199. * @returns a new forward Vector3
  83200. */
  83201. static Forward(rightHandedSystem?: boolean): Vector3;
  83202. /**
  83203. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83204. * @param rightHandedSystem is the scene right-handed (negative-z)
  83205. * @returns a new forward Vector3
  83206. */
  83207. static Backward(rightHandedSystem?: boolean): Vector3;
  83208. /**
  83209. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83210. * @returns a new right Vector3
  83211. */
  83212. static Right(): Vector3;
  83213. /**
  83214. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83215. * @returns a new left Vector3
  83216. */
  83217. static Left(): Vector3;
  83218. /**
  83219. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83220. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83221. * @param vector defines the Vector3 to transform
  83222. * @param transformation defines the transformation matrix
  83223. * @returns the transformed Vector3
  83224. */
  83225. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83226. /**
  83227. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83228. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83229. * @param vector defines the Vector3 to transform
  83230. * @param transformation defines the transformation matrix
  83231. * @param result defines the Vector3 where to store the result
  83232. */
  83233. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83234. /**
  83235. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83236. * This method computes tranformed coordinates only, not transformed direction vectors
  83237. * @param x define the x coordinate of the source vector
  83238. * @param y define the y coordinate of the source vector
  83239. * @param z define the z coordinate of the source vector
  83240. * @param transformation defines the transformation matrix
  83241. * @param result defines the Vector3 where to store the result
  83242. */
  83243. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83244. /**
  83245. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83246. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83247. * @param vector defines the Vector3 to transform
  83248. * @param transformation defines the transformation matrix
  83249. * @returns the new Vector3
  83250. */
  83251. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83252. /**
  83253. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83254. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83255. * @param vector defines the Vector3 to transform
  83256. * @param transformation defines the transformation matrix
  83257. * @param result defines the Vector3 where to store the result
  83258. */
  83259. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83260. /**
  83261. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83262. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83263. * @param x define the x coordinate of the source vector
  83264. * @param y define the y coordinate of the source vector
  83265. * @param z define the z coordinate of the source vector
  83266. * @param transformation defines the transformation matrix
  83267. * @param result defines the Vector3 where to store the result
  83268. */
  83269. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83270. /**
  83271. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83272. * @param value1 defines the first control point
  83273. * @param value2 defines the second control point
  83274. * @param value3 defines the third control point
  83275. * @param value4 defines the fourth control point
  83276. * @param amount defines the amount on the spline to use
  83277. * @returns the new Vector3
  83278. */
  83279. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83280. /**
  83281. * 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"
  83282. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83283. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83284. * @param value defines the current value
  83285. * @param min defines the lower range value
  83286. * @param max defines the upper range value
  83287. * @returns the new Vector3
  83288. */
  83289. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83290. /**
  83291. * 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"
  83292. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83293. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83294. * @param value defines the current value
  83295. * @param min defines the lower range value
  83296. * @param max defines the upper range value
  83297. * @param result defines the Vector3 where to store the result
  83298. */
  83299. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83300. /**
  83301. * Checks if a given vector is inside a specific range
  83302. * @param v defines the vector to test
  83303. * @param min defines the minimum range
  83304. * @param max defines the maximum range
  83305. */
  83306. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83307. /**
  83308. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83309. * @param value1 defines the first control point
  83310. * @param tangent1 defines the first tangent vector
  83311. * @param value2 defines the second control point
  83312. * @param tangent2 defines the second tangent vector
  83313. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83314. * @returns the new Vector3
  83315. */
  83316. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83317. /**
  83318. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83319. * @param start defines the start value
  83320. * @param end defines the end value
  83321. * @param amount max defines amount between both (between 0 and 1)
  83322. * @returns the new Vector3
  83323. */
  83324. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83325. /**
  83326. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83327. * @param start defines the start value
  83328. * @param end defines the end value
  83329. * @param amount max defines amount between both (between 0 and 1)
  83330. * @param result defines the Vector3 where to store the result
  83331. */
  83332. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83333. /**
  83334. * Returns the dot product (float) between the vectors "left" and "right"
  83335. * @param left defines the left operand
  83336. * @param right defines the right operand
  83337. * @returns the dot product
  83338. */
  83339. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83340. /**
  83341. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83342. * The cross product is then orthogonal to both "left" and "right"
  83343. * @param left defines the left operand
  83344. * @param right defines the right operand
  83345. * @returns the cross product
  83346. */
  83347. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83348. /**
  83349. * Sets the given vector "result" with the cross product of "left" and "right"
  83350. * The cross product is then orthogonal to both "left" and "right"
  83351. * @param left defines the left operand
  83352. * @param right defines the right operand
  83353. * @param result defines the Vector3 where to store the result
  83354. */
  83355. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83356. /**
  83357. * Returns a new Vector3 as the normalization of the given vector
  83358. * @param vector defines the Vector3 to normalize
  83359. * @returns the new Vector3
  83360. */
  83361. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83362. /**
  83363. * Sets the given vector "result" with the normalization of the given first vector
  83364. * @param vector defines the Vector3 to normalize
  83365. * @param result defines the Vector3 where to store the result
  83366. */
  83367. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83368. /**
  83369. * Project a Vector3 onto screen space
  83370. * @param vector defines the Vector3 to project
  83371. * @param world defines the world matrix to use
  83372. * @param transform defines the transform (view x projection) matrix to use
  83373. * @param viewport defines the screen viewport to use
  83374. * @returns the new Vector3
  83375. */
  83376. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83377. /** @hidden */
  83378. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83379. /**
  83380. * Unproject from screen space to object space
  83381. * @param source defines the screen space Vector3 to use
  83382. * @param viewportWidth defines the current width of the viewport
  83383. * @param viewportHeight defines the current height of the viewport
  83384. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83385. * @param transform defines the transform (view x projection) matrix to use
  83386. * @returns the new Vector3
  83387. */
  83388. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83389. /**
  83390. * Unproject from screen space to object space
  83391. * @param source defines the screen space Vector3 to use
  83392. * @param viewportWidth defines the current width of the viewport
  83393. * @param viewportHeight defines the current height of the viewport
  83394. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83395. * @param view defines the view matrix to use
  83396. * @param projection defines the projection matrix to use
  83397. * @returns the new Vector3
  83398. */
  83399. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83400. /**
  83401. * Unproject from screen space to object space
  83402. * @param source defines the screen space Vector3 to use
  83403. * @param viewportWidth defines the current width of the viewport
  83404. * @param viewportHeight defines the current height of the viewport
  83405. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83406. * @param view defines the view matrix to use
  83407. * @param projection defines the projection matrix to use
  83408. * @param result defines the Vector3 where to store the result
  83409. */
  83410. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83411. /**
  83412. * Unproject from screen space to object space
  83413. * @param sourceX defines the screen space x coordinate to use
  83414. * @param sourceY defines the screen space y coordinate to use
  83415. * @param sourceZ defines the screen space z coordinate to use
  83416. * @param viewportWidth defines the current width of the viewport
  83417. * @param viewportHeight defines the current height of the viewport
  83418. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83419. * @param view defines the view matrix to use
  83420. * @param projection defines the projection matrix to use
  83421. * @param result defines the Vector3 where to store the result
  83422. */
  83423. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83424. /**
  83425. * Gets the minimal coordinate values between two Vector3
  83426. * @param left defines the first operand
  83427. * @param right defines the second operand
  83428. * @returns the new Vector3
  83429. */
  83430. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83431. /**
  83432. * Gets the maximal coordinate values between two Vector3
  83433. * @param left defines the first operand
  83434. * @param right defines the second operand
  83435. * @returns the new Vector3
  83436. */
  83437. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83438. /**
  83439. * Returns the distance between the vectors "value1" and "value2"
  83440. * @param value1 defines the first operand
  83441. * @param value2 defines the second operand
  83442. * @returns the distance
  83443. */
  83444. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83445. /**
  83446. * Returns the squared distance between the vectors "value1" and "value2"
  83447. * @param value1 defines the first operand
  83448. * @param value2 defines the second operand
  83449. * @returns the squared distance
  83450. */
  83451. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83452. /**
  83453. * Returns a new Vector3 located at the center between "value1" and "value2"
  83454. * @param value1 defines the first operand
  83455. * @param value2 defines the second operand
  83456. * @returns the new Vector3
  83457. */
  83458. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83459. /**
  83460. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83461. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83462. * to something in order to rotate it from its local system to the given target system
  83463. * Note: axis1, axis2 and axis3 are normalized during this operation
  83464. * @param axis1 defines the first axis
  83465. * @param axis2 defines the second axis
  83466. * @param axis3 defines the third axis
  83467. * @returns a new Vector3
  83468. */
  83469. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83470. /**
  83471. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83472. * @param axis1 defines the first axis
  83473. * @param axis2 defines the second axis
  83474. * @param axis3 defines the third axis
  83475. * @param ref defines the Vector3 where to store the result
  83476. */
  83477. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83478. }
  83479. /**
  83480. * Vector4 class created for EulerAngle class conversion to Quaternion
  83481. */
  83482. export class Vector4 {
  83483. /** x value of the vector */
  83484. x: number;
  83485. /** y value of the vector */
  83486. y: number;
  83487. /** z value of the vector */
  83488. z: number;
  83489. /** w value of the vector */
  83490. w: number;
  83491. /**
  83492. * Creates a Vector4 object from the given floats.
  83493. * @param x x value of the vector
  83494. * @param y y value of the vector
  83495. * @param z z value of the vector
  83496. * @param w w value of the vector
  83497. */
  83498. constructor(
  83499. /** x value of the vector */
  83500. x: number,
  83501. /** y value of the vector */
  83502. y: number,
  83503. /** z value of the vector */
  83504. z: number,
  83505. /** w value of the vector */
  83506. w: number);
  83507. /**
  83508. * Returns the string with the Vector4 coordinates.
  83509. * @returns a string containing all the vector values
  83510. */
  83511. toString(): string;
  83512. /**
  83513. * Returns the string "Vector4".
  83514. * @returns "Vector4"
  83515. */
  83516. getClassName(): string;
  83517. /**
  83518. * Returns the Vector4 hash code.
  83519. * @returns a unique hash code
  83520. */
  83521. getHashCode(): number;
  83522. /**
  83523. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83524. * @returns the resulting array
  83525. */
  83526. asArray(): number[];
  83527. /**
  83528. * Populates the given array from the given index with the Vector4 coordinates.
  83529. * @param array array to populate
  83530. * @param index index of the array to start at (default: 0)
  83531. * @returns the Vector4.
  83532. */
  83533. toArray(array: FloatArray, index?: number): Vector4;
  83534. /**
  83535. * Update the current vector from an array
  83536. * @param array defines the destination array
  83537. * @param index defines the offset in the destination array
  83538. * @returns the current Vector3
  83539. */
  83540. fromArray(array: FloatArray, index?: number): Vector4;
  83541. /**
  83542. * Adds the given vector to the current Vector4.
  83543. * @param otherVector the vector to add
  83544. * @returns the updated Vector4.
  83545. */
  83546. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83547. /**
  83548. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83549. * @param otherVector the vector to add
  83550. * @returns the resulting vector
  83551. */
  83552. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83553. /**
  83554. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83555. * @param otherVector the vector to add
  83556. * @param result the vector to store the result
  83557. * @returns the current Vector4.
  83558. */
  83559. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83560. /**
  83561. * Subtract in place the given vector from the current Vector4.
  83562. * @param otherVector the vector to subtract
  83563. * @returns the updated Vector4.
  83564. */
  83565. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83566. /**
  83567. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83568. * @param otherVector the vector to add
  83569. * @returns the new vector with the result
  83570. */
  83571. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83572. /**
  83573. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83574. * @param otherVector the vector to subtract
  83575. * @param result the vector to store the result
  83576. * @returns the current Vector4.
  83577. */
  83578. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83579. /**
  83580. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83581. */
  83582. /**
  83583. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83584. * @param x value to subtract
  83585. * @param y value to subtract
  83586. * @param z value to subtract
  83587. * @param w value to subtract
  83588. * @returns new vector containing the result
  83589. */
  83590. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83591. /**
  83592. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83593. * @param x value to subtract
  83594. * @param y value to subtract
  83595. * @param z value to subtract
  83596. * @param w value to subtract
  83597. * @param result the vector to store the result in
  83598. * @returns the current Vector4.
  83599. */
  83600. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83601. /**
  83602. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83603. * @returns a new vector with the negated values
  83604. */
  83605. negate(): Vector4;
  83606. /**
  83607. * Negate this vector in place
  83608. * @returns this
  83609. */
  83610. negateInPlace(): Vector4;
  83611. /**
  83612. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83613. * @param result defines the Vector3 object where to store the result
  83614. * @returns the current Vector4
  83615. */
  83616. negateToRef(result: Vector4): Vector4;
  83617. /**
  83618. * Multiplies the current Vector4 coordinates by scale (float).
  83619. * @param scale the number to scale with
  83620. * @returns the updated Vector4.
  83621. */
  83622. scaleInPlace(scale: number): Vector4;
  83623. /**
  83624. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83625. * @param scale the number to scale with
  83626. * @returns a new vector with the result
  83627. */
  83628. scale(scale: number): Vector4;
  83629. /**
  83630. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83631. * @param scale the number to scale with
  83632. * @param result a vector to store the result in
  83633. * @returns the current Vector4.
  83634. */
  83635. scaleToRef(scale: number, result: Vector4): Vector4;
  83636. /**
  83637. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83638. * @param scale defines the scale factor
  83639. * @param result defines the Vector4 object where to store the result
  83640. * @returns the unmodified current Vector4
  83641. */
  83642. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83643. /**
  83644. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83645. * @param otherVector the vector to compare against
  83646. * @returns true if they are equal
  83647. */
  83648. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83649. /**
  83650. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83651. * @param otherVector vector to compare against
  83652. * @param epsilon (Default: very small number)
  83653. * @returns true if they are equal
  83654. */
  83655. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83656. /**
  83657. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83658. * @param x x value to compare against
  83659. * @param y y value to compare against
  83660. * @param z z value to compare against
  83661. * @param w w value to compare against
  83662. * @returns true if equal
  83663. */
  83664. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83665. /**
  83666. * Multiplies in place the current Vector4 by the given one.
  83667. * @param otherVector vector to multiple with
  83668. * @returns the updated Vector4.
  83669. */
  83670. multiplyInPlace(otherVector: Vector4): Vector4;
  83671. /**
  83672. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83673. * @param otherVector vector to multiple with
  83674. * @returns resulting new vector
  83675. */
  83676. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83677. /**
  83678. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83679. * @param otherVector vector to multiple with
  83680. * @param result vector to store the result
  83681. * @returns the current Vector4.
  83682. */
  83683. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83684. /**
  83685. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83686. * @param x x value multiply with
  83687. * @param y y value multiply with
  83688. * @param z z value multiply with
  83689. * @param w w value multiply with
  83690. * @returns resulting new vector
  83691. */
  83692. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83693. /**
  83694. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83695. * @param otherVector vector to devide with
  83696. * @returns resulting new vector
  83697. */
  83698. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83699. /**
  83700. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83701. * @param otherVector vector to devide with
  83702. * @param result vector to store the result
  83703. * @returns the current Vector4.
  83704. */
  83705. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83706. /**
  83707. * Divides the current Vector3 coordinates by the given ones.
  83708. * @param otherVector vector to devide with
  83709. * @returns the updated Vector3.
  83710. */
  83711. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83712. /**
  83713. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83714. * @param other defines the second operand
  83715. * @returns the current updated Vector4
  83716. */
  83717. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83718. /**
  83719. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83720. * @param other defines the second operand
  83721. * @returns the current updated Vector4
  83722. */
  83723. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83724. /**
  83725. * Gets a new Vector4 from current Vector4 floored values
  83726. * @returns a new Vector4
  83727. */
  83728. floor(): Vector4;
  83729. /**
  83730. * Gets a new Vector4 from current Vector3 floored values
  83731. * @returns a new Vector4
  83732. */
  83733. fract(): Vector4;
  83734. /**
  83735. * Returns the Vector4 length (float).
  83736. * @returns the length
  83737. */
  83738. length(): number;
  83739. /**
  83740. * Returns the Vector4 squared length (float).
  83741. * @returns the length squared
  83742. */
  83743. lengthSquared(): number;
  83744. /**
  83745. * Normalizes in place the Vector4.
  83746. * @returns the updated Vector4.
  83747. */
  83748. normalize(): Vector4;
  83749. /**
  83750. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83751. * @returns this converted to a new vector3
  83752. */
  83753. toVector3(): Vector3;
  83754. /**
  83755. * Returns a new Vector4 copied from the current one.
  83756. * @returns the new cloned vector
  83757. */
  83758. clone(): Vector4;
  83759. /**
  83760. * Updates the current Vector4 with the given one coordinates.
  83761. * @param source the source vector to copy from
  83762. * @returns the updated Vector4.
  83763. */
  83764. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  83765. /**
  83766. * Updates the current Vector4 coordinates with the given floats.
  83767. * @param x float to copy from
  83768. * @param y float to copy from
  83769. * @param z float to copy from
  83770. * @param w float to copy from
  83771. * @returns the updated Vector4.
  83772. */
  83773. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83774. /**
  83775. * Updates the current Vector4 coordinates with the given floats.
  83776. * @param x float to set from
  83777. * @param y float to set from
  83778. * @param z float to set from
  83779. * @param w float to set from
  83780. * @returns the updated Vector4.
  83781. */
  83782. set(x: number, y: number, z: number, w: number): Vector4;
  83783. /**
  83784. * Copies the given float to the current Vector3 coordinates
  83785. * @param v defines the x, y, z and w coordinates of the operand
  83786. * @returns the current updated Vector3
  83787. */
  83788. setAll(v: number): Vector4;
  83789. /**
  83790. * Returns a new Vector4 set from the starting index of the given array.
  83791. * @param array the array to pull values from
  83792. * @param offset the offset into the array to start at
  83793. * @returns the new vector
  83794. */
  83795. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  83796. /**
  83797. * Updates the given vector "result" from the starting index of the given array.
  83798. * @param array the array to pull values from
  83799. * @param offset the offset into the array to start at
  83800. * @param result the vector to store the result in
  83801. */
  83802. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  83803. /**
  83804. * Updates the given vector "result" from the starting index of the given Float32Array.
  83805. * @param array the array to pull values from
  83806. * @param offset the offset into the array to start at
  83807. * @param result the vector to store the result in
  83808. */
  83809. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  83810. /**
  83811. * Updates the given vector "result" coordinates from the given floats.
  83812. * @param x float to set from
  83813. * @param y float to set from
  83814. * @param z float to set from
  83815. * @param w float to set from
  83816. * @param result the vector to the floats in
  83817. */
  83818. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  83819. /**
  83820. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  83821. * @returns the new vector
  83822. */
  83823. static Zero(): Vector4;
  83824. /**
  83825. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  83826. * @returns the new vector
  83827. */
  83828. static One(): Vector4;
  83829. /**
  83830. * Returns a new normalized Vector4 from the given one.
  83831. * @param vector the vector to normalize
  83832. * @returns the vector
  83833. */
  83834. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  83835. /**
  83836. * Updates the given vector "result" from the normalization of the given one.
  83837. * @param vector the vector to normalize
  83838. * @param result the vector to store the result in
  83839. */
  83840. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  83841. /**
  83842. * Returns a vector with the minimum values from the left and right vectors
  83843. * @param left left vector to minimize
  83844. * @param right right vector to minimize
  83845. * @returns a new vector with the minimum of the left and right vector values
  83846. */
  83847. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83848. /**
  83849. * Returns a vector with the maximum values from the left and right vectors
  83850. * @param left left vector to maximize
  83851. * @param right right vector to maximize
  83852. * @returns a new vector with the maximum of the left and right vector values
  83853. */
  83854. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  83855. /**
  83856. * Returns the distance (float) between the vectors "value1" and "value2".
  83857. * @param value1 value to calulate the distance between
  83858. * @param value2 value to calulate the distance between
  83859. * @return the distance between the two vectors
  83860. */
  83861. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83862. /**
  83863. * Returns the squared distance (float) between the vectors "value1" and "value2".
  83864. * @param value1 value to calulate the distance between
  83865. * @param value2 value to calulate the distance between
  83866. * @return the distance between the two vectors squared
  83867. */
  83868. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  83869. /**
  83870. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  83871. * @param value1 value to calulate the center between
  83872. * @param value2 value to calulate the center between
  83873. * @return the center between the two vectors
  83874. */
  83875. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  83876. /**
  83877. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  83878. * This methods computes transformed normalized direction vectors only.
  83879. * @param vector the vector to transform
  83880. * @param transformation the transformation matrix to apply
  83881. * @returns the new vector
  83882. */
  83883. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  83884. /**
  83885. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  83886. * This methods computes transformed normalized direction vectors only.
  83887. * @param vector the vector to transform
  83888. * @param transformation the transformation matrix to apply
  83889. * @param result the vector to store the result in
  83890. */
  83891. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83892. /**
  83893. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  83894. * This methods computes transformed normalized direction vectors only.
  83895. * @param x value to transform
  83896. * @param y value to transform
  83897. * @param z value to transform
  83898. * @param w value to transform
  83899. * @param transformation the transformation matrix to apply
  83900. * @param result the vector to store the results in
  83901. */
  83902. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  83903. /**
  83904. * Creates a new Vector4 from a Vector3
  83905. * @param source defines the source data
  83906. * @param w defines the 4th component (default is 0)
  83907. * @returns a new Vector4
  83908. */
  83909. static FromVector3(source: Vector3, w?: number): Vector4;
  83910. }
  83911. /**
  83912. * Class used to store quaternion data
  83913. * @see https://en.wikipedia.org/wiki/Quaternion
  83914. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  83915. */
  83916. export class Quaternion {
  83917. /** @hidden */
  83918. _x: number;
  83919. /** @hidden */
  83920. _y: number;
  83921. /** @hidden */
  83922. _z: number;
  83923. /** @hidden */
  83924. _w: number;
  83925. /** @hidden */
  83926. _isDirty: boolean;
  83927. /** Gets or sets the x coordinate */
  83928. get x(): number;
  83929. set x(value: number);
  83930. /** Gets or sets the y coordinate */
  83931. get y(): number;
  83932. set y(value: number);
  83933. /** Gets or sets the z coordinate */
  83934. get z(): number;
  83935. set z(value: number);
  83936. /** Gets or sets the w coordinate */
  83937. get w(): number;
  83938. set w(value: number);
  83939. /**
  83940. * Creates a new Quaternion from the given floats
  83941. * @param x defines the first component (0 by default)
  83942. * @param y defines the second component (0 by default)
  83943. * @param z defines the third component (0 by default)
  83944. * @param w defines the fourth component (1.0 by default)
  83945. */
  83946. constructor(x?: number, y?: number, z?: number, w?: number);
  83947. /**
  83948. * Gets a string representation for the current quaternion
  83949. * @returns a string with the Quaternion coordinates
  83950. */
  83951. toString(): string;
  83952. /**
  83953. * Gets the class name of the quaternion
  83954. * @returns the string "Quaternion"
  83955. */
  83956. getClassName(): string;
  83957. /**
  83958. * Gets a hash code for this quaternion
  83959. * @returns the quaternion hash code
  83960. */
  83961. getHashCode(): number;
  83962. /**
  83963. * Copy the quaternion to an array
  83964. * @returns a new array populated with 4 elements from the quaternion coordinates
  83965. */
  83966. asArray(): number[];
  83967. /**
  83968. * Check if two quaternions are equals
  83969. * @param otherQuaternion defines the second operand
  83970. * @return true if the current quaternion and the given one coordinates are strictly equals
  83971. */
  83972. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  83973. /**
  83974. * Gets a boolean if two quaternions are equals (using an epsilon value)
  83975. * @param otherQuaternion defines the other quaternion
  83976. * @param epsilon defines the minimal distance to consider equality
  83977. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  83978. */
  83979. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  83980. /**
  83981. * Clone the current quaternion
  83982. * @returns a new quaternion copied from the current one
  83983. */
  83984. clone(): Quaternion;
  83985. /**
  83986. * Copy a quaternion to the current one
  83987. * @param other defines the other quaternion
  83988. * @returns the updated current quaternion
  83989. */
  83990. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  83991. /**
  83992. * Updates the current quaternion with the given float coordinates
  83993. * @param x defines the x coordinate
  83994. * @param y defines the y coordinate
  83995. * @param z defines the z coordinate
  83996. * @param w defines the w coordinate
  83997. * @returns the updated current quaternion
  83998. */
  83999. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84000. /**
  84001. * Updates the current quaternion from the given float coordinates
  84002. * @param x defines the x coordinate
  84003. * @param y defines the y coordinate
  84004. * @param z defines the z coordinate
  84005. * @param w defines the w coordinate
  84006. * @returns the updated current quaternion
  84007. */
  84008. set(x: number, y: number, z: number, w: number): Quaternion;
  84009. /**
  84010. * Adds two quaternions
  84011. * @param other defines the second operand
  84012. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84013. */
  84014. add(other: DeepImmutable<Quaternion>): Quaternion;
  84015. /**
  84016. * Add a quaternion to the current one
  84017. * @param other defines the quaternion to add
  84018. * @returns the current quaternion
  84019. */
  84020. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84021. /**
  84022. * Subtract two quaternions
  84023. * @param other defines the second operand
  84024. * @returns a new quaternion as the subtraction result of the given one from the current one
  84025. */
  84026. subtract(other: Quaternion): Quaternion;
  84027. /**
  84028. * Multiplies the current quaternion by a scale factor
  84029. * @param value defines the scale factor
  84030. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84031. */
  84032. scale(value: number): Quaternion;
  84033. /**
  84034. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84035. * @param scale defines the scale factor
  84036. * @param result defines the Quaternion object where to store the result
  84037. * @returns the unmodified current quaternion
  84038. */
  84039. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84040. /**
  84041. * Multiplies in place the current quaternion by a scale factor
  84042. * @param value defines the scale factor
  84043. * @returns the current modified quaternion
  84044. */
  84045. scaleInPlace(value: number): Quaternion;
  84046. /**
  84047. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84048. * @param scale defines the scale factor
  84049. * @param result defines the Quaternion object where to store the result
  84050. * @returns the unmodified current quaternion
  84051. */
  84052. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84053. /**
  84054. * Multiplies two quaternions
  84055. * @param q1 defines the second operand
  84056. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84057. */
  84058. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84059. /**
  84060. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84061. * @param q1 defines the second operand
  84062. * @param result defines the target quaternion
  84063. * @returns the current quaternion
  84064. */
  84065. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84066. /**
  84067. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84068. * @param q1 defines the second operand
  84069. * @returns the currentupdated quaternion
  84070. */
  84071. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84072. /**
  84073. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84074. * @param ref defines the target quaternion
  84075. * @returns the current quaternion
  84076. */
  84077. conjugateToRef(ref: Quaternion): Quaternion;
  84078. /**
  84079. * Conjugates in place (1-q) the current quaternion
  84080. * @returns the current updated quaternion
  84081. */
  84082. conjugateInPlace(): Quaternion;
  84083. /**
  84084. * Conjugates in place (1-q) the current quaternion
  84085. * @returns a new quaternion
  84086. */
  84087. conjugate(): Quaternion;
  84088. /**
  84089. * Gets length of current quaternion
  84090. * @returns the quaternion length (float)
  84091. */
  84092. length(): number;
  84093. /**
  84094. * Normalize in place the current quaternion
  84095. * @returns the current updated quaternion
  84096. */
  84097. normalize(): Quaternion;
  84098. /**
  84099. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84100. * @param order is a reserved parameter and is ignore for now
  84101. * @returns a new Vector3 containing the Euler angles
  84102. */
  84103. toEulerAngles(order?: string): Vector3;
  84104. /**
  84105. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84106. * @param result defines the vector which will be filled with the Euler angles
  84107. * @param order is a reserved parameter and is ignore for now
  84108. * @returns the current unchanged quaternion
  84109. */
  84110. toEulerAnglesToRef(result: Vector3): Quaternion;
  84111. /**
  84112. * Updates the given rotation matrix with the current quaternion values
  84113. * @param result defines the target matrix
  84114. * @returns the current unchanged quaternion
  84115. */
  84116. toRotationMatrix(result: Matrix): Quaternion;
  84117. /**
  84118. * Updates the current quaternion from the given rotation matrix values
  84119. * @param matrix defines the source matrix
  84120. * @returns the current updated quaternion
  84121. */
  84122. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84123. /**
  84124. * Creates a new quaternion from a rotation matrix
  84125. * @param matrix defines the source matrix
  84126. * @returns a new quaternion created from the given rotation matrix values
  84127. */
  84128. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84129. /**
  84130. * Updates the given quaternion with the given rotation matrix values
  84131. * @param matrix defines the source matrix
  84132. * @param result defines the target quaternion
  84133. */
  84134. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84135. /**
  84136. * Returns the dot product (float) between the quaternions "left" and "right"
  84137. * @param left defines the left operand
  84138. * @param right defines the right operand
  84139. * @returns the dot product
  84140. */
  84141. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84142. /**
  84143. * Checks if the two quaternions are close to each other
  84144. * @param quat0 defines the first quaternion to check
  84145. * @param quat1 defines the second quaternion to check
  84146. * @returns true if the two quaternions are close to each other
  84147. */
  84148. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84149. /**
  84150. * Creates an empty quaternion
  84151. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84152. */
  84153. static Zero(): Quaternion;
  84154. /**
  84155. * Inverse a given quaternion
  84156. * @param q defines the source quaternion
  84157. * @returns a new quaternion as the inverted current quaternion
  84158. */
  84159. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84160. /**
  84161. * Inverse a given quaternion
  84162. * @param q defines the source quaternion
  84163. * @param result the quaternion the result will be stored in
  84164. * @returns the result quaternion
  84165. */
  84166. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84167. /**
  84168. * Creates an identity quaternion
  84169. * @returns the identity quaternion
  84170. */
  84171. static Identity(): Quaternion;
  84172. /**
  84173. * Gets a boolean indicating if the given quaternion is identity
  84174. * @param quaternion defines the quaternion to check
  84175. * @returns true if the quaternion is identity
  84176. */
  84177. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84178. /**
  84179. * Creates a quaternion from a rotation around an axis
  84180. * @param axis defines the axis to use
  84181. * @param angle defines the angle to use
  84182. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84183. */
  84184. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84185. /**
  84186. * Creates a rotation around an axis and stores it into the given quaternion
  84187. * @param axis defines the axis to use
  84188. * @param angle defines the angle to use
  84189. * @param result defines the target quaternion
  84190. * @returns the target quaternion
  84191. */
  84192. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84193. /**
  84194. * Creates a new quaternion from data stored into an array
  84195. * @param array defines the data source
  84196. * @param offset defines the offset in the source array where the data starts
  84197. * @returns a new quaternion
  84198. */
  84199. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84200. /**
  84201. * Updates the given quaternion "result" from the starting index of the given array.
  84202. * @param array the array to pull values from
  84203. * @param offset the offset into the array to start at
  84204. * @param result the quaternion to store the result in
  84205. */
  84206. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84207. /**
  84208. * Create a quaternion from Euler rotation angles
  84209. * @param x Pitch
  84210. * @param y Yaw
  84211. * @param z Roll
  84212. * @returns the new Quaternion
  84213. */
  84214. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84215. /**
  84216. * Updates a quaternion from Euler rotation angles
  84217. * @param x Pitch
  84218. * @param y Yaw
  84219. * @param z Roll
  84220. * @param result the quaternion to store the result
  84221. * @returns the updated quaternion
  84222. */
  84223. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84224. /**
  84225. * Create a quaternion from Euler rotation vector
  84226. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84227. * @returns the new Quaternion
  84228. */
  84229. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84230. /**
  84231. * Updates a quaternion from Euler rotation vector
  84232. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84233. * @param result the quaternion to store the result
  84234. * @returns the updated quaternion
  84235. */
  84236. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84237. /**
  84238. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84239. * @param yaw defines the rotation around Y axis
  84240. * @param pitch defines the rotation around X axis
  84241. * @param roll defines the rotation around Z axis
  84242. * @returns the new quaternion
  84243. */
  84244. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84245. /**
  84246. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84247. * @param yaw defines the rotation around Y axis
  84248. * @param pitch defines the rotation around X axis
  84249. * @param roll defines the rotation around Z axis
  84250. * @param result defines the target quaternion
  84251. */
  84252. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84253. /**
  84254. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84255. * @param alpha defines the rotation around first axis
  84256. * @param beta defines the rotation around second axis
  84257. * @param gamma defines the rotation around third axis
  84258. * @returns the new quaternion
  84259. */
  84260. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84261. /**
  84262. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84263. * @param alpha defines the rotation around first axis
  84264. * @param beta defines the rotation around second axis
  84265. * @param gamma defines the rotation around third axis
  84266. * @param result defines the target quaternion
  84267. */
  84268. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84269. /**
  84270. * 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)
  84271. * @param axis1 defines the first axis
  84272. * @param axis2 defines the second axis
  84273. * @param axis3 defines the third axis
  84274. * @returns the new quaternion
  84275. */
  84276. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84277. /**
  84278. * 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
  84279. * @param axis1 defines the first axis
  84280. * @param axis2 defines the second axis
  84281. * @param axis3 defines the third axis
  84282. * @param ref defines the target quaternion
  84283. */
  84284. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84285. /**
  84286. * Interpolates between two quaternions
  84287. * @param left defines first quaternion
  84288. * @param right defines second quaternion
  84289. * @param amount defines the gradient to use
  84290. * @returns the new interpolated quaternion
  84291. */
  84292. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84293. /**
  84294. * Interpolates between two quaternions and stores it into a target quaternion
  84295. * @param left defines first quaternion
  84296. * @param right defines second quaternion
  84297. * @param amount defines the gradient to use
  84298. * @param result defines the target quaternion
  84299. */
  84300. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84301. /**
  84302. * Interpolate between two quaternions using Hermite interpolation
  84303. * @param value1 defines first quaternion
  84304. * @param tangent1 defines the incoming tangent
  84305. * @param value2 defines second quaternion
  84306. * @param tangent2 defines the outgoing tangent
  84307. * @param amount defines the target quaternion
  84308. * @returns the new interpolated quaternion
  84309. */
  84310. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84311. }
  84312. /**
  84313. * Class used to store matrix data (4x4)
  84314. */
  84315. export class Matrix {
  84316. /**
  84317. * Gets the precision of matrix computations
  84318. */
  84319. static get Use64Bits(): boolean;
  84320. private static _updateFlagSeed;
  84321. private static _identityReadOnly;
  84322. private _isIdentity;
  84323. private _isIdentityDirty;
  84324. private _isIdentity3x2;
  84325. private _isIdentity3x2Dirty;
  84326. /**
  84327. * Gets the update flag of the matrix which is an unique number for the matrix.
  84328. * It will be incremented every time the matrix data change.
  84329. * You can use it to speed the comparison between two versions of the same matrix.
  84330. */
  84331. updateFlag: number;
  84332. private readonly _m;
  84333. /**
  84334. * Gets the internal data of the matrix
  84335. */
  84336. get m(): DeepImmutable<Float32Array | Array<number>>;
  84337. /** @hidden */
  84338. _markAsUpdated(): void;
  84339. /** @hidden */
  84340. private _updateIdentityStatus;
  84341. /**
  84342. * Creates an empty matrix (filled with zeros)
  84343. */
  84344. constructor();
  84345. /**
  84346. * Check if the current matrix is identity
  84347. * @returns true is the matrix is the identity matrix
  84348. */
  84349. isIdentity(): boolean;
  84350. /**
  84351. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84352. * @returns true is the matrix is the identity matrix
  84353. */
  84354. isIdentityAs3x2(): boolean;
  84355. /**
  84356. * Gets the determinant of the matrix
  84357. * @returns the matrix determinant
  84358. */
  84359. determinant(): number;
  84360. /**
  84361. * Returns the matrix as a Float32Array or Array<number>
  84362. * @returns the matrix underlying array
  84363. */
  84364. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84365. /**
  84366. * Returns the matrix as a Float32Array or Array<number>
  84367. * @returns the matrix underlying array.
  84368. */
  84369. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84370. /**
  84371. * Inverts the current matrix in place
  84372. * @returns the current inverted matrix
  84373. */
  84374. invert(): Matrix;
  84375. /**
  84376. * Sets all the matrix elements to zero
  84377. * @returns the current matrix
  84378. */
  84379. reset(): Matrix;
  84380. /**
  84381. * Adds the current matrix with a second one
  84382. * @param other defines the matrix to add
  84383. * @returns a new matrix as the addition of the current matrix and the given one
  84384. */
  84385. add(other: DeepImmutable<Matrix>): Matrix;
  84386. /**
  84387. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84388. * @param other defines the matrix to add
  84389. * @param result defines the target matrix
  84390. * @returns the current matrix
  84391. */
  84392. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84393. /**
  84394. * Adds in place the given matrix to the current matrix
  84395. * @param other defines the second operand
  84396. * @returns the current updated matrix
  84397. */
  84398. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84399. /**
  84400. * Sets the given matrix to the current inverted Matrix
  84401. * @param other defines the target matrix
  84402. * @returns the unmodified current matrix
  84403. */
  84404. invertToRef(other: Matrix): Matrix;
  84405. /**
  84406. * add a value at the specified position in the current Matrix
  84407. * @param index the index of the value within the matrix. between 0 and 15.
  84408. * @param value the value to be added
  84409. * @returns the current updated matrix
  84410. */
  84411. addAtIndex(index: number, value: number): Matrix;
  84412. /**
  84413. * mutiply the specified position in the current Matrix by a value
  84414. * @param index the index of the value within the matrix. between 0 and 15.
  84415. * @param value the value to be added
  84416. * @returns the current updated matrix
  84417. */
  84418. multiplyAtIndex(index: number, value: number): Matrix;
  84419. /**
  84420. * Inserts the translation vector (using 3 floats) in the current matrix
  84421. * @param x defines the 1st component of the translation
  84422. * @param y defines the 2nd component of the translation
  84423. * @param z defines the 3rd component of the translation
  84424. * @returns the current updated matrix
  84425. */
  84426. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84427. /**
  84428. * Adds the translation vector (using 3 floats) in the current matrix
  84429. * @param x defines the 1st component of the translation
  84430. * @param y defines the 2nd component of the translation
  84431. * @param z defines the 3rd component of the translation
  84432. * @returns the current updated matrix
  84433. */
  84434. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84435. /**
  84436. * Inserts the translation vector in the current matrix
  84437. * @param vector3 defines the translation to insert
  84438. * @returns the current updated matrix
  84439. */
  84440. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84441. /**
  84442. * Gets the translation value of the current matrix
  84443. * @returns a new Vector3 as the extracted translation from the matrix
  84444. */
  84445. getTranslation(): Vector3;
  84446. /**
  84447. * Fill a Vector3 with the extracted translation from the matrix
  84448. * @param result defines the Vector3 where to store the translation
  84449. * @returns the current matrix
  84450. */
  84451. getTranslationToRef(result: Vector3): Matrix;
  84452. /**
  84453. * Remove rotation and scaling part from the matrix
  84454. * @returns the updated matrix
  84455. */
  84456. removeRotationAndScaling(): Matrix;
  84457. /**
  84458. * Multiply two matrices
  84459. * @param other defines the second operand
  84460. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84461. */
  84462. multiply(other: DeepImmutable<Matrix>): Matrix;
  84463. /**
  84464. * Copy the current matrix from the given one
  84465. * @param other defines the source matrix
  84466. * @returns the current updated matrix
  84467. */
  84468. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84469. /**
  84470. * Populates the given array from the starting index with the current matrix values
  84471. * @param array defines the target array
  84472. * @param offset defines the offset in the target array where to start storing values
  84473. * @returns the current matrix
  84474. */
  84475. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84476. /**
  84477. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84478. * @param other defines the second operand
  84479. * @param result defines the matrix where to store the multiplication
  84480. * @returns the current matrix
  84481. */
  84482. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84483. /**
  84484. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84485. * @param other defines the second operand
  84486. * @param result defines the array where to store the multiplication
  84487. * @param offset defines the offset in the target array where to start storing values
  84488. * @returns the current matrix
  84489. */
  84490. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84491. /**
  84492. * Check equality between this matrix and a second one
  84493. * @param value defines the second matrix to compare
  84494. * @returns true is the current matrix and the given one values are strictly equal
  84495. */
  84496. equals(value: DeepImmutable<Matrix>): boolean;
  84497. /**
  84498. * Clone the current matrix
  84499. * @returns a new matrix from the current matrix
  84500. */
  84501. clone(): Matrix;
  84502. /**
  84503. * Returns the name of the current matrix class
  84504. * @returns the string "Matrix"
  84505. */
  84506. getClassName(): string;
  84507. /**
  84508. * Gets the hash code of the current matrix
  84509. * @returns the hash code
  84510. */
  84511. getHashCode(): number;
  84512. /**
  84513. * Decomposes the current Matrix into a translation, rotation and scaling components
  84514. * @param scale defines the scale vector3 given as a reference to update
  84515. * @param rotation defines the rotation quaternion given as a reference to update
  84516. * @param translation defines the translation vector3 given as a reference to update
  84517. * @returns true if operation was successful
  84518. */
  84519. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84520. /**
  84521. * Gets specific row of the matrix
  84522. * @param index defines the number of the row to get
  84523. * @returns the index-th row of the current matrix as a new Vector4
  84524. */
  84525. getRow(index: number): Nullable<Vector4>;
  84526. /**
  84527. * Sets the index-th row of the current matrix to the vector4 values
  84528. * @param index defines the number of the row to set
  84529. * @param row defines the target vector4
  84530. * @returns the updated current matrix
  84531. */
  84532. setRow(index: number, row: Vector4): Matrix;
  84533. /**
  84534. * Compute the transpose of the matrix
  84535. * @returns the new transposed matrix
  84536. */
  84537. transpose(): Matrix;
  84538. /**
  84539. * Compute the transpose of the matrix and store it in a given matrix
  84540. * @param result defines the target matrix
  84541. * @returns the current matrix
  84542. */
  84543. transposeToRef(result: Matrix): Matrix;
  84544. /**
  84545. * Sets the index-th row of the current matrix with the given 4 x float values
  84546. * @param index defines the row index
  84547. * @param x defines the x component to set
  84548. * @param y defines the y component to set
  84549. * @param z defines the z component to set
  84550. * @param w defines the w component to set
  84551. * @returns the updated current matrix
  84552. */
  84553. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84554. /**
  84555. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84556. * @param scale defines the scale factor
  84557. * @returns a new matrix
  84558. */
  84559. scale(scale: number): Matrix;
  84560. /**
  84561. * Scale the current matrix values by a factor to a given result matrix
  84562. * @param scale defines the scale factor
  84563. * @param result defines the matrix to store the result
  84564. * @returns the current matrix
  84565. */
  84566. scaleToRef(scale: number, result: Matrix): Matrix;
  84567. /**
  84568. * Scale the current matrix values by a factor and add the result to a given matrix
  84569. * @param scale defines the scale factor
  84570. * @param result defines the Matrix to store the result
  84571. * @returns the current matrix
  84572. */
  84573. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84574. /**
  84575. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84576. * @param ref matrix to store the result
  84577. */
  84578. toNormalMatrix(ref: Matrix): void;
  84579. /**
  84580. * Gets only rotation part of the current matrix
  84581. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84582. */
  84583. getRotationMatrix(): Matrix;
  84584. /**
  84585. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84586. * @param result defines the target matrix to store data to
  84587. * @returns the current matrix
  84588. */
  84589. getRotationMatrixToRef(result: Matrix): Matrix;
  84590. /**
  84591. * Toggles model matrix from being right handed to left handed in place and vice versa
  84592. */
  84593. toggleModelMatrixHandInPlace(): void;
  84594. /**
  84595. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84596. */
  84597. toggleProjectionMatrixHandInPlace(): void;
  84598. /**
  84599. * Creates a matrix from an array
  84600. * @param array defines the source array
  84601. * @param offset defines an offset in the source array
  84602. * @returns a new Matrix set from the starting index of the given array
  84603. */
  84604. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84605. /**
  84606. * Copy the content of an array into a given matrix
  84607. * @param array defines the source array
  84608. * @param offset defines an offset in the source array
  84609. * @param result defines the target matrix
  84610. */
  84611. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84612. /**
  84613. * Stores an array into a matrix after having multiplied each component by a given factor
  84614. * @param array defines the source array
  84615. * @param offset defines the offset in the source array
  84616. * @param scale defines the scaling factor
  84617. * @param result defines the target matrix
  84618. */
  84619. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84620. /**
  84621. * Gets an identity matrix that must not be updated
  84622. */
  84623. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84624. /**
  84625. * Stores a list of values (16) inside a given matrix
  84626. * @param initialM11 defines 1st value of 1st row
  84627. * @param initialM12 defines 2nd value of 1st row
  84628. * @param initialM13 defines 3rd value of 1st row
  84629. * @param initialM14 defines 4th value of 1st row
  84630. * @param initialM21 defines 1st value of 2nd row
  84631. * @param initialM22 defines 2nd value of 2nd row
  84632. * @param initialM23 defines 3rd value of 2nd row
  84633. * @param initialM24 defines 4th value of 2nd row
  84634. * @param initialM31 defines 1st value of 3rd row
  84635. * @param initialM32 defines 2nd value of 3rd row
  84636. * @param initialM33 defines 3rd value of 3rd row
  84637. * @param initialM34 defines 4th value of 3rd row
  84638. * @param initialM41 defines 1st value of 4th row
  84639. * @param initialM42 defines 2nd value of 4th row
  84640. * @param initialM43 defines 3rd value of 4th row
  84641. * @param initialM44 defines 4th value of 4th row
  84642. * @param result defines the target matrix
  84643. */
  84644. 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;
  84645. /**
  84646. * Creates new matrix from a list of values (16)
  84647. * @param initialM11 defines 1st value of 1st row
  84648. * @param initialM12 defines 2nd value of 1st row
  84649. * @param initialM13 defines 3rd value of 1st row
  84650. * @param initialM14 defines 4th value of 1st row
  84651. * @param initialM21 defines 1st value of 2nd row
  84652. * @param initialM22 defines 2nd value of 2nd row
  84653. * @param initialM23 defines 3rd value of 2nd row
  84654. * @param initialM24 defines 4th value of 2nd row
  84655. * @param initialM31 defines 1st value of 3rd row
  84656. * @param initialM32 defines 2nd value of 3rd row
  84657. * @param initialM33 defines 3rd value of 3rd row
  84658. * @param initialM34 defines 4th value of 3rd row
  84659. * @param initialM41 defines 1st value of 4th row
  84660. * @param initialM42 defines 2nd value of 4th row
  84661. * @param initialM43 defines 3rd value of 4th row
  84662. * @param initialM44 defines 4th value of 4th row
  84663. * @returns the new matrix
  84664. */
  84665. 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;
  84666. /**
  84667. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84668. * @param scale defines the scale vector3
  84669. * @param rotation defines the rotation quaternion
  84670. * @param translation defines the translation vector3
  84671. * @returns a new matrix
  84672. */
  84673. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84674. /**
  84675. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84676. * @param scale defines the scale vector3
  84677. * @param rotation defines the rotation quaternion
  84678. * @param translation defines the translation vector3
  84679. * @param result defines the target matrix
  84680. */
  84681. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84682. /**
  84683. * Creates a new identity matrix
  84684. * @returns a new identity matrix
  84685. */
  84686. static Identity(): Matrix;
  84687. /**
  84688. * Creates a new identity matrix and stores the result in a given matrix
  84689. * @param result defines the target matrix
  84690. */
  84691. static IdentityToRef(result: Matrix): void;
  84692. /**
  84693. * Creates a new zero matrix
  84694. * @returns a new zero matrix
  84695. */
  84696. static Zero(): Matrix;
  84697. /**
  84698. * Creates a new rotation matrix for "angle" radians around the X axis
  84699. * @param angle defines the angle (in radians) to use
  84700. * @return the new matrix
  84701. */
  84702. static RotationX(angle: number): Matrix;
  84703. /**
  84704. * Creates a new matrix as the invert of a given matrix
  84705. * @param source defines the source matrix
  84706. * @returns the new matrix
  84707. */
  84708. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84709. /**
  84710. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84711. * @param angle defines the angle (in radians) to use
  84712. * @param result defines the target matrix
  84713. */
  84714. static RotationXToRef(angle: number, result: Matrix): void;
  84715. /**
  84716. * Creates a new rotation matrix for "angle" radians around the Y axis
  84717. * @param angle defines the angle (in radians) to use
  84718. * @return the new matrix
  84719. */
  84720. static RotationY(angle: number): Matrix;
  84721. /**
  84722. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84723. * @param angle defines the angle (in radians) to use
  84724. * @param result defines the target matrix
  84725. */
  84726. static RotationYToRef(angle: number, result: Matrix): void;
  84727. /**
  84728. * Creates a new rotation matrix for "angle" radians around the Z axis
  84729. * @param angle defines the angle (in radians) to use
  84730. * @return the new matrix
  84731. */
  84732. static RotationZ(angle: number): Matrix;
  84733. /**
  84734. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84735. * @param angle defines the angle (in radians) to use
  84736. * @param result defines the target matrix
  84737. */
  84738. static RotationZToRef(angle: number, result: Matrix): void;
  84739. /**
  84740. * Creates a new rotation matrix for "angle" radians around the given axis
  84741. * @param axis defines the axis to use
  84742. * @param angle defines the angle (in radians) to use
  84743. * @return the new matrix
  84744. */
  84745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84746. /**
  84747. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84748. * @param axis defines the axis to use
  84749. * @param angle defines the angle (in radians) to use
  84750. * @param result defines the target matrix
  84751. */
  84752. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84753. /**
  84754. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84755. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84756. * @param from defines the vector to align
  84757. * @param to defines the vector to align to
  84758. * @param result defines the target matrix
  84759. */
  84760. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84761. /**
  84762. * Creates a rotation matrix
  84763. * @param yaw defines the yaw angle in radians (Y axis)
  84764. * @param pitch defines the pitch angle in radians (X axis)
  84765. * @param roll defines the roll angle in radians (Z axis)
  84766. * @returns the new rotation matrix
  84767. */
  84768. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  84769. /**
  84770. * Creates a rotation matrix and stores it in a given matrix
  84771. * @param yaw defines the yaw angle in radians (Y axis)
  84772. * @param pitch defines the pitch angle in radians (X axis)
  84773. * @param roll defines the roll angle in radians (Z axis)
  84774. * @param result defines the target matrix
  84775. */
  84776. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  84777. /**
  84778. * Creates a scaling matrix
  84779. * @param x defines the scale factor on X axis
  84780. * @param y defines the scale factor on Y axis
  84781. * @param z defines the scale factor on Z axis
  84782. * @returns the new matrix
  84783. */
  84784. static Scaling(x: number, y: number, z: number): Matrix;
  84785. /**
  84786. * Creates a scaling matrix and stores it in a given matrix
  84787. * @param x defines the scale factor on X axis
  84788. * @param y defines the scale factor on Y axis
  84789. * @param z defines the scale factor on Z axis
  84790. * @param result defines the target matrix
  84791. */
  84792. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  84793. /**
  84794. * Creates a translation matrix
  84795. * @param x defines the translation on X axis
  84796. * @param y defines the translation on Y axis
  84797. * @param z defines the translationon Z axis
  84798. * @returns the new matrix
  84799. */
  84800. static Translation(x: number, y: number, z: number): Matrix;
  84801. /**
  84802. * Creates a translation matrix and stores it in a given matrix
  84803. * @param x defines the translation on X axis
  84804. * @param y defines the translation on Y axis
  84805. * @param z defines the translationon Z axis
  84806. * @param result defines the target matrix
  84807. */
  84808. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  84809. /**
  84810. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84811. * @param startValue defines the start value
  84812. * @param endValue defines the end value
  84813. * @param gradient defines the gradient factor
  84814. * @returns the new matrix
  84815. */
  84816. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84817. /**
  84818. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  84819. * @param startValue defines the start value
  84820. * @param endValue defines the end value
  84821. * @param gradient defines the gradient factor
  84822. * @param result defines the Matrix object where to store data
  84823. */
  84824. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84825. /**
  84826. * Builds a new matrix whose values are computed by:
  84827. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84828. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84829. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84830. * @param startValue defines the first matrix
  84831. * @param endValue defines the second matrix
  84832. * @param gradient defines the gradient between the two matrices
  84833. * @returns the new matrix
  84834. */
  84835. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  84836. /**
  84837. * Update a matrix to values which are computed by:
  84838. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  84839. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  84840. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  84841. * @param startValue defines the first matrix
  84842. * @param endValue defines the second matrix
  84843. * @param gradient defines the gradient between the two matrices
  84844. * @param result defines the target matrix
  84845. */
  84846. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  84847. /**
  84848. * 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"
  84849. * This function works in left handed mode
  84850. * @param eye defines the final position of the entity
  84851. * @param target defines where the entity should look at
  84852. * @param up defines the up vector for the entity
  84853. * @returns the new matrix
  84854. */
  84855. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84856. /**
  84857. * 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".
  84858. * This function works in left handed mode
  84859. * @param eye defines the final position of the entity
  84860. * @param target defines where the entity should look at
  84861. * @param up defines the up vector for the entity
  84862. * @param result defines the target matrix
  84863. */
  84864. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84865. /**
  84866. * 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"
  84867. * This function works in right handed mode
  84868. * @param eye defines the final position of the entity
  84869. * @param target defines where the entity should look at
  84870. * @param up defines the up vector for the entity
  84871. * @returns the new matrix
  84872. */
  84873. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  84874. /**
  84875. * 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".
  84876. * This function works in right handed mode
  84877. * @param eye defines the final position of the entity
  84878. * @param target defines where the entity should look at
  84879. * @param up defines the up vector for the entity
  84880. * @param result defines the target matrix
  84881. */
  84882. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  84883. /**
  84884. * Create a left-handed orthographic projection matrix
  84885. * @param width defines the viewport width
  84886. * @param height defines the viewport height
  84887. * @param znear defines the near clip plane
  84888. * @param zfar defines the far clip plane
  84889. * @returns a new matrix as a left-handed orthographic projection matrix
  84890. */
  84891. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84892. /**
  84893. * Store a left-handed orthographic projection to a given matrix
  84894. * @param width defines the viewport width
  84895. * @param height defines the viewport height
  84896. * @param znear defines the near clip plane
  84897. * @param zfar defines the far clip plane
  84898. * @param result defines the target matrix
  84899. */
  84900. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  84901. /**
  84902. * Create a left-handed orthographic projection matrix
  84903. * @param left defines the viewport left coordinate
  84904. * @param right defines the viewport right coordinate
  84905. * @param bottom defines the viewport bottom coordinate
  84906. * @param top defines the viewport top coordinate
  84907. * @param znear defines the near clip plane
  84908. * @param zfar defines the far clip plane
  84909. * @returns a new matrix as a left-handed orthographic projection matrix
  84910. */
  84911. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84912. /**
  84913. * Stores a left-handed orthographic projection into a given matrix
  84914. * @param left defines the viewport left coordinate
  84915. * @param right defines the viewport right coordinate
  84916. * @param bottom defines the viewport bottom coordinate
  84917. * @param top defines the viewport top coordinate
  84918. * @param znear defines the near clip plane
  84919. * @param zfar defines the far clip plane
  84920. * @param result defines the target matrix
  84921. */
  84922. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84923. /**
  84924. * Creates a right-handed orthographic projection matrix
  84925. * @param left defines the viewport left coordinate
  84926. * @param right defines the viewport right coordinate
  84927. * @param bottom defines the viewport bottom coordinate
  84928. * @param top defines the viewport top coordinate
  84929. * @param znear defines the near clip plane
  84930. * @param zfar defines the far clip plane
  84931. * @returns a new matrix as a right-handed orthographic projection matrix
  84932. */
  84933. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  84934. /**
  84935. * Stores a right-handed orthographic projection into a given matrix
  84936. * @param left defines the viewport left coordinate
  84937. * @param right defines the viewport right coordinate
  84938. * @param bottom defines the viewport bottom coordinate
  84939. * @param top defines the viewport top coordinate
  84940. * @param znear defines the near clip plane
  84941. * @param zfar defines the far clip plane
  84942. * @param result defines the target matrix
  84943. */
  84944. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  84945. /**
  84946. * Creates a left-handed perspective projection matrix
  84947. * @param width defines the viewport width
  84948. * @param height defines the viewport height
  84949. * @param znear defines the near clip plane
  84950. * @param zfar defines the far clip plane
  84951. * @returns a new matrix as a left-handed perspective projection matrix
  84952. */
  84953. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  84954. /**
  84955. * Creates a left-handed perspective projection matrix
  84956. * @param fov defines the horizontal field of view
  84957. * @param aspect defines the aspect ratio
  84958. * @param znear defines the near clip plane
  84959. * @param zfar defines the far clip plane
  84960. * @returns a new matrix as a left-handed perspective projection matrix
  84961. */
  84962. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84963. /**
  84964. * Stores a left-handed perspective projection into a given matrix
  84965. * @param fov defines the horizontal field of view
  84966. * @param aspect defines the aspect ratio
  84967. * @param znear defines the near clip plane
  84968. * @param zfar defines the far clip plane
  84969. * @param result defines the target matrix
  84970. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84971. */
  84972. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84973. /**
  84974. * Stores a left-handed perspective projection into a given matrix with depth reversed
  84975. * @param fov defines the horizontal field of view
  84976. * @param aspect defines the aspect ratio
  84977. * @param znear defines the near clip plane
  84978. * @param zfar not used as infinity is used as far clip
  84979. * @param result defines the target matrix
  84980. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  84981. */
  84982. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  84983. /**
  84984. * Creates a right-handed perspective projection matrix
  84985. * @param fov defines the horizontal field of view
  84986. * @param aspect defines the aspect ratio
  84987. * @param znear defines the near clip plane
  84988. * @param zfar defines the far clip plane
  84989. * @returns a new matrix as a right-handed perspective projection matrix
  84990. */
  84991. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  84992. /**
  84993. * Stores a right-handed perspective projection into a given matrix
  84994. * @param fov defines the horizontal field of view
  84995. * @param aspect defines the aspect ratio
  84996. * @param znear defines the near clip plane
  84997. * @param zfar defines the far clip plane
  84998. * @param result defines the target matrix
  84999. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85000. */
  85001. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85002. /**
  85003. * Stores a right-handed perspective projection into a given matrix
  85004. * @param fov defines the horizontal field of view
  85005. * @param aspect defines the aspect ratio
  85006. * @param znear defines the near clip plane
  85007. * @param zfar not used as infinity is used as far clip
  85008. * @param result defines the target matrix
  85009. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85010. */
  85011. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85012. /**
  85013. * Stores a perspective projection for WebVR info a given matrix
  85014. * @param fov defines the field of view
  85015. * @param znear defines the near clip plane
  85016. * @param zfar defines the far clip plane
  85017. * @param result defines the target matrix
  85018. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85019. */
  85020. static PerspectiveFovWebVRToRef(fov: {
  85021. upDegrees: number;
  85022. downDegrees: number;
  85023. leftDegrees: number;
  85024. rightDegrees: number;
  85025. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85026. /**
  85027. * Computes a complete transformation matrix
  85028. * @param viewport defines the viewport to use
  85029. * @param world defines the world matrix
  85030. * @param view defines the view matrix
  85031. * @param projection defines the projection matrix
  85032. * @param zmin defines the near clip plane
  85033. * @param zmax defines the far clip plane
  85034. * @returns the transformation matrix
  85035. */
  85036. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85037. /**
  85038. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85039. * @param matrix defines the matrix to use
  85040. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85041. */
  85042. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85043. /**
  85044. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85045. * @param matrix defines the matrix to use
  85046. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85047. */
  85048. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85049. /**
  85050. * Compute the transpose of a given matrix
  85051. * @param matrix defines the matrix to transpose
  85052. * @returns the new matrix
  85053. */
  85054. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85055. /**
  85056. * Compute the transpose of a matrix and store it in a target matrix
  85057. * @param matrix defines the matrix to transpose
  85058. * @param result defines the target matrix
  85059. */
  85060. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85061. /**
  85062. * Computes a reflection matrix from a plane
  85063. * @param plane defines the reflection plane
  85064. * @returns a new matrix
  85065. */
  85066. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85067. /**
  85068. * Computes a reflection matrix from a plane
  85069. * @param plane defines the reflection plane
  85070. * @param result defines the target matrix
  85071. */
  85072. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85073. /**
  85074. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85075. * @param xaxis defines the value of the 1st axis
  85076. * @param yaxis defines the value of the 2nd axis
  85077. * @param zaxis defines the value of the 3rd axis
  85078. * @param result defines the target matrix
  85079. */
  85080. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85081. /**
  85082. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85083. * @param quat defines the quaternion to use
  85084. * @param result defines the target matrix
  85085. */
  85086. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85087. }
  85088. /**
  85089. * @hidden
  85090. */
  85091. export class TmpVectors {
  85092. static Vector2: Vector2[];
  85093. static Vector3: Vector3[];
  85094. static Vector4: Vector4[];
  85095. static Quaternion: Quaternion[];
  85096. static Matrix: Matrix[];
  85097. }
  85098. }
  85099. declare module BABYLON {
  85100. /**
  85101. * Defines potential orientation for back face culling
  85102. */
  85103. export enum Orientation {
  85104. /**
  85105. * Clockwise
  85106. */
  85107. CW = 0,
  85108. /** Counter clockwise */
  85109. CCW = 1
  85110. }
  85111. /** Class used to represent a Bezier curve */
  85112. export class BezierCurve {
  85113. /**
  85114. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85115. * @param t defines the time
  85116. * @param x1 defines the left coordinate on X axis
  85117. * @param y1 defines the left coordinate on Y axis
  85118. * @param x2 defines the right coordinate on X axis
  85119. * @param y2 defines the right coordinate on Y axis
  85120. * @returns the interpolated value
  85121. */
  85122. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85123. }
  85124. /**
  85125. * Defines angle representation
  85126. */
  85127. export class Angle {
  85128. private _radians;
  85129. /**
  85130. * Creates an Angle object of "radians" radians (float).
  85131. * @param radians the angle in radians
  85132. */
  85133. constructor(radians: number);
  85134. /**
  85135. * Get value in degrees
  85136. * @returns the Angle value in degrees (float)
  85137. */
  85138. degrees(): number;
  85139. /**
  85140. * Get value in radians
  85141. * @returns the Angle value in radians (float)
  85142. */
  85143. radians(): number;
  85144. /**
  85145. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85146. * @param a defines first point as the origin
  85147. * @param b defines point
  85148. * @returns a new Angle
  85149. */
  85150. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85151. /**
  85152. * Gets a new Angle object from the given float in radians
  85153. * @param radians defines the angle value in radians
  85154. * @returns a new Angle
  85155. */
  85156. static FromRadians(radians: number): Angle;
  85157. /**
  85158. * Gets a new Angle object from the given float in degrees
  85159. * @param degrees defines the angle value in degrees
  85160. * @returns a new Angle
  85161. */
  85162. static FromDegrees(degrees: number): Angle;
  85163. }
  85164. /**
  85165. * This represents an arc in a 2d space.
  85166. */
  85167. export class Arc2 {
  85168. /** Defines the start point of the arc */
  85169. startPoint: Vector2;
  85170. /** Defines the mid point of the arc */
  85171. midPoint: Vector2;
  85172. /** Defines the end point of the arc */
  85173. endPoint: Vector2;
  85174. /**
  85175. * Defines the center point of the arc.
  85176. */
  85177. centerPoint: Vector2;
  85178. /**
  85179. * Defines the radius of the arc.
  85180. */
  85181. radius: number;
  85182. /**
  85183. * Defines the angle of the arc (from mid point to end point).
  85184. */
  85185. angle: Angle;
  85186. /**
  85187. * Defines the start angle of the arc (from start point to middle point).
  85188. */
  85189. startAngle: Angle;
  85190. /**
  85191. * Defines the orientation of the arc (clock wise/counter clock wise).
  85192. */
  85193. orientation: Orientation;
  85194. /**
  85195. * Creates an Arc object from the three given points : start, middle and end.
  85196. * @param startPoint Defines the start point of the arc
  85197. * @param midPoint Defines the midlle point of the arc
  85198. * @param endPoint Defines the end point of the arc
  85199. */
  85200. constructor(
  85201. /** Defines the start point of the arc */
  85202. startPoint: Vector2,
  85203. /** Defines the mid point of the arc */
  85204. midPoint: Vector2,
  85205. /** Defines the end point of the arc */
  85206. endPoint: Vector2);
  85207. }
  85208. /**
  85209. * Represents a 2D path made up of multiple 2D points
  85210. */
  85211. export class Path2 {
  85212. private _points;
  85213. private _length;
  85214. /**
  85215. * If the path start and end point are the same
  85216. */
  85217. closed: boolean;
  85218. /**
  85219. * Creates a Path2 object from the starting 2D coordinates x and y.
  85220. * @param x the starting points x value
  85221. * @param y the starting points y value
  85222. */
  85223. constructor(x: number, y: number);
  85224. /**
  85225. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85226. * @param x the added points x value
  85227. * @param y the added points y value
  85228. * @returns the updated Path2.
  85229. */
  85230. addLineTo(x: number, y: number): Path2;
  85231. /**
  85232. * 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.
  85233. * @param midX middle point x value
  85234. * @param midY middle point y value
  85235. * @param endX end point x value
  85236. * @param endY end point y value
  85237. * @param numberOfSegments (default: 36)
  85238. * @returns the updated Path2.
  85239. */
  85240. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85241. /**
  85242. * Closes the Path2.
  85243. * @returns the Path2.
  85244. */
  85245. close(): Path2;
  85246. /**
  85247. * Gets the sum of the distance between each sequential point in the path
  85248. * @returns the Path2 total length (float).
  85249. */
  85250. length(): number;
  85251. /**
  85252. * Gets the points which construct the path
  85253. * @returns the Path2 internal array of points.
  85254. */
  85255. getPoints(): Vector2[];
  85256. /**
  85257. * Retreives the point at the distance aways from the starting point
  85258. * @param normalizedLengthPosition the length along the path to retreive the point from
  85259. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85260. */
  85261. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85262. /**
  85263. * Creates a new path starting from an x and y position
  85264. * @param x starting x value
  85265. * @param y starting y value
  85266. * @returns a new Path2 starting at the coordinates (x, y).
  85267. */
  85268. static StartingAt(x: number, y: number): Path2;
  85269. }
  85270. /**
  85271. * Represents a 3D path made up of multiple 3D points
  85272. */
  85273. export class Path3D {
  85274. /**
  85275. * an array of Vector3, the curve axis of the Path3D
  85276. */
  85277. path: Vector3[];
  85278. private _curve;
  85279. private _distances;
  85280. private _tangents;
  85281. private _normals;
  85282. private _binormals;
  85283. private _raw;
  85284. private _alignTangentsWithPath;
  85285. private readonly _pointAtData;
  85286. /**
  85287. * new Path3D(path, normal, raw)
  85288. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85289. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85290. * @param path an array of Vector3, the curve axis of the Path3D
  85291. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85292. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85293. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85294. */
  85295. constructor(
  85296. /**
  85297. * an array of Vector3, the curve axis of the Path3D
  85298. */
  85299. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85300. /**
  85301. * Returns the Path3D array of successive Vector3 designing its curve.
  85302. * @returns the Path3D array of successive Vector3 designing its curve.
  85303. */
  85304. getCurve(): Vector3[];
  85305. /**
  85306. * Returns the Path3D array of successive Vector3 designing its curve.
  85307. * @returns the Path3D array of successive Vector3 designing its curve.
  85308. */
  85309. getPoints(): Vector3[];
  85310. /**
  85311. * @returns the computed length (float) of the path.
  85312. */
  85313. length(): number;
  85314. /**
  85315. * Returns an array populated with tangent vectors on each Path3D curve point.
  85316. * @returns an array populated with tangent vectors on each Path3D curve point.
  85317. */
  85318. getTangents(): Vector3[];
  85319. /**
  85320. * Returns an array populated with normal vectors on each Path3D curve point.
  85321. * @returns an array populated with normal vectors on each Path3D curve point.
  85322. */
  85323. getNormals(): Vector3[];
  85324. /**
  85325. * Returns an array populated with binormal vectors on each Path3D curve point.
  85326. * @returns an array populated with binormal vectors on each Path3D curve point.
  85327. */
  85328. getBinormals(): Vector3[];
  85329. /**
  85330. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85331. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85332. */
  85333. getDistances(): number[];
  85334. /**
  85335. * Returns an interpolated point along this path
  85336. * @param position the position of the point along this path, from 0.0 to 1.0
  85337. * @returns a new Vector3 as the point
  85338. */
  85339. getPointAt(position: number): Vector3;
  85340. /**
  85341. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85342. * @param position the position of the point along this path, from 0.0 to 1.0
  85343. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85344. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85345. */
  85346. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85347. /**
  85348. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85349. * @param position the position of the point along this path, from 0.0 to 1.0
  85350. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85351. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85352. */
  85353. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85354. /**
  85355. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85356. * @param position the position of the point along this path, from 0.0 to 1.0
  85357. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85358. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85359. */
  85360. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85361. /**
  85362. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85363. * @param position the position of the point along this path, from 0.0 to 1.0
  85364. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85365. */
  85366. getDistanceAt(position: number): number;
  85367. /**
  85368. * Returns the array index of the previous point of an interpolated point along this path
  85369. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85370. * @returns the array index
  85371. */
  85372. getPreviousPointIndexAt(position: number): number;
  85373. /**
  85374. * 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)
  85375. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85376. * @returns the sub position
  85377. */
  85378. getSubPositionAt(position: number): number;
  85379. /**
  85380. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85381. * @param target the vector of which to get the closest position to
  85382. * @returns the position of the closest virtual point on this path to the target vector
  85383. */
  85384. getClosestPositionTo(target: Vector3): number;
  85385. /**
  85386. * Returns a sub path (slice) of this path
  85387. * @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
  85388. * @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
  85389. * @returns a sub path (slice) of this path
  85390. */
  85391. slice(start?: number, end?: number): Path3D;
  85392. /**
  85393. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85394. * @param path path which all values are copied into the curves points
  85395. * @param firstNormal which should be projected onto the curve
  85396. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85397. * @returns the same object updated.
  85398. */
  85399. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85400. private _compute;
  85401. private _getFirstNonNullVector;
  85402. private _getLastNonNullVector;
  85403. private _normalVector;
  85404. /**
  85405. * Updates the point at data for an interpolated point along this curve
  85406. * @param position the position of the point along this curve, from 0.0 to 1.0
  85407. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85408. * @returns the (updated) point at data
  85409. */
  85410. private _updatePointAtData;
  85411. /**
  85412. * Updates the point at data from the specified parameters
  85413. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85414. * @param point the interpolated point
  85415. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85416. */
  85417. private _setPointAtData;
  85418. /**
  85419. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85420. */
  85421. private _updateInterpolationMatrix;
  85422. }
  85423. /**
  85424. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85425. * A Curve3 is designed from a series of successive Vector3.
  85426. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85427. */
  85428. export class Curve3 {
  85429. private _points;
  85430. private _length;
  85431. /**
  85432. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85433. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85434. * @param v1 (Vector3) the control point
  85435. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85436. * @param nbPoints (integer) the wanted number of points in the curve
  85437. * @returns the created Curve3
  85438. */
  85439. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85440. /**
  85441. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85442. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85443. * @param v1 (Vector3) the first control point
  85444. * @param v2 (Vector3) the second control point
  85445. * @param v3 (Vector3) the end point of the Cubic Bezier
  85446. * @param nbPoints (integer) the wanted number of points in the curve
  85447. * @returns the created Curve3
  85448. */
  85449. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85450. /**
  85451. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85452. * @param p1 (Vector3) the origin point of the Hermite Spline
  85453. * @param t1 (Vector3) the tangent vector at the origin point
  85454. * @param p2 (Vector3) the end point of the Hermite Spline
  85455. * @param t2 (Vector3) the tangent vector at the end point
  85456. * @param nbPoints (integer) the wanted number of points in the curve
  85457. * @returns the created Curve3
  85458. */
  85459. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85460. /**
  85461. * Returns a Curve3 object along a CatmullRom Spline curve :
  85462. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85463. * @param nbPoints (integer) the wanted number of points between each curve control points
  85464. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85465. * @returns the created Curve3
  85466. */
  85467. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85468. /**
  85469. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85470. * A Curve3 is designed from a series of successive Vector3.
  85471. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85472. * @param points points which make up the curve
  85473. */
  85474. constructor(points: Vector3[]);
  85475. /**
  85476. * @returns the Curve3 stored array of successive Vector3
  85477. */
  85478. getPoints(): Vector3[];
  85479. /**
  85480. * @returns the computed length (float) of the curve.
  85481. */
  85482. length(): number;
  85483. /**
  85484. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85485. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85486. * curveA and curveB keep unchanged.
  85487. * @param curve the curve to continue from this curve
  85488. * @returns the newly constructed curve
  85489. */
  85490. continue(curve: DeepImmutable<Curve3>): Curve3;
  85491. private _computeLength;
  85492. }
  85493. }
  85494. declare module BABYLON {
  85495. /**
  85496. * This represents the main contract an easing function should follow.
  85497. * Easing functions are used throughout the animation system.
  85498. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85499. */
  85500. export interface IEasingFunction {
  85501. /**
  85502. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85503. * of the easing function.
  85504. * The link below provides some of the most common examples of easing functions.
  85505. * @see https://easings.net/
  85506. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85507. * @returns the corresponding value on the curve defined by the easing function
  85508. */
  85509. ease(gradient: number): number;
  85510. }
  85511. /**
  85512. * Base class used for every default easing function.
  85513. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85514. */
  85515. export class EasingFunction implements IEasingFunction {
  85516. /**
  85517. * Interpolation follows the mathematical formula associated with the easing function.
  85518. */
  85519. static readonly EASINGMODE_EASEIN: number;
  85520. /**
  85521. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85522. */
  85523. static readonly EASINGMODE_EASEOUT: number;
  85524. /**
  85525. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85526. */
  85527. static readonly EASINGMODE_EASEINOUT: number;
  85528. private _easingMode;
  85529. /**
  85530. * Sets the easing mode of the current function.
  85531. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85532. */
  85533. setEasingMode(easingMode: number): void;
  85534. /**
  85535. * Gets the current easing mode.
  85536. * @returns the easing mode
  85537. */
  85538. getEasingMode(): number;
  85539. /**
  85540. * @hidden
  85541. */
  85542. easeInCore(gradient: number): number;
  85543. /**
  85544. * Given an input gradient between 0 and 1, this returns the corresponding value
  85545. * of the easing function.
  85546. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85547. * @returns the corresponding value on the curve defined by the easing function
  85548. */
  85549. ease(gradient: number): number;
  85550. }
  85551. /**
  85552. * Easing function with a circle shape (see link below).
  85553. * @see https://easings.net/#easeInCirc
  85554. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85555. */
  85556. export class CircleEase extends EasingFunction implements IEasingFunction {
  85557. /** @hidden */
  85558. easeInCore(gradient: number): number;
  85559. }
  85560. /**
  85561. * Easing function with a ease back shape (see link below).
  85562. * @see https://easings.net/#easeInBack
  85563. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85564. */
  85565. export class BackEase extends EasingFunction implements IEasingFunction {
  85566. /** Defines the amplitude of the function */
  85567. amplitude: number;
  85568. /**
  85569. * Instantiates a back ease easing
  85570. * @see https://easings.net/#easeInBack
  85571. * @param amplitude Defines the amplitude of the function
  85572. */
  85573. constructor(
  85574. /** Defines the amplitude of the function */
  85575. amplitude?: number);
  85576. /** @hidden */
  85577. easeInCore(gradient: number): number;
  85578. }
  85579. /**
  85580. * Easing function with a bouncing shape (see link below).
  85581. * @see https://easings.net/#easeInBounce
  85582. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85583. */
  85584. export class BounceEase extends EasingFunction implements IEasingFunction {
  85585. /** Defines the number of bounces */
  85586. bounces: number;
  85587. /** Defines the amplitude of the bounce */
  85588. bounciness: number;
  85589. /**
  85590. * Instantiates a bounce easing
  85591. * @see https://easings.net/#easeInBounce
  85592. * @param bounces Defines the number of bounces
  85593. * @param bounciness Defines the amplitude of the bounce
  85594. */
  85595. constructor(
  85596. /** Defines the number of bounces */
  85597. bounces?: number,
  85598. /** Defines the amplitude of the bounce */
  85599. bounciness?: number);
  85600. /** @hidden */
  85601. easeInCore(gradient: number): number;
  85602. }
  85603. /**
  85604. * Easing function with a power of 3 shape (see link below).
  85605. * @see https://easings.net/#easeInCubic
  85606. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85607. */
  85608. export class CubicEase extends EasingFunction implements IEasingFunction {
  85609. /** @hidden */
  85610. easeInCore(gradient: number): number;
  85611. }
  85612. /**
  85613. * Easing function with an elastic shape (see link below).
  85614. * @see https://easings.net/#easeInElastic
  85615. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85616. */
  85617. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85618. /** Defines the number of oscillations*/
  85619. oscillations: number;
  85620. /** Defines the amplitude of the oscillations*/
  85621. springiness: number;
  85622. /**
  85623. * Instantiates an elastic easing function
  85624. * @see https://easings.net/#easeInElastic
  85625. * @param oscillations Defines the number of oscillations
  85626. * @param springiness Defines the amplitude of the oscillations
  85627. */
  85628. constructor(
  85629. /** Defines the number of oscillations*/
  85630. oscillations?: number,
  85631. /** Defines the amplitude of the oscillations*/
  85632. springiness?: number);
  85633. /** @hidden */
  85634. easeInCore(gradient: number): number;
  85635. }
  85636. /**
  85637. * Easing function with an exponential shape (see link below).
  85638. * @see https://easings.net/#easeInExpo
  85639. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85640. */
  85641. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85642. /** Defines the exponent of the function */
  85643. exponent: number;
  85644. /**
  85645. * Instantiates an exponential easing function
  85646. * @see https://easings.net/#easeInExpo
  85647. * @param exponent Defines the exponent of the function
  85648. */
  85649. constructor(
  85650. /** Defines the exponent of the function */
  85651. exponent?: number);
  85652. /** @hidden */
  85653. easeInCore(gradient: number): number;
  85654. }
  85655. /**
  85656. * Easing function with a power shape (see link below).
  85657. * @see https://easings.net/#easeInQuad
  85658. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85659. */
  85660. export class PowerEase extends EasingFunction implements IEasingFunction {
  85661. /** Defines the power of the function */
  85662. power: number;
  85663. /**
  85664. * Instantiates an power base easing function
  85665. * @see https://easings.net/#easeInQuad
  85666. * @param power Defines the power of the function
  85667. */
  85668. constructor(
  85669. /** Defines the power of the function */
  85670. power?: number);
  85671. /** @hidden */
  85672. easeInCore(gradient: number): number;
  85673. }
  85674. /**
  85675. * Easing function with a power of 2 shape (see link below).
  85676. * @see https://easings.net/#easeInQuad
  85677. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85678. */
  85679. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85680. /** @hidden */
  85681. easeInCore(gradient: number): number;
  85682. }
  85683. /**
  85684. * Easing function with a power of 4 shape (see link below).
  85685. * @see https://easings.net/#easeInQuart
  85686. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85687. */
  85688. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85689. /** @hidden */
  85690. easeInCore(gradient: number): number;
  85691. }
  85692. /**
  85693. * Easing function with a power of 5 shape (see link below).
  85694. * @see https://easings.net/#easeInQuint
  85695. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85696. */
  85697. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85698. /** @hidden */
  85699. easeInCore(gradient: number): number;
  85700. }
  85701. /**
  85702. * Easing function with a sin shape (see link below).
  85703. * @see https://easings.net/#easeInSine
  85704. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85705. */
  85706. export class SineEase extends EasingFunction implements IEasingFunction {
  85707. /** @hidden */
  85708. easeInCore(gradient: number): number;
  85709. }
  85710. /**
  85711. * Easing function with a bezier shape (see link below).
  85712. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85713. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85714. */
  85715. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85716. /** Defines the x component of the start tangent in the bezier curve */
  85717. x1: number;
  85718. /** Defines the y component of the start tangent in the bezier curve */
  85719. y1: number;
  85720. /** Defines the x component of the end tangent in the bezier curve */
  85721. x2: number;
  85722. /** Defines the y component of the end tangent in the bezier curve */
  85723. y2: number;
  85724. /**
  85725. * Instantiates a bezier function
  85726. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85727. * @param x1 Defines the x component of the start tangent in the bezier curve
  85728. * @param y1 Defines the y component of the start tangent in the bezier curve
  85729. * @param x2 Defines the x component of the end tangent in the bezier curve
  85730. * @param y2 Defines the y component of the end tangent in the bezier curve
  85731. */
  85732. constructor(
  85733. /** Defines the x component of the start tangent in the bezier curve */
  85734. x1?: number,
  85735. /** Defines the y component of the start tangent in the bezier curve */
  85736. y1?: number,
  85737. /** Defines the x component of the end tangent in the bezier curve */
  85738. x2?: number,
  85739. /** Defines the y component of the end tangent in the bezier curve */
  85740. y2?: number);
  85741. /** @hidden */
  85742. easeInCore(gradient: number): number;
  85743. }
  85744. }
  85745. declare module BABYLON {
  85746. /**
  85747. * Class used to hold a RBG color
  85748. */
  85749. export class Color3 {
  85750. /**
  85751. * Defines the red component (between 0 and 1, default is 0)
  85752. */
  85753. r: number;
  85754. /**
  85755. * Defines the green component (between 0 and 1, default is 0)
  85756. */
  85757. g: number;
  85758. /**
  85759. * Defines the blue component (between 0 and 1, default is 0)
  85760. */
  85761. b: number;
  85762. /**
  85763. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  85764. * @param r defines the red component (between 0 and 1, default is 0)
  85765. * @param g defines the green component (between 0 and 1, default is 0)
  85766. * @param b defines the blue component (between 0 and 1, default is 0)
  85767. */
  85768. constructor(
  85769. /**
  85770. * Defines the red component (between 0 and 1, default is 0)
  85771. */
  85772. r?: number,
  85773. /**
  85774. * Defines the green component (between 0 and 1, default is 0)
  85775. */
  85776. g?: number,
  85777. /**
  85778. * Defines the blue component (between 0 and 1, default is 0)
  85779. */
  85780. b?: number);
  85781. /**
  85782. * Creates a string with the Color3 current values
  85783. * @returns the string representation of the Color3 object
  85784. */
  85785. toString(): string;
  85786. /**
  85787. * Returns the string "Color3"
  85788. * @returns "Color3"
  85789. */
  85790. getClassName(): string;
  85791. /**
  85792. * Compute the Color3 hash code
  85793. * @returns an unique number that can be used to hash Color3 objects
  85794. */
  85795. getHashCode(): number;
  85796. /**
  85797. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  85798. * @param array defines the array where to store the r,g,b components
  85799. * @param index defines an optional index in the target array to define where to start storing values
  85800. * @returns the current Color3 object
  85801. */
  85802. toArray(array: FloatArray, index?: number): Color3;
  85803. /**
  85804. * Update the current color with values stored in an array from the starting index of the given array
  85805. * @param array defines the source array
  85806. * @param offset defines an offset in the source array
  85807. * @returns the current Color3 object
  85808. */
  85809. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85810. /**
  85811. * Returns a new Color4 object from the current Color3 and the given alpha
  85812. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  85813. * @returns a new Color4 object
  85814. */
  85815. toColor4(alpha?: number): Color4;
  85816. /**
  85817. * Returns a new array populated with 3 numeric elements : red, green and blue values
  85818. * @returns the new array
  85819. */
  85820. asArray(): number[];
  85821. /**
  85822. * Returns the luminance value
  85823. * @returns a float value
  85824. */
  85825. toLuminance(): number;
  85826. /**
  85827. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  85828. * @param otherColor defines the second operand
  85829. * @returns the new Color3 object
  85830. */
  85831. multiply(otherColor: DeepImmutable<Color3>): Color3;
  85832. /**
  85833. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  85834. * @param otherColor defines the second operand
  85835. * @param result defines the Color3 object where to store the result
  85836. * @returns the current Color3
  85837. */
  85838. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85839. /**
  85840. * Determines equality between Color3 objects
  85841. * @param otherColor defines the second operand
  85842. * @returns true if the rgb values are equal to the given ones
  85843. */
  85844. equals(otherColor: DeepImmutable<Color3>): boolean;
  85845. /**
  85846. * Determines equality between the current Color3 object and a set of r,b,g values
  85847. * @param r defines the red component to check
  85848. * @param g defines the green component to check
  85849. * @param b defines the blue component to check
  85850. * @returns true if the rgb values are equal to the given ones
  85851. */
  85852. equalsFloats(r: number, g: number, b: number): boolean;
  85853. /**
  85854. * Multiplies in place each rgb value by scale
  85855. * @param scale defines the scaling factor
  85856. * @returns the updated Color3
  85857. */
  85858. scale(scale: number): Color3;
  85859. /**
  85860. * Multiplies the rgb values by scale and stores the result into "result"
  85861. * @param scale defines the scaling factor
  85862. * @param result defines the Color3 object where to store the result
  85863. * @returns the unmodified current Color3
  85864. */
  85865. scaleToRef(scale: number, result: Color3): Color3;
  85866. /**
  85867. * Scale the current Color3 values by a factor and add the result to a given Color3
  85868. * @param scale defines the scale factor
  85869. * @param result defines color to store the result into
  85870. * @returns the unmodified current Color3
  85871. */
  85872. scaleAndAddToRef(scale: number, result: Color3): Color3;
  85873. /**
  85874. * Clamps the rgb values by the min and max values and stores the result into "result"
  85875. * @param min defines minimum clamping value (default is 0)
  85876. * @param max defines maximum clamping value (default is 1)
  85877. * @param result defines color to store the result into
  85878. * @returns the original Color3
  85879. */
  85880. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  85881. /**
  85882. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  85883. * @param otherColor defines the second operand
  85884. * @returns the new Color3
  85885. */
  85886. add(otherColor: DeepImmutable<Color3>): Color3;
  85887. /**
  85888. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  85889. * @param otherColor defines the second operand
  85890. * @param result defines Color3 object to store the result into
  85891. * @returns the unmodified current Color3
  85892. */
  85893. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85894. /**
  85895. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  85896. * @param otherColor defines the second operand
  85897. * @returns the new Color3
  85898. */
  85899. subtract(otherColor: DeepImmutable<Color3>): Color3;
  85900. /**
  85901. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  85902. * @param otherColor defines the second operand
  85903. * @param result defines Color3 object to store the result into
  85904. * @returns the unmodified current Color3
  85905. */
  85906. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  85907. /**
  85908. * Copy the current object
  85909. * @returns a new Color3 copied the current one
  85910. */
  85911. clone(): Color3;
  85912. /**
  85913. * Copies the rgb values from the source in the current Color3
  85914. * @param source defines the source Color3 object
  85915. * @returns the updated Color3 object
  85916. */
  85917. copyFrom(source: DeepImmutable<Color3>): Color3;
  85918. /**
  85919. * Updates the Color3 rgb values from the given floats
  85920. * @param r defines the red component to read from
  85921. * @param g defines the green component to read from
  85922. * @param b defines the blue component to read from
  85923. * @returns the current Color3 object
  85924. */
  85925. copyFromFloats(r: number, g: number, b: number): Color3;
  85926. /**
  85927. * Updates the Color3 rgb values from the given floats
  85928. * @param r defines the red component to read from
  85929. * @param g defines the green component to read from
  85930. * @param b defines the blue component to read from
  85931. * @returns the current Color3 object
  85932. */
  85933. set(r: number, g: number, b: number): Color3;
  85934. /**
  85935. * Compute the Color3 hexadecimal code as a string
  85936. * @returns a string containing the hexadecimal representation of the Color3 object
  85937. */
  85938. toHexString(): string;
  85939. /**
  85940. * Computes a new Color3 converted from the current one to linear space
  85941. * @returns a new Color3 object
  85942. */
  85943. toLinearSpace(): Color3;
  85944. /**
  85945. * Converts current color in rgb space to HSV values
  85946. * @returns a new color3 representing the HSV values
  85947. */
  85948. toHSV(): Color3;
  85949. /**
  85950. * Converts current color in rgb space to HSV values
  85951. * @param result defines the Color3 where to store the HSV values
  85952. */
  85953. toHSVToRef(result: Color3): void;
  85954. /**
  85955. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  85956. * @param convertedColor defines the Color3 object where to store the linear space version
  85957. * @returns the unmodified Color3
  85958. */
  85959. toLinearSpaceToRef(convertedColor: Color3): Color3;
  85960. /**
  85961. * Computes a new Color3 converted from the current one to gamma space
  85962. * @returns a new Color3 object
  85963. */
  85964. toGammaSpace(): Color3;
  85965. /**
  85966. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  85967. * @param convertedColor defines the Color3 object where to store the gamma space version
  85968. * @returns the unmodified Color3
  85969. */
  85970. toGammaSpaceToRef(convertedColor: Color3): Color3;
  85971. private static _BlackReadOnly;
  85972. /**
  85973. * Convert Hue, saturation and value to a Color3 (RGB)
  85974. * @param hue defines the hue
  85975. * @param saturation defines the saturation
  85976. * @param value defines the value
  85977. * @param result defines the Color3 where to store the RGB values
  85978. */
  85979. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  85980. /**
  85981. * Creates a new Color3 from the string containing valid hexadecimal values
  85982. * @param hex defines a string containing valid hexadecimal values
  85983. * @returns a new Color3 object
  85984. */
  85985. static FromHexString(hex: string): Color3;
  85986. /**
  85987. * Creates a new Color3 from the starting index of the given array
  85988. * @param array defines the source array
  85989. * @param offset defines an offset in the source array
  85990. * @returns a new Color3 object
  85991. */
  85992. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  85993. /**
  85994. * Creates a new Color3 from the starting index element of the given array
  85995. * @param array defines the source array to read from
  85996. * @param offset defines the offset in the source array
  85997. * @param result defines the target Color3 object
  85998. */
  85999. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86000. /**
  86001. * Creates a new Color3 from integer values (< 256)
  86002. * @param r defines the red component to read from (value between 0 and 255)
  86003. * @param g defines the green component to read from (value between 0 and 255)
  86004. * @param b defines the blue component to read from (value between 0 and 255)
  86005. * @returns a new Color3 object
  86006. */
  86007. static FromInts(r: number, g: number, b: number): Color3;
  86008. /**
  86009. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86010. * @param start defines the start Color3 value
  86011. * @param end defines the end Color3 value
  86012. * @param amount defines the gradient value between start and end
  86013. * @returns a new Color3 object
  86014. */
  86015. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86016. /**
  86017. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86018. * @param left defines the start value
  86019. * @param right defines the end value
  86020. * @param amount defines the gradient factor
  86021. * @param result defines the Color3 object where to store the result
  86022. */
  86023. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86024. /**
  86025. * Returns a Color3 value containing a red color
  86026. * @returns a new Color3 object
  86027. */
  86028. static Red(): Color3;
  86029. /**
  86030. * Returns a Color3 value containing a green color
  86031. * @returns a new Color3 object
  86032. */
  86033. static Green(): Color3;
  86034. /**
  86035. * Returns a Color3 value containing a blue color
  86036. * @returns a new Color3 object
  86037. */
  86038. static Blue(): Color3;
  86039. /**
  86040. * Returns a Color3 value containing a black color
  86041. * @returns a new Color3 object
  86042. */
  86043. static Black(): Color3;
  86044. /**
  86045. * Gets a Color3 value containing a black color that must not be updated
  86046. */
  86047. static get BlackReadOnly(): DeepImmutable<Color3>;
  86048. /**
  86049. * Returns a Color3 value containing a white color
  86050. * @returns a new Color3 object
  86051. */
  86052. static White(): Color3;
  86053. /**
  86054. * Returns a Color3 value containing a purple color
  86055. * @returns a new Color3 object
  86056. */
  86057. static Purple(): Color3;
  86058. /**
  86059. * Returns a Color3 value containing a magenta color
  86060. * @returns a new Color3 object
  86061. */
  86062. static Magenta(): Color3;
  86063. /**
  86064. * Returns a Color3 value containing a yellow color
  86065. * @returns a new Color3 object
  86066. */
  86067. static Yellow(): Color3;
  86068. /**
  86069. * Returns a Color3 value containing a gray color
  86070. * @returns a new Color3 object
  86071. */
  86072. static Gray(): Color3;
  86073. /**
  86074. * Returns a Color3 value containing a teal color
  86075. * @returns a new Color3 object
  86076. */
  86077. static Teal(): Color3;
  86078. /**
  86079. * Returns a Color3 value containing a random color
  86080. * @returns a new Color3 object
  86081. */
  86082. static Random(): Color3;
  86083. }
  86084. /**
  86085. * Class used to hold a RBGA color
  86086. */
  86087. export class Color4 {
  86088. /**
  86089. * Defines the red component (between 0 and 1, default is 0)
  86090. */
  86091. r: number;
  86092. /**
  86093. * Defines the green component (between 0 and 1, default is 0)
  86094. */
  86095. g: number;
  86096. /**
  86097. * Defines the blue component (between 0 and 1, default is 0)
  86098. */
  86099. b: number;
  86100. /**
  86101. * Defines the alpha component (between 0 and 1, default is 1)
  86102. */
  86103. a: number;
  86104. /**
  86105. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86106. * @param r defines the red component (between 0 and 1, default is 0)
  86107. * @param g defines the green component (between 0 and 1, default is 0)
  86108. * @param b defines the blue component (between 0 and 1, default is 0)
  86109. * @param a defines the alpha component (between 0 and 1, default is 1)
  86110. */
  86111. constructor(
  86112. /**
  86113. * Defines the red component (between 0 and 1, default is 0)
  86114. */
  86115. r?: number,
  86116. /**
  86117. * Defines the green component (between 0 and 1, default is 0)
  86118. */
  86119. g?: number,
  86120. /**
  86121. * Defines the blue component (between 0 and 1, default is 0)
  86122. */
  86123. b?: number,
  86124. /**
  86125. * Defines the alpha component (between 0 and 1, default is 1)
  86126. */
  86127. a?: number);
  86128. /**
  86129. * Adds in place the given Color4 values to the current Color4 object
  86130. * @param right defines the second operand
  86131. * @returns the current updated Color4 object
  86132. */
  86133. addInPlace(right: DeepImmutable<Color4>): Color4;
  86134. /**
  86135. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86136. * @returns the new array
  86137. */
  86138. asArray(): number[];
  86139. /**
  86140. * Stores from the starting index in the given array the Color4 successive values
  86141. * @param array defines the array where to store the r,g,b components
  86142. * @param index defines an optional index in the target array to define where to start storing values
  86143. * @returns the current Color4 object
  86144. */
  86145. toArray(array: number[], index?: number): Color4;
  86146. /**
  86147. * Update the current color with values stored in an array from the starting index of the given array
  86148. * @param array defines the source array
  86149. * @param offset defines an offset in the source array
  86150. * @returns the current Color4 object
  86151. */
  86152. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86153. /**
  86154. * Determines equality between Color4 objects
  86155. * @param otherColor defines the second operand
  86156. * @returns true if the rgba values are equal to the given ones
  86157. */
  86158. equals(otherColor: DeepImmutable<Color4>): boolean;
  86159. /**
  86160. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86161. * @param right defines the second operand
  86162. * @returns a new Color4 object
  86163. */
  86164. add(right: DeepImmutable<Color4>): Color4;
  86165. /**
  86166. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86167. * @param right defines the second operand
  86168. * @returns a new Color4 object
  86169. */
  86170. subtract(right: DeepImmutable<Color4>): Color4;
  86171. /**
  86172. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86173. * @param right defines the second operand
  86174. * @param result defines the Color4 object where to store the result
  86175. * @returns the current Color4 object
  86176. */
  86177. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86178. /**
  86179. * Creates a new Color4 with the current Color4 values multiplied by scale
  86180. * @param scale defines the scaling factor to apply
  86181. * @returns a new Color4 object
  86182. */
  86183. scale(scale: number): Color4;
  86184. /**
  86185. * Multiplies the current Color4 values by scale and stores the result in "result"
  86186. * @param scale defines the scaling factor to apply
  86187. * @param result defines the Color4 object where to store the result
  86188. * @returns the current unmodified Color4
  86189. */
  86190. scaleToRef(scale: number, result: Color4): Color4;
  86191. /**
  86192. * Scale the current Color4 values by a factor and add the result to a given Color4
  86193. * @param scale defines the scale factor
  86194. * @param result defines the Color4 object where to store the result
  86195. * @returns the unmodified current Color4
  86196. */
  86197. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86198. /**
  86199. * Clamps the rgb values by the min and max values and stores the result into "result"
  86200. * @param min defines minimum clamping value (default is 0)
  86201. * @param max defines maximum clamping value (default is 1)
  86202. * @param result defines color to store the result into.
  86203. * @returns the cuurent Color4
  86204. */
  86205. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86206. /**
  86207. * Multipy an Color4 value by another and return a new Color4 object
  86208. * @param color defines the Color4 value to multiply by
  86209. * @returns a new Color4 object
  86210. */
  86211. multiply(color: Color4): Color4;
  86212. /**
  86213. * Multipy a Color4 value by another and push the result in a reference value
  86214. * @param color defines the Color4 value to multiply by
  86215. * @param result defines the Color4 to fill the result in
  86216. * @returns the result Color4
  86217. */
  86218. multiplyToRef(color: Color4, result: Color4): Color4;
  86219. /**
  86220. * Creates a string with the Color4 current values
  86221. * @returns the string representation of the Color4 object
  86222. */
  86223. toString(): string;
  86224. /**
  86225. * Returns the string "Color4"
  86226. * @returns "Color4"
  86227. */
  86228. getClassName(): string;
  86229. /**
  86230. * Compute the Color4 hash code
  86231. * @returns an unique number that can be used to hash Color4 objects
  86232. */
  86233. getHashCode(): number;
  86234. /**
  86235. * Creates a new Color4 copied from the current one
  86236. * @returns a new Color4 object
  86237. */
  86238. clone(): Color4;
  86239. /**
  86240. * Copies the given Color4 values into the current one
  86241. * @param source defines the source Color4 object
  86242. * @returns the current updated Color4 object
  86243. */
  86244. copyFrom(source: Color4): Color4;
  86245. /**
  86246. * Copies the given float values into the current one
  86247. * @param r defines the red component to read from
  86248. * @param g defines the green component to read from
  86249. * @param b defines the blue component to read from
  86250. * @param a defines the alpha component to read from
  86251. * @returns the current updated Color4 object
  86252. */
  86253. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86254. /**
  86255. * Copies the given float values into the current one
  86256. * @param r defines the red component to read from
  86257. * @param g defines the green component to read from
  86258. * @param b defines the blue component to read from
  86259. * @param a defines the alpha component to read from
  86260. * @returns the current updated Color4 object
  86261. */
  86262. set(r: number, g: number, b: number, a: number): Color4;
  86263. /**
  86264. * Compute the Color4 hexadecimal code as a string
  86265. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86266. * @returns a string containing the hexadecimal representation of the Color4 object
  86267. */
  86268. toHexString(returnAsColor3?: boolean): string;
  86269. /**
  86270. * Computes a new Color4 converted from the current one to linear space
  86271. * @returns a new Color4 object
  86272. */
  86273. toLinearSpace(): Color4;
  86274. /**
  86275. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86276. * @param convertedColor defines the Color4 object where to store the linear space version
  86277. * @returns the unmodified Color4
  86278. */
  86279. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86280. /**
  86281. * Computes a new Color4 converted from the current one to gamma space
  86282. * @returns a new Color4 object
  86283. */
  86284. toGammaSpace(): Color4;
  86285. /**
  86286. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86287. * @param convertedColor defines the Color4 object where to store the gamma space version
  86288. * @returns the unmodified Color4
  86289. */
  86290. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86291. /**
  86292. * Creates a new Color4 from the string containing valid hexadecimal values
  86293. * @param hex defines a string containing valid hexadecimal values
  86294. * @returns a new Color4 object
  86295. */
  86296. static FromHexString(hex: string): Color4;
  86297. /**
  86298. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86299. * @param left defines the start value
  86300. * @param right defines the end value
  86301. * @param amount defines the gradient factor
  86302. * @returns a new Color4 object
  86303. */
  86304. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86305. /**
  86306. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86307. * @param left defines the start value
  86308. * @param right defines the end value
  86309. * @param amount defines the gradient factor
  86310. * @param result defines the Color4 object where to store data
  86311. */
  86312. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86313. /**
  86314. * Creates a new Color4 from a Color3 and an alpha value
  86315. * @param color3 defines the source Color3 to read from
  86316. * @param alpha defines the alpha component (1.0 by default)
  86317. * @returns a new Color4 object
  86318. */
  86319. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86320. /**
  86321. * Creates a new Color4 from the starting index element of the given array
  86322. * @param array defines the source array to read from
  86323. * @param offset defines the offset in the source array
  86324. * @returns a new Color4 object
  86325. */
  86326. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86327. /**
  86328. * Creates a new Color4 from the starting index element of the given array
  86329. * @param array defines the source array to read from
  86330. * @param offset defines the offset in the source array
  86331. * @param result defines the target Color4 object
  86332. */
  86333. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86334. /**
  86335. * Creates a new Color3 from integer values (< 256)
  86336. * @param r defines the red component to read from (value between 0 and 255)
  86337. * @param g defines the green component to read from (value between 0 and 255)
  86338. * @param b defines the blue component to read from (value between 0 and 255)
  86339. * @param a defines the alpha component to read from (value between 0 and 255)
  86340. * @returns a new Color3 object
  86341. */
  86342. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86343. /**
  86344. * Check the content of a given array and convert it to an array containing RGBA data
  86345. * If the original array was already containing count * 4 values then it is returned directly
  86346. * @param colors defines the array to check
  86347. * @param count defines the number of RGBA data to expect
  86348. * @returns an array containing count * 4 values (RGBA)
  86349. */
  86350. static CheckColors4(colors: number[], count: number): number[];
  86351. }
  86352. /**
  86353. * @hidden
  86354. */
  86355. export class TmpColors {
  86356. static Color3: Color3[];
  86357. static Color4: Color4[];
  86358. }
  86359. }
  86360. declare module BABYLON {
  86361. /**
  86362. * Defines an interface which represents an animation key frame
  86363. */
  86364. export interface IAnimationKey {
  86365. /**
  86366. * Frame of the key frame
  86367. */
  86368. frame: number;
  86369. /**
  86370. * Value at the specifies key frame
  86371. */
  86372. value: any;
  86373. /**
  86374. * The input tangent for the cubic hermite spline
  86375. */
  86376. inTangent?: any;
  86377. /**
  86378. * The output tangent for the cubic hermite spline
  86379. */
  86380. outTangent?: any;
  86381. /**
  86382. * The animation interpolation type
  86383. */
  86384. interpolation?: AnimationKeyInterpolation;
  86385. }
  86386. /**
  86387. * Enum for the animation key frame interpolation type
  86388. */
  86389. export enum AnimationKeyInterpolation {
  86390. /**
  86391. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86392. */
  86393. STEP = 1
  86394. }
  86395. }
  86396. declare module BABYLON {
  86397. /**
  86398. * Represents the range of an animation
  86399. */
  86400. export class AnimationRange {
  86401. /**The name of the animation range**/
  86402. name: string;
  86403. /**The starting frame of the animation */
  86404. from: number;
  86405. /**The ending frame of the animation*/
  86406. to: number;
  86407. /**
  86408. * Initializes the range of an animation
  86409. * @param name The name of the animation range
  86410. * @param from The starting frame of the animation
  86411. * @param to The ending frame of the animation
  86412. */
  86413. constructor(
  86414. /**The name of the animation range**/
  86415. name: string,
  86416. /**The starting frame of the animation */
  86417. from: number,
  86418. /**The ending frame of the animation*/
  86419. to: number);
  86420. /**
  86421. * Makes a copy of the animation range
  86422. * @returns A copy of the animation range
  86423. */
  86424. clone(): AnimationRange;
  86425. }
  86426. }
  86427. declare module BABYLON {
  86428. /**
  86429. * Composed of a frame, and an action function
  86430. */
  86431. export class AnimationEvent {
  86432. /** The frame for which the event is triggered **/
  86433. frame: number;
  86434. /** The event to perform when triggered **/
  86435. action: (currentFrame: number) => void;
  86436. /** Specifies if the event should be triggered only once**/
  86437. onlyOnce?: boolean | undefined;
  86438. /**
  86439. * Specifies if the animation event is done
  86440. */
  86441. isDone: boolean;
  86442. /**
  86443. * Initializes the animation event
  86444. * @param frame The frame for which the event is triggered
  86445. * @param action The event to perform when triggered
  86446. * @param onlyOnce Specifies if the event should be triggered only once
  86447. */
  86448. constructor(
  86449. /** The frame for which the event is triggered **/
  86450. frame: number,
  86451. /** The event to perform when triggered **/
  86452. action: (currentFrame: number) => void,
  86453. /** Specifies if the event should be triggered only once**/
  86454. onlyOnce?: boolean | undefined);
  86455. /** @hidden */
  86456. _clone(): AnimationEvent;
  86457. }
  86458. }
  86459. declare module BABYLON {
  86460. /**
  86461. * Interface used to define a behavior
  86462. */
  86463. export interface Behavior<T> {
  86464. /** gets or sets behavior's name */
  86465. name: string;
  86466. /**
  86467. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86468. */
  86469. init(): void;
  86470. /**
  86471. * Called when the behavior is attached to a target
  86472. * @param target defines the target where the behavior is attached to
  86473. */
  86474. attach(target: T): void;
  86475. /**
  86476. * Called when the behavior is detached from its target
  86477. */
  86478. detach(): void;
  86479. }
  86480. /**
  86481. * Interface implemented by classes supporting behaviors
  86482. */
  86483. export interface IBehaviorAware<T> {
  86484. /**
  86485. * Attach a behavior
  86486. * @param behavior defines the behavior to attach
  86487. * @returns the current host
  86488. */
  86489. addBehavior(behavior: Behavior<T>): T;
  86490. /**
  86491. * Remove a behavior from the current object
  86492. * @param behavior defines the behavior to detach
  86493. * @returns the current host
  86494. */
  86495. removeBehavior(behavior: Behavior<T>): T;
  86496. /**
  86497. * Gets a behavior using its name to search
  86498. * @param name defines the name to search
  86499. * @returns the behavior or null if not found
  86500. */
  86501. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86502. }
  86503. }
  86504. declare module BABYLON {
  86505. /**
  86506. * Defines an array and its length.
  86507. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86508. */
  86509. export interface ISmartArrayLike<T> {
  86510. /**
  86511. * The data of the array.
  86512. */
  86513. data: Array<T>;
  86514. /**
  86515. * The active length of the array.
  86516. */
  86517. length: number;
  86518. }
  86519. /**
  86520. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86521. */
  86522. export class SmartArray<T> implements ISmartArrayLike<T> {
  86523. /**
  86524. * The full set of data from the array.
  86525. */
  86526. data: Array<T>;
  86527. /**
  86528. * The active length of the array.
  86529. */
  86530. length: number;
  86531. protected _id: number;
  86532. /**
  86533. * Instantiates a Smart Array.
  86534. * @param capacity defines the default capacity of the array.
  86535. */
  86536. constructor(capacity: number);
  86537. /**
  86538. * Pushes a value at the end of the active data.
  86539. * @param value defines the object to push in the array.
  86540. */
  86541. push(value: T): void;
  86542. /**
  86543. * Iterates over the active data and apply the lambda to them.
  86544. * @param func defines the action to apply on each value.
  86545. */
  86546. forEach(func: (content: T) => void): void;
  86547. /**
  86548. * Sorts the full sets of data.
  86549. * @param compareFn defines the comparison function to apply.
  86550. */
  86551. sort(compareFn: (a: T, b: T) => number): void;
  86552. /**
  86553. * Resets the active data to an empty array.
  86554. */
  86555. reset(): void;
  86556. /**
  86557. * Releases all the data from the array as well as the array.
  86558. */
  86559. dispose(): void;
  86560. /**
  86561. * Concats the active data with a given array.
  86562. * @param array defines the data to concatenate with.
  86563. */
  86564. concat(array: any): void;
  86565. /**
  86566. * Returns the position of a value in the active data.
  86567. * @param value defines the value to find the index for
  86568. * @returns the index if found in the active data otherwise -1
  86569. */
  86570. indexOf(value: T): number;
  86571. /**
  86572. * Returns whether an element is part of the active data.
  86573. * @param value defines the value to look for
  86574. * @returns true if found in the active data otherwise false
  86575. */
  86576. contains(value: T): boolean;
  86577. private static _GlobalId;
  86578. }
  86579. /**
  86580. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86581. * The data in this array can only be present once
  86582. */
  86583. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86584. private _duplicateId;
  86585. /**
  86586. * Pushes a value at the end of the active data.
  86587. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86588. * @param value defines the object to push in the array.
  86589. */
  86590. push(value: T): void;
  86591. /**
  86592. * Pushes a value at the end of the active data.
  86593. * If the data is already present, it won t be added again
  86594. * @param value defines the object to push in the array.
  86595. * @returns true if added false if it was already present
  86596. */
  86597. pushNoDuplicate(value: T): boolean;
  86598. /**
  86599. * Resets the active data to an empty array.
  86600. */
  86601. reset(): void;
  86602. /**
  86603. * Concats the active data with a given array.
  86604. * This ensures no dupplicate will be present in the result.
  86605. * @param array defines the data to concatenate with.
  86606. */
  86607. concatWithNoDuplicate(array: any): void;
  86608. }
  86609. }
  86610. declare module BABYLON {
  86611. /**
  86612. * @ignore
  86613. * This is a list of all the different input types that are available in the application.
  86614. * Fo instance: ArcRotateCameraGamepadInput...
  86615. */
  86616. export var CameraInputTypes: {};
  86617. /**
  86618. * This is the contract to implement in order to create a new input class.
  86619. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86620. */
  86621. export interface ICameraInput<TCamera extends Camera> {
  86622. /**
  86623. * Defines the camera the input is attached to.
  86624. */
  86625. camera: Nullable<TCamera>;
  86626. /**
  86627. * Gets the class name of the current intput.
  86628. * @returns the class name
  86629. */
  86630. getClassName(): string;
  86631. /**
  86632. * Get the friendly name associated with the input class.
  86633. * @returns the input friendly name
  86634. */
  86635. getSimpleName(): string;
  86636. /**
  86637. * Attach the input controls to a specific dom element to get the input from.
  86638. * @param element Defines the element the controls should be listened from
  86639. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86640. */
  86641. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86642. /**
  86643. * Detach the current controls from the specified dom element.
  86644. * @param element Defines the element to stop listening the inputs from
  86645. */
  86646. detachControl(element: Nullable<HTMLElement>): void;
  86647. /**
  86648. * Update the current camera state depending on the inputs that have been used this frame.
  86649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86650. */
  86651. checkInputs?: () => void;
  86652. }
  86653. /**
  86654. * Represents a map of input types to input instance or input index to input instance.
  86655. */
  86656. export interface CameraInputsMap<TCamera extends Camera> {
  86657. /**
  86658. * Accessor to the input by input type.
  86659. */
  86660. [name: string]: ICameraInput<TCamera>;
  86661. /**
  86662. * Accessor to the input by input index.
  86663. */
  86664. [idx: number]: ICameraInput<TCamera>;
  86665. }
  86666. /**
  86667. * This represents the input manager used within a camera.
  86668. * It helps dealing with all the different kind of input attached to a camera.
  86669. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86670. */
  86671. export class CameraInputsManager<TCamera extends Camera> {
  86672. /**
  86673. * Defines the list of inputs attahed to the camera.
  86674. */
  86675. attached: CameraInputsMap<TCamera>;
  86676. /**
  86677. * Defines the dom element the camera is collecting inputs from.
  86678. * This is null if the controls have not been attached.
  86679. */
  86680. attachedElement: Nullable<HTMLElement>;
  86681. /**
  86682. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86683. */
  86684. noPreventDefault: boolean;
  86685. /**
  86686. * Defined the camera the input manager belongs to.
  86687. */
  86688. camera: TCamera;
  86689. /**
  86690. * Update the current camera state depending on the inputs that have been used this frame.
  86691. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86692. */
  86693. checkInputs: () => void;
  86694. /**
  86695. * Instantiate a new Camera Input Manager.
  86696. * @param camera Defines the camera the input manager blongs to
  86697. */
  86698. constructor(camera: TCamera);
  86699. /**
  86700. * Add an input method to a camera
  86701. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86702. * @param input camera input method
  86703. */
  86704. add(input: ICameraInput<TCamera>): void;
  86705. /**
  86706. * Remove a specific input method from a camera
  86707. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86708. * @param inputToRemove camera input method
  86709. */
  86710. remove(inputToRemove: ICameraInput<TCamera>): void;
  86711. /**
  86712. * Remove a specific input type from a camera
  86713. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86714. * @param inputType the type of the input to remove
  86715. */
  86716. removeByType(inputType: string): void;
  86717. private _addCheckInputs;
  86718. /**
  86719. * Attach the input controls to the currently attached dom element to listen the events from.
  86720. * @param input Defines the input to attach
  86721. */
  86722. attachInput(input: ICameraInput<TCamera>): void;
  86723. /**
  86724. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86725. * @param element Defines the dom element to collect the events from
  86726. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86727. */
  86728. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86729. /**
  86730. * Detach the current manager inputs controls from a specific dom element.
  86731. * @param element Defines the dom element to collect the events from
  86732. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86733. */
  86734. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86735. /**
  86736. * Rebuild the dynamic inputCheck function from the current list of
  86737. * defined inputs in the manager.
  86738. */
  86739. rebuildInputCheck(): void;
  86740. /**
  86741. * Remove all attached input methods from a camera
  86742. */
  86743. clear(): void;
  86744. /**
  86745. * Serialize the current input manager attached to a camera.
  86746. * This ensures than once parsed,
  86747. * the input associated to the camera will be identical to the current ones
  86748. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86749. */
  86750. serialize(serializedCamera: any): void;
  86751. /**
  86752. * Parses an input manager serialized JSON to restore the previous list of inputs
  86753. * and states associated to a camera.
  86754. * @param parsedCamera Defines the JSON to parse
  86755. */
  86756. parse(parsedCamera: any): void;
  86757. }
  86758. }
  86759. declare module BABYLON {
  86760. /**
  86761. * Class used to store data that will be store in GPU memory
  86762. */
  86763. export class Buffer {
  86764. private _engine;
  86765. private _buffer;
  86766. /** @hidden */
  86767. _data: Nullable<DataArray>;
  86768. private _updatable;
  86769. private _instanced;
  86770. private _divisor;
  86771. /**
  86772. * Gets the byte stride.
  86773. */
  86774. readonly byteStride: number;
  86775. /**
  86776. * Constructor
  86777. * @param engine the engine
  86778. * @param data the data to use for this buffer
  86779. * @param updatable whether the data is updatable
  86780. * @param stride the stride (optional)
  86781. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86782. * @param instanced whether the buffer is instanced (optional)
  86783. * @param useBytes set to true if the stride in in bytes (optional)
  86784. * @param divisor sets an optional divisor for instances (1 by default)
  86785. */
  86786. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  86787. /**
  86788. * Create a new VertexBuffer based on the current buffer
  86789. * @param kind defines the vertex buffer kind (position, normal, etc.)
  86790. * @param offset defines offset in the buffer (0 by default)
  86791. * @param size defines the size in floats of attributes (position is 3 for instance)
  86792. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  86793. * @param instanced defines if the vertex buffer contains indexed data
  86794. * @param useBytes defines if the offset and stride are in bytes *
  86795. * @param divisor sets an optional divisor for instances (1 by default)
  86796. * @returns the new vertex buffer
  86797. */
  86798. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  86799. /**
  86800. * Gets a boolean indicating if the Buffer is updatable?
  86801. * @returns true if the buffer is updatable
  86802. */
  86803. isUpdatable(): boolean;
  86804. /**
  86805. * Gets current buffer's data
  86806. * @returns a DataArray or null
  86807. */
  86808. getData(): Nullable<DataArray>;
  86809. /**
  86810. * Gets underlying native buffer
  86811. * @returns underlying native buffer
  86812. */
  86813. getBuffer(): Nullable<DataBuffer>;
  86814. /**
  86815. * Gets the stride in float32 units (i.e. byte stride / 4).
  86816. * May not be an integer if the byte stride is not divisible by 4.
  86817. * @returns the stride in float32 units
  86818. * @deprecated Please use byteStride instead.
  86819. */
  86820. getStrideSize(): number;
  86821. /**
  86822. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86823. * @param data defines the data to store
  86824. */
  86825. create(data?: Nullable<DataArray>): void;
  86826. /** @hidden */
  86827. _rebuild(): void;
  86828. /**
  86829. * Update current buffer data
  86830. * @param data defines the data to store
  86831. */
  86832. update(data: DataArray): void;
  86833. /**
  86834. * Updates the data directly.
  86835. * @param data the new data
  86836. * @param offset the new offset
  86837. * @param vertexCount the vertex count (optional)
  86838. * @param useBytes set to true if the offset is in bytes
  86839. */
  86840. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  86841. /**
  86842. * Release all resources
  86843. */
  86844. dispose(): void;
  86845. }
  86846. /**
  86847. * Specialized buffer used to store vertex data
  86848. */
  86849. export class VertexBuffer {
  86850. /** @hidden */
  86851. _buffer: Buffer;
  86852. private _kind;
  86853. private _size;
  86854. private _ownsBuffer;
  86855. private _instanced;
  86856. private _instanceDivisor;
  86857. /**
  86858. * The byte type.
  86859. */
  86860. static readonly BYTE: number;
  86861. /**
  86862. * The unsigned byte type.
  86863. */
  86864. static readonly UNSIGNED_BYTE: number;
  86865. /**
  86866. * The short type.
  86867. */
  86868. static readonly SHORT: number;
  86869. /**
  86870. * The unsigned short type.
  86871. */
  86872. static readonly UNSIGNED_SHORT: number;
  86873. /**
  86874. * The integer type.
  86875. */
  86876. static readonly INT: number;
  86877. /**
  86878. * The unsigned integer type.
  86879. */
  86880. static readonly UNSIGNED_INT: number;
  86881. /**
  86882. * The float type.
  86883. */
  86884. static readonly FLOAT: number;
  86885. /**
  86886. * Gets or sets the instance divisor when in instanced mode
  86887. */
  86888. get instanceDivisor(): number;
  86889. set instanceDivisor(value: number);
  86890. /**
  86891. * Gets the byte stride.
  86892. */
  86893. readonly byteStride: number;
  86894. /**
  86895. * Gets the byte offset.
  86896. */
  86897. readonly byteOffset: number;
  86898. /**
  86899. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  86900. */
  86901. readonly normalized: boolean;
  86902. /**
  86903. * Gets the data type of each component in the array.
  86904. */
  86905. readonly type: number;
  86906. /**
  86907. * Constructor
  86908. * @param engine the engine
  86909. * @param data the data to use for this vertex buffer
  86910. * @param kind the vertex buffer kind
  86911. * @param updatable whether the data is updatable
  86912. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  86913. * @param stride the stride (optional)
  86914. * @param instanced whether the buffer is instanced (optional)
  86915. * @param offset the offset of the data (optional)
  86916. * @param size the number of components (optional)
  86917. * @param type the type of the component (optional)
  86918. * @param normalized whether the data contains normalized data (optional)
  86919. * @param useBytes set to true if stride and offset are in bytes (optional)
  86920. * @param divisor defines the instance divisor to use (1 by default)
  86921. */
  86922. 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);
  86923. /** @hidden */
  86924. _rebuild(): void;
  86925. /**
  86926. * Returns the kind of the VertexBuffer (string)
  86927. * @returns a string
  86928. */
  86929. getKind(): string;
  86930. /**
  86931. * Gets a boolean indicating if the VertexBuffer is updatable?
  86932. * @returns true if the buffer is updatable
  86933. */
  86934. isUpdatable(): boolean;
  86935. /**
  86936. * Gets current buffer's data
  86937. * @returns a DataArray or null
  86938. */
  86939. getData(): Nullable<DataArray>;
  86940. /**
  86941. * Gets underlying native buffer
  86942. * @returns underlying native buffer
  86943. */
  86944. getBuffer(): Nullable<DataBuffer>;
  86945. /**
  86946. * Gets the stride in float32 units (i.e. byte stride / 4).
  86947. * May not be an integer if the byte stride is not divisible by 4.
  86948. * @returns the stride in float32 units
  86949. * @deprecated Please use byteStride instead.
  86950. */
  86951. getStrideSize(): number;
  86952. /**
  86953. * Returns the offset as a multiple of the type byte length.
  86954. * @returns the offset in bytes
  86955. * @deprecated Please use byteOffset instead.
  86956. */
  86957. getOffset(): number;
  86958. /**
  86959. * Returns the number of components per vertex attribute (integer)
  86960. * @returns the size in float
  86961. */
  86962. getSize(): number;
  86963. /**
  86964. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  86965. * @returns true if this buffer is instanced
  86966. */
  86967. getIsInstanced(): boolean;
  86968. /**
  86969. * Returns the instancing divisor, zero for non-instanced (integer).
  86970. * @returns a number
  86971. */
  86972. getInstanceDivisor(): number;
  86973. /**
  86974. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  86975. * @param data defines the data to store
  86976. */
  86977. create(data?: DataArray): void;
  86978. /**
  86979. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  86980. * This function will create a new buffer if the current one is not updatable
  86981. * @param data defines the data to store
  86982. */
  86983. update(data: DataArray): void;
  86984. /**
  86985. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  86986. * Returns the directly updated WebGLBuffer.
  86987. * @param data the new data
  86988. * @param offset the new offset
  86989. * @param useBytes set to true if the offset is in bytes
  86990. */
  86991. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  86992. /**
  86993. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  86994. */
  86995. dispose(): void;
  86996. /**
  86997. * Enumerates each value of this vertex buffer as numbers.
  86998. * @param count the number of values to enumerate
  86999. * @param callback the callback function called for each value
  87000. */
  87001. forEach(count: number, callback: (value: number, index: number) => void): void;
  87002. /**
  87003. * Positions
  87004. */
  87005. static readonly PositionKind: string;
  87006. /**
  87007. * Normals
  87008. */
  87009. static readonly NormalKind: string;
  87010. /**
  87011. * Tangents
  87012. */
  87013. static readonly TangentKind: string;
  87014. /**
  87015. * Texture coordinates
  87016. */
  87017. static readonly UVKind: string;
  87018. /**
  87019. * Texture coordinates 2
  87020. */
  87021. static readonly UV2Kind: string;
  87022. /**
  87023. * Texture coordinates 3
  87024. */
  87025. static readonly UV3Kind: string;
  87026. /**
  87027. * Texture coordinates 4
  87028. */
  87029. static readonly UV4Kind: string;
  87030. /**
  87031. * Texture coordinates 5
  87032. */
  87033. static readonly UV5Kind: string;
  87034. /**
  87035. * Texture coordinates 6
  87036. */
  87037. static readonly UV6Kind: string;
  87038. /**
  87039. * Colors
  87040. */
  87041. static readonly ColorKind: string;
  87042. /**
  87043. * Matrix indices (for bones)
  87044. */
  87045. static readonly MatricesIndicesKind: string;
  87046. /**
  87047. * Matrix weights (for bones)
  87048. */
  87049. static readonly MatricesWeightsKind: string;
  87050. /**
  87051. * Additional matrix indices (for bones)
  87052. */
  87053. static readonly MatricesIndicesExtraKind: string;
  87054. /**
  87055. * Additional matrix weights (for bones)
  87056. */
  87057. static readonly MatricesWeightsExtraKind: string;
  87058. /**
  87059. * Deduces the stride given a kind.
  87060. * @param kind The kind string to deduce
  87061. * @returns The deduced stride
  87062. */
  87063. static DeduceStride(kind: string): number;
  87064. /**
  87065. * Gets the byte length of the given type.
  87066. * @param type the type
  87067. * @returns the number of bytes
  87068. */
  87069. static GetTypeByteLength(type: number): number;
  87070. /**
  87071. * Enumerates each value of the given parameters as numbers.
  87072. * @param data the data to enumerate
  87073. * @param byteOffset the byte offset of the data
  87074. * @param byteStride the byte stride of the data
  87075. * @param componentCount the number of components per element
  87076. * @param componentType the type of the component
  87077. * @param count the number of values to enumerate
  87078. * @param normalized whether the data is normalized
  87079. * @param callback the callback function called for each value
  87080. */
  87081. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87082. private static _GetFloatValue;
  87083. }
  87084. }
  87085. declare module BABYLON {
  87086. /**
  87087. * The options Interface for creating a Capsule Mesh
  87088. */
  87089. export interface ICreateCapsuleOptions {
  87090. /** The Orientation of the capsule. Default : Vector3.Up() */
  87091. orientation?: Vector3;
  87092. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87093. subdivisions: number;
  87094. /** Number of cylindrical segments on the capsule. */
  87095. tessellation: number;
  87096. /** Height or Length of the capsule. */
  87097. height: number;
  87098. /** Radius of the capsule. */
  87099. radius: number;
  87100. /** Height or Length of the capsule. */
  87101. capSubdivisions: number;
  87102. /** Overwrite for the top radius. */
  87103. radiusTop?: number;
  87104. /** Overwrite for the bottom radius. */
  87105. radiusBottom?: number;
  87106. /** Overwrite for the top capSubdivisions. */
  87107. topCapSubdivisions?: number;
  87108. /** Overwrite for the bottom capSubdivisions. */
  87109. bottomCapSubdivisions?: number;
  87110. }
  87111. /**
  87112. * Class containing static functions to help procedurally build meshes
  87113. */
  87114. export class CapsuleBuilder {
  87115. /**
  87116. * Creates a capsule or a pill mesh
  87117. * @param name defines the name of the mesh
  87118. * @param options The constructors options.
  87119. * @param scene The scene the mesh is scoped to.
  87120. * @returns Capsule Mesh
  87121. */
  87122. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87123. }
  87124. }
  87125. declare module BABYLON {
  87126. /**
  87127. * @hidden
  87128. */
  87129. export class IntersectionInfo {
  87130. bu: Nullable<number>;
  87131. bv: Nullable<number>;
  87132. distance: number;
  87133. faceId: number;
  87134. subMeshId: number;
  87135. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87136. }
  87137. }
  87138. declare module BABYLON {
  87139. /**
  87140. * Class used to store bounding sphere information
  87141. */
  87142. export class BoundingSphere {
  87143. /**
  87144. * Gets the center of the bounding sphere in local space
  87145. */
  87146. readonly center: Vector3;
  87147. /**
  87148. * Radius of the bounding sphere in local space
  87149. */
  87150. radius: number;
  87151. /**
  87152. * Gets the center of the bounding sphere in world space
  87153. */
  87154. readonly centerWorld: Vector3;
  87155. /**
  87156. * Radius of the bounding sphere in world space
  87157. */
  87158. radiusWorld: number;
  87159. /**
  87160. * Gets the minimum vector in local space
  87161. */
  87162. readonly minimum: Vector3;
  87163. /**
  87164. * Gets the maximum vector in local space
  87165. */
  87166. readonly maximum: Vector3;
  87167. private _worldMatrix;
  87168. private static readonly TmpVector3;
  87169. /**
  87170. * Creates a new bounding sphere
  87171. * @param min defines the minimum vector (in local space)
  87172. * @param max defines the maximum vector (in local space)
  87173. * @param worldMatrix defines the new world matrix
  87174. */
  87175. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87176. /**
  87177. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87178. * @param min defines the new minimum vector (in local space)
  87179. * @param max defines the new maximum vector (in local space)
  87180. * @param worldMatrix defines the new world matrix
  87181. */
  87182. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87183. /**
  87184. * Scale the current bounding sphere by applying a scale factor
  87185. * @param factor defines the scale factor to apply
  87186. * @returns the current bounding box
  87187. */
  87188. scale(factor: number): BoundingSphere;
  87189. /**
  87190. * Gets the world matrix of the bounding box
  87191. * @returns a matrix
  87192. */
  87193. getWorldMatrix(): DeepImmutable<Matrix>;
  87194. /** @hidden */
  87195. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87196. /**
  87197. * Tests if the bounding sphere is intersecting the frustum planes
  87198. * @param frustumPlanes defines the frustum planes to test
  87199. * @returns true if there is an intersection
  87200. */
  87201. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87202. /**
  87203. * Tests if the bounding sphere center is in between the frustum planes.
  87204. * Used for optimistic fast inclusion.
  87205. * @param frustumPlanes defines the frustum planes to test
  87206. * @returns true if the sphere center is in between the frustum planes
  87207. */
  87208. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87209. /**
  87210. * Tests if a point is inside the bounding sphere
  87211. * @param point defines the point to test
  87212. * @returns true if the point is inside the bounding sphere
  87213. */
  87214. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87215. /**
  87216. * Checks if two sphere intersct
  87217. * @param sphere0 sphere 0
  87218. * @param sphere1 sphere 1
  87219. * @returns true if the speres intersect
  87220. */
  87221. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87222. }
  87223. }
  87224. declare module BABYLON {
  87225. /**
  87226. * Class used to store bounding box information
  87227. */
  87228. export class BoundingBox implements ICullable {
  87229. /**
  87230. * Gets the 8 vectors representing the bounding box in local space
  87231. */
  87232. readonly vectors: Vector3[];
  87233. /**
  87234. * Gets the center of the bounding box in local space
  87235. */
  87236. readonly center: Vector3;
  87237. /**
  87238. * Gets the center of the bounding box in world space
  87239. */
  87240. readonly centerWorld: Vector3;
  87241. /**
  87242. * Gets the extend size in local space
  87243. */
  87244. readonly extendSize: Vector3;
  87245. /**
  87246. * Gets the extend size in world space
  87247. */
  87248. readonly extendSizeWorld: Vector3;
  87249. /**
  87250. * Gets the OBB (object bounding box) directions
  87251. */
  87252. readonly directions: Vector3[];
  87253. /**
  87254. * Gets the 8 vectors representing the bounding box in world space
  87255. */
  87256. readonly vectorsWorld: Vector3[];
  87257. /**
  87258. * Gets the minimum vector in world space
  87259. */
  87260. readonly minimumWorld: Vector3;
  87261. /**
  87262. * Gets the maximum vector in world space
  87263. */
  87264. readonly maximumWorld: Vector3;
  87265. /**
  87266. * Gets the minimum vector in local space
  87267. */
  87268. readonly minimum: Vector3;
  87269. /**
  87270. * Gets the maximum vector in local space
  87271. */
  87272. readonly maximum: Vector3;
  87273. private _worldMatrix;
  87274. private static readonly TmpVector3;
  87275. /**
  87276. * @hidden
  87277. */
  87278. _tag: number;
  87279. /**
  87280. * Creates a new bounding box
  87281. * @param min defines the minimum vector (in local space)
  87282. * @param max defines the maximum vector (in local space)
  87283. * @param worldMatrix defines the new world matrix
  87284. */
  87285. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87286. /**
  87287. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87288. * @param min defines the new minimum vector (in local space)
  87289. * @param max defines the new maximum vector (in local space)
  87290. * @param worldMatrix defines the new world matrix
  87291. */
  87292. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87293. /**
  87294. * Scale the current bounding box by applying a scale factor
  87295. * @param factor defines the scale factor to apply
  87296. * @returns the current bounding box
  87297. */
  87298. scale(factor: number): BoundingBox;
  87299. /**
  87300. * Gets the world matrix of the bounding box
  87301. * @returns a matrix
  87302. */
  87303. getWorldMatrix(): DeepImmutable<Matrix>;
  87304. /** @hidden */
  87305. _update(world: DeepImmutable<Matrix>): void;
  87306. /**
  87307. * Tests if the bounding box is intersecting the frustum planes
  87308. * @param frustumPlanes defines the frustum planes to test
  87309. * @returns true if there is an intersection
  87310. */
  87311. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87312. /**
  87313. * Tests if the bounding box is entirely inside the frustum planes
  87314. * @param frustumPlanes defines the frustum planes to test
  87315. * @returns true if there is an inclusion
  87316. */
  87317. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87318. /**
  87319. * Tests if a point is inside the bounding box
  87320. * @param point defines the point to test
  87321. * @returns true if the point is inside the bounding box
  87322. */
  87323. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87324. /**
  87325. * Tests if the bounding box intersects with a bounding sphere
  87326. * @param sphere defines the sphere to test
  87327. * @returns true if there is an intersection
  87328. */
  87329. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87330. /**
  87331. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87332. * @param min defines the min vector to use
  87333. * @param max defines the max vector to use
  87334. * @returns true if there is an intersection
  87335. */
  87336. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87337. /**
  87338. * Tests if two bounding boxes are intersections
  87339. * @param box0 defines the first box to test
  87340. * @param box1 defines the second box to test
  87341. * @returns true if there is an intersection
  87342. */
  87343. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87344. /**
  87345. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87346. * @param minPoint defines the minimum vector of the bounding box
  87347. * @param maxPoint defines the maximum vector of the bounding box
  87348. * @param sphereCenter defines the sphere center
  87349. * @param sphereRadius defines the sphere radius
  87350. * @returns true if there is an intersection
  87351. */
  87352. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87353. /**
  87354. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87355. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87356. * @param frustumPlanes defines the frustum planes to test
  87357. * @return true if there is an inclusion
  87358. */
  87359. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87360. /**
  87361. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87362. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87363. * @param frustumPlanes defines the frustum planes to test
  87364. * @return true if there is an intersection
  87365. */
  87366. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87367. }
  87368. }
  87369. declare module BABYLON {
  87370. /** @hidden */
  87371. export class Collider {
  87372. /** Define if a collision was found */
  87373. collisionFound: boolean;
  87374. /**
  87375. * Define last intersection point in local space
  87376. */
  87377. intersectionPoint: Vector3;
  87378. /**
  87379. * Define last collided mesh
  87380. */
  87381. collidedMesh: Nullable<AbstractMesh>;
  87382. private _collisionPoint;
  87383. private _planeIntersectionPoint;
  87384. private _tempVector;
  87385. private _tempVector2;
  87386. private _tempVector3;
  87387. private _tempVector4;
  87388. private _edge;
  87389. private _baseToVertex;
  87390. private _destinationPoint;
  87391. private _slidePlaneNormal;
  87392. private _displacementVector;
  87393. /** @hidden */
  87394. _radius: Vector3;
  87395. /** @hidden */
  87396. _retry: number;
  87397. private _velocity;
  87398. private _basePoint;
  87399. private _epsilon;
  87400. /** @hidden */
  87401. _velocityWorldLength: number;
  87402. /** @hidden */
  87403. _basePointWorld: Vector3;
  87404. private _velocityWorld;
  87405. private _normalizedVelocity;
  87406. /** @hidden */
  87407. _initialVelocity: Vector3;
  87408. /** @hidden */
  87409. _initialPosition: Vector3;
  87410. private _nearestDistance;
  87411. private _collisionMask;
  87412. get collisionMask(): number;
  87413. set collisionMask(mask: number);
  87414. /**
  87415. * Gets the plane normal used to compute the sliding response (in local space)
  87416. */
  87417. get slidePlaneNormal(): Vector3;
  87418. /** @hidden */
  87419. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87420. /** @hidden */
  87421. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87422. /** @hidden */
  87423. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87424. /** @hidden */
  87425. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87426. /** @hidden */
  87427. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87428. /** @hidden */
  87429. _getResponse(pos: Vector3, vel: Vector3): void;
  87430. }
  87431. }
  87432. declare module BABYLON {
  87433. /**
  87434. * Interface for cullable objects
  87435. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87436. */
  87437. export interface ICullable {
  87438. /**
  87439. * Checks if the object or part of the object is in the frustum
  87440. * @param frustumPlanes Camera near/planes
  87441. * @returns true if the object is in frustum otherwise false
  87442. */
  87443. isInFrustum(frustumPlanes: Plane[]): boolean;
  87444. /**
  87445. * Checks if a cullable object (mesh...) is in the camera frustum
  87446. * Unlike isInFrustum this cheks the full bounding box
  87447. * @param frustumPlanes Camera near/planes
  87448. * @returns true if the object is in frustum otherwise false
  87449. */
  87450. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87451. }
  87452. /**
  87453. * Info for a bounding data of a mesh
  87454. */
  87455. export class BoundingInfo implements ICullable {
  87456. /**
  87457. * Bounding box for the mesh
  87458. */
  87459. readonly boundingBox: BoundingBox;
  87460. /**
  87461. * Bounding sphere for the mesh
  87462. */
  87463. readonly boundingSphere: BoundingSphere;
  87464. private _isLocked;
  87465. private static readonly TmpVector3;
  87466. /**
  87467. * Constructs bounding info
  87468. * @param minimum min vector of the bounding box/sphere
  87469. * @param maximum max vector of the bounding box/sphere
  87470. * @param worldMatrix defines the new world matrix
  87471. */
  87472. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87473. /**
  87474. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87475. * @param min defines the new minimum vector (in local space)
  87476. * @param max defines the new maximum vector (in local space)
  87477. * @param worldMatrix defines the new world matrix
  87478. */
  87479. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87480. /**
  87481. * min vector of the bounding box/sphere
  87482. */
  87483. get minimum(): Vector3;
  87484. /**
  87485. * max vector of the bounding box/sphere
  87486. */
  87487. get maximum(): Vector3;
  87488. /**
  87489. * If the info is locked and won't be updated to avoid perf overhead
  87490. */
  87491. get isLocked(): boolean;
  87492. set isLocked(value: boolean);
  87493. /**
  87494. * Updates the bounding sphere and box
  87495. * @param world world matrix to be used to update
  87496. */
  87497. update(world: DeepImmutable<Matrix>): void;
  87498. /**
  87499. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87500. * @param center New center of the bounding info
  87501. * @param extend New extend of the bounding info
  87502. * @returns the current bounding info
  87503. */
  87504. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87505. /**
  87506. * Scale the current bounding info by applying a scale factor
  87507. * @param factor defines the scale factor to apply
  87508. * @returns the current bounding info
  87509. */
  87510. scale(factor: number): BoundingInfo;
  87511. /**
  87512. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87513. * @param frustumPlanes defines the frustum to test
  87514. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87515. * @returns true if the bounding info is in the frustum planes
  87516. */
  87517. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87518. /**
  87519. * Gets the world distance between the min and max points of the bounding box
  87520. */
  87521. get diagonalLength(): number;
  87522. /**
  87523. * Checks if a cullable object (mesh...) is in the camera frustum
  87524. * Unlike isInFrustum this cheks the full bounding box
  87525. * @param frustumPlanes Camera near/planes
  87526. * @returns true if the object is in frustum otherwise false
  87527. */
  87528. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87529. /** @hidden */
  87530. _checkCollision(collider: Collider): boolean;
  87531. /**
  87532. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87533. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87534. * @param point the point to check intersection with
  87535. * @returns if the point intersects
  87536. */
  87537. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87538. /**
  87539. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87540. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87541. * @param boundingInfo the bounding info to check intersection with
  87542. * @param precise if the intersection should be done using OBB
  87543. * @returns if the bounding info intersects
  87544. */
  87545. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87546. }
  87547. }
  87548. declare module BABYLON {
  87549. /**
  87550. * Extracts minimum and maximum values from a list of indexed positions
  87551. * @param positions defines the positions to use
  87552. * @param indices defines the indices to the positions
  87553. * @param indexStart defines the start index
  87554. * @param indexCount defines the end index
  87555. * @param bias defines bias value to add to the result
  87556. * @return minimum and maximum values
  87557. */
  87558. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87559. minimum: Vector3;
  87560. maximum: Vector3;
  87561. };
  87562. /**
  87563. * Extracts minimum and maximum values from a list of positions
  87564. * @param positions defines the positions to use
  87565. * @param start defines the start index in the positions array
  87566. * @param count defines the number of positions to handle
  87567. * @param bias defines bias value to add to the result
  87568. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87569. * @return minimum and maximum values
  87570. */
  87571. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87572. minimum: Vector3;
  87573. maximum: Vector3;
  87574. };
  87575. }
  87576. declare module BABYLON {
  87577. /** @hidden */
  87578. export class WebGLDataBuffer extends DataBuffer {
  87579. private _buffer;
  87580. constructor(resource: WebGLBuffer);
  87581. get underlyingResource(): any;
  87582. }
  87583. }
  87584. declare module BABYLON {
  87585. /** @hidden */
  87586. export class WebGLPipelineContext implements IPipelineContext {
  87587. engine: ThinEngine;
  87588. program: Nullable<WebGLProgram>;
  87589. context?: WebGLRenderingContext;
  87590. vertexShader?: WebGLShader;
  87591. fragmentShader?: WebGLShader;
  87592. isParallelCompiled: boolean;
  87593. onCompiled?: () => void;
  87594. transformFeedback?: WebGLTransformFeedback | null;
  87595. vertexCompilationError: Nullable<string>;
  87596. fragmentCompilationError: Nullable<string>;
  87597. programLinkError: Nullable<string>;
  87598. programValidationError: Nullable<string>;
  87599. get isAsync(): boolean;
  87600. get isReady(): boolean;
  87601. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87602. _getVertexShaderCode(): string | null;
  87603. _getFragmentShaderCode(): string | null;
  87604. }
  87605. }
  87606. declare module BABYLON {
  87607. interface ThinEngine {
  87608. /**
  87609. * Create an uniform buffer
  87610. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87611. * @param elements defines the content of the uniform buffer
  87612. * @returns the webGL uniform buffer
  87613. */
  87614. createUniformBuffer(elements: FloatArray): DataBuffer;
  87615. /**
  87616. * Create a dynamic uniform buffer
  87617. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87618. * @param elements defines the content of the uniform buffer
  87619. * @returns the webGL uniform buffer
  87620. */
  87621. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87622. /**
  87623. * Update an existing uniform buffer
  87624. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87625. * @param uniformBuffer defines the target uniform buffer
  87626. * @param elements defines the content to update
  87627. * @param offset defines the offset in the uniform buffer where update should start
  87628. * @param count defines the size of the data to update
  87629. */
  87630. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87631. /**
  87632. * Bind an uniform buffer to the current webGL context
  87633. * @param buffer defines the buffer to bind
  87634. */
  87635. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87636. /**
  87637. * Bind a buffer to the current webGL context at a given location
  87638. * @param buffer defines the buffer to bind
  87639. * @param location defines the index where to bind the buffer
  87640. */
  87641. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87642. /**
  87643. * Bind a specific block at a given index in a specific shader program
  87644. * @param pipelineContext defines the pipeline context to use
  87645. * @param blockName defines the block name
  87646. * @param index defines the index where to bind the block
  87647. */
  87648. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87649. }
  87650. }
  87651. declare module BABYLON {
  87652. /**
  87653. * Uniform buffer objects.
  87654. *
  87655. * Handles blocks of uniform on the GPU.
  87656. *
  87657. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87658. *
  87659. * For more information, please refer to :
  87660. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87661. */
  87662. export class UniformBuffer {
  87663. private _engine;
  87664. private _buffer;
  87665. private _data;
  87666. private _bufferData;
  87667. private _dynamic?;
  87668. private _uniformLocations;
  87669. private _uniformSizes;
  87670. private _uniformLocationPointer;
  87671. private _needSync;
  87672. private _noUBO;
  87673. private _currentEffect;
  87674. /** @hidden */
  87675. _alreadyBound: boolean;
  87676. private static _MAX_UNIFORM_SIZE;
  87677. private static _tempBuffer;
  87678. /**
  87679. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87680. * This is dynamic to allow compat with webgl 1 and 2.
  87681. * You will need to pass the name of the uniform as well as the value.
  87682. */
  87683. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87684. /**
  87685. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87686. * This is dynamic to allow compat with webgl 1 and 2.
  87687. * You will need to pass the name of the uniform as well as the value.
  87688. */
  87689. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87690. /**
  87691. * Lambda to Update a single float in a uniform buffer.
  87692. * This is dynamic to allow compat with webgl 1 and 2.
  87693. * You will need to pass the name of the uniform as well as the value.
  87694. */
  87695. updateFloat: (name: string, x: number) => void;
  87696. /**
  87697. * Lambda to Update a vec2 of float in a uniform buffer.
  87698. * This is dynamic to allow compat with webgl 1 and 2.
  87699. * You will need to pass the name of the uniform as well as the value.
  87700. */
  87701. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87702. /**
  87703. * Lambda to Update a vec3 of float in a uniform buffer.
  87704. * This is dynamic to allow compat with webgl 1 and 2.
  87705. * You will need to pass the name of the uniform as well as the value.
  87706. */
  87707. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87708. /**
  87709. * Lambda to Update a vec4 of float in a uniform buffer.
  87710. * This is dynamic to allow compat with webgl 1 and 2.
  87711. * You will need to pass the name of the uniform as well as the value.
  87712. */
  87713. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87714. /**
  87715. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87716. * This is dynamic to allow compat with webgl 1 and 2.
  87717. * You will need to pass the name of the uniform as well as the value.
  87718. */
  87719. updateMatrix: (name: string, mat: Matrix) => void;
  87720. /**
  87721. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87722. * This is dynamic to allow compat with webgl 1 and 2.
  87723. * You will need to pass the name of the uniform as well as the value.
  87724. */
  87725. updateVector3: (name: string, vector: Vector3) => void;
  87726. /**
  87727. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87728. * This is dynamic to allow compat with webgl 1 and 2.
  87729. * You will need to pass the name of the uniform as well as the value.
  87730. */
  87731. updateVector4: (name: string, vector: Vector4) => void;
  87732. /**
  87733. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87734. * This is dynamic to allow compat with webgl 1 and 2.
  87735. * You will need to pass the name of the uniform as well as the value.
  87736. */
  87737. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87738. /**
  87739. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87740. * This is dynamic to allow compat with webgl 1 and 2.
  87741. * You will need to pass the name of the uniform as well as the value.
  87742. */
  87743. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87744. /**
  87745. * Instantiates a new Uniform buffer objects.
  87746. *
  87747. * Handles blocks of uniform on the GPU.
  87748. *
  87749. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87750. *
  87751. * For more information, please refer to :
  87752. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87753. * @param engine Define the engine the buffer is associated with
  87754. * @param data Define the data contained in the buffer
  87755. * @param dynamic Define if the buffer is updatable
  87756. */
  87757. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87758. /**
  87759. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87760. * or just falling back on setUniformXXX calls.
  87761. */
  87762. get useUbo(): boolean;
  87763. /**
  87764. * Indicates if the WebGL underlying uniform buffer is in sync
  87765. * with the javascript cache data.
  87766. */
  87767. get isSync(): boolean;
  87768. /**
  87769. * Indicates if the WebGL underlying uniform buffer is dynamic.
  87770. * Also, a dynamic UniformBuffer will disable cache verification and always
  87771. * update the underlying WebGL uniform buffer to the GPU.
  87772. * @returns if Dynamic, otherwise false
  87773. */
  87774. isDynamic(): boolean;
  87775. /**
  87776. * The data cache on JS side.
  87777. * @returns the underlying data as a float array
  87778. */
  87779. getData(): Float32Array;
  87780. /**
  87781. * The underlying WebGL Uniform buffer.
  87782. * @returns the webgl buffer
  87783. */
  87784. getBuffer(): Nullable<DataBuffer>;
  87785. /**
  87786. * std140 layout specifies how to align data within an UBO structure.
  87787. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  87788. * for specs.
  87789. */
  87790. private _fillAlignment;
  87791. /**
  87792. * Adds an uniform in the buffer.
  87793. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  87794. * for the layout to be correct !
  87795. * @param name Name of the uniform, as used in the uniform block in the shader.
  87796. * @param size Data size, or data directly.
  87797. */
  87798. addUniform(name: string, size: number | number[]): void;
  87799. /**
  87800. * Adds a Matrix 4x4 to the uniform buffer.
  87801. * @param name Name of the uniform, as used in the uniform block in the shader.
  87802. * @param mat A 4x4 matrix.
  87803. */
  87804. addMatrix(name: string, mat: Matrix): void;
  87805. /**
  87806. * Adds a vec2 to the uniform buffer.
  87807. * @param name Name of the uniform, as used in the uniform block in the shader.
  87808. * @param x Define the x component value of the vec2
  87809. * @param y Define the y component value of the vec2
  87810. */
  87811. addFloat2(name: string, x: number, y: number): void;
  87812. /**
  87813. * Adds a vec3 to the uniform buffer.
  87814. * @param name Name of the uniform, as used in the uniform block in the shader.
  87815. * @param x Define the x component value of the vec3
  87816. * @param y Define the y component value of the vec3
  87817. * @param z Define the z component value of the vec3
  87818. */
  87819. addFloat3(name: string, x: number, y: number, z: number): void;
  87820. /**
  87821. * Adds a vec3 to the uniform buffer.
  87822. * @param name Name of the uniform, as used in the uniform block in the shader.
  87823. * @param color Define the vec3 from a Color
  87824. */
  87825. addColor3(name: string, color: Color3): void;
  87826. /**
  87827. * Adds a vec4 to the uniform buffer.
  87828. * @param name Name of the uniform, as used in the uniform block in the shader.
  87829. * @param color Define the rgb components from a Color
  87830. * @param alpha Define the a component of the vec4
  87831. */
  87832. addColor4(name: string, color: Color3, alpha: number): void;
  87833. /**
  87834. * Adds a vec3 to the uniform buffer.
  87835. * @param name Name of the uniform, as used in the uniform block in the shader.
  87836. * @param vector Define the vec3 components from a Vector
  87837. */
  87838. addVector3(name: string, vector: Vector3): void;
  87839. /**
  87840. * Adds a Matrix 3x3 to the uniform buffer.
  87841. * @param name Name of the uniform, as used in the uniform block in the shader.
  87842. */
  87843. addMatrix3x3(name: string): void;
  87844. /**
  87845. * Adds a Matrix 2x2 to the uniform buffer.
  87846. * @param name Name of the uniform, as used in the uniform block in the shader.
  87847. */
  87848. addMatrix2x2(name: string): void;
  87849. /**
  87850. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  87851. */
  87852. create(): void;
  87853. /** @hidden */
  87854. _rebuild(): void;
  87855. /**
  87856. * Updates the WebGL Uniform Buffer on the GPU.
  87857. * If the `dynamic` flag is set to true, no cache comparison is done.
  87858. * Otherwise, the buffer will be updated only if the cache differs.
  87859. */
  87860. update(): void;
  87861. /**
  87862. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  87863. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87864. * @param data Define the flattened data
  87865. * @param size Define the size of the data.
  87866. */
  87867. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  87868. private _valueCache;
  87869. private _cacheMatrix;
  87870. private _updateMatrix3x3ForUniform;
  87871. private _updateMatrix3x3ForEffect;
  87872. private _updateMatrix2x2ForEffect;
  87873. private _updateMatrix2x2ForUniform;
  87874. private _updateFloatForEffect;
  87875. private _updateFloatForUniform;
  87876. private _updateFloat2ForEffect;
  87877. private _updateFloat2ForUniform;
  87878. private _updateFloat3ForEffect;
  87879. private _updateFloat3ForUniform;
  87880. private _updateFloat4ForEffect;
  87881. private _updateFloat4ForUniform;
  87882. private _updateMatrixForEffect;
  87883. private _updateMatrixForUniform;
  87884. private _updateVector3ForEffect;
  87885. private _updateVector3ForUniform;
  87886. private _updateVector4ForEffect;
  87887. private _updateVector4ForUniform;
  87888. private _updateColor3ForEffect;
  87889. private _updateColor3ForUniform;
  87890. private _updateColor4ForEffect;
  87891. private _updateColor4ForUniform;
  87892. /**
  87893. * Sets a sampler uniform on the effect.
  87894. * @param name Define the name of the sampler.
  87895. * @param texture Define the texture to set in the sampler
  87896. */
  87897. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  87898. /**
  87899. * Directly updates the value of the uniform in the cache AND on the GPU.
  87900. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  87901. * @param data Define the flattened data
  87902. */
  87903. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  87904. /**
  87905. * Binds this uniform buffer to an effect.
  87906. * @param effect Define the effect to bind the buffer to
  87907. * @param name Name of the uniform block in the shader.
  87908. */
  87909. bindToEffect(effect: Effect, name: string): void;
  87910. /**
  87911. * Disposes the uniform buffer.
  87912. */
  87913. dispose(): void;
  87914. }
  87915. }
  87916. declare module BABYLON {
  87917. /**
  87918. * Enum that determines the text-wrapping mode to use.
  87919. */
  87920. export enum InspectableType {
  87921. /**
  87922. * Checkbox for booleans
  87923. */
  87924. Checkbox = 0,
  87925. /**
  87926. * Sliders for numbers
  87927. */
  87928. Slider = 1,
  87929. /**
  87930. * Vector3
  87931. */
  87932. Vector3 = 2,
  87933. /**
  87934. * Quaternions
  87935. */
  87936. Quaternion = 3,
  87937. /**
  87938. * Color3
  87939. */
  87940. Color3 = 4,
  87941. /**
  87942. * String
  87943. */
  87944. String = 5
  87945. }
  87946. /**
  87947. * Interface used to define custom inspectable properties.
  87948. * This interface is used by the inspector to display custom property grids
  87949. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87950. */
  87951. export interface IInspectable {
  87952. /**
  87953. * Gets the label to display
  87954. */
  87955. label: string;
  87956. /**
  87957. * Gets the name of the property to edit
  87958. */
  87959. propertyName: string;
  87960. /**
  87961. * Gets the type of the editor to use
  87962. */
  87963. type: InspectableType;
  87964. /**
  87965. * Gets the minimum value of the property when using in "slider" mode
  87966. */
  87967. min?: number;
  87968. /**
  87969. * Gets the maximum value of the property when using in "slider" mode
  87970. */
  87971. max?: number;
  87972. /**
  87973. * Gets the setp to use when using in "slider" mode
  87974. */
  87975. step?: number;
  87976. }
  87977. }
  87978. declare module BABYLON {
  87979. /**
  87980. * Class used to provide helper for timing
  87981. */
  87982. export class TimingTools {
  87983. /**
  87984. * Polyfill for setImmediate
  87985. * @param action defines the action to execute after the current execution block
  87986. */
  87987. static SetImmediate(action: () => void): void;
  87988. }
  87989. }
  87990. declare module BABYLON {
  87991. /**
  87992. * Class used to enable instatition of objects by class name
  87993. */
  87994. export class InstantiationTools {
  87995. /**
  87996. * Use this object to register external classes like custom textures or material
  87997. * to allow the laoders to instantiate them
  87998. */
  87999. static RegisteredExternalClasses: {
  88000. [key: string]: Object;
  88001. };
  88002. /**
  88003. * Tries to instantiate a new object from a given class name
  88004. * @param className defines the class name to instantiate
  88005. * @returns the new object or null if the system was not able to do the instantiation
  88006. */
  88007. static Instantiate(className: string): any;
  88008. }
  88009. }
  88010. declare module BABYLON {
  88011. /**
  88012. * Define options used to create a depth texture
  88013. */
  88014. export class DepthTextureCreationOptions {
  88015. /** Specifies whether or not a stencil should be allocated in the texture */
  88016. generateStencil?: boolean;
  88017. /** Specifies whether or not bilinear filtering is enable on the texture */
  88018. bilinearFiltering?: boolean;
  88019. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88020. comparisonFunction?: number;
  88021. /** Specifies if the created texture is a cube texture */
  88022. isCube?: boolean;
  88023. }
  88024. }
  88025. declare module BABYLON {
  88026. interface ThinEngine {
  88027. /**
  88028. * Creates a depth stencil cube texture.
  88029. * This is only available in WebGL 2.
  88030. * @param size The size of face edge in the cube texture.
  88031. * @param options The options defining the cube texture.
  88032. * @returns The cube texture
  88033. */
  88034. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88035. /**
  88036. * Creates a cube texture
  88037. * @param rootUrl defines the url where the files to load is located
  88038. * @param scene defines the current scene
  88039. * @param files defines the list of files to load (1 per face)
  88040. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88041. * @param onLoad defines an optional callback raised when the texture is loaded
  88042. * @param onError defines an optional callback raised if there is an issue to load the texture
  88043. * @param format defines the format of the data
  88044. * @param forcedExtension defines the extension to use to pick the right loader
  88045. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88046. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88047. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88048. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88049. * @returns the cube texture as an InternalTexture
  88050. */
  88051. 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;
  88052. /**
  88053. * Creates a cube texture
  88054. * @param rootUrl defines the url where the files to load is located
  88055. * @param scene defines the current scene
  88056. * @param files defines the list of files to load (1 per face)
  88057. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88058. * @param onLoad defines an optional callback raised when the texture is loaded
  88059. * @param onError defines an optional callback raised if there is an issue to load the texture
  88060. * @param format defines the format of the data
  88061. * @param forcedExtension defines the extension to use to pick the right loader
  88062. * @returns the cube texture as an InternalTexture
  88063. */
  88064. 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;
  88065. /**
  88066. * Creates a cube texture
  88067. * @param rootUrl defines the url where the files to load is located
  88068. * @param scene defines the current scene
  88069. * @param files defines the list of files to load (1 per face)
  88070. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88071. * @param onLoad defines an optional callback raised when the texture is loaded
  88072. * @param onError defines an optional callback raised if there is an issue to load the texture
  88073. * @param format defines the format of the data
  88074. * @param forcedExtension defines the extension to use to pick the right loader
  88075. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88076. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88077. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88078. * @returns the cube texture as an InternalTexture
  88079. */
  88080. 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;
  88081. /** @hidden */
  88082. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88083. /** @hidden */
  88084. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88085. /** @hidden */
  88086. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88087. /** @hidden */
  88088. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88089. /**
  88090. * @hidden
  88091. */
  88092. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88093. }
  88094. }
  88095. declare module BABYLON {
  88096. /**
  88097. * Class for creating a cube texture
  88098. */
  88099. export class CubeTexture extends BaseTexture {
  88100. private _delayedOnLoad;
  88101. /**
  88102. * Observable triggered once the texture has been loaded.
  88103. */
  88104. onLoadObservable: Observable<CubeTexture>;
  88105. /**
  88106. * The url of the texture
  88107. */
  88108. url: string;
  88109. /**
  88110. * Gets or sets the center of the bounding box associated with the cube texture.
  88111. * It must define where the camera used to render the texture was set
  88112. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88113. */
  88114. boundingBoxPosition: Vector3;
  88115. private _boundingBoxSize;
  88116. /**
  88117. * Gets or sets the size of the bounding box associated with the cube texture
  88118. * When defined, the cubemap will switch to local mode
  88119. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88120. * @example https://www.babylonjs-playground.com/#RNASML
  88121. */
  88122. set boundingBoxSize(value: Vector3);
  88123. /**
  88124. * Returns the bounding box size
  88125. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88126. */
  88127. get boundingBoxSize(): Vector3;
  88128. protected _rotationY: number;
  88129. /**
  88130. * Sets texture matrix rotation angle around Y axis in radians.
  88131. */
  88132. set rotationY(value: number);
  88133. /**
  88134. * Gets texture matrix rotation angle around Y axis radians.
  88135. */
  88136. get rotationY(): number;
  88137. /**
  88138. * Are mip maps generated for this texture or not.
  88139. */
  88140. get noMipmap(): boolean;
  88141. private _noMipmap;
  88142. private _files;
  88143. protected _forcedExtension: Nullable<string>;
  88144. private _extensions;
  88145. private _textureMatrix;
  88146. private _format;
  88147. private _createPolynomials;
  88148. /**
  88149. * Creates a cube texture from an array of image urls
  88150. * @param files defines an array of image urls
  88151. * @param scene defines the hosting scene
  88152. * @param noMipmap specifies if mip maps are not used
  88153. * @returns a cube texture
  88154. */
  88155. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88156. /**
  88157. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88158. * @param url defines the url of the prefiltered texture
  88159. * @param scene defines the scene the texture is attached to
  88160. * @param forcedExtension defines the extension of the file if different from the url
  88161. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88162. * @return the prefiltered texture
  88163. */
  88164. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88165. /**
  88166. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88167. * as prefiltered data.
  88168. * @param rootUrl defines the url of the texture or the root name of the six images
  88169. * @param null defines the scene or engine the texture is attached to
  88170. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88171. * @param noMipmap defines if mipmaps should be created or not
  88172. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88173. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88174. * @param onError defines a callback triggered in case of error during load
  88175. * @param format defines the internal format to use for the texture once loaded
  88176. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88177. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88178. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88179. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88180. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88181. * @return the cube texture
  88182. */
  88183. 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);
  88184. /**
  88185. * Get the current class name of the texture useful for serialization or dynamic coding.
  88186. * @returns "CubeTexture"
  88187. */
  88188. getClassName(): string;
  88189. /**
  88190. * Update the url (and optional buffer) of this texture if url was null during construction.
  88191. * @param url the url of the texture
  88192. * @param forcedExtension defines the extension to use
  88193. * @param onLoad callback called when the texture is loaded (defaults to null)
  88194. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88195. */
  88196. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88197. /**
  88198. * Delays loading of the cube texture
  88199. * @param forcedExtension defines the extension to use
  88200. */
  88201. delayLoad(forcedExtension?: string): void;
  88202. /**
  88203. * Returns the reflection texture matrix
  88204. * @returns the reflection texture matrix
  88205. */
  88206. getReflectionTextureMatrix(): Matrix;
  88207. /**
  88208. * Sets the reflection texture matrix
  88209. * @param value Reflection texture matrix
  88210. */
  88211. setReflectionTextureMatrix(value: Matrix): void;
  88212. /**
  88213. * Parses text to create a cube texture
  88214. * @param parsedTexture define the serialized text to read from
  88215. * @param scene defines the hosting scene
  88216. * @param rootUrl defines the root url of the cube texture
  88217. * @returns a cube texture
  88218. */
  88219. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88220. /**
  88221. * Makes a clone, or deep copy, of the cube texture
  88222. * @returns a new cube texture
  88223. */
  88224. clone(): CubeTexture;
  88225. }
  88226. }
  88227. declare module BABYLON {
  88228. /**
  88229. * Manages the defines for the Material
  88230. */
  88231. export class MaterialDefines {
  88232. /** @hidden */
  88233. protected _keys: string[];
  88234. private _isDirty;
  88235. /** @hidden */
  88236. _renderId: number;
  88237. /** @hidden */
  88238. _areLightsDirty: boolean;
  88239. /** @hidden */
  88240. _areLightsDisposed: boolean;
  88241. /** @hidden */
  88242. _areAttributesDirty: boolean;
  88243. /** @hidden */
  88244. _areTexturesDirty: boolean;
  88245. /** @hidden */
  88246. _areFresnelDirty: boolean;
  88247. /** @hidden */
  88248. _areMiscDirty: boolean;
  88249. /** @hidden */
  88250. _areImageProcessingDirty: boolean;
  88251. /** @hidden */
  88252. _normals: boolean;
  88253. /** @hidden */
  88254. _uvs: boolean;
  88255. /** @hidden */
  88256. _needNormals: boolean;
  88257. /** @hidden */
  88258. _needUVs: boolean;
  88259. [id: string]: any;
  88260. /**
  88261. * Specifies if the material needs to be re-calculated
  88262. */
  88263. get isDirty(): boolean;
  88264. /**
  88265. * Marks the material to indicate that it has been re-calculated
  88266. */
  88267. markAsProcessed(): void;
  88268. /**
  88269. * Marks the material to indicate that it needs to be re-calculated
  88270. */
  88271. markAsUnprocessed(): void;
  88272. /**
  88273. * Marks the material to indicate all of its defines need to be re-calculated
  88274. */
  88275. markAllAsDirty(): void;
  88276. /**
  88277. * Marks the material to indicate that image processing needs to be re-calculated
  88278. */
  88279. markAsImageProcessingDirty(): void;
  88280. /**
  88281. * Marks the material to indicate the lights need to be re-calculated
  88282. * @param disposed Defines whether the light is dirty due to dispose or not
  88283. */
  88284. markAsLightDirty(disposed?: boolean): void;
  88285. /**
  88286. * Marks the attribute state as changed
  88287. */
  88288. markAsAttributesDirty(): void;
  88289. /**
  88290. * Marks the texture state as changed
  88291. */
  88292. markAsTexturesDirty(): void;
  88293. /**
  88294. * Marks the fresnel state as changed
  88295. */
  88296. markAsFresnelDirty(): void;
  88297. /**
  88298. * Marks the misc state as changed
  88299. */
  88300. markAsMiscDirty(): void;
  88301. /**
  88302. * Rebuilds the material defines
  88303. */
  88304. rebuild(): void;
  88305. /**
  88306. * Specifies if two material defines are equal
  88307. * @param other - A material define instance to compare to
  88308. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88309. */
  88310. isEqual(other: MaterialDefines): boolean;
  88311. /**
  88312. * Clones this instance's defines to another instance
  88313. * @param other - material defines to clone values to
  88314. */
  88315. cloneTo(other: MaterialDefines): void;
  88316. /**
  88317. * Resets the material define values
  88318. */
  88319. reset(): void;
  88320. /**
  88321. * Converts the material define values to a string
  88322. * @returns - String of material define information
  88323. */
  88324. toString(): string;
  88325. }
  88326. }
  88327. declare module BABYLON {
  88328. /**
  88329. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88330. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88331. * 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;
  88332. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88333. */
  88334. export class ColorCurves {
  88335. private _dirty;
  88336. private _tempColor;
  88337. private _globalCurve;
  88338. private _highlightsCurve;
  88339. private _midtonesCurve;
  88340. private _shadowsCurve;
  88341. private _positiveCurve;
  88342. private _negativeCurve;
  88343. private _globalHue;
  88344. private _globalDensity;
  88345. private _globalSaturation;
  88346. private _globalExposure;
  88347. /**
  88348. * Gets the global Hue value.
  88349. * 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).
  88350. */
  88351. get globalHue(): number;
  88352. /**
  88353. * Sets the global Hue value.
  88354. * 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).
  88355. */
  88356. set globalHue(value: number);
  88357. /**
  88358. * Gets the global Density value.
  88359. * 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.
  88360. * Values less than zero provide a filter of opposite hue.
  88361. */
  88362. get globalDensity(): number;
  88363. /**
  88364. * Sets the global Density value.
  88365. * 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.
  88366. * Values less than zero provide a filter of opposite hue.
  88367. */
  88368. set globalDensity(value: number);
  88369. /**
  88370. * Gets the global Saturation value.
  88371. * 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.
  88372. */
  88373. get globalSaturation(): number;
  88374. /**
  88375. * Sets the global Saturation value.
  88376. * 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.
  88377. */
  88378. set globalSaturation(value: number);
  88379. /**
  88380. * Gets the global Exposure value.
  88381. * 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.
  88382. */
  88383. get globalExposure(): number;
  88384. /**
  88385. * Sets the global Exposure value.
  88386. * 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.
  88387. */
  88388. set globalExposure(value: number);
  88389. private _highlightsHue;
  88390. private _highlightsDensity;
  88391. private _highlightsSaturation;
  88392. private _highlightsExposure;
  88393. /**
  88394. * Gets the highlights Hue value.
  88395. * 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).
  88396. */
  88397. get highlightsHue(): number;
  88398. /**
  88399. * Sets the highlights Hue value.
  88400. * 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).
  88401. */
  88402. set highlightsHue(value: number);
  88403. /**
  88404. * Gets the highlights Density value.
  88405. * 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.
  88406. * Values less than zero provide a filter of opposite hue.
  88407. */
  88408. get highlightsDensity(): number;
  88409. /**
  88410. * Sets the highlights Density value.
  88411. * 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.
  88412. * Values less than zero provide a filter of opposite hue.
  88413. */
  88414. set highlightsDensity(value: number);
  88415. /**
  88416. * Gets the highlights Saturation value.
  88417. * 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.
  88418. */
  88419. get highlightsSaturation(): number;
  88420. /**
  88421. * Sets the highlights Saturation value.
  88422. * 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.
  88423. */
  88424. set highlightsSaturation(value: number);
  88425. /**
  88426. * Gets the highlights Exposure value.
  88427. * 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.
  88428. */
  88429. get highlightsExposure(): number;
  88430. /**
  88431. * Sets the highlights Exposure value.
  88432. * 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.
  88433. */
  88434. set highlightsExposure(value: number);
  88435. private _midtonesHue;
  88436. private _midtonesDensity;
  88437. private _midtonesSaturation;
  88438. private _midtonesExposure;
  88439. /**
  88440. * Gets the midtones Hue value.
  88441. * 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).
  88442. */
  88443. get midtonesHue(): number;
  88444. /**
  88445. * Sets the midtones Hue value.
  88446. * 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).
  88447. */
  88448. set midtonesHue(value: number);
  88449. /**
  88450. * Gets the midtones Density value.
  88451. * 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.
  88452. * Values less than zero provide a filter of opposite hue.
  88453. */
  88454. get midtonesDensity(): number;
  88455. /**
  88456. * Sets the midtones Density value.
  88457. * 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.
  88458. * Values less than zero provide a filter of opposite hue.
  88459. */
  88460. set midtonesDensity(value: number);
  88461. /**
  88462. * Gets the midtones Saturation value.
  88463. * 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.
  88464. */
  88465. get midtonesSaturation(): number;
  88466. /**
  88467. * Sets the midtones Saturation value.
  88468. * 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.
  88469. */
  88470. set midtonesSaturation(value: number);
  88471. /**
  88472. * Gets the midtones Exposure value.
  88473. * 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.
  88474. */
  88475. get midtonesExposure(): number;
  88476. /**
  88477. * Sets the midtones Exposure value.
  88478. * 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.
  88479. */
  88480. set midtonesExposure(value: number);
  88481. private _shadowsHue;
  88482. private _shadowsDensity;
  88483. private _shadowsSaturation;
  88484. private _shadowsExposure;
  88485. /**
  88486. * Gets the shadows Hue value.
  88487. * 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).
  88488. */
  88489. get shadowsHue(): number;
  88490. /**
  88491. * Sets the shadows Hue value.
  88492. * 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).
  88493. */
  88494. set shadowsHue(value: number);
  88495. /**
  88496. * Gets the shadows Density value.
  88497. * 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.
  88498. * Values less than zero provide a filter of opposite hue.
  88499. */
  88500. get shadowsDensity(): number;
  88501. /**
  88502. * Sets the shadows Density value.
  88503. * 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.
  88504. * Values less than zero provide a filter of opposite hue.
  88505. */
  88506. set shadowsDensity(value: number);
  88507. /**
  88508. * Gets the shadows Saturation value.
  88509. * 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.
  88510. */
  88511. get shadowsSaturation(): number;
  88512. /**
  88513. * Sets the shadows Saturation value.
  88514. * 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.
  88515. */
  88516. set shadowsSaturation(value: number);
  88517. /**
  88518. * Gets the shadows Exposure value.
  88519. * 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.
  88520. */
  88521. get shadowsExposure(): number;
  88522. /**
  88523. * Sets the shadows Exposure value.
  88524. * 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.
  88525. */
  88526. set shadowsExposure(value: number);
  88527. /**
  88528. * Returns the class name
  88529. * @returns The class name
  88530. */
  88531. getClassName(): string;
  88532. /**
  88533. * Binds the color curves to the shader.
  88534. * @param colorCurves The color curve to bind
  88535. * @param effect The effect to bind to
  88536. * @param positiveUniform The positive uniform shader parameter
  88537. * @param neutralUniform The neutral uniform shader parameter
  88538. * @param negativeUniform The negative uniform shader parameter
  88539. */
  88540. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88541. /**
  88542. * Prepare the list of uniforms associated with the ColorCurves effects.
  88543. * @param uniformsList The list of uniforms used in the effect
  88544. */
  88545. static PrepareUniforms(uniformsList: string[]): void;
  88546. /**
  88547. * Returns color grading data based on a hue, density, saturation and exposure value.
  88548. * @param filterHue The hue of the color filter.
  88549. * @param filterDensity The density of the color filter.
  88550. * @param saturation The saturation.
  88551. * @param exposure The exposure.
  88552. * @param result The result data container.
  88553. */
  88554. private getColorGradingDataToRef;
  88555. /**
  88556. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88557. * @param value The input slider value in range [-100,100].
  88558. * @returns Adjusted value.
  88559. */
  88560. private static applyColorGradingSliderNonlinear;
  88561. /**
  88562. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88563. * @param hue The hue (H) input.
  88564. * @param saturation The saturation (S) input.
  88565. * @param brightness The brightness (B) input.
  88566. * @result An RGBA color represented as Vector4.
  88567. */
  88568. private static fromHSBToRef;
  88569. /**
  88570. * Returns a value clamped between min and max
  88571. * @param value The value to clamp
  88572. * @param min The minimum of value
  88573. * @param max The maximum of value
  88574. * @returns The clamped value.
  88575. */
  88576. private static clamp;
  88577. /**
  88578. * Clones the current color curve instance.
  88579. * @return The cloned curves
  88580. */
  88581. clone(): ColorCurves;
  88582. /**
  88583. * Serializes the current color curve instance to a json representation.
  88584. * @return a JSON representation
  88585. */
  88586. serialize(): any;
  88587. /**
  88588. * Parses the color curve from a json representation.
  88589. * @param source the JSON source to parse
  88590. * @return The parsed curves
  88591. */
  88592. static Parse(source: any): ColorCurves;
  88593. }
  88594. }
  88595. declare module BABYLON {
  88596. /**
  88597. * Interface to follow in your material defines to integrate easily the
  88598. * Image proccessing functions.
  88599. * @hidden
  88600. */
  88601. export interface IImageProcessingConfigurationDefines {
  88602. IMAGEPROCESSING: boolean;
  88603. VIGNETTE: boolean;
  88604. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88605. VIGNETTEBLENDMODEOPAQUE: boolean;
  88606. TONEMAPPING: boolean;
  88607. TONEMAPPING_ACES: boolean;
  88608. CONTRAST: boolean;
  88609. EXPOSURE: boolean;
  88610. COLORCURVES: boolean;
  88611. COLORGRADING: boolean;
  88612. COLORGRADING3D: boolean;
  88613. SAMPLER3DGREENDEPTH: boolean;
  88614. SAMPLER3DBGRMAP: boolean;
  88615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88616. }
  88617. /**
  88618. * @hidden
  88619. */
  88620. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88621. IMAGEPROCESSING: boolean;
  88622. VIGNETTE: boolean;
  88623. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88624. VIGNETTEBLENDMODEOPAQUE: boolean;
  88625. TONEMAPPING: boolean;
  88626. TONEMAPPING_ACES: boolean;
  88627. CONTRAST: boolean;
  88628. COLORCURVES: boolean;
  88629. COLORGRADING: boolean;
  88630. COLORGRADING3D: boolean;
  88631. SAMPLER3DGREENDEPTH: boolean;
  88632. SAMPLER3DBGRMAP: boolean;
  88633. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88634. EXPOSURE: boolean;
  88635. constructor();
  88636. }
  88637. /**
  88638. * This groups together the common properties used for image processing either in direct forward pass
  88639. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88640. * or not.
  88641. */
  88642. export class ImageProcessingConfiguration {
  88643. /**
  88644. * Default tone mapping applied in BabylonJS.
  88645. */
  88646. static readonly TONEMAPPING_STANDARD: number;
  88647. /**
  88648. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88649. * to other engines rendering to increase portability.
  88650. */
  88651. static readonly TONEMAPPING_ACES: number;
  88652. /**
  88653. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88654. */
  88655. colorCurves: Nullable<ColorCurves>;
  88656. private _colorCurvesEnabled;
  88657. /**
  88658. * Gets wether the color curves effect is enabled.
  88659. */
  88660. get colorCurvesEnabled(): boolean;
  88661. /**
  88662. * Sets wether the color curves effect is enabled.
  88663. */
  88664. set colorCurvesEnabled(value: boolean);
  88665. private _colorGradingTexture;
  88666. /**
  88667. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88668. */
  88669. get colorGradingTexture(): Nullable<BaseTexture>;
  88670. /**
  88671. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88672. */
  88673. set colorGradingTexture(value: Nullable<BaseTexture>);
  88674. private _colorGradingEnabled;
  88675. /**
  88676. * Gets wether the color grading effect is enabled.
  88677. */
  88678. get colorGradingEnabled(): boolean;
  88679. /**
  88680. * Sets wether the color grading effect is enabled.
  88681. */
  88682. set colorGradingEnabled(value: boolean);
  88683. private _colorGradingWithGreenDepth;
  88684. /**
  88685. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88686. */
  88687. get colorGradingWithGreenDepth(): boolean;
  88688. /**
  88689. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88690. */
  88691. set colorGradingWithGreenDepth(value: boolean);
  88692. private _colorGradingBGR;
  88693. /**
  88694. * Gets wether the color grading texture contains BGR values.
  88695. */
  88696. get colorGradingBGR(): boolean;
  88697. /**
  88698. * Sets wether the color grading texture contains BGR values.
  88699. */
  88700. set colorGradingBGR(value: boolean);
  88701. /** @hidden */
  88702. _exposure: number;
  88703. /**
  88704. * Gets the Exposure used in the effect.
  88705. */
  88706. get exposure(): number;
  88707. /**
  88708. * Sets the Exposure used in the effect.
  88709. */
  88710. set exposure(value: number);
  88711. private _toneMappingEnabled;
  88712. /**
  88713. * Gets wether the tone mapping effect is enabled.
  88714. */
  88715. get toneMappingEnabled(): boolean;
  88716. /**
  88717. * Sets wether the tone mapping effect is enabled.
  88718. */
  88719. set toneMappingEnabled(value: boolean);
  88720. private _toneMappingType;
  88721. /**
  88722. * Gets the type of tone mapping effect.
  88723. */
  88724. get toneMappingType(): number;
  88725. /**
  88726. * Sets the type of tone mapping effect used in BabylonJS.
  88727. */
  88728. set toneMappingType(value: number);
  88729. protected _contrast: number;
  88730. /**
  88731. * Gets the contrast used in the effect.
  88732. */
  88733. get contrast(): number;
  88734. /**
  88735. * Sets the contrast used in the effect.
  88736. */
  88737. set contrast(value: number);
  88738. /**
  88739. * Vignette stretch size.
  88740. */
  88741. vignetteStretch: number;
  88742. /**
  88743. * Vignette centre X Offset.
  88744. */
  88745. vignetteCentreX: number;
  88746. /**
  88747. * Vignette centre Y Offset.
  88748. */
  88749. vignetteCentreY: number;
  88750. /**
  88751. * Vignette weight or intensity of the vignette effect.
  88752. */
  88753. vignetteWeight: number;
  88754. /**
  88755. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88756. * if vignetteEnabled is set to true.
  88757. */
  88758. vignetteColor: Color4;
  88759. /**
  88760. * Camera field of view used by the Vignette effect.
  88761. */
  88762. vignetteCameraFov: number;
  88763. private _vignetteBlendMode;
  88764. /**
  88765. * Gets the vignette blend mode allowing different kind of effect.
  88766. */
  88767. get vignetteBlendMode(): number;
  88768. /**
  88769. * Sets the vignette blend mode allowing different kind of effect.
  88770. */
  88771. set vignetteBlendMode(value: number);
  88772. private _vignetteEnabled;
  88773. /**
  88774. * Gets wether the vignette effect is enabled.
  88775. */
  88776. get vignetteEnabled(): boolean;
  88777. /**
  88778. * Sets wether the vignette effect is enabled.
  88779. */
  88780. set vignetteEnabled(value: boolean);
  88781. private _applyByPostProcess;
  88782. /**
  88783. * Gets wether the image processing is applied through a post process or not.
  88784. */
  88785. get applyByPostProcess(): boolean;
  88786. /**
  88787. * Sets wether the image processing is applied through a post process or not.
  88788. */
  88789. set applyByPostProcess(value: boolean);
  88790. private _isEnabled;
  88791. /**
  88792. * Gets wether the image processing is enabled or not.
  88793. */
  88794. get isEnabled(): boolean;
  88795. /**
  88796. * Sets wether the image processing is enabled or not.
  88797. */
  88798. set isEnabled(value: boolean);
  88799. /**
  88800. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  88801. */
  88802. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  88803. /**
  88804. * Method called each time the image processing information changes requires to recompile the effect.
  88805. */
  88806. protected _updateParameters(): void;
  88807. /**
  88808. * Gets the current class name.
  88809. * @return "ImageProcessingConfiguration"
  88810. */
  88811. getClassName(): string;
  88812. /**
  88813. * Prepare the list of uniforms associated with the Image Processing effects.
  88814. * @param uniforms The list of uniforms used in the effect
  88815. * @param defines the list of defines currently in use
  88816. */
  88817. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  88818. /**
  88819. * Prepare the list of samplers associated with the Image Processing effects.
  88820. * @param samplersList The list of uniforms used in the effect
  88821. * @param defines the list of defines currently in use
  88822. */
  88823. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  88824. /**
  88825. * Prepare the list of defines associated to the shader.
  88826. * @param defines the list of defines to complete
  88827. * @param forPostProcess Define if we are currently in post process mode or not
  88828. */
  88829. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  88830. /**
  88831. * Returns true if all the image processing information are ready.
  88832. * @returns True if ready, otherwise, false
  88833. */
  88834. isReady(): boolean;
  88835. /**
  88836. * Binds the image processing to the shader.
  88837. * @param effect The effect to bind to
  88838. * @param overrideAspectRatio Override the aspect ratio of the effect
  88839. */
  88840. bind(effect: Effect, overrideAspectRatio?: number): void;
  88841. /**
  88842. * Clones the current image processing instance.
  88843. * @return The cloned image processing
  88844. */
  88845. clone(): ImageProcessingConfiguration;
  88846. /**
  88847. * Serializes the current image processing instance to a json representation.
  88848. * @return a JSON representation
  88849. */
  88850. serialize(): any;
  88851. /**
  88852. * Parses the image processing from a json representation.
  88853. * @param source the JSON source to parse
  88854. * @return The parsed image processing
  88855. */
  88856. static Parse(source: any): ImageProcessingConfiguration;
  88857. private static _VIGNETTEMODE_MULTIPLY;
  88858. private static _VIGNETTEMODE_OPAQUE;
  88859. /**
  88860. * Used to apply the vignette as a mix with the pixel color.
  88861. */
  88862. static get VIGNETTEMODE_MULTIPLY(): number;
  88863. /**
  88864. * Used to apply the vignette as a replacement of the pixel color.
  88865. */
  88866. static get VIGNETTEMODE_OPAQUE(): number;
  88867. }
  88868. }
  88869. declare module BABYLON {
  88870. /** @hidden */
  88871. export var postprocessVertexShader: {
  88872. name: string;
  88873. shader: string;
  88874. };
  88875. }
  88876. declare module BABYLON {
  88877. /**
  88878. * Type used to define a render target texture size (either with a number or with a rect width and height)
  88879. */
  88880. export type RenderTargetTextureSize = number | {
  88881. width: number;
  88882. height: number;
  88883. layers?: number;
  88884. };
  88885. interface ThinEngine {
  88886. /**
  88887. * Creates a new render target texture
  88888. * @param size defines the size of the texture
  88889. * @param options defines the options used to create the texture
  88890. * @returns a new render target texture stored in an InternalTexture
  88891. */
  88892. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88893. /**
  88894. * Creates a depth stencil texture.
  88895. * This is only available in WebGL 2 or with the depth texture extension available.
  88896. * @param size The size of face edge in the texture.
  88897. * @param options The options defining the texture.
  88898. * @returns The texture
  88899. */
  88900. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88901. /** @hidden */
  88902. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  88903. }
  88904. }
  88905. declare module BABYLON {
  88906. /**
  88907. * Defines the kind of connection point for node based material
  88908. */
  88909. export enum NodeMaterialBlockConnectionPointTypes {
  88910. /** Float */
  88911. Float = 1,
  88912. /** Int */
  88913. Int = 2,
  88914. /** Vector2 */
  88915. Vector2 = 4,
  88916. /** Vector3 */
  88917. Vector3 = 8,
  88918. /** Vector4 */
  88919. Vector4 = 16,
  88920. /** Color3 */
  88921. Color3 = 32,
  88922. /** Color4 */
  88923. Color4 = 64,
  88924. /** Matrix */
  88925. Matrix = 128,
  88926. /** Custom object */
  88927. Object = 256,
  88928. /** Detect type based on connection */
  88929. AutoDetect = 1024,
  88930. /** Output type that will be defined by input type */
  88931. BasedOnInput = 2048
  88932. }
  88933. }
  88934. declare module BABYLON {
  88935. /**
  88936. * Enum used to define the target of a block
  88937. */
  88938. export enum NodeMaterialBlockTargets {
  88939. /** Vertex shader */
  88940. Vertex = 1,
  88941. /** Fragment shader */
  88942. Fragment = 2,
  88943. /** Neutral */
  88944. Neutral = 4,
  88945. /** Vertex and Fragment */
  88946. VertexAndFragment = 3
  88947. }
  88948. }
  88949. declare module BABYLON {
  88950. /**
  88951. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  88952. */
  88953. export enum NodeMaterialBlockConnectionPointMode {
  88954. /** Value is an uniform */
  88955. Uniform = 0,
  88956. /** Value is a mesh attribute */
  88957. Attribute = 1,
  88958. /** Value is a varying between vertex and fragment shaders */
  88959. Varying = 2,
  88960. /** Mode is undefined */
  88961. Undefined = 3
  88962. }
  88963. }
  88964. declare module BABYLON {
  88965. /**
  88966. * Enum used to define system values e.g. values automatically provided by the system
  88967. */
  88968. export enum NodeMaterialSystemValues {
  88969. /** World */
  88970. World = 1,
  88971. /** View */
  88972. View = 2,
  88973. /** Projection */
  88974. Projection = 3,
  88975. /** ViewProjection */
  88976. ViewProjection = 4,
  88977. /** WorldView */
  88978. WorldView = 5,
  88979. /** WorldViewProjection */
  88980. WorldViewProjection = 6,
  88981. /** CameraPosition */
  88982. CameraPosition = 7,
  88983. /** Fog Color */
  88984. FogColor = 8,
  88985. /** Delta time */
  88986. DeltaTime = 9
  88987. }
  88988. }
  88989. declare module BABYLON {
  88990. /** Defines supported spaces */
  88991. export enum Space {
  88992. /** Local (object) space */
  88993. LOCAL = 0,
  88994. /** World space */
  88995. WORLD = 1,
  88996. /** Bone space */
  88997. BONE = 2
  88998. }
  88999. /** Defines the 3 main axes */
  89000. export class Axis {
  89001. /** X axis */
  89002. static X: Vector3;
  89003. /** Y axis */
  89004. static Y: Vector3;
  89005. /** Z axis */
  89006. static Z: Vector3;
  89007. }
  89008. }
  89009. declare module BABYLON {
  89010. /**
  89011. * Represents a camera frustum
  89012. */
  89013. export class Frustum {
  89014. /**
  89015. * Gets the planes representing the frustum
  89016. * @param transform matrix to be applied to the returned planes
  89017. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89018. */
  89019. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89020. /**
  89021. * Gets the near frustum plane transformed by the transform matrix
  89022. * @param transform transformation matrix to be applied to the resulting frustum plane
  89023. * @param frustumPlane the resuling frustum plane
  89024. */
  89025. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89026. /**
  89027. * Gets the far frustum plane transformed by the transform matrix
  89028. * @param transform transformation matrix to be applied to the resulting frustum plane
  89029. * @param frustumPlane the resuling frustum plane
  89030. */
  89031. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89032. /**
  89033. * Gets the left frustum plane transformed by the transform matrix
  89034. * @param transform transformation matrix to be applied to the resulting frustum plane
  89035. * @param frustumPlane the resuling frustum plane
  89036. */
  89037. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89038. /**
  89039. * Gets the right frustum plane transformed by the transform matrix
  89040. * @param transform transformation matrix to be applied to the resulting frustum plane
  89041. * @param frustumPlane the resuling frustum plane
  89042. */
  89043. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89044. /**
  89045. * Gets the top frustum plane transformed by the transform matrix
  89046. * @param transform transformation matrix to be applied to the resulting frustum plane
  89047. * @param frustumPlane the resuling frustum plane
  89048. */
  89049. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89050. /**
  89051. * Gets the bottom frustum plane transformed by the transform matrix
  89052. * @param transform transformation matrix to be applied to the resulting frustum plane
  89053. * @param frustumPlane the resuling frustum plane
  89054. */
  89055. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89056. /**
  89057. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89058. * @param transform transformation matrix to be applied to the resulting frustum planes
  89059. * @param frustumPlanes the resuling frustum planes
  89060. */
  89061. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89062. }
  89063. }
  89064. declare module BABYLON {
  89065. /**
  89066. * Interface for the size containing width and height
  89067. */
  89068. export interface ISize {
  89069. /**
  89070. * Width
  89071. */
  89072. width: number;
  89073. /**
  89074. * Heighht
  89075. */
  89076. height: number;
  89077. }
  89078. /**
  89079. * Size containing widht and height
  89080. */
  89081. export class Size implements ISize {
  89082. /**
  89083. * Width
  89084. */
  89085. width: number;
  89086. /**
  89087. * Height
  89088. */
  89089. height: number;
  89090. /**
  89091. * Creates a Size object from the given width and height (floats).
  89092. * @param width width of the new size
  89093. * @param height height of the new size
  89094. */
  89095. constructor(width: number, height: number);
  89096. /**
  89097. * Returns a string with the Size width and height
  89098. * @returns a string with the Size width and height
  89099. */
  89100. toString(): string;
  89101. /**
  89102. * "Size"
  89103. * @returns the string "Size"
  89104. */
  89105. getClassName(): string;
  89106. /**
  89107. * Returns the Size hash code.
  89108. * @returns a hash code for a unique width and height
  89109. */
  89110. getHashCode(): number;
  89111. /**
  89112. * Updates the current size from the given one.
  89113. * @param src the given size
  89114. */
  89115. copyFrom(src: Size): void;
  89116. /**
  89117. * Updates in place the current Size from the given floats.
  89118. * @param width width of the new size
  89119. * @param height height of the new size
  89120. * @returns the updated Size.
  89121. */
  89122. copyFromFloats(width: number, height: number): Size;
  89123. /**
  89124. * Updates in place the current Size from the given floats.
  89125. * @param width width to set
  89126. * @param height height to set
  89127. * @returns the updated Size.
  89128. */
  89129. set(width: number, height: number): Size;
  89130. /**
  89131. * Multiplies the width and height by numbers
  89132. * @param w factor to multiple the width by
  89133. * @param h factor to multiple the height by
  89134. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89135. */
  89136. multiplyByFloats(w: number, h: number): Size;
  89137. /**
  89138. * Clones the size
  89139. * @returns a new Size copied from the given one.
  89140. */
  89141. clone(): Size;
  89142. /**
  89143. * True if the current Size and the given one width and height are strictly equal.
  89144. * @param other the other size to compare against
  89145. * @returns True if the current Size and the given one width and height are strictly equal.
  89146. */
  89147. equals(other: Size): boolean;
  89148. /**
  89149. * The surface of the Size : width * height (float).
  89150. */
  89151. get surface(): number;
  89152. /**
  89153. * Create a new size of zero
  89154. * @returns a new Size set to (0.0, 0.0)
  89155. */
  89156. static Zero(): Size;
  89157. /**
  89158. * Sums the width and height of two sizes
  89159. * @param otherSize size to add to this size
  89160. * @returns a new Size set as the addition result of the current Size and the given one.
  89161. */
  89162. add(otherSize: Size): Size;
  89163. /**
  89164. * Subtracts the width and height of two
  89165. * @param otherSize size to subtract to this size
  89166. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89167. */
  89168. subtract(otherSize: Size): Size;
  89169. /**
  89170. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89171. * @param start starting size to lerp between
  89172. * @param end end size to lerp between
  89173. * @param amount amount to lerp between the start and end values
  89174. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89175. */
  89176. static Lerp(start: Size, end: Size, amount: number): Size;
  89177. }
  89178. }
  89179. declare module BABYLON {
  89180. /**
  89181. * Contains position and normal vectors for a vertex
  89182. */
  89183. export class PositionNormalVertex {
  89184. /** the position of the vertex (defaut: 0,0,0) */
  89185. position: Vector3;
  89186. /** the normal of the vertex (defaut: 0,1,0) */
  89187. normal: Vector3;
  89188. /**
  89189. * Creates a PositionNormalVertex
  89190. * @param position the position of the vertex (defaut: 0,0,0)
  89191. * @param normal the normal of the vertex (defaut: 0,1,0)
  89192. */
  89193. constructor(
  89194. /** the position of the vertex (defaut: 0,0,0) */
  89195. position?: Vector3,
  89196. /** the normal of the vertex (defaut: 0,1,0) */
  89197. normal?: Vector3);
  89198. /**
  89199. * Clones the PositionNormalVertex
  89200. * @returns the cloned PositionNormalVertex
  89201. */
  89202. clone(): PositionNormalVertex;
  89203. }
  89204. /**
  89205. * Contains position, normal and uv vectors for a vertex
  89206. */
  89207. export class PositionNormalTextureVertex {
  89208. /** the position of the vertex (defaut: 0,0,0) */
  89209. position: Vector3;
  89210. /** the normal of the vertex (defaut: 0,1,0) */
  89211. normal: Vector3;
  89212. /** the uv of the vertex (default: 0,0) */
  89213. uv: Vector2;
  89214. /**
  89215. * Creates a PositionNormalTextureVertex
  89216. * @param position the position of the vertex (defaut: 0,0,0)
  89217. * @param normal the normal of the vertex (defaut: 0,1,0)
  89218. * @param uv the uv of the vertex (default: 0,0)
  89219. */
  89220. constructor(
  89221. /** the position of the vertex (defaut: 0,0,0) */
  89222. position?: Vector3,
  89223. /** the normal of the vertex (defaut: 0,1,0) */
  89224. normal?: Vector3,
  89225. /** the uv of the vertex (default: 0,0) */
  89226. uv?: Vector2);
  89227. /**
  89228. * Clones the PositionNormalTextureVertex
  89229. * @returns the cloned PositionNormalTextureVertex
  89230. */
  89231. clone(): PositionNormalTextureVertex;
  89232. }
  89233. }
  89234. declare module BABYLON {
  89235. /**
  89236. * Enum defining the type of animations supported by InputBlock
  89237. */
  89238. export enum AnimatedInputBlockTypes {
  89239. /** No animation */
  89240. None = 0,
  89241. /** Time based animation. Will only work for floats */
  89242. Time = 1
  89243. }
  89244. }
  89245. declare module BABYLON {
  89246. /**
  89247. * Interface describing all the common properties and methods a shadow light needs to implement.
  89248. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89249. * as well as binding the different shadow properties to the effects.
  89250. */
  89251. export interface IShadowLight extends Light {
  89252. /**
  89253. * The light id in the scene (used in scene.findLighById for instance)
  89254. */
  89255. id: string;
  89256. /**
  89257. * The position the shdow will be casted from.
  89258. */
  89259. position: Vector3;
  89260. /**
  89261. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89262. */
  89263. direction: Vector3;
  89264. /**
  89265. * The transformed position. Position of the light in world space taking parenting in account.
  89266. */
  89267. transformedPosition: Vector3;
  89268. /**
  89269. * The transformed direction. Direction of the light in world space taking parenting in account.
  89270. */
  89271. transformedDirection: Vector3;
  89272. /**
  89273. * The friendly name of the light in the scene.
  89274. */
  89275. name: string;
  89276. /**
  89277. * Defines the shadow projection clipping minimum z value.
  89278. */
  89279. shadowMinZ: number;
  89280. /**
  89281. * Defines the shadow projection clipping maximum z value.
  89282. */
  89283. shadowMaxZ: number;
  89284. /**
  89285. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89286. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89287. */
  89288. computeTransformedInformation(): boolean;
  89289. /**
  89290. * Gets the scene the light belongs to.
  89291. * @returns The scene
  89292. */
  89293. getScene(): Scene;
  89294. /**
  89295. * Callback defining a custom Projection Matrix Builder.
  89296. * This can be used to override the default projection matrix computation.
  89297. */
  89298. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89299. /**
  89300. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89301. * @param matrix The materix to updated with the projection information
  89302. * @param viewMatrix The transform matrix of the light
  89303. * @param renderList The list of mesh to render in the map
  89304. * @returns The current light
  89305. */
  89306. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89307. /**
  89308. * Gets the current depth scale used in ESM.
  89309. * @returns The scale
  89310. */
  89311. getDepthScale(): number;
  89312. /**
  89313. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89314. * @returns true if a cube texture needs to be use
  89315. */
  89316. needCube(): boolean;
  89317. /**
  89318. * Detects if the projection matrix requires to be recomputed this frame.
  89319. * @returns true if it requires to be recomputed otherwise, false.
  89320. */
  89321. needProjectionMatrixCompute(): boolean;
  89322. /**
  89323. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89324. */
  89325. forceProjectionMatrixCompute(): void;
  89326. /**
  89327. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89328. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89329. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89330. */
  89331. getShadowDirection(faceIndex?: number): Vector3;
  89332. /**
  89333. * Gets the minZ used for shadow according to both the scene and the light.
  89334. * @param activeCamera The camera we are returning the min for
  89335. * @returns the depth min z
  89336. */
  89337. getDepthMinZ(activeCamera: Camera): number;
  89338. /**
  89339. * Gets the maxZ used for shadow according to both the scene and the light.
  89340. * @param activeCamera The camera we are returning the max for
  89341. * @returns the depth max z
  89342. */
  89343. getDepthMaxZ(activeCamera: Camera): number;
  89344. }
  89345. /**
  89346. * Base implementation IShadowLight
  89347. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89348. */
  89349. export abstract class ShadowLight extends Light implements IShadowLight {
  89350. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89351. protected _position: Vector3;
  89352. protected _setPosition(value: Vector3): void;
  89353. /**
  89354. * Sets the position the shadow will be casted from. Also use as the light position for both
  89355. * point and spot lights.
  89356. */
  89357. get position(): Vector3;
  89358. /**
  89359. * Sets the position the shadow will be casted from. Also use as the light position for both
  89360. * point and spot lights.
  89361. */
  89362. set position(value: Vector3);
  89363. protected _direction: Vector3;
  89364. protected _setDirection(value: Vector3): void;
  89365. /**
  89366. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89367. * Also use as the light direction on spot and directional lights.
  89368. */
  89369. get direction(): Vector3;
  89370. /**
  89371. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89372. * Also use as the light direction on spot and directional lights.
  89373. */
  89374. set direction(value: Vector3);
  89375. protected _shadowMinZ: number;
  89376. /**
  89377. * Gets the shadow projection clipping minimum z value.
  89378. */
  89379. get shadowMinZ(): number;
  89380. /**
  89381. * Sets the shadow projection clipping minimum z value.
  89382. */
  89383. set shadowMinZ(value: number);
  89384. protected _shadowMaxZ: number;
  89385. /**
  89386. * Sets the shadow projection clipping maximum z value.
  89387. */
  89388. get shadowMaxZ(): number;
  89389. /**
  89390. * Gets the shadow projection clipping maximum z value.
  89391. */
  89392. set shadowMaxZ(value: number);
  89393. /**
  89394. * Callback defining a custom Projection Matrix Builder.
  89395. * This can be used to override the default projection matrix computation.
  89396. */
  89397. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89398. /**
  89399. * The transformed position. Position of the light in world space taking parenting in account.
  89400. */
  89401. transformedPosition: Vector3;
  89402. /**
  89403. * The transformed direction. Direction of the light in world space taking parenting in account.
  89404. */
  89405. transformedDirection: Vector3;
  89406. private _needProjectionMatrixCompute;
  89407. /**
  89408. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89409. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89410. */
  89411. computeTransformedInformation(): boolean;
  89412. /**
  89413. * Return the depth scale used for the shadow map.
  89414. * @returns the depth scale.
  89415. */
  89416. getDepthScale(): number;
  89417. /**
  89418. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89419. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89420. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89421. */
  89422. getShadowDirection(faceIndex?: number): Vector3;
  89423. /**
  89424. * Returns the ShadowLight absolute position in the World.
  89425. * @returns the position vector in world space
  89426. */
  89427. getAbsolutePosition(): Vector3;
  89428. /**
  89429. * Sets the ShadowLight direction toward the passed target.
  89430. * @param target The point to target in local space
  89431. * @returns the updated ShadowLight direction
  89432. */
  89433. setDirectionToTarget(target: Vector3): Vector3;
  89434. /**
  89435. * Returns the light rotation in euler definition.
  89436. * @returns the x y z rotation in local space.
  89437. */
  89438. getRotation(): Vector3;
  89439. /**
  89440. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89441. * @returns true if a cube texture needs to be use
  89442. */
  89443. needCube(): boolean;
  89444. /**
  89445. * Detects if the projection matrix requires to be recomputed this frame.
  89446. * @returns true if it requires to be recomputed otherwise, false.
  89447. */
  89448. needProjectionMatrixCompute(): boolean;
  89449. /**
  89450. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89451. */
  89452. forceProjectionMatrixCompute(): void;
  89453. /** @hidden */
  89454. _initCache(): void;
  89455. /** @hidden */
  89456. _isSynchronized(): boolean;
  89457. /**
  89458. * Computes the world matrix of the node
  89459. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89460. * @returns the world matrix
  89461. */
  89462. computeWorldMatrix(force?: boolean): Matrix;
  89463. /**
  89464. * Gets the minZ used for shadow according to both the scene and the light.
  89465. * @param activeCamera The camera we are returning the min for
  89466. * @returns the depth min z
  89467. */
  89468. getDepthMinZ(activeCamera: Camera): number;
  89469. /**
  89470. * Gets the maxZ used for shadow according to both the scene and the light.
  89471. * @param activeCamera The camera we are returning the max for
  89472. * @returns the depth max z
  89473. */
  89474. getDepthMaxZ(activeCamera: Camera): number;
  89475. /**
  89476. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89477. * @param matrix The materix to updated with the projection information
  89478. * @param viewMatrix The transform matrix of the light
  89479. * @param renderList The list of mesh to render in the map
  89480. * @returns The current light
  89481. */
  89482. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89483. }
  89484. }
  89485. declare module BABYLON {
  89486. /** @hidden */
  89487. export var packingFunctions: {
  89488. name: string;
  89489. shader: string;
  89490. };
  89491. }
  89492. declare module BABYLON {
  89493. /** @hidden */
  89494. export var bayerDitherFunctions: {
  89495. name: string;
  89496. shader: string;
  89497. };
  89498. }
  89499. declare module BABYLON {
  89500. /** @hidden */
  89501. export var shadowMapFragmentDeclaration: {
  89502. name: string;
  89503. shader: string;
  89504. };
  89505. }
  89506. declare module BABYLON {
  89507. /** @hidden */
  89508. export var clipPlaneFragmentDeclaration: {
  89509. name: string;
  89510. shader: string;
  89511. };
  89512. }
  89513. declare module BABYLON {
  89514. /** @hidden */
  89515. export var clipPlaneFragment: {
  89516. name: string;
  89517. shader: string;
  89518. };
  89519. }
  89520. declare module BABYLON {
  89521. /** @hidden */
  89522. export var shadowMapFragment: {
  89523. name: string;
  89524. shader: string;
  89525. };
  89526. }
  89527. declare module BABYLON {
  89528. /** @hidden */
  89529. export var shadowMapPixelShader: {
  89530. name: string;
  89531. shader: string;
  89532. };
  89533. }
  89534. declare module BABYLON {
  89535. /** @hidden */
  89536. export var bonesDeclaration: {
  89537. name: string;
  89538. shader: string;
  89539. };
  89540. }
  89541. declare module BABYLON {
  89542. /** @hidden */
  89543. export var morphTargetsVertexGlobalDeclaration: {
  89544. name: string;
  89545. shader: string;
  89546. };
  89547. }
  89548. declare module BABYLON {
  89549. /** @hidden */
  89550. export var morphTargetsVertexDeclaration: {
  89551. name: string;
  89552. shader: string;
  89553. };
  89554. }
  89555. declare module BABYLON {
  89556. /** @hidden */
  89557. export var instancesDeclaration: {
  89558. name: string;
  89559. shader: string;
  89560. };
  89561. }
  89562. declare module BABYLON {
  89563. /** @hidden */
  89564. export var helperFunctions: {
  89565. name: string;
  89566. shader: string;
  89567. };
  89568. }
  89569. declare module BABYLON {
  89570. /** @hidden */
  89571. export var shadowMapVertexDeclaration: {
  89572. name: string;
  89573. shader: string;
  89574. };
  89575. }
  89576. declare module BABYLON {
  89577. /** @hidden */
  89578. export var clipPlaneVertexDeclaration: {
  89579. name: string;
  89580. shader: string;
  89581. };
  89582. }
  89583. declare module BABYLON {
  89584. /** @hidden */
  89585. export var morphTargetsVertex: {
  89586. name: string;
  89587. shader: string;
  89588. };
  89589. }
  89590. declare module BABYLON {
  89591. /** @hidden */
  89592. export var instancesVertex: {
  89593. name: string;
  89594. shader: string;
  89595. };
  89596. }
  89597. declare module BABYLON {
  89598. /** @hidden */
  89599. export var bonesVertex: {
  89600. name: string;
  89601. shader: string;
  89602. };
  89603. }
  89604. declare module BABYLON {
  89605. /** @hidden */
  89606. export var shadowMapVertexNormalBias: {
  89607. name: string;
  89608. shader: string;
  89609. };
  89610. }
  89611. declare module BABYLON {
  89612. /** @hidden */
  89613. export var shadowMapVertexMetric: {
  89614. name: string;
  89615. shader: string;
  89616. };
  89617. }
  89618. declare module BABYLON {
  89619. /** @hidden */
  89620. export var clipPlaneVertex: {
  89621. name: string;
  89622. shader: string;
  89623. };
  89624. }
  89625. declare module BABYLON {
  89626. /** @hidden */
  89627. export var shadowMapVertexShader: {
  89628. name: string;
  89629. shader: string;
  89630. };
  89631. }
  89632. declare module BABYLON {
  89633. /** @hidden */
  89634. export var depthBoxBlurPixelShader: {
  89635. name: string;
  89636. shader: string;
  89637. };
  89638. }
  89639. declare module BABYLON {
  89640. /** @hidden */
  89641. export var shadowMapFragmentSoftTransparentShadow: {
  89642. name: string;
  89643. shader: string;
  89644. };
  89645. }
  89646. declare module BABYLON {
  89647. /**
  89648. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89649. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89650. */
  89651. export class EffectFallbacks implements IEffectFallbacks {
  89652. private _defines;
  89653. private _currentRank;
  89654. private _maxRank;
  89655. private _mesh;
  89656. /**
  89657. * Removes the fallback from the bound mesh.
  89658. */
  89659. unBindMesh(): void;
  89660. /**
  89661. * Adds a fallback on the specified property.
  89662. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89663. * @param define The name of the define in the shader
  89664. */
  89665. addFallback(rank: number, define: string): void;
  89666. /**
  89667. * Sets the mesh to use CPU skinning when needing to fallback.
  89668. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89669. * @param mesh The mesh to use the fallbacks.
  89670. */
  89671. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89672. /**
  89673. * Checks to see if more fallbacks are still availible.
  89674. */
  89675. get hasMoreFallbacks(): boolean;
  89676. /**
  89677. * Removes the defines that should be removed when falling back.
  89678. * @param currentDefines defines the current define statements for the shader.
  89679. * @param effect defines the current effect we try to compile
  89680. * @returns The resulting defines with defines of the current rank removed.
  89681. */
  89682. reduce(currentDefines: string, effect: Effect): string;
  89683. }
  89684. }
  89685. declare module BABYLON {
  89686. /**
  89687. * Interface used to define Action
  89688. */
  89689. export interface IAction {
  89690. /**
  89691. * Trigger for the action
  89692. */
  89693. trigger: number;
  89694. /** Options of the trigger */
  89695. triggerOptions: any;
  89696. /**
  89697. * Gets the trigger parameters
  89698. * @returns the trigger parameters
  89699. */
  89700. getTriggerParameter(): any;
  89701. /**
  89702. * Internal only - executes current action event
  89703. * @hidden
  89704. */
  89705. _executeCurrent(evt?: ActionEvent): void;
  89706. /**
  89707. * Serialize placeholder for child classes
  89708. * @param parent of child
  89709. * @returns the serialized object
  89710. */
  89711. serialize(parent: any): any;
  89712. /**
  89713. * Internal only
  89714. * @hidden
  89715. */
  89716. _prepare(): void;
  89717. /**
  89718. * Internal only - manager for action
  89719. * @hidden
  89720. */
  89721. _actionManager: Nullable<AbstractActionManager>;
  89722. /**
  89723. * Adds action to chain of actions, may be a DoNothingAction
  89724. * @param action defines the next action to execute
  89725. * @returns The action passed in
  89726. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89727. */
  89728. then(action: IAction): IAction;
  89729. }
  89730. /**
  89731. * The action to be carried out following a trigger
  89732. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89733. */
  89734. export class Action implements IAction {
  89735. /** the trigger, with or without parameters, for the action */
  89736. triggerOptions: any;
  89737. /**
  89738. * Trigger for the action
  89739. */
  89740. trigger: number;
  89741. /**
  89742. * Internal only - manager for action
  89743. * @hidden
  89744. */
  89745. _actionManager: ActionManager;
  89746. private _nextActiveAction;
  89747. private _child;
  89748. private _condition?;
  89749. private _triggerParameter;
  89750. /**
  89751. * An event triggered prior to action being executed.
  89752. */
  89753. onBeforeExecuteObservable: Observable<Action>;
  89754. /**
  89755. * Creates a new Action
  89756. * @param triggerOptions the trigger, with or without parameters, for the action
  89757. * @param condition an optional determinant of action
  89758. */
  89759. constructor(
  89760. /** the trigger, with or without parameters, for the action */
  89761. triggerOptions: any, condition?: Condition);
  89762. /**
  89763. * Internal only
  89764. * @hidden
  89765. */
  89766. _prepare(): void;
  89767. /**
  89768. * Gets the trigger parameters
  89769. * @returns the trigger parameters
  89770. */
  89771. getTriggerParameter(): any;
  89772. /**
  89773. * Internal only - executes current action event
  89774. * @hidden
  89775. */
  89776. _executeCurrent(evt?: ActionEvent): void;
  89777. /**
  89778. * Execute placeholder for child classes
  89779. * @param evt optional action event
  89780. */
  89781. execute(evt?: ActionEvent): void;
  89782. /**
  89783. * Skips to next active action
  89784. */
  89785. skipToNextActiveAction(): void;
  89786. /**
  89787. * Adds action to chain of actions, may be a DoNothingAction
  89788. * @param action defines the next action to execute
  89789. * @returns The action passed in
  89790. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89791. */
  89792. then(action: Action): Action;
  89793. /**
  89794. * Internal only
  89795. * @hidden
  89796. */
  89797. _getProperty(propertyPath: string): string;
  89798. /**
  89799. * Internal only
  89800. * @hidden
  89801. */
  89802. _getEffectiveTarget(target: any, propertyPath: string): any;
  89803. /**
  89804. * Serialize placeholder for child classes
  89805. * @param parent of child
  89806. * @returns the serialized object
  89807. */
  89808. serialize(parent: any): any;
  89809. /**
  89810. * Internal only called by serialize
  89811. * @hidden
  89812. */
  89813. protected _serialize(serializedAction: any, parent?: any): any;
  89814. /**
  89815. * Internal only
  89816. * @hidden
  89817. */
  89818. static _SerializeValueAsString: (value: any) => string;
  89819. /**
  89820. * Internal only
  89821. * @hidden
  89822. */
  89823. static _GetTargetProperty: (target: Scene | Node) => {
  89824. name: string;
  89825. targetType: string;
  89826. value: string;
  89827. };
  89828. }
  89829. }
  89830. declare module BABYLON {
  89831. /**
  89832. * A Condition applied to an Action
  89833. */
  89834. export class Condition {
  89835. /**
  89836. * Internal only - manager for action
  89837. * @hidden
  89838. */
  89839. _actionManager: ActionManager;
  89840. /**
  89841. * Internal only
  89842. * @hidden
  89843. */
  89844. _evaluationId: number;
  89845. /**
  89846. * Internal only
  89847. * @hidden
  89848. */
  89849. _currentResult: boolean;
  89850. /**
  89851. * Creates a new Condition
  89852. * @param actionManager the manager of the action the condition is applied to
  89853. */
  89854. constructor(actionManager: ActionManager);
  89855. /**
  89856. * Check if the current condition is valid
  89857. * @returns a boolean
  89858. */
  89859. isValid(): boolean;
  89860. /**
  89861. * Internal only
  89862. * @hidden
  89863. */
  89864. _getProperty(propertyPath: string): string;
  89865. /**
  89866. * Internal only
  89867. * @hidden
  89868. */
  89869. _getEffectiveTarget(target: any, propertyPath: string): any;
  89870. /**
  89871. * Serialize placeholder for child classes
  89872. * @returns the serialized object
  89873. */
  89874. serialize(): any;
  89875. /**
  89876. * Internal only
  89877. * @hidden
  89878. */
  89879. protected _serialize(serializedCondition: any): any;
  89880. }
  89881. /**
  89882. * Defines specific conditional operators as extensions of Condition
  89883. */
  89884. export class ValueCondition extends Condition {
  89885. /** path to specify the property of the target the conditional operator uses */
  89886. propertyPath: string;
  89887. /** the value compared by the conditional operator against the current value of the property */
  89888. value: any;
  89889. /** the conditional operator, default ValueCondition.IsEqual */
  89890. operator: number;
  89891. /**
  89892. * Internal only
  89893. * @hidden
  89894. */
  89895. private static _IsEqual;
  89896. /**
  89897. * Internal only
  89898. * @hidden
  89899. */
  89900. private static _IsDifferent;
  89901. /**
  89902. * Internal only
  89903. * @hidden
  89904. */
  89905. private static _IsGreater;
  89906. /**
  89907. * Internal only
  89908. * @hidden
  89909. */
  89910. private static _IsLesser;
  89911. /**
  89912. * returns the number for IsEqual
  89913. */
  89914. static get IsEqual(): number;
  89915. /**
  89916. * Returns the number for IsDifferent
  89917. */
  89918. static get IsDifferent(): number;
  89919. /**
  89920. * Returns the number for IsGreater
  89921. */
  89922. static get IsGreater(): number;
  89923. /**
  89924. * Returns the number for IsLesser
  89925. */
  89926. static get IsLesser(): number;
  89927. /**
  89928. * Internal only The action manager for the condition
  89929. * @hidden
  89930. */
  89931. _actionManager: ActionManager;
  89932. /**
  89933. * Internal only
  89934. * @hidden
  89935. */
  89936. private _target;
  89937. /**
  89938. * Internal only
  89939. * @hidden
  89940. */
  89941. private _effectiveTarget;
  89942. /**
  89943. * Internal only
  89944. * @hidden
  89945. */
  89946. private _property;
  89947. /**
  89948. * Creates a new ValueCondition
  89949. * @param actionManager manager for the action the condition applies to
  89950. * @param target for the action
  89951. * @param propertyPath path to specify the property of the target the conditional operator uses
  89952. * @param value the value compared by the conditional operator against the current value of the property
  89953. * @param operator the conditional operator, default ValueCondition.IsEqual
  89954. */
  89955. constructor(actionManager: ActionManager, target: any,
  89956. /** path to specify the property of the target the conditional operator uses */
  89957. propertyPath: string,
  89958. /** the value compared by the conditional operator against the current value of the property */
  89959. value: any,
  89960. /** the conditional operator, default ValueCondition.IsEqual */
  89961. operator?: number);
  89962. /**
  89963. * Compares the given value with the property value for the specified conditional operator
  89964. * @returns the result of the comparison
  89965. */
  89966. isValid(): boolean;
  89967. /**
  89968. * Serialize the ValueCondition into a JSON compatible object
  89969. * @returns serialization object
  89970. */
  89971. serialize(): any;
  89972. /**
  89973. * Gets the name of the conditional operator for the ValueCondition
  89974. * @param operator the conditional operator
  89975. * @returns the name
  89976. */
  89977. static GetOperatorName(operator: number): string;
  89978. }
  89979. /**
  89980. * Defines a predicate condition as an extension of Condition
  89981. */
  89982. export class PredicateCondition extends Condition {
  89983. /** defines the predicate function used to validate the condition */
  89984. predicate: () => boolean;
  89985. /**
  89986. * Internal only - manager for action
  89987. * @hidden
  89988. */
  89989. _actionManager: ActionManager;
  89990. /**
  89991. * Creates a new PredicateCondition
  89992. * @param actionManager manager for the action the condition applies to
  89993. * @param predicate defines the predicate function used to validate the condition
  89994. */
  89995. constructor(actionManager: ActionManager,
  89996. /** defines the predicate function used to validate the condition */
  89997. predicate: () => boolean);
  89998. /**
  89999. * @returns the validity of the predicate condition
  90000. */
  90001. isValid(): boolean;
  90002. }
  90003. /**
  90004. * Defines a state condition as an extension of Condition
  90005. */
  90006. export class StateCondition extends Condition {
  90007. /** Value to compare with target state */
  90008. value: string;
  90009. /**
  90010. * Internal only - manager for action
  90011. * @hidden
  90012. */
  90013. _actionManager: ActionManager;
  90014. /**
  90015. * Internal only
  90016. * @hidden
  90017. */
  90018. private _target;
  90019. /**
  90020. * Creates a new StateCondition
  90021. * @param actionManager manager for the action the condition applies to
  90022. * @param target of the condition
  90023. * @param value to compare with target state
  90024. */
  90025. constructor(actionManager: ActionManager, target: any,
  90026. /** Value to compare with target state */
  90027. value: string);
  90028. /**
  90029. * Gets a boolean indicating if the current condition is met
  90030. * @returns the validity of the state
  90031. */
  90032. isValid(): boolean;
  90033. /**
  90034. * Serialize the StateCondition into a JSON compatible object
  90035. * @returns serialization object
  90036. */
  90037. serialize(): any;
  90038. }
  90039. }
  90040. declare module BABYLON {
  90041. /**
  90042. * This defines an action responsible to toggle a boolean once triggered.
  90043. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90044. */
  90045. export class SwitchBooleanAction extends Action {
  90046. /**
  90047. * The path to the boolean property in the target object
  90048. */
  90049. propertyPath: string;
  90050. private _target;
  90051. private _effectiveTarget;
  90052. private _property;
  90053. /**
  90054. * Instantiate the action
  90055. * @param triggerOptions defines the trigger options
  90056. * @param target defines the object containing the boolean
  90057. * @param propertyPath defines the path to the boolean property in the target object
  90058. * @param condition defines the trigger related conditions
  90059. */
  90060. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90061. /** @hidden */
  90062. _prepare(): void;
  90063. /**
  90064. * Execute the action toggle the boolean value.
  90065. */
  90066. execute(): void;
  90067. /**
  90068. * Serializes the actions and its related information.
  90069. * @param parent defines the object to serialize in
  90070. * @returns the serialized object
  90071. */
  90072. serialize(parent: any): any;
  90073. }
  90074. /**
  90075. * This defines an action responsible to set a the state field of the target
  90076. * to a desired value once triggered.
  90077. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90078. */
  90079. export class SetStateAction extends Action {
  90080. /**
  90081. * The value to store in the state field.
  90082. */
  90083. value: string;
  90084. private _target;
  90085. /**
  90086. * Instantiate the action
  90087. * @param triggerOptions defines the trigger options
  90088. * @param target defines the object containing the state property
  90089. * @param value defines the value to store in the state field
  90090. * @param condition defines the trigger related conditions
  90091. */
  90092. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90093. /**
  90094. * Execute the action and store the value on the target state property.
  90095. */
  90096. execute(): void;
  90097. /**
  90098. * Serializes the actions and its related information.
  90099. * @param parent defines the object to serialize in
  90100. * @returns the serialized object
  90101. */
  90102. serialize(parent: any): any;
  90103. }
  90104. /**
  90105. * This defines an action responsible to set a property of the target
  90106. * to a desired value once triggered.
  90107. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90108. */
  90109. export class SetValueAction extends Action {
  90110. /**
  90111. * The path of the property to set in the target.
  90112. */
  90113. propertyPath: string;
  90114. /**
  90115. * The value to set in the property
  90116. */
  90117. value: any;
  90118. private _target;
  90119. private _effectiveTarget;
  90120. private _property;
  90121. /**
  90122. * Instantiate the action
  90123. * @param triggerOptions defines the trigger options
  90124. * @param target defines the object containing the property
  90125. * @param propertyPath defines the path of the property to set in the target
  90126. * @param value defines the value to set in the property
  90127. * @param condition defines the trigger related conditions
  90128. */
  90129. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90130. /** @hidden */
  90131. _prepare(): void;
  90132. /**
  90133. * Execute the action and set the targetted property to the desired value.
  90134. */
  90135. execute(): void;
  90136. /**
  90137. * Serializes the actions and its related information.
  90138. * @param parent defines the object to serialize in
  90139. * @returns the serialized object
  90140. */
  90141. serialize(parent: any): any;
  90142. }
  90143. /**
  90144. * This defines an action responsible to increment the target value
  90145. * to a desired value once triggered.
  90146. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90147. */
  90148. export class IncrementValueAction extends Action {
  90149. /**
  90150. * The path of the property to increment in the target.
  90151. */
  90152. propertyPath: string;
  90153. /**
  90154. * The value we should increment the property by.
  90155. */
  90156. value: any;
  90157. private _target;
  90158. private _effectiveTarget;
  90159. private _property;
  90160. /**
  90161. * Instantiate the action
  90162. * @param triggerOptions defines the trigger options
  90163. * @param target defines the object containing the property
  90164. * @param propertyPath defines the path of the property to increment in the target
  90165. * @param value defines the value value we should increment the property by
  90166. * @param condition defines the trigger related conditions
  90167. */
  90168. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90169. /** @hidden */
  90170. _prepare(): void;
  90171. /**
  90172. * Execute the action and increment the target of the value amount.
  90173. */
  90174. execute(): void;
  90175. /**
  90176. * Serializes the actions and its related information.
  90177. * @param parent defines the object to serialize in
  90178. * @returns the serialized object
  90179. */
  90180. serialize(parent: any): any;
  90181. }
  90182. /**
  90183. * This defines an action responsible to start an animation once triggered.
  90184. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90185. */
  90186. export class PlayAnimationAction extends Action {
  90187. /**
  90188. * Where the animation should start (animation frame)
  90189. */
  90190. from: number;
  90191. /**
  90192. * Where the animation should stop (animation frame)
  90193. */
  90194. to: number;
  90195. /**
  90196. * Define if the animation should loop or stop after the first play.
  90197. */
  90198. loop?: boolean;
  90199. private _target;
  90200. /**
  90201. * Instantiate the action
  90202. * @param triggerOptions defines the trigger options
  90203. * @param target defines the target animation or animation name
  90204. * @param from defines from where the animation should start (animation frame)
  90205. * @param end defines where the animation should stop (animation frame)
  90206. * @param loop defines if the animation should loop or stop after the first play
  90207. * @param condition defines the trigger related conditions
  90208. */
  90209. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90210. /** @hidden */
  90211. _prepare(): void;
  90212. /**
  90213. * Execute the action and play the animation.
  90214. */
  90215. execute(): void;
  90216. /**
  90217. * Serializes the actions and its related information.
  90218. * @param parent defines the object to serialize in
  90219. * @returns the serialized object
  90220. */
  90221. serialize(parent: any): any;
  90222. }
  90223. /**
  90224. * This defines an action responsible to stop an animation once triggered.
  90225. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90226. */
  90227. export class StopAnimationAction extends Action {
  90228. private _target;
  90229. /**
  90230. * Instantiate the action
  90231. * @param triggerOptions defines the trigger options
  90232. * @param target defines the target animation or animation name
  90233. * @param condition defines the trigger related conditions
  90234. */
  90235. constructor(triggerOptions: any, target: any, condition?: Condition);
  90236. /** @hidden */
  90237. _prepare(): void;
  90238. /**
  90239. * Execute the action and stop the animation.
  90240. */
  90241. execute(): void;
  90242. /**
  90243. * Serializes the actions and its related information.
  90244. * @param parent defines the object to serialize in
  90245. * @returns the serialized object
  90246. */
  90247. serialize(parent: any): any;
  90248. }
  90249. /**
  90250. * This defines an action responsible that does nothing once triggered.
  90251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90252. */
  90253. export class DoNothingAction extends Action {
  90254. /**
  90255. * Instantiate the action
  90256. * @param triggerOptions defines the trigger options
  90257. * @param condition defines the trigger related conditions
  90258. */
  90259. constructor(triggerOptions?: any, condition?: Condition);
  90260. /**
  90261. * Execute the action and do nothing.
  90262. */
  90263. execute(): void;
  90264. /**
  90265. * Serializes the actions and its related information.
  90266. * @param parent defines the object to serialize in
  90267. * @returns the serialized object
  90268. */
  90269. serialize(parent: any): any;
  90270. }
  90271. /**
  90272. * This defines an action responsible to trigger several actions once triggered.
  90273. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90274. */
  90275. export class CombineAction extends Action {
  90276. /**
  90277. * The list of aggregated animations to run.
  90278. */
  90279. children: Action[];
  90280. /**
  90281. * Instantiate the action
  90282. * @param triggerOptions defines the trigger options
  90283. * @param children defines the list of aggregated animations to run
  90284. * @param condition defines the trigger related conditions
  90285. */
  90286. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90287. /** @hidden */
  90288. _prepare(): void;
  90289. /**
  90290. * Execute the action and executes all the aggregated actions.
  90291. */
  90292. execute(evt: ActionEvent): void;
  90293. /**
  90294. * Serializes the actions and its related information.
  90295. * @param parent defines the object to serialize in
  90296. * @returns the serialized object
  90297. */
  90298. serialize(parent: any): any;
  90299. }
  90300. /**
  90301. * This defines an action responsible to run code (external event) once triggered.
  90302. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90303. */
  90304. export class ExecuteCodeAction extends Action {
  90305. /**
  90306. * The callback function to run.
  90307. */
  90308. func: (evt: ActionEvent) => void;
  90309. /**
  90310. * Instantiate the action
  90311. * @param triggerOptions defines the trigger options
  90312. * @param func defines the callback function to run
  90313. * @param condition defines the trigger related conditions
  90314. */
  90315. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90316. /**
  90317. * Execute the action and run the attached code.
  90318. */
  90319. execute(evt: ActionEvent): void;
  90320. }
  90321. /**
  90322. * This defines an action responsible to set the parent property of the target once triggered.
  90323. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90324. */
  90325. export class SetParentAction extends Action {
  90326. private _parent;
  90327. private _target;
  90328. /**
  90329. * Instantiate the action
  90330. * @param triggerOptions defines the trigger options
  90331. * @param target defines the target containing the parent property
  90332. * @param parent defines from where the animation should start (animation frame)
  90333. * @param condition defines the trigger related conditions
  90334. */
  90335. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90336. /** @hidden */
  90337. _prepare(): void;
  90338. /**
  90339. * Execute the action and set the parent property.
  90340. */
  90341. execute(): void;
  90342. /**
  90343. * Serializes the actions and its related information.
  90344. * @param parent defines the object to serialize in
  90345. * @returns the serialized object
  90346. */
  90347. serialize(parent: any): any;
  90348. }
  90349. }
  90350. declare module BABYLON {
  90351. /**
  90352. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90353. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90354. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90355. */
  90356. export class ActionManager extends AbstractActionManager {
  90357. /**
  90358. * Nothing
  90359. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90360. */
  90361. static readonly NothingTrigger: number;
  90362. /**
  90363. * On pick
  90364. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90365. */
  90366. static readonly OnPickTrigger: number;
  90367. /**
  90368. * On left pick
  90369. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90370. */
  90371. static readonly OnLeftPickTrigger: number;
  90372. /**
  90373. * On right pick
  90374. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90375. */
  90376. static readonly OnRightPickTrigger: number;
  90377. /**
  90378. * On center pick
  90379. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90380. */
  90381. static readonly OnCenterPickTrigger: number;
  90382. /**
  90383. * On pick down
  90384. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90385. */
  90386. static readonly OnPickDownTrigger: number;
  90387. /**
  90388. * On double pick
  90389. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90390. */
  90391. static readonly OnDoublePickTrigger: number;
  90392. /**
  90393. * On pick up
  90394. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90395. */
  90396. static readonly OnPickUpTrigger: number;
  90397. /**
  90398. * On pick out.
  90399. * This trigger will only be raised if you also declared a OnPickDown
  90400. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90401. */
  90402. static readonly OnPickOutTrigger: number;
  90403. /**
  90404. * On long press
  90405. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90406. */
  90407. static readonly OnLongPressTrigger: number;
  90408. /**
  90409. * On pointer over
  90410. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90411. */
  90412. static readonly OnPointerOverTrigger: number;
  90413. /**
  90414. * On pointer out
  90415. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90416. */
  90417. static readonly OnPointerOutTrigger: number;
  90418. /**
  90419. * On every frame
  90420. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90421. */
  90422. static readonly OnEveryFrameTrigger: number;
  90423. /**
  90424. * On intersection enter
  90425. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90426. */
  90427. static readonly OnIntersectionEnterTrigger: number;
  90428. /**
  90429. * On intersection exit
  90430. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90431. */
  90432. static readonly OnIntersectionExitTrigger: number;
  90433. /**
  90434. * On key down
  90435. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90436. */
  90437. static readonly OnKeyDownTrigger: number;
  90438. /**
  90439. * On key up
  90440. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90441. */
  90442. static readonly OnKeyUpTrigger: number;
  90443. private _scene;
  90444. /**
  90445. * Creates a new action manager
  90446. * @param scene defines the hosting scene
  90447. */
  90448. constructor(scene: Scene);
  90449. /**
  90450. * Releases all associated resources
  90451. */
  90452. dispose(): void;
  90453. /**
  90454. * Gets hosting scene
  90455. * @returns the hosting scene
  90456. */
  90457. getScene(): Scene;
  90458. /**
  90459. * Does this action manager handles actions of any of the given triggers
  90460. * @param triggers defines the triggers to be tested
  90461. * @return a boolean indicating whether one (or more) of the triggers is handled
  90462. */
  90463. hasSpecificTriggers(triggers: number[]): boolean;
  90464. /**
  90465. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90466. * speed.
  90467. * @param triggerA defines the trigger to be tested
  90468. * @param triggerB defines the trigger to be tested
  90469. * @return a boolean indicating whether one (or more) of the triggers is handled
  90470. */
  90471. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90472. /**
  90473. * Does this action manager handles actions of a given trigger
  90474. * @param trigger defines the trigger to be tested
  90475. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90476. * @return whether the trigger is handled
  90477. */
  90478. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90479. /**
  90480. * Does this action manager has pointer triggers
  90481. */
  90482. get hasPointerTriggers(): boolean;
  90483. /**
  90484. * Does this action manager has pick triggers
  90485. */
  90486. get hasPickTriggers(): boolean;
  90487. /**
  90488. * Registers an action to this action manager
  90489. * @param action defines the action to be registered
  90490. * @return the action amended (prepared) after registration
  90491. */
  90492. registerAction(action: IAction): Nullable<IAction>;
  90493. /**
  90494. * Unregisters an action to this action manager
  90495. * @param action defines the action to be unregistered
  90496. * @return a boolean indicating whether the action has been unregistered
  90497. */
  90498. unregisterAction(action: IAction): Boolean;
  90499. /**
  90500. * Process a specific trigger
  90501. * @param trigger defines the trigger to process
  90502. * @param evt defines the event details to be processed
  90503. */
  90504. processTrigger(trigger: number, evt?: IActionEvent): void;
  90505. /** @hidden */
  90506. _getEffectiveTarget(target: any, propertyPath: string): any;
  90507. /** @hidden */
  90508. _getProperty(propertyPath: string): string;
  90509. /**
  90510. * Serialize this manager to a JSON object
  90511. * @param name defines the property name to store this manager
  90512. * @returns a JSON representation of this manager
  90513. */
  90514. serialize(name: string): any;
  90515. /**
  90516. * Creates a new ActionManager from a JSON data
  90517. * @param parsedActions defines the JSON data to read from
  90518. * @param object defines the hosting mesh
  90519. * @param scene defines the hosting scene
  90520. */
  90521. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90522. /**
  90523. * Get a trigger name by index
  90524. * @param trigger defines the trigger index
  90525. * @returns a trigger name
  90526. */
  90527. static GetTriggerName(trigger: number): string;
  90528. }
  90529. }
  90530. declare module BABYLON {
  90531. /**
  90532. * Class used to represent a sprite
  90533. * @see https://doc.babylonjs.com/babylon101/sprites
  90534. */
  90535. export class Sprite implements IAnimatable {
  90536. /** defines the name */
  90537. name: string;
  90538. /** Gets or sets the current world position */
  90539. position: Vector3;
  90540. /** Gets or sets the main color */
  90541. color: Color4;
  90542. /** Gets or sets the width */
  90543. width: number;
  90544. /** Gets or sets the height */
  90545. height: number;
  90546. /** Gets or sets rotation angle */
  90547. angle: number;
  90548. /** Gets or sets the cell index in the sprite sheet */
  90549. cellIndex: number;
  90550. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90551. cellRef: string;
  90552. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90553. invertU: boolean;
  90554. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90555. invertV: boolean;
  90556. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90557. disposeWhenFinishedAnimating: boolean;
  90558. /** Gets the list of attached animations */
  90559. animations: Nullable<Array<Animation>>;
  90560. /** Gets or sets a boolean indicating if the sprite can be picked */
  90561. isPickable: boolean;
  90562. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90563. useAlphaForPicking: boolean;
  90564. /** @hidden */
  90565. _xOffset: number;
  90566. /** @hidden */
  90567. _yOffset: number;
  90568. /** @hidden */
  90569. _xSize: number;
  90570. /** @hidden */
  90571. _ySize: number;
  90572. /**
  90573. * Gets or sets the associated action manager
  90574. */
  90575. actionManager: Nullable<ActionManager>;
  90576. /**
  90577. * An event triggered when the control has been disposed
  90578. */
  90579. onDisposeObservable: Observable<Sprite>;
  90580. private _animationStarted;
  90581. private _loopAnimation;
  90582. private _fromIndex;
  90583. private _toIndex;
  90584. private _delay;
  90585. private _direction;
  90586. private _manager;
  90587. private _time;
  90588. private _onAnimationEnd;
  90589. /**
  90590. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90591. */
  90592. isVisible: boolean;
  90593. /**
  90594. * Gets or sets the sprite size
  90595. */
  90596. get size(): number;
  90597. set size(value: number);
  90598. /**
  90599. * Returns a boolean indicating if the animation is started
  90600. */
  90601. get animationStarted(): boolean;
  90602. /**
  90603. * Gets or sets the unique id of the sprite
  90604. */
  90605. uniqueId: number;
  90606. /**
  90607. * Gets the manager of this sprite
  90608. */
  90609. get manager(): ISpriteManager;
  90610. /**
  90611. * Creates a new Sprite
  90612. * @param name defines the name
  90613. * @param manager defines the manager
  90614. */
  90615. constructor(
  90616. /** defines the name */
  90617. name: string, manager: ISpriteManager);
  90618. /**
  90619. * Returns the string "Sprite"
  90620. * @returns "Sprite"
  90621. */
  90622. getClassName(): string;
  90623. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90624. get fromIndex(): number;
  90625. set fromIndex(value: number);
  90626. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90627. get toIndex(): number;
  90628. set toIndex(value: number);
  90629. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90630. get loopAnimation(): boolean;
  90631. set loopAnimation(value: boolean);
  90632. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90633. get delay(): number;
  90634. set delay(value: number);
  90635. /**
  90636. * Starts an animation
  90637. * @param from defines the initial key
  90638. * @param to defines the end key
  90639. * @param loop defines if the animation must loop
  90640. * @param delay defines the start delay (in ms)
  90641. * @param onAnimationEnd defines a callback to call when animation ends
  90642. */
  90643. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90644. /** Stops current animation (if any) */
  90645. stopAnimation(): void;
  90646. /** @hidden */
  90647. _animate(deltaTime: number): void;
  90648. /** Release associated resources */
  90649. dispose(): void;
  90650. /**
  90651. * Serializes the sprite to a JSON object
  90652. * @returns the JSON object
  90653. */
  90654. serialize(): any;
  90655. /**
  90656. * Parses a JSON object to create a new sprite
  90657. * @param parsedSprite The JSON object to parse
  90658. * @param manager defines the hosting manager
  90659. * @returns the new sprite
  90660. */
  90661. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90662. }
  90663. }
  90664. declare module BABYLON {
  90665. /**
  90666. * Information about the result of picking within a scene
  90667. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90668. */
  90669. export class PickingInfo {
  90670. /** @hidden */
  90671. _pickingUnavailable: boolean;
  90672. /**
  90673. * If the pick collided with an object
  90674. */
  90675. hit: boolean;
  90676. /**
  90677. * Distance away where the pick collided
  90678. */
  90679. distance: number;
  90680. /**
  90681. * The location of pick collision
  90682. */
  90683. pickedPoint: Nullable<Vector3>;
  90684. /**
  90685. * The mesh corresponding the the pick collision
  90686. */
  90687. pickedMesh: Nullable<AbstractMesh>;
  90688. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90689. bu: number;
  90690. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90691. bv: number;
  90692. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90693. faceId: number;
  90694. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90695. subMeshFaceId: number;
  90696. /** Id of the the submesh that was picked */
  90697. subMeshId: number;
  90698. /** If a sprite was picked, this will be the sprite the pick collided with */
  90699. pickedSprite: Nullable<Sprite>;
  90700. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90701. thinInstanceIndex: number;
  90702. /**
  90703. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90704. */
  90705. originMesh: Nullable<AbstractMesh>;
  90706. /**
  90707. * The ray that was used to perform the picking.
  90708. */
  90709. ray: Nullable<Ray>;
  90710. /**
  90711. * Gets the normal correspodning to the face the pick collided with
  90712. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90713. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90714. * @returns The normal correspodning to the face the pick collided with
  90715. */
  90716. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90717. /**
  90718. * Gets the texture coordinates of where the pick occured
  90719. * @returns the vector containing the coordnates of the texture
  90720. */
  90721. getTextureCoordinates(): Nullable<Vector2>;
  90722. }
  90723. }
  90724. declare module BABYLON {
  90725. /**
  90726. * Class representing a ray with position and direction
  90727. */
  90728. export class Ray {
  90729. /** origin point */
  90730. origin: Vector3;
  90731. /** direction */
  90732. direction: Vector3;
  90733. /** length of the ray */
  90734. length: number;
  90735. private static readonly _TmpVector3;
  90736. private _tmpRay;
  90737. /**
  90738. * Creates a new ray
  90739. * @param origin origin point
  90740. * @param direction direction
  90741. * @param length length of the ray
  90742. */
  90743. constructor(
  90744. /** origin point */
  90745. origin: Vector3,
  90746. /** direction */
  90747. direction: Vector3,
  90748. /** length of the ray */
  90749. length?: number);
  90750. /**
  90751. * Checks if the ray intersects a box
  90752. * This does not account for the ray lenght by design to improve perfs.
  90753. * @param minimum bound of the box
  90754. * @param maximum bound of the box
  90755. * @param intersectionTreshold extra extend to be added to the box in all direction
  90756. * @returns if the box was hit
  90757. */
  90758. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  90759. /**
  90760. * Checks if the ray intersects a box
  90761. * This does not account for the ray lenght by design to improve perfs.
  90762. * @param box the bounding box to check
  90763. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  90764. * @returns if the box was hit
  90765. */
  90766. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  90767. /**
  90768. * If the ray hits a sphere
  90769. * @param sphere the bounding sphere to check
  90770. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  90771. * @returns true if it hits the sphere
  90772. */
  90773. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  90774. /**
  90775. * If the ray hits a triange
  90776. * @param vertex0 triangle vertex
  90777. * @param vertex1 triangle vertex
  90778. * @param vertex2 triangle vertex
  90779. * @returns intersection information if hit
  90780. */
  90781. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  90782. /**
  90783. * Checks if ray intersects a plane
  90784. * @param plane the plane to check
  90785. * @returns the distance away it was hit
  90786. */
  90787. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  90788. /**
  90789. * Calculate the intercept of a ray on a given axis
  90790. * @param axis to check 'x' | 'y' | 'z'
  90791. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  90792. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  90793. */
  90794. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  90795. /**
  90796. * Checks if ray intersects a mesh
  90797. * @param mesh the mesh to check
  90798. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90799. * @returns picking info of the intersecton
  90800. */
  90801. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  90802. /**
  90803. * Checks if ray intersects a mesh
  90804. * @param meshes the meshes to check
  90805. * @param fastCheck defines if the first intersection will be used (and not the closest)
  90806. * @param results array to store result in
  90807. * @returns Array of picking infos
  90808. */
  90809. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  90810. private _comparePickingInfo;
  90811. private static smallnum;
  90812. private static rayl;
  90813. /**
  90814. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  90815. * @param sega the first point of the segment to test the intersection against
  90816. * @param segb the second point of the segment to test the intersection against
  90817. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  90818. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  90819. */
  90820. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  90821. /**
  90822. * Update the ray from viewport position
  90823. * @param x position
  90824. * @param y y position
  90825. * @param viewportWidth viewport width
  90826. * @param viewportHeight viewport height
  90827. * @param world world matrix
  90828. * @param view view matrix
  90829. * @param projection projection matrix
  90830. * @returns this ray updated
  90831. */
  90832. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90833. /**
  90834. * Creates a ray with origin and direction of 0,0,0
  90835. * @returns the new ray
  90836. */
  90837. static Zero(): Ray;
  90838. /**
  90839. * Creates a new ray from screen space and viewport
  90840. * @param x position
  90841. * @param y y position
  90842. * @param viewportWidth viewport width
  90843. * @param viewportHeight viewport height
  90844. * @param world world matrix
  90845. * @param view view matrix
  90846. * @param projection projection matrix
  90847. * @returns new ray
  90848. */
  90849. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  90850. /**
  90851. * 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
  90852. * transformed to the given world matrix.
  90853. * @param origin The origin point
  90854. * @param end The end point
  90855. * @param world a matrix to transform the ray to. Default is the identity matrix.
  90856. * @returns the new ray
  90857. */
  90858. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  90859. /**
  90860. * Transforms a ray by a matrix
  90861. * @param ray ray to transform
  90862. * @param matrix matrix to apply
  90863. * @returns the resulting new ray
  90864. */
  90865. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  90866. /**
  90867. * Transforms a ray by a matrix
  90868. * @param ray ray to transform
  90869. * @param matrix matrix to apply
  90870. * @param result ray to store result in
  90871. */
  90872. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  90873. /**
  90874. * Unproject a ray from screen space to object space
  90875. * @param sourceX defines the screen space x coordinate to use
  90876. * @param sourceY defines the screen space y coordinate to use
  90877. * @param viewportWidth defines the current width of the viewport
  90878. * @param viewportHeight defines the current height of the viewport
  90879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  90880. * @param view defines the view matrix to use
  90881. * @param projection defines the projection matrix to use
  90882. */
  90883. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  90884. }
  90885. /**
  90886. * Type used to define predicate used to select faces when a mesh intersection is detected
  90887. */
  90888. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  90889. interface Scene {
  90890. /** @hidden */
  90891. _tempPickingRay: Nullable<Ray>;
  90892. /** @hidden */
  90893. _cachedRayForTransform: Ray;
  90894. /** @hidden */
  90895. _pickWithRayInverseMatrix: Matrix;
  90896. /** @hidden */
  90897. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90898. /** @hidden */
  90899. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  90900. /** @hidden */
  90901. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  90902. }
  90903. }
  90904. declare module BABYLON {
  90905. /**
  90906. * Groups all the scene component constants in one place to ease maintenance.
  90907. * @hidden
  90908. */
  90909. export class SceneComponentConstants {
  90910. static readonly NAME_EFFECTLAYER: string;
  90911. static readonly NAME_LAYER: string;
  90912. static readonly NAME_LENSFLARESYSTEM: string;
  90913. static readonly NAME_BOUNDINGBOXRENDERER: string;
  90914. static readonly NAME_PARTICLESYSTEM: string;
  90915. static readonly NAME_GAMEPAD: string;
  90916. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  90917. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  90918. static readonly NAME_PREPASSRENDERER: string;
  90919. static readonly NAME_DEPTHRENDERER: string;
  90920. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  90921. static readonly NAME_SPRITE: string;
  90922. static readonly NAME_SUBSURFACE: string;
  90923. static readonly NAME_OUTLINERENDERER: string;
  90924. static readonly NAME_PROCEDURALTEXTURE: string;
  90925. static readonly NAME_SHADOWGENERATOR: string;
  90926. static readonly NAME_OCTREE: string;
  90927. static readonly NAME_PHYSICSENGINE: string;
  90928. static readonly NAME_AUDIO: string;
  90929. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  90930. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90931. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  90932. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  90933. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  90934. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  90935. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  90936. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  90937. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  90938. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  90939. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  90940. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  90941. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  90942. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  90943. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  90944. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  90945. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  90946. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  90947. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  90948. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  90949. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  90950. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  90951. static readonly STEP_AFTERRENDER_AUDIO: number;
  90952. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  90953. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  90954. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  90955. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  90956. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  90957. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  90958. static readonly STEP_POINTERMOVE_SPRITE: number;
  90959. static readonly STEP_POINTERDOWN_SPRITE: number;
  90960. static readonly STEP_POINTERUP_SPRITE: number;
  90961. }
  90962. /**
  90963. * This represents a scene component.
  90964. *
  90965. * This is used to decouple the dependency the scene is having on the different workloads like
  90966. * layers, post processes...
  90967. */
  90968. export interface ISceneComponent {
  90969. /**
  90970. * The name of the component. Each component must have a unique name.
  90971. */
  90972. name: string;
  90973. /**
  90974. * The scene the component belongs to.
  90975. */
  90976. scene: Scene;
  90977. /**
  90978. * Register the component to one instance of a scene.
  90979. */
  90980. register(): void;
  90981. /**
  90982. * Rebuilds the elements related to this component in case of
  90983. * context lost for instance.
  90984. */
  90985. rebuild(): void;
  90986. /**
  90987. * Disposes the component and the associated ressources.
  90988. */
  90989. dispose(): void;
  90990. }
  90991. /**
  90992. * This represents a SERIALIZABLE scene component.
  90993. *
  90994. * This extends Scene Component to add Serialization methods on top.
  90995. */
  90996. export interface ISceneSerializableComponent extends ISceneComponent {
  90997. /**
  90998. * Adds all the elements from the container to the scene
  90999. * @param container the container holding the elements
  91000. */
  91001. addFromContainer(container: AbstractScene): void;
  91002. /**
  91003. * Removes all the elements in the container from the scene
  91004. * @param container contains the elements to remove
  91005. * @param dispose if the removed element should be disposed (default: false)
  91006. */
  91007. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91008. /**
  91009. * Serializes the component data to the specified json object
  91010. * @param serializationObject The object to serialize to
  91011. */
  91012. serialize(serializationObject: any): void;
  91013. }
  91014. /**
  91015. * Strong typing of a Mesh related stage step action
  91016. */
  91017. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91018. /**
  91019. * Strong typing of a Evaluate Sub Mesh related stage step action
  91020. */
  91021. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91022. /**
  91023. * Strong typing of a Active Mesh related stage step action
  91024. */
  91025. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91026. /**
  91027. * Strong typing of a Camera related stage step action
  91028. */
  91029. export type CameraStageAction = (camera: Camera) => void;
  91030. /**
  91031. * Strong typing of a Camera Frame buffer related stage step action
  91032. */
  91033. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91034. /**
  91035. * Strong typing of a Render Target related stage step action
  91036. */
  91037. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91038. /**
  91039. * Strong typing of a RenderingGroup related stage step action
  91040. */
  91041. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91042. /**
  91043. * Strong typing of a Mesh Render related stage step action
  91044. */
  91045. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91046. /**
  91047. * Strong typing of a simple stage step action
  91048. */
  91049. export type SimpleStageAction = () => void;
  91050. /**
  91051. * Strong typing of a render target action.
  91052. */
  91053. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91054. /**
  91055. * Strong typing of a pointer move action.
  91056. */
  91057. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91058. /**
  91059. * Strong typing of a pointer up/down action.
  91060. */
  91061. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91062. /**
  91063. * Representation of a stage in the scene (Basically a list of ordered steps)
  91064. * @hidden
  91065. */
  91066. export class Stage<T extends Function> extends Array<{
  91067. index: number;
  91068. component: ISceneComponent;
  91069. action: T;
  91070. }> {
  91071. /**
  91072. * Hide ctor from the rest of the world.
  91073. * @param items The items to add.
  91074. */
  91075. private constructor();
  91076. /**
  91077. * Creates a new Stage.
  91078. * @returns A new instance of a Stage
  91079. */
  91080. static Create<T extends Function>(): Stage<T>;
  91081. /**
  91082. * Registers a step in an ordered way in the targeted stage.
  91083. * @param index Defines the position to register the step in
  91084. * @param component Defines the component attached to the step
  91085. * @param action Defines the action to launch during the step
  91086. */
  91087. registerStep(index: number, component: ISceneComponent, action: T): void;
  91088. /**
  91089. * Clears all the steps from the stage.
  91090. */
  91091. clear(): void;
  91092. }
  91093. }
  91094. declare module BABYLON {
  91095. interface Scene {
  91096. /** @hidden */
  91097. _pointerOverSprite: Nullable<Sprite>;
  91098. /** @hidden */
  91099. _pickedDownSprite: Nullable<Sprite>;
  91100. /** @hidden */
  91101. _tempSpritePickingRay: Nullable<Ray>;
  91102. /**
  91103. * All of the sprite managers added to this scene
  91104. * @see https://doc.babylonjs.com/babylon101/sprites
  91105. */
  91106. spriteManagers: Array<ISpriteManager>;
  91107. /**
  91108. * An event triggered when sprites rendering is about to start
  91109. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91110. */
  91111. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91112. /**
  91113. * An event triggered when sprites rendering is done
  91114. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91115. */
  91116. onAfterSpritesRenderingObservable: Observable<Scene>;
  91117. /** @hidden */
  91118. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91119. /** Launch a ray to try to pick a sprite in the scene
  91120. * @param x position on screen
  91121. * @param y position on screen
  91122. * @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
  91123. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91124. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91125. * @returns a PickingInfo
  91126. */
  91127. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91128. /** Use the given ray to pick a sprite in the scene
  91129. * @param ray The ray (in world space) to use to pick meshes
  91130. * @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
  91131. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91132. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91133. * @returns a PickingInfo
  91134. */
  91135. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91136. /** @hidden */
  91137. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91138. /** Launch a ray to try to pick sprites in the scene
  91139. * @param x position on screen
  91140. * @param y position on screen
  91141. * @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
  91142. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91143. * @returns a PickingInfo array
  91144. */
  91145. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91146. /** Use the given ray to pick sprites in the scene
  91147. * @param ray The ray (in world space) to use to pick meshes
  91148. * @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
  91149. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91150. * @returns a PickingInfo array
  91151. */
  91152. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91153. /**
  91154. * Force the sprite under the pointer
  91155. * @param sprite defines the sprite to use
  91156. */
  91157. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91158. /**
  91159. * Gets the sprite under the pointer
  91160. * @returns a Sprite or null if no sprite is under the pointer
  91161. */
  91162. getPointerOverSprite(): Nullable<Sprite>;
  91163. }
  91164. /**
  91165. * Defines the sprite scene component responsible to manage sprites
  91166. * in a given scene.
  91167. */
  91168. export class SpriteSceneComponent implements ISceneComponent {
  91169. /**
  91170. * The component name helpfull to identify the component in the list of scene components.
  91171. */
  91172. readonly name: string;
  91173. /**
  91174. * The scene the component belongs to.
  91175. */
  91176. scene: Scene;
  91177. /** @hidden */
  91178. private _spritePredicate;
  91179. /**
  91180. * Creates a new instance of the component for the given scene
  91181. * @param scene Defines the scene to register the component in
  91182. */
  91183. constructor(scene: Scene);
  91184. /**
  91185. * Registers the component in a given scene
  91186. */
  91187. register(): void;
  91188. /**
  91189. * Rebuilds the elements related to this component in case of
  91190. * context lost for instance.
  91191. */
  91192. rebuild(): void;
  91193. /**
  91194. * Disposes the component and the associated ressources.
  91195. */
  91196. dispose(): void;
  91197. private _pickSpriteButKeepRay;
  91198. private _pointerMove;
  91199. private _pointerDown;
  91200. private _pointerUp;
  91201. }
  91202. }
  91203. declare module BABYLON {
  91204. /** @hidden */
  91205. export var fogFragmentDeclaration: {
  91206. name: string;
  91207. shader: string;
  91208. };
  91209. }
  91210. declare module BABYLON {
  91211. /** @hidden */
  91212. export var fogFragment: {
  91213. name: string;
  91214. shader: string;
  91215. };
  91216. }
  91217. declare module BABYLON {
  91218. /** @hidden */
  91219. export var spritesPixelShader: {
  91220. name: string;
  91221. shader: string;
  91222. };
  91223. }
  91224. declare module BABYLON {
  91225. /** @hidden */
  91226. export var fogVertexDeclaration: {
  91227. name: string;
  91228. shader: string;
  91229. };
  91230. }
  91231. declare module BABYLON {
  91232. /** @hidden */
  91233. export var spritesVertexShader: {
  91234. name: string;
  91235. shader: string;
  91236. };
  91237. }
  91238. declare module BABYLON {
  91239. /**
  91240. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91241. */
  91242. export interface ISpriteManager extends IDisposable {
  91243. /**
  91244. * Gets manager's name
  91245. */
  91246. name: string;
  91247. /**
  91248. * Restricts the camera to viewing objects with the same layerMask.
  91249. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91250. */
  91251. layerMask: number;
  91252. /**
  91253. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91254. */
  91255. isPickable: boolean;
  91256. /**
  91257. * Gets the hosting scene
  91258. */
  91259. scene: Scene;
  91260. /**
  91261. * Specifies the rendering group id for this mesh (0 by default)
  91262. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91263. */
  91264. renderingGroupId: number;
  91265. /**
  91266. * Defines the list of sprites managed by the manager.
  91267. */
  91268. sprites: Array<Sprite>;
  91269. /**
  91270. * Gets or sets the spritesheet texture
  91271. */
  91272. texture: Texture;
  91273. /** Defines the default width of a cell in the spritesheet */
  91274. cellWidth: number;
  91275. /** Defines the default height of a cell in the spritesheet */
  91276. cellHeight: number;
  91277. /**
  91278. * Tests the intersection of a sprite with a specific ray.
  91279. * @param ray The ray we are sending to test the collision
  91280. * @param camera The camera space we are sending rays in
  91281. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91282. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91283. * @returns picking info or null.
  91284. */
  91285. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91286. /**
  91287. * Intersects the sprites with a ray
  91288. * @param ray defines the ray to intersect with
  91289. * @param camera defines the current active camera
  91290. * @param predicate defines a predicate used to select candidate sprites
  91291. * @returns null if no hit or a PickingInfo array
  91292. */
  91293. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91294. /**
  91295. * Renders the list of sprites on screen.
  91296. */
  91297. render(): void;
  91298. }
  91299. /**
  91300. * Class used to manage multiple sprites on the same spritesheet
  91301. * @see https://doc.babylonjs.com/babylon101/sprites
  91302. */
  91303. export class SpriteManager implements ISpriteManager {
  91304. /** defines the manager's name */
  91305. name: string;
  91306. /** Define the Url to load snippets */
  91307. static SnippetUrl: string;
  91308. /** Snippet ID if the manager was created from the snippet server */
  91309. snippetId: string;
  91310. /** Gets the list of sprites */
  91311. sprites: Sprite[];
  91312. /** Gets or sets the rendering group id (0 by default) */
  91313. renderingGroupId: number;
  91314. /** Gets or sets camera layer mask */
  91315. layerMask: number;
  91316. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91317. fogEnabled: boolean;
  91318. /** Gets or sets a boolean indicating if the sprites are pickable */
  91319. isPickable: boolean;
  91320. /** Defines the default width of a cell in the spritesheet */
  91321. cellWidth: number;
  91322. /** Defines the default height of a cell in the spritesheet */
  91323. cellHeight: number;
  91324. /** Associative array from JSON sprite data file */
  91325. private _cellData;
  91326. /** Array of sprite names from JSON sprite data file */
  91327. private _spriteMap;
  91328. /** True when packed cell data from JSON file is ready*/
  91329. private _packedAndReady;
  91330. private _textureContent;
  91331. private _useInstancing;
  91332. /**
  91333. * An event triggered when the manager is disposed.
  91334. */
  91335. onDisposeObservable: Observable<SpriteManager>;
  91336. private _onDisposeObserver;
  91337. /**
  91338. * Callback called when the manager is disposed
  91339. */
  91340. set onDispose(callback: () => void);
  91341. private _capacity;
  91342. private _fromPacked;
  91343. private _spriteTexture;
  91344. private _epsilon;
  91345. private _scene;
  91346. private _vertexData;
  91347. private _buffer;
  91348. private _vertexBuffers;
  91349. private _spriteBuffer;
  91350. private _indexBuffer;
  91351. private _effectBase;
  91352. private _effectFog;
  91353. private _vertexBufferSize;
  91354. /**
  91355. * Gets or sets the unique id of the sprite
  91356. */
  91357. uniqueId: number;
  91358. /**
  91359. * Gets the array of sprites
  91360. */
  91361. get children(): Sprite[];
  91362. /**
  91363. * Gets the hosting scene
  91364. */
  91365. get scene(): Scene;
  91366. /**
  91367. * Gets the capacity of the manager
  91368. */
  91369. get capacity(): number;
  91370. /**
  91371. * Gets or sets the spritesheet texture
  91372. */
  91373. get texture(): Texture;
  91374. set texture(value: Texture);
  91375. private _blendMode;
  91376. /**
  91377. * Blend mode use to render the particle, it can be any of
  91378. * the static Constants.ALPHA_x properties provided in this class.
  91379. * Default value is Constants.ALPHA_COMBINE
  91380. */
  91381. get blendMode(): number;
  91382. set blendMode(blendMode: number);
  91383. /** Disables writing to the depth buffer when rendering the sprites.
  91384. * It can be handy to disable depth writing when using textures without alpha channel
  91385. * and setting some specific blend modes.
  91386. */
  91387. disableDepthWrite: boolean;
  91388. /**
  91389. * Creates a new sprite manager
  91390. * @param name defines the manager's name
  91391. * @param imgUrl defines the sprite sheet url
  91392. * @param capacity defines the maximum allowed number of sprites
  91393. * @param cellSize defines the size of a sprite cell
  91394. * @param scene defines the hosting scene
  91395. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91396. * @param samplingMode defines the smapling mode to use with spritesheet
  91397. * @param fromPacked set to false; do not alter
  91398. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91399. */
  91400. constructor(
  91401. /** defines the manager's name */
  91402. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91403. /**
  91404. * Returns the string "SpriteManager"
  91405. * @returns "SpriteManager"
  91406. */
  91407. getClassName(): string;
  91408. private _makePacked;
  91409. private _appendSpriteVertex;
  91410. private _checkTextureAlpha;
  91411. /**
  91412. * Intersects the sprites with a ray
  91413. * @param ray defines the ray to intersect with
  91414. * @param camera defines the current active camera
  91415. * @param predicate defines a predicate used to select candidate sprites
  91416. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91417. * @returns null if no hit or a PickingInfo
  91418. */
  91419. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91420. /**
  91421. * Intersects the sprites with a ray
  91422. * @param ray defines the ray to intersect with
  91423. * @param camera defines the current active camera
  91424. * @param predicate defines a predicate used to select candidate sprites
  91425. * @returns null if no hit or a PickingInfo array
  91426. */
  91427. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91428. /**
  91429. * Render all child sprites
  91430. */
  91431. render(): void;
  91432. /**
  91433. * Release associated resources
  91434. */
  91435. dispose(): void;
  91436. /**
  91437. * Serializes the sprite manager to a JSON object
  91438. * @param serializeTexture defines if the texture must be serialized as well
  91439. * @returns the JSON object
  91440. */
  91441. serialize(serializeTexture?: boolean): any;
  91442. /**
  91443. * Parses a JSON object to create a new sprite manager.
  91444. * @param parsedManager The JSON object to parse
  91445. * @param scene The scene to create the sprite managerin
  91446. * @param rootUrl The root url to use to load external dependencies like texture
  91447. * @returns the new sprite manager
  91448. */
  91449. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91450. /**
  91451. * Creates a sprite manager from a snippet saved in a remote file
  91452. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91453. * @param url defines the url to load from
  91454. * @param scene defines the hosting scene
  91455. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91456. * @returns a promise that will resolve to the new sprite manager
  91457. */
  91458. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91459. /**
  91460. * Creates a sprite manager from a snippet saved by the sprite editor
  91461. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91462. * @param scene defines the hosting scene
  91463. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91464. * @returns a promise that will resolve to the new sprite manager
  91465. */
  91466. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91467. }
  91468. }
  91469. declare module BABYLON {
  91470. /** Interface used by value gradients (color, factor, ...) */
  91471. export interface IValueGradient {
  91472. /**
  91473. * Gets or sets the gradient value (between 0 and 1)
  91474. */
  91475. gradient: number;
  91476. }
  91477. /** Class used to store color4 gradient */
  91478. export class ColorGradient implements IValueGradient {
  91479. /**
  91480. * Gets or sets the gradient value (between 0 and 1)
  91481. */
  91482. gradient: number;
  91483. /**
  91484. * Gets or sets first associated color
  91485. */
  91486. color1: Color4;
  91487. /**
  91488. * Gets or sets second associated color
  91489. */
  91490. color2?: Color4 | undefined;
  91491. /**
  91492. * Creates a new color4 gradient
  91493. * @param gradient gets or sets the gradient value (between 0 and 1)
  91494. * @param color1 gets or sets first associated color
  91495. * @param color2 gets or sets first second color
  91496. */
  91497. constructor(
  91498. /**
  91499. * Gets or sets the gradient value (between 0 and 1)
  91500. */
  91501. gradient: number,
  91502. /**
  91503. * Gets or sets first associated color
  91504. */
  91505. color1: Color4,
  91506. /**
  91507. * Gets or sets second associated color
  91508. */
  91509. color2?: Color4 | undefined);
  91510. /**
  91511. * Will get a color picked randomly between color1 and color2.
  91512. * If color2 is undefined then color1 will be used
  91513. * @param result defines the target Color4 to store the result in
  91514. */
  91515. getColorToRef(result: Color4): void;
  91516. }
  91517. /** Class used to store color 3 gradient */
  91518. export class Color3Gradient implements IValueGradient {
  91519. /**
  91520. * Gets or sets the gradient value (between 0 and 1)
  91521. */
  91522. gradient: number;
  91523. /**
  91524. * Gets or sets the associated color
  91525. */
  91526. color: Color3;
  91527. /**
  91528. * Creates a new color3 gradient
  91529. * @param gradient gets or sets the gradient value (between 0 and 1)
  91530. * @param color gets or sets associated color
  91531. */
  91532. constructor(
  91533. /**
  91534. * Gets or sets the gradient value (between 0 and 1)
  91535. */
  91536. gradient: number,
  91537. /**
  91538. * Gets or sets the associated color
  91539. */
  91540. color: Color3);
  91541. }
  91542. /** Class used to store factor gradient */
  91543. export class FactorGradient implements IValueGradient {
  91544. /**
  91545. * Gets or sets the gradient value (between 0 and 1)
  91546. */
  91547. gradient: number;
  91548. /**
  91549. * Gets or sets first associated factor
  91550. */
  91551. factor1: number;
  91552. /**
  91553. * Gets or sets second associated factor
  91554. */
  91555. factor2?: number | undefined;
  91556. /**
  91557. * Creates a new factor gradient
  91558. * @param gradient gets or sets the gradient value (between 0 and 1)
  91559. * @param factor1 gets or sets first associated factor
  91560. * @param factor2 gets or sets second associated factor
  91561. */
  91562. constructor(
  91563. /**
  91564. * Gets or sets the gradient value (between 0 and 1)
  91565. */
  91566. gradient: number,
  91567. /**
  91568. * Gets or sets first associated factor
  91569. */
  91570. factor1: number,
  91571. /**
  91572. * Gets or sets second associated factor
  91573. */
  91574. factor2?: number | undefined);
  91575. /**
  91576. * Will get a number picked randomly between factor1 and factor2.
  91577. * If factor2 is undefined then factor1 will be used
  91578. * @returns the picked number
  91579. */
  91580. getFactor(): number;
  91581. }
  91582. /**
  91583. * Helper used to simplify some generic gradient tasks
  91584. */
  91585. export class GradientHelper {
  91586. /**
  91587. * Gets the current gradient from an array of IValueGradient
  91588. * @param ratio defines the current ratio to get
  91589. * @param gradients defines the array of IValueGradient
  91590. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91591. */
  91592. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91593. }
  91594. }
  91595. declare module BABYLON {
  91596. interface ThinEngine {
  91597. /**
  91598. * Creates a raw texture
  91599. * @param data defines the data to store in the texture
  91600. * @param width defines the width of the texture
  91601. * @param height defines the height of the texture
  91602. * @param format defines the format of the data
  91603. * @param generateMipMaps defines if the engine should generate the mip levels
  91604. * @param invertY defines if data must be stored with Y axis inverted
  91605. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91606. * @param compression defines the compression used (null by default)
  91607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91608. * @returns the raw texture inside an InternalTexture
  91609. */
  91610. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91611. /**
  91612. * Update a raw texture
  91613. * @param texture defines the texture to update
  91614. * @param data defines the data to store in the texture
  91615. * @param format defines the format of the data
  91616. * @param invertY defines if data must be stored with Y axis inverted
  91617. */
  91618. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91619. /**
  91620. * Update a raw texture
  91621. * @param texture defines the texture to update
  91622. * @param data defines the data to store in the texture
  91623. * @param format defines the format of the data
  91624. * @param invertY defines if data must be stored with Y axis inverted
  91625. * @param compression defines the compression used (null by default)
  91626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91627. */
  91628. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91629. /**
  91630. * Creates a new raw cube texture
  91631. * @param data defines the array of data to use to create each face
  91632. * @param size defines the size of the textures
  91633. * @param format defines the format of the data
  91634. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91635. * @param generateMipMaps defines if the engine should generate the mip levels
  91636. * @param invertY defines if data must be stored with Y axis inverted
  91637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91638. * @param compression defines the compression used (null by default)
  91639. * @returns the cube texture as an InternalTexture
  91640. */
  91641. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91642. /**
  91643. * Update a raw cube texture
  91644. * @param texture defines the texture to udpdate
  91645. * @param data defines the data to store
  91646. * @param format defines the data format
  91647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91648. * @param invertY defines if data must be stored with Y axis inverted
  91649. */
  91650. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91651. /**
  91652. * Update a raw cube texture
  91653. * @param texture defines the texture to udpdate
  91654. * @param data defines the data to store
  91655. * @param format defines the data format
  91656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91657. * @param invertY defines if data must be stored with Y axis inverted
  91658. * @param compression defines the compression used (null by default)
  91659. */
  91660. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91661. /**
  91662. * Update a raw cube texture
  91663. * @param texture defines the texture to udpdate
  91664. * @param data defines the data to store
  91665. * @param format defines the data format
  91666. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91667. * @param invertY defines if data must be stored with Y axis inverted
  91668. * @param compression defines the compression used (null by default)
  91669. * @param level defines which level of the texture to update
  91670. */
  91671. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91672. /**
  91673. * Creates a new raw cube texture from a specified url
  91674. * @param url defines the url where the data is located
  91675. * @param scene defines the current scene
  91676. * @param size defines the size of the textures
  91677. * @param format defines the format of the data
  91678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91679. * @param noMipmap defines if the engine should avoid generating the mip levels
  91680. * @param callback defines a callback used to extract texture data from loaded data
  91681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91682. * @param onLoad defines a callback called when texture is loaded
  91683. * @param onError defines a callback called if there is an error
  91684. * @returns the cube texture as an InternalTexture
  91685. */
  91686. 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;
  91687. /**
  91688. * Creates a new raw cube texture from a specified url
  91689. * @param url defines the url where the data is located
  91690. * @param scene defines the current scene
  91691. * @param size defines the size of the textures
  91692. * @param format defines the format of the data
  91693. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91694. * @param noMipmap defines if the engine should avoid generating the mip levels
  91695. * @param callback defines a callback used to extract texture data from loaded data
  91696. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91697. * @param onLoad defines a callback called when texture is loaded
  91698. * @param onError defines a callback called if there is an error
  91699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91700. * @param invertY defines if data must be stored with Y axis inverted
  91701. * @returns the cube texture as an InternalTexture
  91702. */
  91703. 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;
  91704. /**
  91705. * Creates a new raw 3D texture
  91706. * @param data defines the data used to create the texture
  91707. * @param width defines the width of the texture
  91708. * @param height defines the height of the texture
  91709. * @param depth defines the depth of the texture
  91710. * @param format defines the format of the texture
  91711. * @param generateMipMaps defines if the engine must generate mip levels
  91712. * @param invertY defines if data must be stored with Y axis inverted
  91713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91714. * @param compression defines the compressed used (can be null)
  91715. * @param textureType defines the compressed used (can be null)
  91716. * @returns a new raw 3D texture (stored in an InternalTexture)
  91717. */
  91718. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91719. /**
  91720. * Update a raw 3D texture
  91721. * @param texture defines the texture to update
  91722. * @param data defines the data to store
  91723. * @param format defines the data format
  91724. * @param invertY defines if data must be stored with Y axis inverted
  91725. */
  91726. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91727. /**
  91728. * Update a raw 3D texture
  91729. * @param texture defines the texture to update
  91730. * @param data defines the data to store
  91731. * @param format defines the data format
  91732. * @param invertY defines if data must be stored with Y axis inverted
  91733. * @param compression defines the used compression (can be null)
  91734. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91735. */
  91736. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91737. /**
  91738. * Creates a new raw 2D array texture
  91739. * @param data defines the data used to create the texture
  91740. * @param width defines the width of the texture
  91741. * @param height defines the height of the texture
  91742. * @param depth defines the number of layers of the texture
  91743. * @param format defines the format of the texture
  91744. * @param generateMipMaps defines if the engine must generate mip levels
  91745. * @param invertY defines if data must be stored with Y axis inverted
  91746. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91747. * @param compression defines the compressed used (can be null)
  91748. * @param textureType defines the compressed used (can be null)
  91749. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91750. */
  91751. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91752. /**
  91753. * Update a raw 2D array texture
  91754. * @param texture defines the texture to update
  91755. * @param data defines the data to store
  91756. * @param format defines the data format
  91757. * @param invertY defines if data must be stored with Y axis inverted
  91758. */
  91759. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91760. /**
  91761. * Update a raw 2D array texture
  91762. * @param texture defines the texture to update
  91763. * @param data defines the data to store
  91764. * @param format defines the data format
  91765. * @param invertY defines if data must be stored with Y axis inverted
  91766. * @param compression defines the used compression (can be null)
  91767. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91768. */
  91769. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91770. }
  91771. }
  91772. declare module BABYLON {
  91773. /**
  91774. * Raw texture can help creating a texture directly from an array of data.
  91775. * This can be super useful if you either get the data from an uncompressed source or
  91776. * if you wish to create your texture pixel by pixel.
  91777. */
  91778. export class RawTexture extends Texture {
  91779. /**
  91780. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91781. */
  91782. format: number;
  91783. /**
  91784. * Instantiates a new RawTexture.
  91785. * Raw texture can help creating a texture directly from an array of data.
  91786. * This can be super useful if you either get the data from an uncompressed source or
  91787. * if you wish to create your texture pixel by pixel.
  91788. * @param data define the array of data to use to create the texture
  91789. * @param width define the width of the texture
  91790. * @param height define the height of the texture
  91791. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91792. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91793. * @param generateMipMaps define whether mip maps should be generated or not
  91794. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91795. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91796. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91797. */
  91798. constructor(data: ArrayBufferView, width: number, height: number,
  91799. /**
  91800. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  91801. */
  91802. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  91803. /**
  91804. * Updates the texture underlying data.
  91805. * @param data Define the new data of the texture
  91806. */
  91807. update(data: ArrayBufferView): void;
  91808. /**
  91809. * Creates a luminance texture from some data.
  91810. * @param data Define the texture data
  91811. * @param width Define the width of the texture
  91812. * @param height Define the height of the texture
  91813. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91817. * @returns the luminance texture
  91818. */
  91819. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91820. /**
  91821. * Creates a luminance alpha texture from some data.
  91822. * @param data Define the texture data
  91823. * @param width Define the width of the texture
  91824. * @param height Define the height of the texture
  91825. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91826. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91827. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91828. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91829. * @returns the luminance alpha texture
  91830. */
  91831. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91832. /**
  91833. * Creates an alpha texture from some data.
  91834. * @param data Define the texture data
  91835. * @param width Define the width of the texture
  91836. * @param height Define the height of the texture
  91837. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91838. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91839. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91840. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91841. * @returns the alpha texture
  91842. */
  91843. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  91844. /**
  91845. * Creates a RGB texture from some data.
  91846. * @param data Define the texture data
  91847. * @param width Define the width of the texture
  91848. * @param height Define the height of the texture
  91849. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91850. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91851. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91852. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91853. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91854. * @returns the RGB alpha texture
  91855. */
  91856. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91857. /**
  91858. * Creates a RGBA texture from some data.
  91859. * @param data Define the texture data
  91860. * @param width Define the width of the texture
  91861. * @param height Define the height of the texture
  91862. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91863. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91864. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91865. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91866. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91867. * @returns the RGBA texture
  91868. */
  91869. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91870. /**
  91871. * Creates a R texture from some data.
  91872. * @param data Define the texture data
  91873. * @param width Define the width of the texture
  91874. * @param height Define the height of the texture
  91875. * @param sceneOrEngine defines the scene or engine the texture will belong to
  91876. * @param generateMipMaps Define whether or not to create mip maps for the texture
  91877. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  91878. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  91879. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  91880. * @returns the R texture
  91881. */
  91882. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  91883. }
  91884. }
  91885. declare module BABYLON {
  91886. interface ThinEngine {
  91887. /**
  91888. * Update a dynamic index buffer
  91889. * @param indexBuffer defines the target index buffer
  91890. * @param indices defines the data to update
  91891. * @param offset defines the offset in the target index buffer where update should start
  91892. */
  91893. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  91894. /**
  91895. * Updates a dynamic vertex buffer.
  91896. * @param vertexBuffer the vertex buffer to update
  91897. * @param data the data used to update the vertex buffer
  91898. * @param byteOffset the byte offset of the data
  91899. * @param byteLength the byte length of the data
  91900. */
  91901. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  91902. }
  91903. }
  91904. declare module BABYLON {
  91905. interface AbstractScene {
  91906. /**
  91907. * The list of procedural textures added to the scene
  91908. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91909. */
  91910. proceduralTextures: Array<ProceduralTexture>;
  91911. }
  91912. /**
  91913. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  91914. * in a given scene.
  91915. */
  91916. export class ProceduralTextureSceneComponent implements ISceneComponent {
  91917. /**
  91918. * The component name helpfull to identify the component in the list of scene components.
  91919. */
  91920. readonly name: string;
  91921. /**
  91922. * The scene the component belongs to.
  91923. */
  91924. scene: Scene;
  91925. /**
  91926. * Creates a new instance of the component for the given scene
  91927. * @param scene Defines the scene to register the component in
  91928. */
  91929. constructor(scene: Scene);
  91930. /**
  91931. * Registers the component in a given scene
  91932. */
  91933. register(): void;
  91934. /**
  91935. * Rebuilds the elements related to this component in case of
  91936. * context lost for instance.
  91937. */
  91938. rebuild(): void;
  91939. /**
  91940. * Disposes the component and the associated ressources.
  91941. */
  91942. dispose(): void;
  91943. private _beforeClear;
  91944. }
  91945. }
  91946. declare module BABYLON {
  91947. interface ThinEngine {
  91948. /**
  91949. * Creates a new render target cube texture
  91950. * @param size defines the size of the texture
  91951. * @param options defines the options used to create the texture
  91952. * @returns a new render target cube texture stored in an InternalTexture
  91953. */
  91954. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  91955. }
  91956. }
  91957. declare module BABYLON {
  91958. /** @hidden */
  91959. export var proceduralVertexShader: {
  91960. name: string;
  91961. shader: string;
  91962. };
  91963. }
  91964. declare module BABYLON {
  91965. /**
  91966. * 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.
  91967. * This is the base class of any Procedural texture and contains most of the shareable code.
  91968. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  91969. */
  91970. export class ProceduralTexture extends Texture {
  91971. /**
  91972. * Define if the texture is enabled or not (disabled texture will not render)
  91973. */
  91974. isEnabled: boolean;
  91975. /**
  91976. * Define if the texture must be cleared before rendering (default is true)
  91977. */
  91978. autoClear: boolean;
  91979. /**
  91980. * Callback called when the texture is generated
  91981. */
  91982. onGenerated: () => void;
  91983. /**
  91984. * Event raised when the texture is generated
  91985. */
  91986. onGeneratedObservable: Observable<ProceduralTexture>;
  91987. /**
  91988. * Event raised before the texture is generated
  91989. */
  91990. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  91991. /**
  91992. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  91993. */
  91994. nodeMaterialSource: Nullable<NodeMaterial>;
  91995. /** @hidden */
  91996. _generateMipMaps: boolean;
  91997. /** @hidden **/
  91998. _effect: Effect;
  91999. /** @hidden */
  92000. _textures: {
  92001. [key: string]: Texture;
  92002. };
  92003. /** @hidden */
  92004. protected _fallbackTexture: Nullable<Texture>;
  92005. private _size;
  92006. private _currentRefreshId;
  92007. private _frameId;
  92008. private _refreshRate;
  92009. private _vertexBuffers;
  92010. private _indexBuffer;
  92011. private _uniforms;
  92012. private _samplers;
  92013. private _fragment;
  92014. private _floats;
  92015. private _ints;
  92016. private _floatsArrays;
  92017. private _colors3;
  92018. private _colors4;
  92019. private _vectors2;
  92020. private _vectors3;
  92021. private _matrices;
  92022. private _fallbackTextureUsed;
  92023. private _fullEngine;
  92024. private _cachedDefines;
  92025. private _contentUpdateId;
  92026. private _contentData;
  92027. /**
  92028. * Instantiates a new procedural texture.
  92029. * 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.
  92030. * This is the base class of any Procedural texture and contains most of the shareable code.
  92031. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92032. * @param name Define the name of the texture
  92033. * @param size Define the size of the texture to create
  92034. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92035. * @param scene Define the scene the texture belongs to
  92036. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92037. * @param generateMipMaps Define if the texture should creates mip maps or not
  92038. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92039. */
  92040. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  92041. /**
  92042. * The effect that is created when initializing the post process.
  92043. * @returns The created effect corresponding the the postprocess.
  92044. */
  92045. getEffect(): Effect;
  92046. /**
  92047. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92048. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92049. */
  92050. getContent(): Nullable<ArrayBufferView>;
  92051. private _createIndexBuffer;
  92052. /** @hidden */
  92053. _rebuild(): void;
  92054. /**
  92055. * Resets the texture in order to recreate its associated resources.
  92056. * This can be called in case of context loss
  92057. */
  92058. reset(): void;
  92059. protected _getDefines(): string;
  92060. /**
  92061. * Is the texture ready to be used ? (rendered at least once)
  92062. * @returns true if ready, otherwise, false.
  92063. */
  92064. isReady(): boolean;
  92065. /**
  92066. * Resets the refresh counter of the texture and start bak from scratch.
  92067. * Could be useful to regenerate the texture if it is setup to render only once.
  92068. */
  92069. resetRefreshCounter(): void;
  92070. /**
  92071. * Set the fragment shader to use in order to render the texture.
  92072. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92073. */
  92074. setFragment(fragment: any): void;
  92075. /**
  92076. * Define the refresh rate of the texture or the rendering frequency.
  92077. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92078. */
  92079. get refreshRate(): number;
  92080. set refreshRate(value: number);
  92081. /** @hidden */
  92082. _shouldRender(): boolean;
  92083. /**
  92084. * Get the size the texture is rendering at.
  92085. * @returns the size (on cube texture it is always squared)
  92086. */
  92087. getRenderSize(): RenderTargetTextureSize;
  92088. /**
  92089. * Resize the texture to new value.
  92090. * @param size Define the new size the texture should have
  92091. * @param generateMipMaps Define whether the new texture should create mip maps
  92092. */
  92093. resize(size: number, generateMipMaps: boolean): void;
  92094. private _checkUniform;
  92095. /**
  92096. * Set a texture in the shader program used to render.
  92097. * @param name Define the name of the uniform samplers as defined in the shader
  92098. * @param texture Define the texture to bind to this sampler
  92099. * @return the texture itself allowing "fluent" like uniform updates
  92100. */
  92101. setTexture(name: string, texture: Texture): ProceduralTexture;
  92102. /**
  92103. * Set a float in the shader.
  92104. * @param name Define the name of the uniform as defined in the shader
  92105. * @param value Define the value to give to the uniform
  92106. * @return the texture itself allowing "fluent" like uniform updates
  92107. */
  92108. setFloat(name: string, value: number): ProceduralTexture;
  92109. /**
  92110. * Set a int in the shader.
  92111. * @param name Define the name of the uniform as defined in the shader
  92112. * @param value Define the value to give to the uniform
  92113. * @return the texture itself allowing "fluent" like uniform updates
  92114. */
  92115. setInt(name: string, value: number): ProceduralTexture;
  92116. /**
  92117. * Set an array of floats in the shader.
  92118. * @param name Define the name of the uniform as defined in the shader
  92119. * @param value Define the value to give to the uniform
  92120. * @return the texture itself allowing "fluent" like uniform updates
  92121. */
  92122. setFloats(name: string, value: number[]): ProceduralTexture;
  92123. /**
  92124. * Set a vec3 in the shader from a Color3.
  92125. * @param name Define the name of the uniform as defined in the shader
  92126. * @param value Define the value to give to the uniform
  92127. * @return the texture itself allowing "fluent" like uniform updates
  92128. */
  92129. setColor3(name: string, value: Color3): ProceduralTexture;
  92130. /**
  92131. * Set a vec4 in the shader from a Color4.
  92132. * @param name Define the name of the uniform as defined in the shader
  92133. * @param value Define the value to give to the uniform
  92134. * @return the texture itself allowing "fluent" like uniform updates
  92135. */
  92136. setColor4(name: string, value: Color4): ProceduralTexture;
  92137. /**
  92138. * Set a vec2 in the shader from a Vector2.
  92139. * @param name Define the name of the uniform as defined in the shader
  92140. * @param value Define the value to give to the uniform
  92141. * @return the texture itself allowing "fluent" like uniform updates
  92142. */
  92143. setVector2(name: string, value: Vector2): ProceduralTexture;
  92144. /**
  92145. * Set a vec3 in the shader from a Vector3.
  92146. * @param name Define the name of the uniform as defined in the shader
  92147. * @param value Define the value to give to the uniform
  92148. * @return the texture itself allowing "fluent" like uniform updates
  92149. */
  92150. setVector3(name: string, value: Vector3): ProceduralTexture;
  92151. /**
  92152. * Set a mat4 in the shader from a MAtrix.
  92153. * @param name Define the name of the uniform as defined in the shader
  92154. * @param value Define the value to give to the uniform
  92155. * @return the texture itself allowing "fluent" like uniform updates
  92156. */
  92157. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92158. /**
  92159. * Render the texture to its associated render target.
  92160. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92161. */
  92162. render(useCameraPostProcess?: boolean): void;
  92163. /**
  92164. * Clone the texture.
  92165. * @returns the cloned texture
  92166. */
  92167. clone(): ProceduralTexture;
  92168. /**
  92169. * Dispose the texture and release its asoociated resources.
  92170. */
  92171. dispose(): void;
  92172. }
  92173. }
  92174. declare module BABYLON {
  92175. /**
  92176. * This represents the base class for particle system in Babylon.
  92177. * 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.
  92178. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92179. * @example https://doc.babylonjs.com/babylon101/particles
  92180. */
  92181. export class BaseParticleSystem {
  92182. /**
  92183. * Source color is added to the destination color without alpha affecting the result
  92184. */
  92185. static BLENDMODE_ONEONE: number;
  92186. /**
  92187. * Blend current color and particle color using particle’s alpha
  92188. */
  92189. static BLENDMODE_STANDARD: number;
  92190. /**
  92191. * Add current color and particle color multiplied by particle’s alpha
  92192. */
  92193. static BLENDMODE_ADD: number;
  92194. /**
  92195. * Multiply current color with particle color
  92196. */
  92197. static BLENDMODE_MULTIPLY: number;
  92198. /**
  92199. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92200. */
  92201. static BLENDMODE_MULTIPLYADD: number;
  92202. /**
  92203. * List of animations used by the particle system.
  92204. */
  92205. animations: Animation[];
  92206. /**
  92207. * Gets or sets the unique id of the particle system
  92208. */
  92209. uniqueId: number;
  92210. /**
  92211. * The id of the Particle system.
  92212. */
  92213. id: string;
  92214. /**
  92215. * The friendly name of the Particle system.
  92216. */
  92217. name: string;
  92218. /**
  92219. * Snippet ID if the particle system was created from the snippet server
  92220. */
  92221. snippetId: string;
  92222. /**
  92223. * The rendering group used by the Particle system to chose when to render.
  92224. */
  92225. renderingGroupId: number;
  92226. /**
  92227. * The emitter represents the Mesh or position we are attaching the particle system to.
  92228. */
  92229. emitter: Nullable<AbstractMesh | Vector3>;
  92230. /**
  92231. * The maximum number of particles to emit per frame
  92232. */
  92233. emitRate: number;
  92234. /**
  92235. * If you want to launch only a few particles at once, that can be done, as well.
  92236. */
  92237. manualEmitCount: number;
  92238. /**
  92239. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92240. */
  92241. updateSpeed: number;
  92242. /**
  92243. * The amount of time the particle system is running (depends of the overall update speed).
  92244. */
  92245. targetStopDuration: number;
  92246. /**
  92247. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92248. */
  92249. disposeOnStop: boolean;
  92250. /**
  92251. * Minimum power of emitting particles.
  92252. */
  92253. minEmitPower: number;
  92254. /**
  92255. * Maximum power of emitting particles.
  92256. */
  92257. maxEmitPower: number;
  92258. /**
  92259. * Minimum life time of emitting particles.
  92260. */
  92261. minLifeTime: number;
  92262. /**
  92263. * Maximum life time of emitting particles.
  92264. */
  92265. maxLifeTime: number;
  92266. /**
  92267. * Minimum Size of emitting particles.
  92268. */
  92269. minSize: number;
  92270. /**
  92271. * Maximum Size of emitting particles.
  92272. */
  92273. maxSize: number;
  92274. /**
  92275. * Minimum scale of emitting particles on X axis.
  92276. */
  92277. minScaleX: number;
  92278. /**
  92279. * Maximum scale of emitting particles on X axis.
  92280. */
  92281. maxScaleX: number;
  92282. /**
  92283. * Minimum scale of emitting particles on Y axis.
  92284. */
  92285. minScaleY: number;
  92286. /**
  92287. * Maximum scale of emitting particles on Y axis.
  92288. */
  92289. maxScaleY: number;
  92290. /**
  92291. * Gets or sets the minimal initial rotation in radians.
  92292. */
  92293. minInitialRotation: number;
  92294. /**
  92295. * Gets or sets the maximal initial rotation in radians.
  92296. */
  92297. maxInitialRotation: number;
  92298. /**
  92299. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92300. */
  92301. minAngularSpeed: number;
  92302. /**
  92303. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92304. */
  92305. maxAngularSpeed: number;
  92306. /**
  92307. * The texture used to render each particle. (this can be a spritesheet)
  92308. */
  92309. particleTexture: Nullable<BaseTexture>;
  92310. /**
  92311. * The layer mask we are rendering the particles through.
  92312. */
  92313. layerMask: number;
  92314. /**
  92315. * This can help using your own shader to render the particle system.
  92316. * The according effect will be created
  92317. */
  92318. customShader: any;
  92319. /**
  92320. * By default particle system starts as soon as they are created. This prevents the
  92321. * automatic start to happen and let you decide when to start emitting particles.
  92322. */
  92323. preventAutoStart: boolean;
  92324. private _noiseTexture;
  92325. /**
  92326. * Gets or sets a texture used to add random noise to particle positions
  92327. */
  92328. get noiseTexture(): Nullable<ProceduralTexture>;
  92329. set noiseTexture(value: Nullable<ProceduralTexture>);
  92330. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92331. noiseStrength: Vector3;
  92332. /**
  92333. * Callback triggered when the particle animation is ending.
  92334. */
  92335. onAnimationEnd: Nullable<() => void>;
  92336. /**
  92337. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92338. */
  92339. blendMode: number;
  92340. /**
  92341. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92342. * to override the particles.
  92343. */
  92344. forceDepthWrite: boolean;
  92345. /** 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 */
  92346. preWarmCycles: number;
  92347. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92348. preWarmStepOffset: number;
  92349. /**
  92350. * 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)
  92351. */
  92352. spriteCellChangeSpeed: number;
  92353. /**
  92354. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92355. */
  92356. startSpriteCellID: number;
  92357. /**
  92358. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92359. */
  92360. endSpriteCellID: number;
  92361. /**
  92362. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92363. */
  92364. spriteCellWidth: number;
  92365. /**
  92366. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92367. */
  92368. spriteCellHeight: number;
  92369. /**
  92370. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92371. */
  92372. spriteRandomStartCell: boolean;
  92373. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92374. translationPivot: Vector2;
  92375. /** @hidden */
  92376. protected _isAnimationSheetEnabled: boolean;
  92377. /**
  92378. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92379. */
  92380. beginAnimationOnStart: boolean;
  92381. /**
  92382. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92383. */
  92384. beginAnimationFrom: number;
  92385. /**
  92386. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92387. */
  92388. beginAnimationTo: number;
  92389. /**
  92390. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92391. */
  92392. beginAnimationLoop: boolean;
  92393. /**
  92394. * Gets or sets a world offset applied to all particles
  92395. */
  92396. worldOffset: Vector3;
  92397. /**
  92398. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92399. */
  92400. get isAnimationSheetEnabled(): boolean;
  92401. set isAnimationSheetEnabled(value: boolean);
  92402. /**
  92403. * Get hosting scene
  92404. * @returns the scene
  92405. */
  92406. getScene(): Nullable<Scene>;
  92407. /**
  92408. * You can use gravity if you want to give an orientation to your particles.
  92409. */
  92410. gravity: Vector3;
  92411. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92412. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92413. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92414. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92415. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92416. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92417. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92418. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92419. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92420. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92421. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92422. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92423. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92424. /**
  92425. * Defines the delay in milliseconds before starting the system (0 by default)
  92426. */
  92427. startDelay: number;
  92428. /**
  92429. * Gets the current list of drag gradients.
  92430. * You must use addDragGradient and removeDragGradient to udpate this list
  92431. * @returns the list of drag gradients
  92432. */
  92433. getDragGradients(): Nullable<Array<FactorGradient>>;
  92434. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92435. limitVelocityDamping: number;
  92436. /**
  92437. * Gets the current list of limit velocity gradients.
  92438. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92439. * @returns the list of limit velocity gradients
  92440. */
  92441. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92442. /**
  92443. * Gets the current list of color gradients.
  92444. * You must use addColorGradient and removeColorGradient to udpate this list
  92445. * @returns the list of color gradients
  92446. */
  92447. getColorGradients(): Nullable<Array<ColorGradient>>;
  92448. /**
  92449. * Gets the current list of size gradients.
  92450. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92451. * @returns the list of size gradients
  92452. */
  92453. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92454. /**
  92455. * Gets the current list of color remap gradients.
  92456. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92457. * @returns the list of color remap gradients
  92458. */
  92459. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92460. /**
  92461. * Gets the current list of alpha remap gradients.
  92462. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92463. * @returns the list of alpha remap gradients
  92464. */
  92465. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92466. /**
  92467. * Gets the current list of life time gradients.
  92468. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92469. * @returns the list of life time gradients
  92470. */
  92471. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92472. /**
  92473. * Gets the current list of angular speed gradients.
  92474. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92475. * @returns the list of angular speed gradients
  92476. */
  92477. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92478. /**
  92479. * Gets the current list of velocity gradients.
  92480. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92481. * @returns the list of velocity gradients
  92482. */
  92483. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92484. /**
  92485. * Gets the current list of start size gradients.
  92486. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92487. * @returns the list of start size gradients
  92488. */
  92489. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92490. /**
  92491. * Gets the current list of emit rate gradients.
  92492. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92493. * @returns the list of emit rate gradients
  92494. */
  92495. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92496. /**
  92497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92499. */
  92500. get direction1(): Vector3;
  92501. set direction1(value: Vector3);
  92502. /**
  92503. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92504. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92505. */
  92506. get direction2(): Vector3;
  92507. set direction2(value: Vector3);
  92508. /**
  92509. * 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.
  92510. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92511. */
  92512. get minEmitBox(): Vector3;
  92513. set minEmitBox(value: Vector3);
  92514. /**
  92515. * 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.
  92516. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92517. */
  92518. get maxEmitBox(): Vector3;
  92519. set maxEmitBox(value: Vector3);
  92520. /**
  92521. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92522. */
  92523. color1: Color4;
  92524. /**
  92525. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92526. */
  92527. color2: Color4;
  92528. /**
  92529. * Color the particle will have at the end of its lifetime
  92530. */
  92531. colorDead: Color4;
  92532. /**
  92533. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92534. */
  92535. textureMask: Color4;
  92536. /**
  92537. * The particle emitter type defines the emitter used by the particle system.
  92538. * It can be for example box, sphere, or cone...
  92539. */
  92540. particleEmitterType: IParticleEmitterType;
  92541. /** @hidden */
  92542. _isSubEmitter: boolean;
  92543. /**
  92544. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92545. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92546. */
  92547. billboardMode: number;
  92548. protected _isBillboardBased: boolean;
  92549. /**
  92550. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92551. */
  92552. get isBillboardBased(): boolean;
  92553. set isBillboardBased(value: boolean);
  92554. /**
  92555. * The scene the particle system belongs to.
  92556. */
  92557. protected _scene: Nullable<Scene>;
  92558. /**
  92559. * The engine the particle system belongs to.
  92560. */
  92561. protected _engine: ThinEngine;
  92562. /**
  92563. * Local cache of defines for image processing.
  92564. */
  92565. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92566. /**
  92567. * Default configuration related to image processing available in the standard Material.
  92568. */
  92569. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92570. /**
  92571. * Gets the image processing configuration used either in this material.
  92572. */
  92573. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92574. /**
  92575. * Sets the Default image processing configuration used either in the this material.
  92576. *
  92577. * If sets to null, the scene one is in use.
  92578. */
  92579. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92580. /**
  92581. * Attaches a new image processing configuration to the Standard Material.
  92582. * @param configuration
  92583. */
  92584. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92585. /** @hidden */
  92586. protected _reset(): void;
  92587. /** @hidden */
  92588. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92589. /**
  92590. * Instantiates a particle system.
  92591. * 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.
  92592. * @param name The name of the particle system
  92593. */
  92594. constructor(name: string);
  92595. /**
  92596. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92597. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92598. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92599. * @returns the emitter
  92600. */
  92601. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92602. /**
  92603. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92604. * @param radius The radius of the hemisphere to emit from
  92605. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92606. * @returns the emitter
  92607. */
  92608. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92609. /**
  92610. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92611. * @param radius The radius of the sphere to emit from
  92612. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92613. * @returns the emitter
  92614. */
  92615. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92616. /**
  92617. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92618. * @param radius The radius of the sphere to emit from
  92619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92621. * @returns the emitter
  92622. */
  92623. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92624. /**
  92625. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92626. * @param radius The radius of the emission cylinder
  92627. * @param height The height of the emission cylinder
  92628. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92629. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92630. * @returns the emitter
  92631. */
  92632. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92633. /**
  92634. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92635. * @param radius The radius of the cylinder to emit from
  92636. * @param height The height of the emission cylinder
  92637. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92640. * @returns the emitter
  92641. */
  92642. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92643. /**
  92644. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92645. * @param radius The radius of the cone to emit from
  92646. * @param angle The base angle of the cone
  92647. * @returns the emitter
  92648. */
  92649. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92650. /**
  92651. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92652. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92653. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92654. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92655. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92656. * @returns the emitter
  92657. */
  92658. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92659. }
  92660. }
  92661. declare module BABYLON {
  92662. /**
  92663. * Type of sub emitter
  92664. */
  92665. export enum SubEmitterType {
  92666. /**
  92667. * Attached to the particle over it's lifetime
  92668. */
  92669. ATTACHED = 0,
  92670. /**
  92671. * Created when the particle dies
  92672. */
  92673. END = 1
  92674. }
  92675. /**
  92676. * Sub emitter class used to emit particles from an existing particle
  92677. */
  92678. export class SubEmitter {
  92679. /**
  92680. * the particle system to be used by the sub emitter
  92681. */
  92682. particleSystem: ParticleSystem;
  92683. /**
  92684. * Type of the submitter (Default: END)
  92685. */
  92686. type: SubEmitterType;
  92687. /**
  92688. * 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)
  92689. * Note: This only is supported when using an emitter of type Mesh
  92690. */
  92691. inheritDirection: boolean;
  92692. /**
  92693. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92694. */
  92695. inheritedVelocityAmount: number;
  92696. /**
  92697. * Creates a sub emitter
  92698. * @param particleSystem the particle system to be used by the sub emitter
  92699. */
  92700. constructor(
  92701. /**
  92702. * the particle system to be used by the sub emitter
  92703. */
  92704. particleSystem: ParticleSystem);
  92705. /**
  92706. * Clones the sub emitter
  92707. * @returns the cloned sub emitter
  92708. */
  92709. clone(): SubEmitter;
  92710. /**
  92711. * Serialize current object to a JSON object
  92712. * @returns the serialized object
  92713. */
  92714. serialize(): any;
  92715. /** @hidden */
  92716. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92717. /**
  92718. * Creates a new SubEmitter from a serialized JSON version
  92719. * @param serializationObject defines the JSON object to read from
  92720. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92721. * @param rootUrl defines the rootUrl for data loading
  92722. * @returns a new SubEmitter
  92723. */
  92724. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92725. /** Release associated resources */
  92726. dispose(): void;
  92727. }
  92728. }
  92729. declare module BABYLON {
  92730. /** @hidden */
  92731. export var imageProcessingDeclaration: {
  92732. name: string;
  92733. shader: string;
  92734. };
  92735. }
  92736. declare module BABYLON {
  92737. /** @hidden */
  92738. export var imageProcessingFunctions: {
  92739. name: string;
  92740. shader: string;
  92741. };
  92742. }
  92743. declare module BABYLON {
  92744. /** @hidden */
  92745. export var particlesPixelShader: {
  92746. name: string;
  92747. shader: string;
  92748. };
  92749. }
  92750. declare module BABYLON {
  92751. /** @hidden */
  92752. export var particlesVertexShader: {
  92753. name: string;
  92754. shader: string;
  92755. };
  92756. }
  92757. declare module BABYLON {
  92758. /**
  92759. * Interface used to define entities containing multiple clip planes
  92760. */
  92761. export interface IClipPlanesHolder {
  92762. /**
  92763. * Gets or sets the active clipplane 1
  92764. */
  92765. clipPlane: Nullable<Plane>;
  92766. /**
  92767. * Gets or sets the active clipplane 2
  92768. */
  92769. clipPlane2: Nullable<Plane>;
  92770. /**
  92771. * Gets or sets the active clipplane 3
  92772. */
  92773. clipPlane3: Nullable<Plane>;
  92774. /**
  92775. * Gets or sets the active clipplane 4
  92776. */
  92777. clipPlane4: Nullable<Plane>;
  92778. /**
  92779. * Gets or sets the active clipplane 5
  92780. */
  92781. clipPlane5: Nullable<Plane>;
  92782. /**
  92783. * Gets or sets the active clipplane 6
  92784. */
  92785. clipPlane6: Nullable<Plane>;
  92786. }
  92787. }
  92788. declare module BABYLON {
  92789. /**
  92790. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  92791. *
  92792. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  92793. *
  92794. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  92795. */
  92796. export class ThinMaterialHelper {
  92797. /**
  92798. * Binds the clip plane information from the holder to the effect.
  92799. * @param effect The effect we are binding the data to
  92800. * @param holder The entity containing the clip plane information
  92801. */
  92802. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  92803. }
  92804. }
  92805. declare module BABYLON {
  92806. interface ThinEngine {
  92807. /**
  92808. * Sets alpha constants used by some alpha blending modes
  92809. * @param r defines the red component
  92810. * @param g defines the green component
  92811. * @param b defines the blue component
  92812. * @param a defines the alpha component
  92813. */
  92814. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  92815. /**
  92816. * Sets the current alpha mode
  92817. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  92818. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  92819. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92820. */
  92821. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  92822. /**
  92823. * Gets the current alpha mode
  92824. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  92825. * @returns the current alpha mode
  92826. */
  92827. getAlphaMode(): number;
  92828. /**
  92829. * Sets the current alpha equation
  92830. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  92831. */
  92832. setAlphaEquation(equation: number): void;
  92833. /**
  92834. * Gets the current alpha equation.
  92835. * @returns the current alpha equation
  92836. */
  92837. getAlphaEquation(): number;
  92838. }
  92839. }
  92840. declare module BABYLON {
  92841. /**
  92842. * This represents a particle system in Babylon.
  92843. * 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.
  92844. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92845. * @example https://doc.babylonjs.com/babylon101/particles
  92846. */
  92847. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  92848. /**
  92849. * Billboard mode will only apply to Y axis
  92850. */
  92851. static readonly BILLBOARDMODE_Y: number;
  92852. /**
  92853. * Billboard mode will apply to all axes
  92854. */
  92855. static readonly BILLBOARDMODE_ALL: number;
  92856. /**
  92857. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  92858. */
  92859. static readonly BILLBOARDMODE_STRETCHED: number;
  92860. /**
  92861. * This function can be defined to provide custom update for active particles.
  92862. * This function will be called instead of regular update (age, position, color, etc.).
  92863. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  92864. */
  92865. updateFunction: (particles: Particle[]) => void;
  92866. private _emitterWorldMatrix;
  92867. /**
  92868. * This function can be defined to specify initial direction for every new particle.
  92869. * It by default use the emitterType defined function
  92870. */
  92871. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92872. /**
  92873. * This function can be defined to specify initial position for every new particle.
  92874. * It by default use the emitterType defined function
  92875. */
  92876. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  92877. /**
  92878. * @hidden
  92879. */
  92880. _inheritedVelocityOffset: Vector3;
  92881. /**
  92882. * An event triggered when the system is disposed
  92883. */
  92884. onDisposeObservable: Observable<IParticleSystem>;
  92885. private _onDisposeObserver;
  92886. /**
  92887. * Sets a callback that will be triggered when the system is disposed
  92888. */
  92889. set onDispose(callback: () => void);
  92890. private _particles;
  92891. private _epsilon;
  92892. private _capacity;
  92893. private _stockParticles;
  92894. private _newPartsExcess;
  92895. private _vertexData;
  92896. private _vertexBuffer;
  92897. private _vertexBuffers;
  92898. private _spriteBuffer;
  92899. private _indexBuffer;
  92900. private _effect;
  92901. private _customEffect;
  92902. private _cachedDefines;
  92903. private _scaledColorStep;
  92904. private _colorDiff;
  92905. private _scaledDirection;
  92906. private _scaledGravity;
  92907. private _currentRenderId;
  92908. private _alive;
  92909. private _useInstancing;
  92910. private _started;
  92911. private _stopped;
  92912. private _actualFrame;
  92913. private _scaledUpdateSpeed;
  92914. private _vertexBufferSize;
  92915. /** @hidden */
  92916. _currentEmitRateGradient: Nullable<FactorGradient>;
  92917. /** @hidden */
  92918. _currentEmitRate1: number;
  92919. /** @hidden */
  92920. _currentEmitRate2: number;
  92921. /** @hidden */
  92922. _currentStartSizeGradient: Nullable<FactorGradient>;
  92923. /** @hidden */
  92924. _currentStartSize1: number;
  92925. /** @hidden */
  92926. _currentStartSize2: number;
  92927. private readonly _rawTextureWidth;
  92928. private _rampGradientsTexture;
  92929. private _useRampGradients;
  92930. /** Gets or sets a matrix to use to compute projection */
  92931. defaultProjectionMatrix: Matrix;
  92932. /** Gets or sets a matrix to use to compute view */
  92933. defaultViewMatrix: Matrix;
  92934. /** Gets or sets a boolean indicating that ramp gradients must be used
  92935. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  92936. */
  92937. get useRampGradients(): boolean;
  92938. set useRampGradients(value: boolean);
  92939. /**
  92940. * 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.
  92941. * 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: [])
  92942. */
  92943. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  92944. private _subEmitters;
  92945. /**
  92946. * @hidden
  92947. * If the particle systems emitter should be disposed when the particle system is disposed
  92948. */
  92949. _disposeEmitterOnDispose: boolean;
  92950. /**
  92951. * The current active Sub-systems, this property is used by the root particle system only.
  92952. */
  92953. activeSubSystems: Array<ParticleSystem>;
  92954. /**
  92955. * Specifies if the particles are updated in emitter local space or world space
  92956. */
  92957. isLocal: boolean;
  92958. private _rootParticleSystem;
  92959. /**
  92960. * Gets the current list of active particles
  92961. */
  92962. get particles(): Particle[];
  92963. /**
  92964. * Gets the number of particles active at the same time.
  92965. * @returns The number of active particles.
  92966. */
  92967. getActiveCount(): number;
  92968. /**
  92969. * Returns the string "ParticleSystem"
  92970. * @returns a string containing the class name
  92971. */
  92972. getClassName(): string;
  92973. /**
  92974. * Gets a boolean indicating that the system is stopping
  92975. * @returns true if the system is currently stopping
  92976. */
  92977. isStopping(): boolean;
  92978. /**
  92979. * Gets the custom effect used to render the particles
  92980. * @param blendMode Blend mode for which the effect should be retrieved
  92981. * @returns The effect
  92982. */
  92983. getCustomEffect(blendMode?: number): Nullable<Effect>;
  92984. /**
  92985. * Sets the custom effect used to render the particles
  92986. * @param effect The effect to set
  92987. * @param blendMode Blend mode for which the effect should be set
  92988. */
  92989. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  92990. /** @hidden */
  92991. private _onBeforeDrawParticlesObservable;
  92992. /**
  92993. * Observable that will be called just before the particles are drawn
  92994. */
  92995. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  92996. /**
  92997. * Gets the name of the particle vertex shader
  92998. */
  92999. get vertexShaderName(): string;
  93000. /**
  93001. * Instantiates a particle system.
  93002. * 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.
  93003. * @param name The name of the particle system
  93004. * @param capacity The max number of particles alive at the same time
  93005. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93006. * @param customEffect a custom effect used to change the way particles are rendered by default
  93007. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93008. * @param epsilon Offset used to render the particles
  93009. */
  93010. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93011. private _addFactorGradient;
  93012. private _removeFactorGradient;
  93013. /**
  93014. * Adds a new life time gradient
  93015. * @param gradient defines the gradient to use (between 0 and 1)
  93016. * @param factor defines the life time factor to affect to the specified gradient
  93017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93018. * @returns the current particle system
  93019. */
  93020. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93021. /**
  93022. * Remove a specific life time gradient
  93023. * @param gradient defines the gradient to remove
  93024. * @returns the current particle system
  93025. */
  93026. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93027. /**
  93028. * Adds a new size gradient
  93029. * @param gradient defines the gradient to use (between 0 and 1)
  93030. * @param factor defines the size factor to affect to the specified gradient
  93031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93032. * @returns the current particle system
  93033. */
  93034. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93035. /**
  93036. * Remove a specific size gradient
  93037. * @param gradient defines the gradient to remove
  93038. * @returns the current particle system
  93039. */
  93040. removeSizeGradient(gradient: number): IParticleSystem;
  93041. /**
  93042. * Adds a new color remap gradient
  93043. * @param gradient defines the gradient to use (between 0 and 1)
  93044. * @param min defines the color remap minimal range
  93045. * @param max defines the color remap maximal range
  93046. * @returns the current particle system
  93047. */
  93048. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93049. /**
  93050. * Remove a specific color remap gradient
  93051. * @param gradient defines the gradient to remove
  93052. * @returns the current particle system
  93053. */
  93054. removeColorRemapGradient(gradient: number): IParticleSystem;
  93055. /**
  93056. * Adds a new alpha remap gradient
  93057. * @param gradient defines the gradient to use (between 0 and 1)
  93058. * @param min defines the alpha remap minimal range
  93059. * @param max defines the alpha remap maximal range
  93060. * @returns the current particle system
  93061. */
  93062. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93063. /**
  93064. * Remove a specific alpha remap gradient
  93065. * @param gradient defines the gradient to remove
  93066. * @returns the current particle system
  93067. */
  93068. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93069. /**
  93070. * Adds a new angular speed gradient
  93071. * @param gradient defines the gradient to use (between 0 and 1)
  93072. * @param factor defines the angular speed to affect to the specified gradient
  93073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93074. * @returns the current particle system
  93075. */
  93076. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93077. /**
  93078. * Remove a specific angular speed gradient
  93079. * @param gradient defines the gradient to remove
  93080. * @returns the current particle system
  93081. */
  93082. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93083. /**
  93084. * Adds a new velocity gradient
  93085. * @param gradient defines the gradient to use (between 0 and 1)
  93086. * @param factor defines the velocity to affect to the specified gradient
  93087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93088. * @returns the current particle system
  93089. */
  93090. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93091. /**
  93092. * Remove a specific velocity gradient
  93093. * @param gradient defines the gradient to remove
  93094. * @returns the current particle system
  93095. */
  93096. removeVelocityGradient(gradient: number): IParticleSystem;
  93097. /**
  93098. * Adds a new limit velocity gradient
  93099. * @param gradient defines the gradient to use (between 0 and 1)
  93100. * @param factor defines the limit velocity value to affect to the specified gradient
  93101. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93102. * @returns the current particle system
  93103. */
  93104. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93105. /**
  93106. * Remove a specific limit velocity gradient
  93107. * @param gradient defines the gradient to remove
  93108. * @returns the current particle system
  93109. */
  93110. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93111. /**
  93112. * Adds a new drag gradient
  93113. * @param gradient defines the gradient to use (between 0 and 1)
  93114. * @param factor defines the drag value to affect to the specified gradient
  93115. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93116. * @returns the current particle system
  93117. */
  93118. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93119. /**
  93120. * Remove a specific drag gradient
  93121. * @param gradient defines the gradient to remove
  93122. * @returns the current particle system
  93123. */
  93124. removeDragGradient(gradient: number): IParticleSystem;
  93125. /**
  93126. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93127. * @param gradient defines the gradient to use (between 0 and 1)
  93128. * @param factor defines the emit rate value to affect to the specified gradient
  93129. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93130. * @returns the current particle system
  93131. */
  93132. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93133. /**
  93134. * Remove a specific emit rate gradient
  93135. * @param gradient defines the gradient to remove
  93136. * @returns the current particle system
  93137. */
  93138. removeEmitRateGradient(gradient: number): IParticleSystem;
  93139. /**
  93140. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93141. * @param gradient defines the gradient to use (between 0 and 1)
  93142. * @param factor defines the start size value to affect to the specified gradient
  93143. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93144. * @returns the current particle system
  93145. */
  93146. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93147. /**
  93148. * Remove a specific start size gradient
  93149. * @param gradient defines the gradient to remove
  93150. * @returns the current particle system
  93151. */
  93152. removeStartSizeGradient(gradient: number): IParticleSystem;
  93153. private _createRampGradientTexture;
  93154. /**
  93155. * Gets the current list of ramp gradients.
  93156. * You must use addRampGradient and removeRampGradient to udpate this list
  93157. * @returns the list of ramp gradients
  93158. */
  93159. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93160. /** Force the system to rebuild all gradients that need to be resync */
  93161. forceRefreshGradients(): void;
  93162. private _syncRampGradientTexture;
  93163. /**
  93164. * Adds a new ramp gradient used to remap particle colors
  93165. * @param gradient defines the gradient to use (between 0 and 1)
  93166. * @param color defines the color to affect to the specified gradient
  93167. * @returns the current particle system
  93168. */
  93169. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93170. /**
  93171. * Remove a specific ramp gradient
  93172. * @param gradient defines the gradient to remove
  93173. * @returns the current particle system
  93174. */
  93175. removeRampGradient(gradient: number): ParticleSystem;
  93176. /**
  93177. * Adds a new color gradient
  93178. * @param gradient defines the gradient to use (between 0 and 1)
  93179. * @param color1 defines the color to affect to the specified gradient
  93180. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93181. * @returns this particle system
  93182. */
  93183. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93184. /**
  93185. * Remove a specific color gradient
  93186. * @param gradient defines the gradient to remove
  93187. * @returns this particle system
  93188. */
  93189. removeColorGradient(gradient: number): IParticleSystem;
  93190. private _fetchR;
  93191. protected _reset(): void;
  93192. private _resetEffect;
  93193. private _createVertexBuffers;
  93194. private _createIndexBuffer;
  93195. /**
  93196. * Gets the maximum number of particles active at the same time.
  93197. * @returns The max number of active particles.
  93198. */
  93199. getCapacity(): number;
  93200. /**
  93201. * Gets whether there are still active particles in the system.
  93202. * @returns True if it is alive, otherwise false.
  93203. */
  93204. isAlive(): boolean;
  93205. /**
  93206. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93207. * @returns True if it has been started, otherwise false.
  93208. */
  93209. isStarted(): boolean;
  93210. private _prepareSubEmitterInternalArray;
  93211. /**
  93212. * Starts the particle system and begins to emit
  93213. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93214. */
  93215. start(delay?: number): void;
  93216. /**
  93217. * Stops the particle system.
  93218. * @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.
  93219. */
  93220. stop(stopSubEmitters?: boolean): void;
  93221. /**
  93222. * Remove all active particles
  93223. */
  93224. reset(): void;
  93225. /**
  93226. * @hidden (for internal use only)
  93227. */
  93228. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93229. /**
  93230. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93231. * Its lifetime will start back at 0.
  93232. */
  93233. recycleParticle: (particle: Particle) => void;
  93234. private _stopSubEmitters;
  93235. private _createParticle;
  93236. private _removeFromRoot;
  93237. private _emitFromParticle;
  93238. private _update;
  93239. /** @hidden */
  93240. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93241. /** @hidden */
  93242. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93243. /**
  93244. * Fill the defines array according to the current settings of the particle system
  93245. * @param defines Array to be updated
  93246. * @param blendMode blend mode to take into account when updating the array
  93247. */
  93248. fillDefines(defines: Array<string>, blendMode: number): void;
  93249. /**
  93250. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93251. * @param uniforms Uniforms array to fill
  93252. * @param attributes Attributes array to fill
  93253. * @param samplers Samplers array to fill
  93254. */
  93255. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93256. /** @hidden */
  93257. private _getEffect;
  93258. /**
  93259. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93260. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93261. */
  93262. animate(preWarmOnly?: boolean): void;
  93263. private _appendParticleVertices;
  93264. /**
  93265. * Rebuilds the particle system.
  93266. */
  93267. rebuild(): void;
  93268. /**
  93269. * Is this system ready to be used/rendered
  93270. * @return true if the system is ready
  93271. */
  93272. isReady(): boolean;
  93273. private _render;
  93274. /**
  93275. * Renders the particle system in its current state.
  93276. * @returns the current number of particles
  93277. */
  93278. render(): number;
  93279. /**
  93280. * Disposes the particle system and free the associated resources
  93281. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93282. */
  93283. dispose(disposeTexture?: boolean): void;
  93284. /**
  93285. * Clones the particle system.
  93286. * @param name The name of the cloned object
  93287. * @param newEmitter The new emitter to use
  93288. * @returns the cloned particle system
  93289. */
  93290. clone(name: string, newEmitter: any): ParticleSystem;
  93291. /**
  93292. * Serializes the particle system to a JSON object
  93293. * @param serializeTexture defines if the texture must be serialized as well
  93294. * @returns the JSON object
  93295. */
  93296. serialize(serializeTexture?: boolean): any;
  93297. /** @hidden */
  93298. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93299. /** @hidden */
  93300. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93301. /**
  93302. * Parses a JSON object to create a particle system.
  93303. * @param parsedParticleSystem The JSON object to parse
  93304. * @param sceneOrEngine The scene or the engine to create the particle system in
  93305. * @param rootUrl The root url to use to load external dependencies like texture
  93306. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93307. * @returns the Parsed particle system
  93308. */
  93309. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93310. }
  93311. }
  93312. declare module BABYLON {
  93313. /**
  93314. * A particle represents one of the element emitted by a particle system.
  93315. * This is mainly define by its coordinates, direction, velocity and age.
  93316. */
  93317. export class Particle {
  93318. /**
  93319. * The particle system the particle belongs to.
  93320. */
  93321. particleSystem: ParticleSystem;
  93322. private static _Count;
  93323. /**
  93324. * Unique ID of the particle
  93325. */
  93326. id: number;
  93327. /**
  93328. * The world position of the particle in the scene.
  93329. */
  93330. position: Vector3;
  93331. /**
  93332. * The world direction of the particle in the scene.
  93333. */
  93334. direction: Vector3;
  93335. /**
  93336. * The color of the particle.
  93337. */
  93338. color: Color4;
  93339. /**
  93340. * The color change of the particle per step.
  93341. */
  93342. colorStep: Color4;
  93343. /**
  93344. * Defines how long will the life of the particle be.
  93345. */
  93346. lifeTime: number;
  93347. /**
  93348. * The current age of the particle.
  93349. */
  93350. age: number;
  93351. /**
  93352. * The current size of the particle.
  93353. */
  93354. size: number;
  93355. /**
  93356. * The current scale of the particle.
  93357. */
  93358. scale: Vector2;
  93359. /**
  93360. * The current angle of the particle.
  93361. */
  93362. angle: number;
  93363. /**
  93364. * Defines how fast is the angle changing.
  93365. */
  93366. angularSpeed: number;
  93367. /**
  93368. * Defines the cell index used by the particle to be rendered from a sprite.
  93369. */
  93370. cellIndex: number;
  93371. /**
  93372. * The information required to support color remapping
  93373. */
  93374. remapData: Vector4;
  93375. /** @hidden */
  93376. _randomCellOffset?: number;
  93377. /** @hidden */
  93378. _initialDirection: Nullable<Vector3>;
  93379. /** @hidden */
  93380. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93381. /** @hidden */
  93382. _initialStartSpriteCellID: number;
  93383. /** @hidden */
  93384. _initialEndSpriteCellID: number;
  93385. /** @hidden */
  93386. _currentColorGradient: Nullable<ColorGradient>;
  93387. /** @hidden */
  93388. _currentColor1: Color4;
  93389. /** @hidden */
  93390. _currentColor2: Color4;
  93391. /** @hidden */
  93392. _currentSizeGradient: Nullable<FactorGradient>;
  93393. /** @hidden */
  93394. _currentSize1: number;
  93395. /** @hidden */
  93396. _currentSize2: number;
  93397. /** @hidden */
  93398. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93399. /** @hidden */
  93400. _currentAngularSpeed1: number;
  93401. /** @hidden */
  93402. _currentAngularSpeed2: number;
  93403. /** @hidden */
  93404. _currentVelocityGradient: Nullable<FactorGradient>;
  93405. /** @hidden */
  93406. _currentVelocity1: number;
  93407. /** @hidden */
  93408. _currentVelocity2: number;
  93409. /** @hidden */
  93410. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93411. /** @hidden */
  93412. _currentLimitVelocity1: number;
  93413. /** @hidden */
  93414. _currentLimitVelocity2: number;
  93415. /** @hidden */
  93416. _currentDragGradient: Nullable<FactorGradient>;
  93417. /** @hidden */
  93418. _currentDrag1: number;
  93419. /** @hidden */
  93420. _currentDrag2: number;
  93421. /** @hidden */
  93422. _randomNoiseCoordinates1: Vector3;
  93423. /** @hidden */
  93424. _randomNoiseCoordinates2: Vector3;
  93425. /** @hidden */
  93426. _localPosition?: Vector3;
  93427. /**
  93428. * Creates a new instance Particle
  93429. * @param particleSystem the particle system the particle belongs to
  93430. */
  93431. constructor(
  93432. /**
  93433. * The particle system the particle belongs to.
  93434. */
  93435. particleSystem: ParticleSystem);
  93436. private updateCellInfoFromSystem;
  93437. /**
  93438. * Defines how the sprite cell index is updated for the particle
  93439. */
  93440. updateCellIndex(): void;
  93441. /** @hidden */
  93442. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93443. /** @hidden */
  93444. _inheritParticleInfoToSubEmitters(): void;
  93445. /** @hidden */
  93446. _reset(): void;
  93447. /**
  93448. * Copy the properties of particle to another one.
  93449. * @param other the particle to copy the information to.
  93450. */
  93451. copyTo(other: Particle): void;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /**
  93456. * Particle emitter represents a volume emitting particles.
  93457. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93458. */
  93459. export interface IParticleEmitterType {
  93460. /**
  93461. * Called by the particle System when the direction is computed for the created particle.
  93462. * @param worldMatrix is the world matrix of the particle system
  93463. * @param directionToUpdate is the direction vector to update with the result
  93464. * @param particle is the particle we are computed the direction for
  93465. * @param isLocal defines if the direction should be set in local space
  93466. */
  93467. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93468. /**
  93469. * Called by the particle System when the position is computed for the created particle.
  93470. * @param worldMatrix is the world matrix of the particle system
  93471. * @param positionToUpdate is the position vector to update with the result
  93472. * @param particle is the particle we are computed the position for
  93473. * @param isLocal defines if the position should be set in local space
  93474. */
  93475. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93476. /**
  93477. * Clones the current emitter and returns a copy of it
  93478. * @returns the new emitter
  93479. */
  93480. clone(): IParticleEmitterType;
  93481. /**
  93482. * Called by the GPUParticleSystem to setup the update shader
  93483. * @param effect defines the update shader
  93484. */
  93485. applyToShader(effect: Effect): void;
  93486. /**
  93487. * Returns a string to use to update the GPU particles update shader
  93488. * @returns the effect defines string
  93489. */
  93490. getEffectDefines(): string;
  93491. /**
  93492. * Returns a string representing the class name
  93493. * @returns a string containing the class name
  93494. */
  93495. getClassName(): string;
  93496. /**
  93497. * Serializes the particle system to a JSON object.
  93498. * @returns the JSON object
  93499. */
  93500. serialize(): any;
  93501. /**
  93502. * Parse properties from a JSON object
  93503. * @param serializationObject defines the JSON object
  93504. * @param scene defines the hosting scene
  93505. */
  93506. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93507. }
  93508. }
  93509. declare module BABYLON {
  93510. /**
  93511. * Particle emitter emitting particles from the inside of a box.
  93512. * It emits the particles randomly between 2 given directions.
  93513. */
  93514. export class BoxParticleEmitter implements IParticleEmitterType {
  93515. /**
  93516. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93517. */
  93518. direction1: Vector3;
  93519. /**
  93520. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93521. */
  93522. direction2: Vector3;
  93523. /**
  93524. * 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.
  93525. */
  93526. minEmitBox: Vector3;
  93527. /**
  93528. * 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.
  93529. */
  93530. maxEmitBox: Vector3;
  93531. /**
  93532. * Creates a new instance BoxParticleEmitter
  93533. */
  93534. constructor();
  93535. /**
  93536. * Called by the particle System when the direction is computed for the created particle.
  93537. * @param worldMatrix is the world matrix of the particle system
  93538. * @param directionToUpdate is the direction vector to update with the result
  93539. * @param particle is the particle we are computed the direction for
  93540. * @param isLocal defines if the direction should be set in local space
  93541. */
  93542. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93543. /**
  93544. * Called by the particle System when the position is computed for the created particle.
  93545. * @param worldMatrix is the world matrix of the particle system
  93546. * @param positionToUpdate is the position vector to update with the result
  93547. * @param particle is the particle we are computed the position for
  93548. * @param isLocal defines if the position should be set in local space
  93549. */
  93550. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93551. /**
  93552. * Clones the current emitter and returns a copy of it
  93553. * @returns the new emitter
  93554. */
  93555. clone(): BoxParticleEmitter;
  93556. /**
  93557. * Called by the GPUParticleSystem to setup the update shader
  93558. * @param effect defines the update shader
  93559. */
  93560. applyToShader(effect: Effect): void;
  93561. /**
  93562. * Returns a string to use to update the GPU particles update shader
  93563. * @returns a string containng the defines string
  93564. */
  93565. getEffectDefines(): string;
  93566. /**
  93567. * Returns the string "BoxParticleEmitter"
  93568. * @returns a string containing the class name
  93569. */
  93570. getClassName(): string;
  93571. /**
  93572. * Serializes the particle system to a JSON object.
  93573. * @returns the JSON object
  93574. */
  93575. serialize(): any;
  93576. /**
  93577. * Parse properties from a JSON object
  93578. * @param serializationObject defines the JSON object
  93579. */
  93580. parse(serializationObject: any): void;
  93581. }
  93582. }
  93583. declare module BABYLON {
  93584. /**
  93585. * Particle emitter emitting particles from the inside of a cone.
  93586. * It emits the particles alongside the cone volume from the base to the particle.
  93587. * The emission direction might be randomized.
  93588. */
  93589. export class ConeParticleEmitter implements IParticleEmitterType {
  93590. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93591. directionRandomizer: number;
  93592. private _radius;
  93593. private _angle;
  93594. private _height;
  93595. /**
  93596. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93597. */
  93598. radiusRange: number;
  93599. /**
  93600. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93601. */
  93602. heightRange: number;
  93603. /**
  93604. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93605. */
  93606. emitFromSpawnPointOnly: boolean;
  93607. /**
  93608. * Gets or sets the radius of the emission cone
  93609. */
  93610. get radius(): number;
  93611. set radius(value: number);
  93612. /**
  93613. * Gets or sets the angle of the emission cone
  93614. */
  93615. get angle(): number;
  93616. set angle(value: number);
  93617. private _buildHeight;
  93618. /**
  93619. * Creates a new instance ConeParticleEmitter
  93620. * @param radius the radius of the emission cone (1 by default)
  93621. * @param angle the cone base angle (PI by default)
  93622. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93623. */
  93624. constructor(radius?: number, angle?: number,
  93625. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93626. directionRandomizer?: number);
  93627. /**
  93628. * Called by the particle System when the direction is computed for the created particle.
  93629. * @param worldMatrix is the world matrix of the particle system
  93630. * @param directionToUpdate is the direction vector to update with the result
  93631. * @param particle is the particle we are computed the direction for
  93632. * @param isLocal defines if the direction should be set in local space
  93633. */
  93634. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93635. /**
  93636. * Called by the particle System when the position is computed for the created particle.
  93637. * @param worldMatrix is the world matrix of the particle system
  93638. * @param positionToUpdate is the position vector to update with the result
  93639. * @param particle is the particle we are computed the position for
  93640. * @param isLocal defines if the position should be set in local space
  93641. */
  93642. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93643. /**
  93644. * Clones the current emitter and returns a copy of it
  93645. * @returns the new emitter
  93646. */
  93647. clone(): ConeParticleEmitter;
  93648. /**
  93649. * Called by the GPUParticleSystem to setup the update shader
  93650. * @param effect defines the update shader
  93651. */
  93652. applyToShader(effect: Effect): void;
  93653. /**
  93654. * Returns a string to use to update the GPU particles update shader
  93655. * @returns a string containng the defines string
  93656. */
  93657. getEffectDefines(): string;
  93658. /**
  93659. * Returns the string "ConeParticleEmitter"
  93660. * @returns a string containing the class name
  93661. */
  93662. getClassName(): string;
  93663. /**
  93664. * Serializes the particle system to a JSON object.
  93665. * @returns the JSON object
  93666. */
  93667. serialize(): any;
  93668. /**
  93669. * Parse properties from a JSON object
  93670. * @param serializationObject defines the JSON object
  93671. */
  93672. parse(serializationObject: any): void;
  93673. }
  93674. }
  93675. declare module BABYLON {
  93676. /**
  93677. * Particle emitter emitting particles from the inside of a cylinder.
  93678. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93679. */
  93680. export class CylinderParticleEmitter implements IParticleEmitterType {
  93681. /**
  93682. * The radius of the emission cylinder.
  93683. */
  93684. radius: number;
  93685. /**
  93686. * The height of the emission cylinder.
  93687. */
  93688. height: number;
  93689. /**
  93690. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93691. */
  93692. radiusRange: number;
  93693. /**
  93694. * How much to randomize the particle direction [0-1].
  93695. */
  93696. directionRandomizer: number;
  93697. /**
  93698. * Creates a new instance CylinderParticleEmitter
  93699. * @param radius the radius of the emission cylinder (1 by default)
  93700. * @param height the height of the emission cylinder (1 by default)
  93701. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93702. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93703. */
  93704. constructor(
  93705. /**
  93706. * The radius of the emission cylinder.
  93707. */
  93708. radius?: number,
  93709. /**
  93710. * The height of the emission cylinder.
  93711. */
  93712. height?: number,
  93713. /**
  93714. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93715. */
  93716. radiusRange?: number,
  93717. /**
  93718. * How much to randomize the particle direction [0-1].
  93719. */
  93720. directionRandomizer?: number);
  93721. /**
  93722. * Called by the particle System when the direction is computed for the created particle.
  93723. * @param worldMatrix is the world matrix of the particle system
  93724. * @param directionToUpdate is the direction vector to update with the result
  93725. * @param particle is the particle we are computed the direction for
  93726. * @param isLocal defines if the direction should be set in local space
  93727. */
  93728. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93729. /**
  93730. * Called by the particle System when the position is computed for the created particle.
  93731. * @param worldMatrix is the world matrix of the particle system
  93732. * @param positionToUpdate is the position vector to update with the result
  93733. * @param particle is the particle we are computed the position for
  93734. * @param isLocal defines if the position should be set in local space
  93735. */
  93736. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93737. /**
  93738. * Clones the current emitter and returns a copy of it
  93739. * @returns the new emitter
  93740. */
  93741. clone(): CylinderParticleEmitter;
  93742. /**
  93743. * Called by the GPUParticleSystem to setup the update shader
  93744. * @param effect defines the update shader
  93745. */
  93746. applyToShader(effect: Effect): void;
  93747. /**
  93748. * Returns a string to use to update the GPU particles update shader
  93749. * @returns a string containng the defines string
  93750. */
  93751. getEffectDefines(): string;
  93752. /**
  93753. * Returns the string "CylinderParticleEmitter"
  93754. * @returns a string containing the class name
  93755. */
  93756. getClassName(): string;
  93757. /**
  93758. * Serializes the particle system to a JSON object.
  93759. * @returns the JSON object
  93760. */
  93761. serialize(): any;
  93762. /**
  93763. * Parse properties from a JSON object
  93764. * @param serializationObject defines the JSON object
  93765. */
  93766. parse(serializationObject: any): void;
  93767. }
  93768. /**
  93769. * Particle emitter emitting particles from the inside of a cylinder.
  93770. * It emits the particles randomly between two vectors.
  93771. */
  93772. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  93773. /**
  93774. * The min limit of the emission direction.
  93775. */
  93776. direction1: Vector3;
  93777. /**
  93778. * The max limit of the emission direction.
  93779. */
  93780. direction2: Vector3;
  93781. /**
  93782. * Creates a new instance CylinderDirectedParticleEmitter
  93783. * @param radius the radius of the emission cylinder (1 by default)
  93784. * @param height the height of the emission cylinder (1 by default)
  93785. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93786. * @param direction1 the min limit of the emission direction (up vector by default)
  93787. * @param direction2 the max limit of the emission direction (up vector by default)
  93788. */
  93789. constructor(radius?: number, height?: number, radiusRange?: number,
  93790. /**
  93791. * The min limit of the emission direction.
  93792. */
  93793. direction1?: Vector3,
  93794. /**
  93795. * The max limit of the emission direction.
  93796. */
  93797. direction2?: Vector3);
  93798. /**
  93799. * Called by the particle System when the direction is computed for the created particle.
  93800. * @param worldMatrix is the world matrix of the particle system
  93801. * @param directionToUpdate is the direction vector to update with the result
  93802. * @param particle is the particle we are computed the direction for
  93803. */
  93804. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  93805. /**
  93806. * Clones the current emitter and returns a copy of it
  93807. * @returns the new emitter
  93808. */
  93809. clone(): CylinderDirectedParticleEmitter;
  93810. /**
  93811. * Called by the GPUParticleSystem to setup the update shader
  93812. * @param effect defines the update shader
  93813. */
  93814. applyToShader(effect: Effect): void;
  93815. /**
  93816. * Returns a string to use to update the GPU particles update shader
  93817. * @returns a string containng the defines string
  93818. */
  93819. getEffectDefines(): string;
  93820. /**
  93821. * Returns the string "CylinderDirectedParticleEmitter"
  93822. * @returns a string containing the class name
  93823. */
  93824. getClassName(): string;
  93825. /**
  93826. * Serializes the particle system to a JSON object.
  93827. * @returns the JSON object
  93828. */
  93829. serialize(): any;
  93830. /**
  93831. * Parse properties from a JSON object
  93832. * @param serializationObject defines the JSON object
  93833. */
  93834. parse(serializationObject: any): void;
  93835. }
  93836. }
  93837. declare module BABYLON {
  93838. /**
  93839. * Particle emitter emitting particles from the inside of a hemisphere.
  93840. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  93841. */
  93842. export class HemisphericParticleEmitter implements IParticleEmitterType {
  93843. /**
  93844. * The radius of the emission hemisphere.
  93845. */
  93846. radius: number;
  93847. /**
  93848. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93849. */
  93850. radiusRange: number;
  93851. /**
  93852. * How much to randomize the particle direction [0-1].
  93853. */
  93854. directionRandomizer: number;
  93855. /**
  93856. * Creates a new instance HemisphericParticleEmitter
  93857. * @param radius the radius of the emission hemisphere (1 by default)
  93858. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93859. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93860. */
  93861. constructor(
  93862. /**
  93863. * The radius of the emission hemisphere.
  93864. */
  93865. radius?: number,
  93866. /**
  93867. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93868. */
  93869. radiusRange?: number,
  93870. /**
  93871. * How much to randomize the particle direction [0-1].
  93872. */
  93873. directionRandomizer?: number);
  93874. /**
  93875. * Called by the particle System when the direction is computed for the created particle.
  93876. * @param worldMatrix is the world matrix of the particle system
  93877. * @param directionToUpdate is the direction vector to update with the result
  93878. * @param particle is the particle we are computed the direction for
  93879. * @param isLocal defines if the direction should be set in local space
  93880. */
  93881. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93882. /**
  93883. * Called by the particle System when the position is computed for the created particle.
  93884. * @param worldMatrix is the world matrix of the particle system
  93885. * @param positionToUpdate is the position vector to update with the result
  93886. * @param particle is the particle we are computed the position for
  93887. * @param isLocal defines if the position should be set in local space
  93888. */
  93889. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93890. /**
  93891. * Clones the current emitter and returns a copy of it
  93892. * @returns the new emitter
  93893. */
  93894. clone(): HemisphericParticleEmitter;
  93895. /**
  93896. * Called by the GPUParticleSystem to setup the update shader
  93897. * @param effect defines the update shader
  93898. */
  93899. applyToShader(effect: Effect): void;
  93900. /**
  93901. * Returns a string to use to update the GPU particles update shader
  93902. * @returns a string containng the defines string
  93903. */
  93904. getEffectDefines(): string;
  93905. /**
  93906. * Returns the string "HemisphericParticleEmitter"
  93907. * @returns a string containing the class name
  93908. */
  93909. getClassName(): string;
  93910. /**
  93911. * Serializes the particle system to a JSON object.
  93912. * @returns the JSON object
  93913. */
  93914. serialize(): any;
  93915. /**
  93916. * Parse properties from a JSON object
  93917. * @param serializationObject defines the JSON object
  93918. */
  93919. parse(serializationObject: any): void;
  93920. }
  93921. }
  93922. declare module BABYLON {
  93923. /**
  93924. * Particle emitter emitting particles from a point.
  93925. * It emits the particles randomly between 2 given directions.
  93926. */
  93927. export class PointParticleEmitter implements IParticleEmitterType {
  93928. /**
  93929. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93930. */
  93931. direction1: Vector3;
  93932. /**
  93933. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93934. */
  93935. direction2: Vector3;
  93936. /**
  93937. * Creates a new instance PointParticleEmitter
  93938. */
  93939. constructor();
  93940. /**
  93941. * Called by the particle System when the direction is computed for the created particle.
  93942. * @param worldMatrix is the world matrix of the particle system
  93943. * @param directionToUpdate is the direction vector to update with the result
  93944. * @param particle is the particle we are computed the direction for
  93945. * @param isLocal defines if the direction should be set in local space
  93946. */
  93947. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93948. /**
  93949. * Called by the particle System when the position is computed for the created particle.
  93950. * @param worldMatrix is the world matrix of the particle system
  93951. * @param positionToUpdate is the position vector to update with the result
  93952. * @param particle is the particle we are computed the position for
  93953. * @param isLocal defines if the position should be set in local space
  93954. */
  93955. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93956. /**
  93957. * Clones the current emitter and returns a copy of it
  93958. * @returns the new emitter
  93959. */
  93960. clone(): PointParticleEmitter;
  93961. /**
  93962. * Called by the GPUParticleSystem to setup the update shader
  93963. * @param effect defines the update shader
  93964. */
  93965. applyToShader(effect: Effect): void;
  93966. /**
  93967. * Returns a string to use to update the GPU particles update shader
  93968. * @returns a string containng the defines string
  93969. */
  93970. getEffectDefines(): string;
  93971. /**
  93972. * Returns the string "PointParticleEmitter"
  93973. * @returns a string containing the class name
  93974. */
  93975. getClassName(): string;
  93976. /**
  93977. * Serializes the particle system to a JSON object.
  93978. * @returns the JSON object
  93979. */
  93980. serialize(): any;
  93981. /**
  93982. * Parse properties from a JSON object
  93983. * @param serializationObject defines the JSON object
  93984. */
  93985. parse(serializationObject: any): void;
  93986. }
  93987. }
  93988. declare module BABYLON {
  93989. /**
  93990. * Particle emitter emitting particles from the inside of a sphere.
  93991. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  93992. */
  93993. export class SphereParticleEmitter implements IParticleEmitterType {
  93994. /**
  93995. * The radius of the emission sphere.
  93996. */
  93997. radius: number;
  93998. /**
  93999. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94000. */
  94001. radiusRange: number;
  94002. /**
  94003. * How much to randomize the particle direction [0-1].
  94004. */
  94005. directionRandomizer: number;
  94006. /**
  94007. * Creates a new instance SphereParticleEmitter
  94008. * @param radius the radius of the emission sphere (1 by default)
  94009. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94010. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94011. */
  94012. constructor(
  94013. /**
  94014. * The radius of the emission sphere.
  94015. */
  94016. radius?: number,
  94017. /**
  94018. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94019. */
  94020. radiusRange?: number,
  94021. /**
  94022. * How much to randomize the particle direction [0-1].
  94023. */
  94024. directionRandomizer?: number);
  94025. /**
  94026. * Called by the particle System when the direction is computed for the created particle.
  94027. * @param worldMatrix is the world matrix of the particle system
  94028. * @param directionToUpdate is the direction vector to update with the result
  94029. * @param particle is the particle we are computed the direction for
  94030. * @param isLocal defines if the direction should be set in local space
  94031. */
  94032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94033. /**
  94034. * Called by the particle System when the position is computed for the created particle.
  94035. * @param worldMatrix is the world matrix of the particle system
  94036. * @param positionToUpdate is the position vector to update with the result
  94037. * @param particle is the particle we are computed the position for
  94038. * @param isLocal defines if the position should be set in local space
  94039. */
  94040. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94041. /**
  94042. * Clones the current emitter and returns a copy of it
  94043. * @returns the new emitter
  94044. */
  94045. clone(): SphereParticleEmitter;
  94046. /**
  94047. * Called by the GPUParticleSystem to setup the update shader
  94048. * @param effect defines the update shader
  94049. */
  94050. applyToShader(effect: Effect): void;
  94051. /**
  94052. * Returns a string to use to update the GPU particles update shader
  94053. * @returns a string containng the defines string
  94054. */
  94055. getEffectDefines(): string;
  94056. /**
  94057. * Returns the string "SphereParticleEmitter"
  94058. * @returns a string containing the class name
  94059. */
  94060. getClassName(): string;
  94061. /**
  94062. * Serializes the particle system to a JSON object.
  94063. * @returns the JSON object
  94064. */
  94065. serialize(): any;
  94066. /**
  94067. * Parse properties from a JSON object
  94068. * @param serializationObject defines the JSON object
  94069. */
  94070. parse(serializationObject: any): void;
  94071. }
  94072. /**
  94073. * Particle emitter emitting particles from the inside of a sphere.
  94074. * It emits the particles randomly between two vectors.
  94075. */
  94076. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94077. /**
  94078. * The min limit of the emission direction.
  94079. */
  94080. direction1: Vector3;
  94081. /**
  94082. * The max limit of the emission direction.
  94083. */
  94084. direction2: Vector3;
  94085. /**
  94086. * Creates a new instance SphereDirectedParticleEmitter
  94087. * @param radius the radius of the emission sphere (1 by default)
  94088. * @param direction1 the min limit of the emission direction (up vector by default)
  94089. * @param direction2 the max limit of the emission direction (up vector by default)
  94090. */
  94091. constructor(radius?: number,
  94092. /**
  94093. * The min limit of the emission direction.
  94094. */
  94095. direction1?: Vector3,
  94096. /**
  94097. * The max limit of the emission direction.
  94098. */
  94099. direction2?: Vector3);
  94100. /**
  94101. * Called by the particle System when the direction is computed for the created particle.
  94102. * @param worldMatrix is the world matrix of the particle system
  94103. * @param directionToUpdate is the direction vector to update with the result
  94104. * @param particle is the particle we are computed the direction for
  94105. */
  94106. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94107. /**
  94108. * Clones the current emitter and returns a copy of it
  94109. * @returns the new emitter
  94110. */
  94111. clone(): SphereDirectedParticleEmitter;
  94112. /**
  94113. * Called by the GPUParticleSystem to setup the update shader
  94114. * @param effect defines the update shader
  94115. */
  94116. applyToShader(effect: Effect): void;
  94117. /**
  94118. * Returns a string to use to update the GPU particles update shader
  94119. * @returns a string containng the defines string
  94120. */
  94121. getEffectDefines(): string;
  94122. /**
  94123. * Returns the string "SphereDirectedParticleEmitter"
  94124. * @returns a string containing the class name
  94125. */
  94126. getClassName(): string;
  94127. /**
  94128. * Serializes the particle system to a JSON object.
  94129. * @returns the JSON object
  94130. */
  94131. serialize(): any;
  94132. /**
  94133. * Parse properties from a JSON object
  94134. * @param serializationObject defines the JSON object
  94135. */
  94136. parse(serializationObject: any): void;
  94137. }
  94138. }
  94139. declare module BABYLON {
  94140. /**
  94141. * Particle emitter emitting particles from a custom list of positions.
  94142. */
  94143. export class CustomParticleEmitter implements IParticleEmitterType {
  94144. /**
  94145. * Gets or sets the position generator that will create the inital position of each particle.
  94146. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94147. */
  94148. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94149. /**
  94150. * Gets or sets the destination generator that will create the final destination of each particle.
  94151. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94152. */
  94153. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94154. /**
  94155. * Creates a new instance CustomParticleEmitter
  94156. */
  94157. constructor();
  94158. /**
  94159. * Called by the particle System when the direction is computed for the created particle.
  94160. * @param worldMatrix is the world matrix of the particle system
  94161. * @param directionToUpdate is the direction vector to update with the result
  94162. * @param particle is the particle we are computed the direction for
  94163. * @param isLocal defines if the direction should be set in local space
  94164. */
  94165. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94166. /**
  94167. * Called by the particle System when the position is computed for the created particle.
  94168. * @param worldMatrix is the world matrix of the particle system
  94169. * @param positionToUpdate is the position vector to update with the result
  94170. * @param particle is the particle we are computed the position for
  94171. * @param isLocal defines if the position should be set in local space
  94172. */
  94173. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94174. /**
  94175. * Clones the current emitter and returns a copy of it
  94176. * @returns the new emitter
  94177. */
  94178. clone(): CustomParticleEmitter;
  94179. /**
  94180. * Called by the GPUParticleSystem to setup the update shader
  94181. * @param effect defines the update shader
  94182. */
  94183. applyToShader(effect: Effect): void;
  94184. /**
  94185. * Returns a string to use to update the GPU particles update shader
  94186. * @returns a string containng the defines string
  94187. */
  94188. getEffectDefines(): string;
  94189. /**
  94190. * Returns the string "PointParticleEmitter"
  94191. * @returns a string containing the class name
  94192. */
  94193. getClassName(): string;
  94194. /**
  94195. * Serializes the particle system to a JSON object.
  94196. * @returns the JSON object
  94197. */
  94198. serialize(): any;
  94199. /**
  94200. * Parse properties from a JSON object
  94201. * @param serializationObject defines the JSON object
  94202. */
  94203. parse(serializationObject: any): void;
  94204. }
  94205. }
  94206. declare module BABYLON {
  94207. /**
  94208. * Particle emitter emitting particles from the inside of a box.
  94209. * It emits the particles randomly between 2 given directions.
  94210. */
  94211. export class MeshParticleEmitter implements IParticleEmitterType {
  94212. private _indices;
  94213. private _positions;
  94214. private _normals;
  94215. private _storedNormal;
  94216. private _mesh;
  94217. /**
  94218. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94219. */
  94220. direction1: Vector3;
  94221. /**
  94222. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94223. */
  94224. direction2: Vector3;
  94225. /**
  94226. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94227. */
  94228. useMeshNormalsForDirection: boolean;
  94229. /** Defines the mesh to use as source */
  94230. get mesh(): Nullable<AbstractMesh>;
  94231. set mesh(value: Nullable<AbstractMesh>);
  94232. /**
  94233. * Creates a new instance MeshParticleEmitter
  94234. * @param mesh defines the mesh to use as source
  94235. */
  94236. constructor(mesh?: Nullable<AbstractMesh>);
  94237. /**
  94238. * Called by the particle System when the direction is computed for the created particle.
  94239. * @param worldMatrix is the world matrix of the particle system
  94240. * @param directionToUpdate is the direction vector to update with the result
  94241. * @param particle is the particle we are computed the direction for
  94242. * @param isLocal defines if the direction should be set in local space
  94243. */
  94244. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94245. /**
  94246. * Called by the particle System when the position is computed for the created particle.
  94247. * @param worldMatrix is the world matrix of the particle system
  94248. * @param positionToUpdate is the position vector to update with the result
  94249. * @param particle is the particle we are computed the position for
  94250. * @param isLocal defines if the position should be set in local space
  94251. */
  94252. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94253. /**
  94254. * Clones the current emitter and returns a copy of it
  94255. * @returns the new emitter
  94256. */
  94257. clone(): MeshParticleEmitter;
  94258. /**
  94259. * Called by the GPUParticleSystem to setup the update shader
  94260. * @param effect defines the update shader
  94261. */
  94262. applyToShader(effect: Effect): void;
  94263. /**
  94264. * Returns a string to use to update the GPU particles update shader
  94265. * @returns a string containng the defines string
  94266. */
  94267. getEffectDefines(): string;
  94268. /**
  94269. * Returns the string "BoxParticleEmitter"
  94270. * @returns a string containing the class name
  94271. */
  94272. getClassName(): string;
  94273. /**
  94274. * Serializes the particle system to a JSON object.
  94275. * @returns the JSON object
  94276. */
  94277. serialize(): any;
  94278. /**
  94279. * Parse properties from a JSON object
  94280. * @param serializationObject defines the JSON object
  94281. * @param scene defines the hosting scene
  94282. */
  94283. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94284. }
  94285. }
  94286. declare module BABYLON {
  94287. /**
  94288. * Interface representing a particle system in Babylon.js.
  94289. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94290. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94291. */
  94292. export interface IParticleSystem {
  94293. /**
  94294. * List of animations used by the particle system.
  94295. */
  94296. animations: Animation[];
  94297. /**
  94298. * The id of the Particle system.
  94299. */
  94300. id: string;
  94301. /**
  94302. * The name of the Particle system.
  94303. */
  94304. name: string;
  94305. /**
  94306. * The emitter represents the Mesh or position we are attaching the particle system to.
  94307. */
  94308. emitter: Nullable<AbstractMesh | Vector3>;
  94309. /**
  94310. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94311. */
  94312. isBillboardBased: boolean;
  94313. /**
  94314. * The rendering group used by the Particle system to chose when to render.
  94315. */
  94316. renderingGroupId: number;
  94317. /**
  94318. * The layer mask we are rendering the particles through.
  94319. */
  94320. layerMask: number;
  94321. /**
  94322. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94323. */
  94324. updateSpeed: number;
  94325. /**
  94326. * The amount of time the particle system is running (depends of the overall update speed).
  94327. */
  94328. targetStopDuration: number;
  94329. /**
  94330. * The texture used to render each particle. (this can be a spritesheet)
  94331. */
  94332. particleTexture: Nullable<BaseTexture>;
  94333. /**
  94334. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94335. */
  94336. blendMode: number;
  94337. /**
  94338. * Minimum life time of emitting particles.
  94339. */
  94340. minLifeTime: number;
  94341. /**
  94342. * Maximum life time of emitting particles.
  94343. */
  94344. maxLifeTime: number;
  94345. /**
  94346. * Minimum Size of emitting particles.
  94347. */
  94348. minSize: number;
  94349. /**
  94350. * Maximum Size of emitting particles.
  94351. */
  94352. maxSize: number;
  94353. /**
  94354. * Minimum scale of emitting particles on X axis.
  94355. */
  94356. minScaleX: number;
  94357. /**
  94358. * Maximum scale of emitting particles on X axis.
  94359. */
  94360. maxScaleX: number;
  94361. /**
  94362. * Minimum scale of emitting particles on Y axis.
  94363. */
  94364. minScaleY: number;
  94365. /**
  94366. * Maximum scale of emitting particles on Y axis.
  94367. */
  94368. maxScaleY: number;
  94369. /**
  94370. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94371. */
  94372. color1: Color4;
  94373. /**
  94374. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94375. */
  94376. color2: Color4;
  94377. /**
  94378. * Color the particle will have at the end of its lifetime.
  94379. */
  94380. colorDead: Color4;
  94381. /**
  94382. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94383. */
  94384. emitRate: number;
  94385. /**
  94386. * You can use gravity if you want to give an orientation to your particles.
  94387. */
  94388. gravity: Vector3;
  94389. /**
  94390. * Minimum power of emitting particles.
  94391. */
  94392. minEmitPower: number;
  94393. /**
  94394. * Maximum power of emitting particles.
  94395. */
  94396. maxEmitPower: number;
  94397. /**
  94398. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94399. */
  94400. minAngularSpeed: number;
  94401. /**
  94402. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94403. */
  94404. maxAngularSpeed: number;
  94405. /**
  94406. * Gets or sets the minimal initial rotation in radians.
  94407. */
  94408. minInitialRotation: number;
  94409. /**
  94410. * Gets or sets the maximal initial rotation in radians.
  94411. */
  94412. maxInitialRotation: number;
  94413. /**
  94414. * The particle emitter type defines the emitter used by the particle system.
  94415. * It can be for example box, sphere, or cone...
  94416. */
  94417. particleEmitterType: Nullable<IParticleEmitterType>;
  94418. /**
  94419. * Defines the delay in milliseconds before starting the system (0 by default)
  94420. */
  94421. startDelay: number;
  94422. /**
  94423. * 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
  94424. */
  94425. preWarmCycles: number;
  94426. /**
  94427. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94428. */
  94429. preWarmStepOffset: number;
  94430. /**
  94431. * 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)
  94432. */
  94433. spriteCellChangeSpeed: number;
  94434. /**
  94435. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94436. */
  94437. startSpriteCellID: number;
  94438. /**
  94439. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94440. */
  94441. endSpriteCellID: number;
  94442. /**
  94443. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94444. */
  94445. spriteCellWidth: number;
  94446. /**
  94447. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94448. */
  94449. spriteCellHeight: number;
  94450. /**
  94451. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94452. */
  94453. spriteRandomStartCell: boolean;
  94454. /**
  94455. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94456. */
  94457. isAnimationSheetEnabled: boolean;
  94458. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94459. translationPivot: Vector2;
  94460. /**
  94461. * Gets or sets a texture used to add random noise to particle positions
  94462. */
  94463. noiseTexture: Nullable<BaseTexture>;
  94464. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94465. noiseStrength: Vector3;
  94466. /**
  94467. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94468. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94469. */
  94470. billboardMode: number;
  94471. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94472. limitVelocityDamping: number;
  94473. /**
  94474. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94475. */
  94476. beginAnimationOnStart: boolean;
  94477. /**
  94478. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94479. */
  94480. beginAnimationFrom: number;
  94481. /**
  94482. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94483. */
  94484. beginAnimationTo: number;
  94485. /**
  94486. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94487. */
  94488. beginAnimationLoop: boolean;
  94489. /**
  94490. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94491. */
  94492. disposeOnStop: boolean;
  94493. /**
  94494. * Specifies if the particles are updated in emitter local space or world space
  94495. */
  94496. isLocal: boolean;
  94497. /** Snippet ID if the particle system was created from the snippet server */
  94498. snippetId: string;
  94499. /** Gets or sets a matrix to use to compute projection */
  94500. defaultProjectionMatrix: Matrix;
  94501. /**
  94502. * Gets the maximum number of particles active at the same time.
  94503. * @returns The max number of active particles.
  94504. */
  94505. getCapacity(): number;
  94506. /**
  94507. * Gets the number of particles active at the same time.
  94508. * @returns The number of active particles.
  94509. */
  94510. getActiveCount(): number;
  94511. /**
  94512. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94513. * @returns True if it has been started, otherwise false.
  94514. */
  94515. isStarted(): boolean;
  94516. /**
  94517. * Animates the particle system for this frame.
  94518. */
  94519. animate(): void;
  94520. /**
  94521. * Renders the particle system in its current state.
  94522. * @returns the current number of particles
  94523. */
  94524. render(): number;
  94525. /**
  94526. * Dispose the particle system and frees its associated resources.
  94527. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94528. */
  94529. dispose(disposeTexture?: boolean): void;
  94530. /**
  94531. * An event triggered when the system is disposed
  94532. */
  94533. onDisposeObservable: Observable<IParticleSystem>;
  94534. /**
  94535. * Clones the particle system.
  94536. * @param name The name of the cloned object
  94537. * @param newEmitter The new emitter to use
  94538. * @returns the cloned particle system
  94539. */
  94540. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94541. /**
  94542. * Serializes the particle system to a JSON object
  94543. * @param serializeTexture defines if the texture must be serialized as well
  94544. * @returns the JSON object
  94545. */
  94546. serialize(serializeTexture: boolean): any;
  94547. /**
  94548. * Rebuild the particle system
  94549. */
  94550. rebuild(): void;
  94551. /** Force the system to rebuild all gradients that need to be resync */
  94552. forceRefreshGradients(): void;
  94553. /**
  94554. * Starts the particle system and begins to emit
  94555. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94556. */
  94557. start(delay?: number): void;
  94558. /**
  94559. * Stops the particle system.
  94560. */
  94561. stop(): void;
  94562. /**
  94563. * Remove all active particles
  94564. */
  94565. reset(): void;
  94566. /**
  94567. * Gets a boolean indicating that the system is stopping
  94568. * @returns true if the system is currently stopping
  94569. */
  94570. isStopping(): boolean;
  94571. /**
  94572. * Is this system ready to be used/rendered
  94573. * @return true if the system is ready
  94574. */
  94575. isReady(): boolean;
  94576. /**
  94577. * Returns the string "ParticleSystem"
  94578. * @returns a string containing the class name
  94579. */
  94580. getClassName(): string;
  94581. /**
  94582. * Gets the custom effect used to render the particles
  94583. * @param blendMode Blend mode for which the effect should be retrieved
  94584. * @returns The effect
  94585. */
  94586. getCustomEffect(blendMode: number): Nullable<Effect>;
  94587. /**
  94588. * Sets the custom effect used to render the particles
  94589. * @param effect The effect to set
  94590. * @param blendMode Blend mode for which the effect should be set
  94591. */
  94592. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94593. /**
  94594. * Fill the defines array according to the current settings of the particle system
  94595. * @param defines Array to be updated
  94596. * @param blendMode blend mode to take into account when updating the array
  94597. */
  94598. fillDefines(defines: Array<string>, blendMode: number): void;
  94599. /**
  94600. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94601. * @param uniforms Uniforms array to fill
  94602. * @param attributes Attributes array to fill
  94603. * @param samplers Samplers array to fill
  94604. */
  94605. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94606. /**
  94607. * Observable that will be called just before the particles are drawn
  94608. */
  94609. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94610. /**
  94611. * Gets the name of the particle vertex shader
  94612. */
  94613. vertexShaderName: string;
  94614. /**
  94615. * Adds a new color gradient
  94616. * @param gradient defines the gradient to use (between 0 and 1)
  94617. * @param color1 defines the color to affect to the specified gradient
  94618. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94619. * @returns the current particle system
  94620. */
  94621. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94622. /**
  94623. * Remove a specific color gradient
  94624. * @param gradient defines the gradient to remove
  94625. * @returns the current particle system
  94626. */
  94627. removeColorGradient(gradient: number): IParticleSystem;
  94628. /**
  94629. * Adds a new size gradient
  94630. * @param gradient defines the gradient to use (between 0 and 1)
  94631. * @param factor defines the size factor to affect to the specified gradient
  94632. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94633. * @returns the current particle system
  94634. */
  94635. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94636. /**
  94637. * Remove a specific size gradient
  94638. * @param gradient defines the gradient to remove
  94639. * @returns the current particle system
  94640. */
  94641. removeSizeGradient(gradient: number): IParticleSystem;
  94642. /**
  94643. * Gets the current list of color gradients.
  94644. * You must use addColorGradient and removeColorGradient to udpate this list
  94645. * @returns the list of color gradients
  94646. */
  94647. getColorGradients(): Nullable<Array<ColorGradient>>;
  94648. /**
  94649. * Gets the current list of size gradients.
  94650. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94651. * @returns the list of size gradients
  94652. */
  94653. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94654. /**
  94655. * Gets the current list of angular speed gradients.
  94656. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94657. * @returns the list of angular speed gradients
  94658. */
  94659. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94660. /**
  94661. * Adds a new angular speed gradient
  94662. * @param gradient defines the gradient to use (between 0 and 1)
  94663. * @param factor defines the angular speed to affect to the specified gradient
  94664. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94665. * @returns the current particle system
  94666. */
  94667. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94668. /**
  94669. * Remove a specific angular speed gradient
  94670. * @param gradient defines the gradient to remove
  94671. * @returns the current particle system
  94672. */
  94673. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94674. /**
  94675. * Gets the current list of velocity gradients.
  94676. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94677. * @returns the list of velocity gradients
  94678. */
  94679. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94680. /**
  94681. * Adds a new velocity gradient
  94682. * @param gradient defines the gradient to use (between 0 and 1)
  94683. * @param factor defines the velocity to affect to the specified gradient
  94684. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94685. * @returns the current particle system
  94686. */
  94687. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94688. /**
  94689. * Remove a specific velocity gradient
  94690. * @param gradient defines the gradient to remove
  94691. * @returns the current particle system
  94692. */
  94693. removeVelocityGradient(gradient: number): IParticleSystem;
  94694. /**
  94695. * Gets the current list of limit velocity gradients.
  94696. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94697. * @returns the list of limit velocity gradients
  94698. */
  94699. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94700. /**
  94701. * Adds a new limit velocity gradient
  94702. * @param gradient defines the gradient to use (between 0 and 1)
  94703. * @param factor defines the limit velocity to affect to the specified gradient
  94704. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94705. * @returns the current particle system
  94706. */
  94707. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94708. /**
  94709. * Remove a specific limit velocity gradient
  94710. * @param gradient defines the gradient to remove
  94711. * @returns the current particle system
  94712. */
  94713. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94714. /**
  94715. * Adds a new drag gradient
  94716. * @param gradient defines the gradient to use (between 0 and 1)
  94717. * @param factor defines the drag to affect to the specified gradient
  94718. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94719. * @returns the current particle system
  94720. */
  94721. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94722. /**
  94723. * Remove a specific drag gradient
  94724. * @param gradient defines the gradient to remove
  94725. * @returns the current particle system
  94726. */
  94727. removeDragGradient(gradient: number): IParticleSystem;
  94728. /**
  94729. * Gets the current list of drag gradients.
  94730. * You must use addDragGradient and removeDragGradient to udpate this list
  94731. * @returns the list of drag gradients
  94732. */
  94733. getDragGradients(): Nullable<Array<FactorGradient>>;
  94734. /**
  94735. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94736. * @param gradient defines the gradient to use (between 0 and 1)
  94737. * @param factor defines the emit rate to affect to the specified gradient
  94738. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94739. * @returns the current particle system
  94740. */
  94741. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94742. /**
  94743. * Remove a specific emit rate gradient
  94744. * @param gradient defines the gradient to remove
  94745. * @returns the current particle system
  94746. */
  94747. removeEmitRateGradient(gradient: number): IParticleSystem;
  94748. /**
  94749. * Gets the current list of emit rate gradients.
  94750. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94751. * @returns the list of emit rate gradients
  94752. */
  94753. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94754. /**
  94755. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94756. * @param gradient defines the gradient to use (between 0 and 1)
  94757. * @param factor defines the start size to affect to the specified gradient
  94758. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94759. * @returns the current particle system
  94760. */
  94761. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94762. /**
  94763. * Remove a specific start size gradient
  94764. * @param gradient defines the gradient to remove
  94765. * @returns the current particle system
  94766. */
  94767. removeStartSizeGradient(gradient: number): IParticleSystem;
  94768. /**
  94769. * Gets the current list of start size gradients.
  94770. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  94771. * @returns the list of start size gradients
  94772. */
  94773. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  94774. /**
  94775. * Adds a new life time gradient
  94776. * @param gradient defines the gradient to use (between 0 and 1)
  94777. * @param factor defines the life time factor to affect to the specified gradient
  94778. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94779. * @returns the current particle system
  94780. */
  94781. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94782. /**
  94783. * Remove a specific life time gradient
  94784. * @param gradient defines the gradient to remove
  94785. * @returns the current particle system
  94786. */
  94787. removeLifeTimeGradient(gradient: number): IParticleSystem;
  94788. /**
  94789. * Gets the current list of life time gradients.
  94790. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  94791. * @returns the list of life time gradients
  94792. */
  94793. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  94794. /**
  94795. * Gets the current list of color gradients.
  94796. * You must use addColorGradient and removeColorGradient to udpate this list
  94797. * @returns the list of color gradients
  94798. */
  94799. getColorGradients(): Nullable<Array<ColorGradient>>;
  94800. /**
  94801. * Adds a new ramp gradient used to remap particle colors
  94802. * @param gradient defines the gradient to use (between 0 and 1)
  94803. * @param color defines the color to affect to the specified gradient
  94804. * @returns the current particle system
  94805. */
  94806. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  94807. /**
  94808. * Gets the current list of ramp gradients.
  94809. * You must use addRampGradient and removeRampGradient to udpate this list
  94810. * @returns the list of ramp gradients
  94811. */
  94812. getRampGradients(): Nullable<Array<Color3Gradient>>;
  94813. /** Gets or sets a boolean indicating that ramp gradients must be used
  94814. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  94815. */
  94816. useRampGradients: boolean;
  94817. /**
  94818. * Adds a new color remap gradient
  94819. * @param gradient defines the gradient to use (between 0 and 1)
  94820. * @param min defines the color remap minimal range
  94821. * @param max defines the color remap maximal range
  94822. * @returns the current particle system
  94823. */
  94824. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94825. /**
  94826. * Gets the current list of color remap gradients.
  94827. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  94828. * @returns the list of color remap gradients
  94829. */
  94830. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  94831. /**
  94832. * Adds a new alpha remap gradient
  94833. * @param gradient defines the gradient to use (between 0 and 1)
  94834. * @param min defines the alpha remap minimal range
  94835. * @param max defines the alpha remap maximal range
  94836. * @returns the current particle system
  94837. */
  94838. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  94839. /**
  94840. * Gets the current list of alpha remap gradients.
  94841. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  94842. * @returns the list of alpha remap gradients
  94843. */
  94844. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  94845. /**
  94846. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  94847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94849. * @returns the emitter
  94850. */
  94851. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  94852. /**
  94853. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  94854. * @param radius The radius of the hemisphere to emit from
  94855. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94856. * @returns the emitter
  94857. */
  94858. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  94859. /**
  94860. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  94861. * @param radius The radius of the sphere to emit from
  94862. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  94863. * @returns the emitter
  94864. */
  94865. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  94866. /**
  94867. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  94868. * @param radius The radius of the sphere to emit from
  94869. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  94870. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  94871. * @returns the emitter
  94872. */
  94873. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94874. /**
  94875. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  94876. * @param radius The radius of the emission cylinder
  94877. * @param height The height of the emission cylinder
  94878. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  94879. * @param directionRandomizer How much to randomize the particle direction [0-1]
  94880. * @returns the emitter
  94881. */
  94882. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  94883. /**
  94884. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  94885. * @param radius The radius of the cylinder to emit from
  94886. * @param height The height of the emission cylinder
  94887. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94888. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  94889. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  94890. * @returns the emitter
  94891. */
  94892. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  94893. /**
  94894. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  94895. * @param radius The radius of the cone to emit from
  94896. * @param angle The base angle of the cone
  94897. * @returns the emitter
  94898. */
  94899. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  94900. /**
  94901. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  94902. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  94903. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  94904. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94905. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  94906. * @returns the emitter
  94907. */
  94908. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  94909. /**
  94910. * Get hosting scene
  94911. * @returns the scene
  94912. */
  94913. getScene(): Nullable<Scene>;
  94914. }
  94915. }
  94916. declare module BABYLON {
  94917. /**
  94918. * 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.
  94919. * @see https://doc.babylonjs.com/how_to/transformnode
  94920. */
  94921. export class TransformNode extends Node {
  94922. /**
  94923. * Object will not rotate to face the camera
  94924. */
  94925. static BILLBOARDMODE_NONE: number;
  94926. /**
  94927. * Object will rotate to face the camera but only on the x axis
  94928. */
  94929. static BILLBOARDMODE_X: number;
  94930. /**
  94931. * Object will rotate to face the camera but only on the y axis
  94932. */
  94933. static BILLBOARDMODE_Y: number;
  94934. /**
  94935. * Object will rotate to face the camera but only on the z axis
  94936. */
  94937. static BILLBOARDMODE_Z: number;
  94938. /**
  94939. * Object will rotate to face the camera
  94940. */
  94941. static BILLBOARDMODE_ALL: number;
  94942. /**
  94943. * Object will rotate to face the camera's position instead of orientation
  94944. */
  94945. static BILLBOARDMODE_USE_POSITION: number;
  94946. private static _TmpRotation;
  94947. private static _TmpScaling;
  94948. private static _TmpTranslation;
  94949. private _forward;
  94950. private _forwardInverted;
  94951. private _up;
  94952. private _right;
  94953. private _rightInverted;
  94954. private _position;
  94955. private _rotation;
  94956. private _rotationQuaternion;
  94957. protected _scaling: Vector3;
  94958. protected _isDirty: boolean;
  94959. private _transformToBoneReferal;
  94960. private _isAbsoluteSynced;
  94961. private _billboardMode;
  94962. /**
  94963. * Gets or sets the billboard mode. Default is 0.
  94964. *
  94965. * | Value | Type | Description |
  94966. * | --- | --- | --- |
  94967. * | 0 | BILLBOARDMODE_NONE | |
  94968. * | 1 | BILLBOARDMODE_X | |
  94969. * | 2 | BILLBOARDMODE_Y | |
  94970. * | 4 | BILLBOARDMODE_Z | |
  94971. * | 7 | BILLBOARDMODE_ALL | |
  94972. *
  94973. */
  94974. get billboardMode(): number;
  94975. set billboardMode(value: number);
  94976. private _preserveParentRotationForBillboard;
  94977. /**
  94978. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  94979. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  94980. */
  94981. get preserveParentRotationForBillboard(): boolean;
  94982. set preserveParentRotationForBillboard(value: boolean);
  94983. /**
  94984. * 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
  94985. */
  94986. scalingDeterminant: number;
  94987. private _infiniteDistance;
  94988. /**
  94989. * Gets or sets the distance of the object to max, often used by skybox
  94990. */
  94991. get infiniteDistance(): boolean;
  94992. set infiniteDistance(value: boolean);
  94993. /**
  94994. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  94995. * By default the system will update normals to compensate
  94996. */
  94997. ignoreNonUniformScaling: boolean;
  94998. /**
  94999. * 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
  95000. */
  95001. reIntegrateRotationIntoRotationQuaternion: boolean;
  95002. /** @hidden */
  95003. _poseMatrix: Nullable<Matrix>;
  95004. /** @hidden */
  95005. _localMatrix: Matrix;
  95006. private _usePivotMatrix;
  95007. private _absolutePosition;
  95008. private _absoluteScaling;
  95009. private _absoluteRotationQuaternion;
  95010. private _pivotMatrix;
  95011. private _pivotMatrixInverse;
  95012. /** @hidden */
  95013. _postMultiplyPivotMatrix: boolean;
  95014. protected _isWorldMatrixFrozen: boolean;
  95015. /** @hidden */
  95016. _indexInSceneTransformNodesArray: number;
  95017. /**
  95018. * An event triggered after the world matrix is updated
  95019. */
  95020. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95021. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95022. /**
  95023. * Gets a string identifying the name of the class
  95024. * @returns "TransformNode" string
  95025. */
  95026. getClassName(): string;
  95027. /**
  95028. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95029. */
  95030. get position(): Vector3;
  95031. set position(newPosition: Vector3);
  95032. /**
  95033. * 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)).
  95034. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95035. */
  95036. get rotation(): Vector3;
  95037. set rotation(newRotation: Vector3);
  95038. /**
  95039. * 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)).
  95040. */
  95041. get scaling(): Vector3;
  95042. set scaling(newScaling: Vector3);
  95043. /**
  95044. * 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).
  95045. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95046. */
  95047. get rotationQuaternion(): Nullable<Quaternion>;
  95048. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95049. /**
  95050. * The forward direction of that transform in world space.
  95051. */
  95052. get forward(): Vector3;
  95053. /**
  95054. * The up direction of that transform in world space.
  95055. */
  95056. get up(): Vector3;
  95057. /**
  95058. * The right direction of that transform in world space.
  95059. */
  95060. get right(): Vector3;
  95061. /**
  95062. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95063. * @param matrix the matrix to copy the pose from
  95064. * @returns this TransformNode.
  95065. */
  95066. updatePoseMatrix(matrix: Matrix): TransformNode;
  95067. /**
  95068. * Returns the mesh Pose matrix.
  95069. * @returns the pose matrix
  95070. */
  95071. getPoseMatrix(): Matrix;
  95072. /** @hidden */
  95073. _isSynchronized(): boolean;
  95074. /** @hidden */
  95075. _initCache(): void;
  95076. /**
  95077. * Flag the transform node as dirty (Forcing it to update everything)
  95078. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95079. * @returns this transform node
  95080. */
  95081. markAsDirty(property: string): TransformNode;
  95082. /**
  95083. * Returns the current mesh absolute position.
  95084. * Returns a Vector3.
  95085. */
  95086. get absolutePosition(): Vector3;
  95087. /**
  95088. * Returns the current mesh absolute scaling.
  95089. * Returns a Vector3.
  95090. */
  95091. get absoluteScaling(): Vector3;
  95092. /**
  95093. * Returns the current mesh absolute rotation.
  95094. * Returns a Quaternion.
  95095. */
  95096. get absoluteRotationQuaternion(): Quaternion;
  95097. /**
  95098. * Sets a new matrix to apply before all other transformation
  95099. * @param matrix defines the transform matrix
  95100. * @returns the current TransformNode
  95101. */
  95102. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95103. /**
  95104. * Sets a new pivot matrix to the current node
  95105. * @param matrix defines the new pivot matrix to use
  95106. * @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
  95107. * @returns the current TransformNode
  95108. */
  95109. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95110. /**
  95111. * Returns the mesh pivot matrix.
  95112. * Default : Identity.
  95113. * @returns the matrix
  95114. */
  95115. getPivotMatrix(): Matrix;
  95116. /**
  95117. * Instantiate (when possible) or clone that node with its hierarchy
  95118. * @param newParent defines the new parent to use for the instance (or clone)
  95119. * @param options defines options to configure how copy is done
  95120. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95121. * @returns an instance (or a clone) of the current node with its hiearchy
  95122. */
  95123. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95124. doNotInstantiate: boolean;
  95125. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95126. /**
  95127. * Prevents the World matrix to be computed any longer
  95128. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95129. * @returns the TransformNode.
  95130. */
  95131. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95132. /**
  95133. * Allows back the World matrix computation.
  95134. * @returns the TransformNode.
  95135. */
  95136. unfreezeWorldMatrix(): this;
  95137. /**
  95138. * True if the World matrix has been frozen.
  95139. */
  95140. get isWorldMatrixFrozen(): boolean;
  95141. /**
  95142. * Retuns the mesh absolute position in the World.
  95143. * @returns a Vector3.
  95144. */
  95145. getAbsolutePosition(): Vector3;
  95146. /**
  95147. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95148. * @param absolutePosition the absolute position to set
  95149. * @returns the TransformNode.
  95150. */
  95151. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95152. /**
  95153. * Sets the mesh position in its local space.
  95154. * @param vector3 the position to set in localspace
  95155. * @returns the TransformNode.
  95156. */
  95157. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95158. /**
  95159. * Returns the mesh position in the local space from the current World matrix values.
  95160. * @returns a new Vector3.
  95161. */
  95162. getPositionExpressedInLocalSpace(): Vector3;
  95163. /**
  95164. * Translates the mesh along the passed Vector3 in its local space.
  95165. * @param vector3 the distance to translate in localspace
  95166. * @returns the TransformNode.
  95167. */
  95168. locallyTranslate(vector3: Vector3): TransformNode;
  95169. private static _lookAtVectorCache;
  95170. /**
  95171. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95172. * @param targetPoint the position (must be in same space as current mesh) to look at
  95173. * @param yawCor optional yaw (y-axis) correction in radians
  95174. * @param pitchCor optional pitch (x-axis) correction in radians
  95175. * @param rollCor optional roll (z-axis) correction in radians
  95176. * @param space the choosen space of the target
  95177. * @returns the TransformNode.
  95178. */
  95179. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95180. /**
  95181. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95182. * This Vector3 is expressed in the World space.
  95183. * @param localAxis axis to rotate
  95184. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95185. */
  95186. getDirection(localAxis: Vector3): Vector3;
  95187. /**
  95188. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95189. * localAxis is expressed in the mesh local space.
  95190. * result is computed in the Wordl space from the mesh World matrix.
  95191. * @param localAxis axis to rotate
  95192. * @param result the resulting transformnode
  95193. * @returns this TransformNode.
  95194. */
  95195. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95196. /**
  95197. * Sets this transform node rotation to the given local axis.
  95198. * @param localAxis the axis in local space
  95199. * @param yawCor optional yaw (y-axis) correction in radians
  95200. * @param pitchCor optional pitch (x-axis) correction in radians
  95201. * @param rollCor optional roll (z-axis) correction in radians
  95202. * @returns this TransformNode
  95203. */
  95204. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95205. /**
  95206. * Sets a new pivot point to the current node
  95207. * @param point defines the new pivot point to use
  95208. * @param space defines if the point is in world or local space (local by default)
  95209. * @returns the current TransformNode
  95210. */
  95211. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95212. /**
  95213. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95214. * @returns the pivot point
  95215. */
  95216. getPivotPoint(): Vector3;
  95217. /**
  95218. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95219. * @param result the vector3 to store the result
  95220. * @returns this TransformNode.
  95221. */
  95222. getPivotPointToRef(result: Vector3): TransformNode;
  95223. /**
  95224. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95225. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95226. */
  95227. getAbsolutePivotPoint(): Vector3;
  95228. /**
  95229. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95230. * @param result vector3 to store the result
  95231. * @returns this TransformNode.
  95232. */
  95233. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95234. /**
  95235. * Defines the passed node as the parent of the current node.
  95236. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95237. * @see https://doc.babylonjs.com/how_to/parenting
  95238. * @param node the node ot set as the parent
  95239. * @returns this TransformNode.
  95240. */
  95241. setParent(node: Nullable<Node>): TransformNode;
  95242. private _nonUniformScaling;
  95243. /**
  95244. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95245. */
  95246. get nonUniformScaling(): boolean;
  95247. /** @hidden */
  95248. _updateNonUniformScalingState(value: boolean): boolean;
  95249. /**
  95250. * Attach the current TransformNode to another TransformNode associated with a bone
  95251. * @param bone Bone affecting the TransformNode
  95252. * @param affectedTransformNode TransformNode associated with the bone
  95253. * @returns this object
  95254. */
  95255. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95256. /**
  95257. * Detach the transform node if its associated with a bone
  95258. * @returns this object
  95259. */
  95260. detachFromBone(): TransformNode;
  95261. private static _rotationAxisCache;
  95262. /**
  95263. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95264. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95265. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95266. * The passed axis is also normalized.
  95267. * @param axis the axis to rotate around
  95268. * @param amount the amount to rotate in radians
  95269. * @param space Space to rotate in (Default: local)
  95270. * @returns the TransformNode.
  95271. */
  95272. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95273. /**
  95274. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95275. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95276. * The passed axis is also normalized. .
  95277. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95278. * @param point the point to rotate around
  95279. * @param axis the axis to rotate around
  95280. * @param amount the amount to rotate in radians
  95281. * @returns the TransformNode
  95282. */
  95283. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95284. /**
  95285. * Translates the mesh along the axis vector for the passed distance in the given space.
  95286. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95287. * @param axis the axis to translate in
  95288. * @param distance the distance to translate
  95289. * @param space Space to rotate in (Default: local)
  95290. * @returns the TransformNode.
  95291. */
  95292. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95293. /**
  95294. * Adds a rotation step to the mesh current rotation.
  95295. * x, y, z are Euler angles expressed in radians.
  95296. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95297. * This means this rotation is made in the mesh local space only.
  95298. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95299. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95300. * ```javascript
  95301. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95302. * ```
  95303. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95304. * 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.
  95305. * @param x Rotation to add
  95306. * @param y Rotation to add
  95307. * @param z Rotation to add
  95308. * @returns the TransformNode.
  95309. */
  95310. addRotation(x: number, y: number, z: number): TransformNode;
  95311. /**
  95312. * @hidden
  95313. */
  95314. protected _getEffectiveParent(): Nullable<Node>;
  95315. /**
  95316. * Computes the world matrix of the node
  95317. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95318. * @returns the world matrix
  95319. */
  95320. computeWorldMatrix(force?: boolean): Matrix;
  95321. /**
  95322. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95323. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95324. */
  95325. resetLocalMatrix(independentOfChildren?: boolean): void;
  95326. protected _afterComputeWorldMatrix(): void;
  95327. /**
  95328. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95329. * @param func callback function to add
  95330. *
  95331. * @returns the TransformNode.
  95332. */
  95333. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95334. /**
  95335. * Removes a registered callback function.
  95336. * @param func callback function to remove
  95337. * @returns the TransformNode.
  95338. */
  95339. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95340. /**
  95341. * Gets the position of the current mesh in camera space
  95342. * @param camera defines the camera to use
  95343. * @returns a position
  95344. */
  95345. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95346. /**
  95347. * Returns the distance from the mesh to the active camera
  95348. * @param camera defines the camera to use
  95349. * @returns the distance
  95350. */
  95351. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95352. /**
  95353. * Clone the current transform node
  95354. * @param name Name of the new clone
  95355. * @param newParent New parent for the clone
  95356. * @param doNotCloneChildren Do not clone children hierarchy
  95357. * @returns the new transform node
  95358. */
  95359. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95360. /**
  95361. * Serializes the objects information.
  95362. * @param currentSerializationObject defines the object to serialize in
  95363. * @returns the serialized object
  95364. */
  95365. serialize(currentSerializationObject?: any): any;
  95366. /**
  95367. * Returns a new TransformNode object parsed from the source provided.
  95368. * @param parsedTransformNode is the source.
  95369. * @param scene the scne the object belongs to
  95370. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95371. * @returns a new TransformNode object parsed from the source provided.
  95372. */
  95373. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95374. /**
  95375. * Get all child-transformNodes of this node
  95376. * @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
  95377. * @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
  95378. * @returns an array of TransformNode
  95379. */
  95380. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95381. /**
  95382. * Releases resources associated with this transform node.
  95383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95385. */
  95386. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95387. /**
  95388. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95389. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95390. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95391. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95392. * @returns the current mesh
  95393. */
  95394. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95395. private _syncAbsoluteScalingAndRotation;
  95396. }
  95397. }
  95398. declare module BABYLON {
  95399. /**
  95400. * Class used to override all child animations of a given target
  95401. */
  95402. export class AnimationPropertiesOverride {
  95403. /**
  95404. * Gets or sets a value indicating if animation blending must be used
  95405. */
  95406. enableBlending: boolean;
  95407. /**
  95408. * Gets or sets the blending speed to use when enableBlending is true
  95409. */
  95410. blendingSpeed: number;
  95411. /**
  95412. * Gets or sets the default loop mode to use
  95413. */
  95414. loopMode: number;
  95415. }
  95416. }
  95417. declare module BABYLON {
  95418. /**
  95419. * Class used to store bone information
  95420. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95421. */
  95422. export class Bone extends Node {
  95423. /**
  95424. * defines the bone name
  95425. */
  95426. name: string;
  95427. private static _tmpVecs;
  95428. private static _tmpQuat;
  95429. private static _tmpMats;
  95430. /**
  95431. * Gets the list of child bones
  95432. */
  95433. children: Bone[];
  95434. /** Gets the animations associated with this bone */
  95435. animations: Animation[];
  95436. /**
  95437. * Gets or sets bone length
  95438. */
  95439. length: number;
  95440. /**
  95441. * @hidden Internal only
  95442. * Set this value to map this bone to a different index in the transform matrices
  95443. * Set this value to -1 to exclude the bone from the transform matrices
  95444. */
  95445. _index: Nullable<number>;
  95446. private _skeleton;
  95447. private _localMatrix;
  95448. private _restPose;
  95449. private _bindPose;
  95450. private _baseMatrix;
  95451. private _absoluteTransform;
  95452. private _invertedAbsoluteTransform;
  95453. private _parent;
  95454. private _scalingDeterminant;
  95455. private _worldTransform;
  95456. private _localScaling;
  95457. private _localRotation;
  95458. private _localPosition;
  95459. private _needToDecompose;
  95460. private _needToCompose;
  95461. /** @hidden */
  95462. _linkedTransformNode: Nullable<TransformNode>;
  95463. /** @hidden */
  95464. _waitingTransformNodeId: Nullable<string>;
  95465. /** @hidden */
  95466. get _matrix(): Matrix;
  95467. /** @hidden */
  95468. set _matrix(value: Matrix);
  95469. /**
  95470. * Create a new bone
  95471. * @param name defines the bone name
  95472. * @param skeleton defines the parent skeleton
  95473. * @param parentBone defines the parent (can be null if the bone is the root)
  95474. * @param localMatrix defines the local matrix
  95475. * @param restPose defines the rest pose matrix
  95476. * @param baseMatrix defines the base matrix
  95477. * @param index defines index of the bone in the hiearchy
  95478. */
  95479. constructor(
  95480. /**
  95481. * defines the bone name
  95482. */
  95483. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95484. /**
  95485. * Gets the current object class name.
  95486. * @return the class name
  95487. */
  95488. getClassName(): string;
  95489. /**
  95490. * Gets the parent skeleton
  95491. * @returns a skeleton
  95492. */
  95493. getSkeleton(): Skeleton;
  95494. /**
  95495. * Gets parent bone
  95496. * @returns a bone or null if the bone is the root of the bone hierarchy
  95497. */
  95498. getParent(): Nullable<Bone>;
  95499. /**
  95500. * Returns an array containing the root bones
  95501. * @returns an array containing the root bones
  95502. */
  95503. getChildren(): Array<Bone>;
  95504. /**
  95505. * Gets the node index in matrix array generated for rendering
  95506. * @returns the node index
  95507. */
  95508. getIndex(): number;
  95509. /**
  95510. * Sets the parent bone
  95511. * @param parent defines the parent (can be null if the bone is the root)
  95512. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95513. */
  95514. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95515. /**
  95516. * Gets the local matrix
  95517. * @returns a matrix
  95518. */
  95519. getLocalMatrix(): Matrix;
  95520. /**
  95521. * Gets the base matrix (initial matrix which remains unchanged)
  95522. * @returns a matrix
  95523. */
  95524. getBaseMatrix(): Matrix;
  95525. /**
  95526. * Gets the rest pose matrix
  95527. * @returns a matrix
  95528. */
  95529. getRestPose(): Matrix;
  95530. /**
  95531. * Sets the rest pose matrix
  95532. * @param matrix the local-space rest pose to set for this bone
  95533. */
  95534. setRestPose(matrix: Matrix): void;
  95535. /**
  95536. * Gets the bind pose matrix
  95537. * @returns the bind pose matrix
  95538. */
  95539. getBindPose(): Matrix;
  95540. /**
  95541. * Sets the bind pose matrix
  95542. * @param matrix the local-space bind pose to set for this bone
  95543. */
  95544. setBindPose(matrix: Matrix): void;
  95545. /**
  95546. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95547. */
  95548. getWorldMatrix(): Matrix;
  95549. /**
  95550. * Sets the local matrix to rest pose matrix
  95551. */
  95552. returnToRest(): void;
  95553. /**
  95554. * Gets the inverse of the absolute transform matrix.
  95555. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95556. * @returns a matrix
  95557. */
  95558. getInvertedAbsoluteTransform(): Matrix;
  95559. /**
  95560. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95561. * @returns a matrix
  95562. */
  95563. getAbsoluteTransform(): Matrix;
  95564. /**
  95565. * Links with the given transform node.
  95566. * The local matrix of this bone is copied from the transform node every frame.
  95567. * @param transformNode defines the transform node to link to
  95568. */
  95569. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95570. /**
  95571. * Gets the node used to drive the bone's transformation
  95572. * @returns a transform node or null
  95573. */
  95574. getTransformNode(): Nullable<TransformNode>;
  95575. /** Gets or sets current position (in local space) */
  95576. get position(): Vector3;
  95577. set position(newPosition: Vector3);
  95578. /** Gets or sets current rotation (in local space) */
  95579. get rotation(): Vector3;
  95580. set rotation(newRotation: Vector3);
  95581. /** Gets or sets current rotation quaternion (in local space) */
  95582. get rotationQuaternion(): Quaternion;
  95583. set rotationQuaternion(newRotation: Quaternion);
  95584. /** Gets or sets current scaling (in local space) */
  95585. get scaling(): Vector3;
  95586. set scaling(newScaling: Vector3);
  95587. /**
  95588. * Gets the animation properties override
  95589. */
  95590. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95591. private _decompose;
  95592. private _compose;
  95593. /**
  95594. * Update the base and local matrices
  95595. * @param matrix defines the new base or local matrix
  95596. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95597. * @param updateLocalMatrix defines if the local matrix should be updated
  95598. */
  95599. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95600. /** @hidden */
  95601. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95602. /**
  95603. * Flag the bone as dirty (Forcing it to update everything)
  95604. */
  95605. markAsDirty(): void;
  95606. /** @hidden */
  95607. _markAsDirtyAndCompose(): void;
  95608. private _markAsDirtyAndDecompose;
  95609. /**
  95610. * Translate the bone in local or world space
  95611. * @param vec The amount to translate the bone
  95612. * @param space The space that the translation is in
  95613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95614. */
  95615. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95616. /**
  95617. * Set the postion of the bone in local or world space
  95618. * @param position The position to set the bone
  95619. * @param space The space that the position is in
  95620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95621. */
  95622. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95623. /**
  95624. * Set the absolute position of the bone (world space)
  95625. * @param position The position to set the bone
  95626. * @param mesh The mesh that this bone is attached to
  95627. */
  95628. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95629. /**
  95630. * Scale the bone on the x, y and z axes (in local space)
  95631. * @param x The amount to scale the bone on the x axis
  95632. * @param y The amount to scale the bone on the y axis
  95633. * @param z The amount to scale the bone on the z axis
  95634. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95635. */
  95636. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95637. /**
  95638. * Set the bone scaling in local space
  95639. * @param scale defines the scaling vector
  95640. */
  95641. setScale(scale: Vector3): void;
  95642. /**
  95643. * Gets the current scaling in local space
  95644. * @returns the current scaling vector
  95645. */
  95646. getScale(): Vector3;
  95647. /**
  95648. * Gets the current scaling in local space and stores it in a target vector
  95649. * @param result defines the target vector
  95650. */
  95651. getScaleToRef(result: Vector3): void;
  95652. /**
  95653. * Set the yaw, pitch, and roll of the bone in local or world space
  95654. * @param yaw The rotation of the bone on the y axis
  95655. * @param pitch The rotation of the bone on the x axis
  95656. * @param roll The rotation of the bone on the z axis
  95657. * @param space The space that the axes of rotation are in
  95658. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95659. */
  95660. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95661. /**
  95662. * Add a rotation to the bone on an axis in local or world space
  95663. * @param axis The axis to rotate the bone on
  95664. * @param amount The amount to rotate the bone
  95665. * @param space The space that the axis is in
  95666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95667. */
  95668. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95669. /**
  95670. * Set the rotation of the bone to a particular axis angle in local or world space
  95671. * @param axis The axis to rotate the bone on
  95672. * @param angle The angle that the bone should be rotated to
  95673. * @param space The space that the axis is in
  95674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95675. */
  95676. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95677. /**
  95678. * Set the euler rotation of the bone in local or world space
  95679. * @param rotation The euler rotation that the bone should be set to
  95680. * @param space The space that the rotation is in
  95681. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95682. */
  95683. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95684. /**
  95685. * Set the quaternion rotation of the bone in local or world space
  95686. * @param quat The quaternion rotation that the bone should be set to
  95687. * @param space The space that the rotation is in
  95688. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95689. */
  95690. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95691. /**
  95692. * Set the rotation matrix of the bone in local or world space
  95693. * @param rotMat The rotation matrix that the bone should be set to
  95694. * @param space The space that the rotation is in
  95695. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95696. */
  95697. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95698. private _rotateWithMatrix;
  95699. private _getNegativeRotationToRef;
  95700. /**
  95701. * Get the position of the bone in local or world space
  95702. * @param space The space that the returned position is in
  95703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95704. * @returns The position of the bone
  95705. */
  95706. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95707. /**
  95708. * Copy the position of the bone to a vector3 in local or world space
  95709. * @param space The space that the returned position is in
  95710. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95711. * @param result The vector3 to copy the position to
  95712. */
  95713. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95714. /**
  95715. * Get the absolute position of the bone (world space)
  95716. * @param mesh The mesh that this bone is attached to
  95717. * @returns The absolute position of the bone
  95718. */
  95719. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95720. /**
  95721. * Copy the absolute position of the bone (world space) to the result param
  95722. * @param mesh The mesh that this bone is attached to
  95723. * @param result The vector3 to copy the absolute position to
  95724. */
  95725. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95726. /**
  95727. * Compute the absolute transforms of this bone and its children
  95728. */
  95729. computeAbsoluteTransforms(): void;
  95730. /**
  95731. * Get the world direction from an axis that is in the local space of the bone
  95732. * @param localAxis The local direction that is used to compute the world direction
  95733. * @param mesh The mesh that this bone is attached to
  95734. * @returns The world direction
  95735. */
  95736. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95737. /**
  95738. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95739. * @param localAxis The local direction that is used to compute the world direction
  95740. * @param mesh The mesh that this bone is attached to
  95741. * @param result The vector3 that the world direction will be copied to
  95742. */
  95743. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95744. /**
  95745. * Get the euler rotation of the bone in local or world space
  95746. * @param space The space that the rotation should be in
  95747. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95748. * @returns The euler rotation
  95749. */
  95750. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95751. /**
  95752. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95753. * @param space The space that the rotation should be in
  95754. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95755. * @param result The vector3 that the rotation should be copied to
  95756. */
  95757. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95758. /**
  95759. * Get the quaternion rotation of the bone in either local or world space
  95760. * @param space The space that the rotation should be in
  95761. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95762. * @returns The quaternion rotation
  95763. */
  95764. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  95765. /**
  95766. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  95767. * @param space The space that the rotation should be in
  95768. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95769. * @param result The quaternion that the rotation should be copied to
  95770. */
  95771. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  95772. /**
  95773. * Get the rotation matrix of the bone in local or world space
  95774. * @param space The space that the rotation should be in
  95775. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95776. * @returns The rotation matrix
  95777. */
  95778. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  95779. /**
  95780. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  95781. * @param space The space that the rotation should be in
  95782. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95783. * @param result The quaternion that the rotation should be copied to
  95784. */
  95785. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  95786. /**
  95787. * Get the world position of a point that is in the local space of the bone
  95788. * @param position The local position
  95789. * @param mesh The mesh that this bone is attached to
  95790. * @returns The world position
  95791. */
  95792. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95793. /**
  95794. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  95795. * @param position The local position
  95796. * @param mesh The mesh that this bone is attached to
  95797. * @param result The vector3 that the world position should be copied to
  95798. */
  95799. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95800. /**
  95801. * Get the local position of a point that is in world space
  95802. * @param position The world position
  95803. * @param mesh The mesh that this bone is attached to
  95804. * @returns The local position
  95805. */
  95806. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95807. /**
  95808. * Get the local position of a point that is in world space and copy it to the result param
  95809. * @param position The world position
  95810. * @param mesh The mesh that this bone is attached to
  95811. * @param result The vector3 that the local position should be copied to
  95812. */
  95813. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95814. /**
  95815. * Set the current local matrix as the restPose for this bone.
  95816. */
  95817. setCurrentPoseAsRest(): void;
  95818. }
  95819. }
  95820. declare module BABYLON {
  95821. /**
  95822. * Defines a runtime animation
  95823. */
  95824. export class RuntimeAnimation {
  95825. private _events;
  95826. /**
  95827. * The current frame of the runtime animation
  95828. */
  95829. private _currentFrame;
  95830. /**
  95831. * The animation used by the runtime animation
  95832. */
  95833. private _animation;
  95834. /**
  95835. * The target of the runtime animation
  95836. */
  95837. private _target;
  95838. /**
  95839. * The initiating animatable
  95840. */
  95841. private _host;
  95842. /**
  95843. * The original value of the runtime animation
  95844. */
  95845. private _originalValue;
  95846. /**
  95847. * The original blend value of the runtime animation
  95848. */
  95849. private _originalBlendValue;
  95850. /**
  95851. * The offsets cache of the runtime animation
  95852. */
  95853. private _offsetsCache;
  95854. /**
  95855. * The high limits cache of the runtime animation
  95856. */
  95857. private _highLimitsCache;
  95858. /**
  95859. * Specifies if the runtime animation has been stopped
  95860. */
  95861. private _stopped;
  95862. /**
  95863. * The blending factor of the runtime animation
  95864. */
  95865. private _blendingFactor;
  95866. /**
  95867. * The BabylonJS scene
  95868. */
  95869. private _scene;
  95870. /**
  95871. * The current value of the runtime animation
  95872. */
  95873. private _currentValue;
  95874. /** @hidden */
  95875. _animationState: _IAnimationState;
  95876. /**
  95877. * The active target of the runtime animation
  95878. */
  95879. private _activeTargets;
  95880. private _currentActiveTarget;
  95881. private _directTarget;
  95882. /**
  95883. * The target path of the runtime animation
  95884. */
  95885. private _targetPath;
  95886. /**
  95887. * The weight of the runtime animation
  95888. */
  95889. private _weight;
  95890. /**
  95891. * The ratio offset of the runtime animation
  95892. */
  95893. private _ratioOffset;
  95894. /**
  95895. * The previous delay of the runtime animation
  95896. */
  95897. private _previousDelay;
  95898. /**
  95899. * The previous ratio of the runtime animation
  95900. */
  95901. private _previousRatio;
  95902. private _enableBlending;
  95903. private _keys;
  95904. private _minFrame;
  95905. private _maxFrame;
  95906. private _minValue;
  95907. private _maxValue;
  95908. private _targetIsArray;
  95909. /**
  95910. * Gets the current frame of the runtime animation
  95911. */
  95912. get currentFrame(): number;
  95913. /**
  95914. * Gets the weight of the runtime animation
  95915. */
  95916. get weight(): number;
  95917. /**
  95918. * Gets the current value of the runtime animation
  95919. */
  95920. get currentValue(): any;
  95921. /**
  95922. * Gets the target path of the runtime animation
  95923. */
  95924. get targetPath(): string;
  95925. /**
  95926. * Gets the actual target of the runtime animation
  95927. */
  95928. get target(): any;
  95929. /**
  95930. * Gets the additive state of the runtime animation
  95931. */
  95932. get isAdditive(): boolean;
  95933. /** @hidden */
  95934. _onLoop: () => void;
  95935. /**
  95936. * Create a new RuntimeAnimation object
  95937. * @param target defines the target of the animation
  95938. * @param animation defines the source animation object
  95939. * @param scene defines the hosting scene
  95940. * @param host defines the initiating Animatable
  95941. */
  95942. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  95943. private _preparePath;
  95944. /**
  95945. * Gets the animation from the runtime animation
  95946. */
  95947. get animation(): Animation;
  95948. /**
  95949. * Resets the runtime animation to the beginning
  95950. * @param restoreOriginal defines whether to restore the target property to the original value
  95951. */
  95952. reset(restoreOriginal?: boolean): void;
  95953. /**
  95954. * Specifies if the runtime animation is stopped
  95955. * @returns Boolean specifying if the runtime animation is stopped
  95956. */
  95957. isStopped(): boolean;
  95958. /**
  95959. * Disposes of the runtime animation
  95960. */
  95961. dispose(): void;
  95962. /**
  95963. * Apply the interpolated value to the target
  95964. * @param currentValue defines the value computed by the animation
  95965. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  95966. */
  95967. setValue(currentValue: any, weight: number): void;
  95968. private _getOriginalValues;
  95969. private _setValue;
  95970. /**
  95971. * Gets the loop pmode of the runtime animation
  95972. * @returns Loop Mode
  95973. */
  95974. private _getCorrectLoopMode;
  95975. /**
  95976. * Move the current animation to a given frame
  95977. * @param frame defines the frame to move to
  95978. */
  95979. goToFrame(frame: number): void;
  95980. /**
  95981. * @hidden Internal use only
  95982. */
  95983. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  95984. /**
  95985. * Execute the current animation
  95986. * @param delay defines the delay to add to the current frame
  95987. * @param from defines the lower bound of the animation range
  95988. * @param to defines the upper bound of the animation range
  95989. * @param loop defines if the current animation must loop
  95990. * @param speedRatio defines the current speed ratio
  95991. * @param weight defines the weight of the animation (default is -1 so no weight)
  95992. * @param onLoop optional callback called when animation loops
  95993. * @returns a boolean indicating if the animation is running
  95994. */
  95995. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  95996. }
  95997. }
  95998. declare module BABYLON {
  95999. /**
  96000. * Class used to store an actual running animation
  96001. */
  96002. export class Animatable {
  96003. /** defines the target object */
  96004. target: any;
  96005. /** defines the starting frame number (default is 0) */
  96006. fromFrame: number;
  96007. /** defines the ending frame number (default is 100) */
  96008. toFrame: number;
  96009. /** defines if the animation must loop (default is false) */
  96010. loopAnimation: boolean;
  96011. /** defines a callback to call when animation ends if it is not looping */
  96012. onAnimationEnd?: (() => void) | null | undefined;
  96013. /** defines a callback to call when animation loops */
  96014. onAnimationLoop?: (() => void) | null | undefined;
  96015. /** defines whether the animation should be evaluated additively */
  96016. isAdditive: boolean;
  96017. private _localDelayOffset;
  96018. private _pausedDelay;
  96019. private _runtimeAnimations;
  96020. private _paused;
  96021. private _scene;
  96022. private _speedRatio;
  96023. private _weight;
  96024. private _syncRoot;
  96025. /**
  96026. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96027. * This will only apply for non looping animation (default is true)
  96028. */
  96029. disposeOnEnd: boolean;
  96030. /**
  96031. * Gets a boolean indicating if the animation has started
  96032. */
  96033. animationStarted: boolean;
  96034. /**
  96035. * Observer raised when the animation ends
  96036. */
  96037. onAnimationEndObservable: Observable<Animatable>;
  96038. /**
  96039. * Observer raised when the animation loops
  96040. */
  96041. onAnimationLoopObservable: Observable<Animatable>;
  96042. /**
  96043. * Gets the root Animatable used to synchronize and normalize animations
  96044. */
  96045. get syncRoot(): Nullable<Animatable>;
  96046. /**
  96047. * Gets the current frame of the first RuntimeAnimation
  96048. * Used to synchronize Animatables
  96049. */
  96050. get masterFrame(): number;
  96051. /**
  96052. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96053. */
  96054. get weight(): number;
  96055. set weight(value: number);
  96056. /**
  96057. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96058. */
  96059. get speedRatio(): number;
  96060. set speedRatio(value: number);
  96061. /**
  96062. * Creates a new Animatable
  96063. * @param scene defines the hosting scene
  96064. * @param target defines the target object
  96065. * @param fromFrame defines the starting frame number (default is 0)
  96066. * @param toFrame defines the ending frame number (default is 100)
  96067. * @param loopAnimation defines if the animation must loop (default is false)
  96068. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96069. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96070. * @param animations defines a group of animation to add to the new Animatable
  96071. * @param onAnimationLoop defines a callback to call when animation loops
  96072. * @param isAdditive defines whether the animation should be evaluated additively
  96073. */
  96074. constructor(scene: Scene,
  96075. /** defines the target object */
  96076. target: any,
  96077. /** defines the starting frame number (default is 0) */
  96078. fromFrame?: number,
  96079. /** defines the ending frame number (default is 100) */
  96080. toFrame?: number,
  96081. /** defines if the animation must loop (default is false) */
  96082. loopAnimation?: boolean, speedRatio?: number,
  96083. /** defines a callback to call when animation ends if it is not looping */
  96084. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96085. /** defines a callback to call when animation loops */
  96086. onAnimationLoop?: (() => void) | null | undefined,
  96087. /** defines whether the animation should be evaluated additively */
  96088. isAdditive?: boolean);
  96089. /**
  96090. * Synchronize and normalize current Animatable with a source Animatable
  96091. * This is useful when using animation weights and when animations are not of the same length
  96092. * @param root defines the root Animatable to synchronize with
  96093. * @returns the current Animatable
  96094. */
  96095. syncWith(root: Animatable): Animatable;
  96096. /**
  96097. * Gets the list of runtime animations
  96098. * @returns an array of RuntimeAnimation
  96099. */
  96100. getAnimations(): RuntimeAnimation[];
  96101. /**
  96102. * Adds more animations to the current animatable
  96103. * @param target defines the target of the animations
  96104. * @param animations defines the new animations to add
  96105. */
  96106. appendAnimations(target: any, animations: Animation[]): void;
  96107. /**
  96108. * Gets the source animation for a specific property
  96109. * @param property defines the propertyu to look for
  96110. * @returns null or the source animation for the given property
  96111. */
  96112. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96113. /**
  96114. * Gets the runtime animation for a specific property
  96115. * @param property defines the propertyu to look for
  96116. * @returns null or the runtime animation for the given property
  96117. */
  96118. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96119. /**
  96120. * Resets the animatable to its original state
  96121. */
  96122. reset(): void;
  96123. /**
  96124. * Allows the animatable to blend with current running animations
  96125. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96126. * @param blendingSpeed defines the blending speed to use
  96127. */
  96128. enableBlending(blendingSpeed: number): void;
  96129. /**
  96130. * Disable animation blending
  96131. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96132. */
  96133. disableBlending(): void;
  96134. /**
  96135. * Jump directly to a given frame
  96136. * @param frame defines the frame to jump to
  96137. */
  96138. goToFrame(frame: number): void;
  96139. /**
  96140. * Pause the animation
  96141. */
  96142. pause(): void;
  96143. /**
  96144. * Restart the animation
  96145. */
  96146. restart(): void;
  96147. private _raiseOnAnimationEnd;
  96148. /**
  96149. * Stop and delete the current animation
  96150. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96151. * @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)
  96152. */
  96153. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96154. /**
  96155. * Wait asynchronously for the animation to end
  96156. * @returns a promise which will be fullfilled when the animation ends
  96157. */
  96158. waitAsync(): Promise<Animatable>;
  96159. /** @hidden */
  96160. _animate(delay: number): boolean;
  96161. }
  96162. interface Scene {
  96163. /** @hidden */
  96164. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96165. /** @hidden */
  96166. _processLateAnimationBindingsForMatrices(holder: {
  96167. totalWeight: number;
  96168. totalAdditiveWeight: number;
  96169. animations: RuntimeAnimation[];
  96170. additiveAnimations: RuntimeAnimation[];
  96171. originalValue: Matrix;
  96172. }): any;
  96173. /** @hidden */
  96174. _processLateAnimationBindingsForQuaternions(holder: {
  96175. totalWeight: number;
  96176. totalAdditiveWeight: number;
  96177. animations: RuntimeAnimation[];
  96178. additiveAnimations: RuntimeAnimation[];
  96179. originalValue: Quaternion;
  96180. }, refQuaternion: Quaternion): Quaternion;
  96181. /** @hidden */
  96182. _processLateAnimationBindings(): void;
  96183. /**
  96184. * Will start the animation sequence of a given target
  96185. * @param target defines the target
  96186. * @param from defines from which frame should animation start
  96187. * @param to defines until which frame should animation run.
  96188. * @param weight defines the weight to apply to the animation (1.0 by default)
  96189. * @param loop defines if the animation loops
  96190. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96191. * @param onAnimationEnd defines the function to be executed when the animation ends
  96192. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96193. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96194. * @param onAnimationLoop defines the callback to call when an animation loops
  96195. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96196. * @returns the animatable object created for this animation
  96197. */
  96198. 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;
  96199. /**
  96200. * Will start the animation sequence of a given target
  96201. * @param target defines the target
  96202. * @param from defines from which frame should animation start
  96203. * @param to defines until which frame should animation run.
  96204. * @param loop defines if the animation loops
  96205. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96206. * @param onAnimationEnd defines the function to be executed when the animation ends
  96207. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96208. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96209. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96210. * @param onAnimationLoop defines the callback to call when an animation loops
  96211. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96212. * @returns the animatable object created for this animation
  96213. */
  96214. 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;
  96215. /**
  96216. * Will start the animation sequence of a given target and its hierarchy
  96217. * @param target defines the target
  96218. * @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.
  96219. * @param from defines from which frame should animation start
  96220. * @param to defines until which frame should animation run.
  96221. * @param loop defines if the animation loops
  96222. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96223. * @param onAnimationEnd defines the function to be executed when the animation ends
  96224. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96225. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96226. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96227. * @param onAnimationLoop defines the callback to call when an animation loops
  96228. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96229. * @returns the list of created animatables
  96230. */
  96231. 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[];
  96232. /**
  96233. * Begin a new animation on a given node
  96234. * @param target defines the target where the animation will take place
  96235. * @param animations defines the list of animations to start
  96236. * @param from defines the initial value
  96237. * @param to defines the final value
  96238. * @param loop defines if you want animation to loop (off by default)
  96239. * @param speedRatio defines the speed ratio to apply to all animations
  96240. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96241. * @param onAnimationLoop defines the callback to call when an animation loops
  96242. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96243. * @returns the list of created animatables
  96244. */
  96245. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96246. /**
  96247. * Begin a new animation on a given node and its hierarchy
  96248. * @param target defines the root node where the animation will take place
  96249. * @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.
  96250. * @param animations defines the list of animations to start
  96251. * @param from defines the initial value
  96252. * @param to defines the final value
  96253. * @param loop defines if you want animation to loop (off by default)
  96254. * @param speedRatio defines the speed ratio to apply to all animations
  96255. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96256. * @param onAnimationLoop defines the callback to call when an animation loops
  96257. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96258. * @returns the list of animatables created for all nodes
  96259. */
  96260. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96261. /**
  96262. * Gets the animatable associated with a specific target
  96263. * @param target defines the target of the animatable
  96264. * @returns the required animatable if found
  96265. */
  96266. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96267. /**
  96268. * Gets all animatables associated with a given target
  96269. * @param target defines the target to look animatables for
  96270. * @returns an array of Animatables
  96271. */
  96272. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96273. /**
  96274. * Stops and removes all animations that have been applied to the scene
  96275. */
  96276. stopAllAnimations(): void;
  96277. /**
  96278. * Gets the current delta time used by animation engine
  96279. */
  96280. deltaTime: number;
  96281. }
  96282. interface Bone {
  96283. /**
  96284. * Copy an animation range from another bone
  96285. * @param source defines the source bone
  96286. * @param rangeName defines the range name to copy
  96287. * @param frameOffset defines the frame offset
  96288. * @param rescaleAsRequired defines if rescaling must be applied if required
  96289. * @param skelDimensionsRatio defines the scaling ratio
  96290. * @returns true if operation was successful
  96291. */
  96292. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96293. }
  96294. }
  96295. declare module BABYLON {
  96296. /**
  96297. * Class used to handle skinning animations
  96298. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96299. */
  96300. export class Skeleton implements IAnimatable {
  96301. /** defines the skeleton name */
  96302. name: string;
  96303. /** defines the skeleton Id */
  96304. id: string;
  96305. /**
  96306. * Defines the list of child bones
  96307. */
  96308. bones: Bone[];
  96309. /**
  96310. * Defines an estimate of the dimension of the skeleton at rest
  96311. */
  96312. dimensionsAtRest: Vector3;
  96313. /**
  96314. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96315. */
  96316. needInitialSkinMatrix: boolean;
  96317. /**
  96318. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96319. */
  96320. overrideMesh: Nullable<AbstractMesh>;
  96321. /**
  96322. * Gets the list of animations attached to this skeleton
  96323. */
  96324. animations: Array<Animation>;
  96325. private _scene;
  96326. private _isDirty;
  96327. private _transformMatrices;
  96328. private _transformMatrixTexture;
  96329. private _meshesWithPoseMatrix;
  96330. private _animatables;
  96331. private _identity;
  96332. private _synchronizedWithMesh;
  96333. private _ranges;
  96334. private _lastAbsoluteTransformsUpdateId;
  96335. private _canUseTextureForBones;
  96336. private _uniqueId;
  96337. /** @hidden */
  96338. _numBonesWithLinkedTransformNode: number;
  96339. /** @hidden */
  96340. _hasWaitingData: Nullable<boolean>;
  96341. /** @hidden */
  96342. _waitingOverrideMeshId: Nullable<string>;
  96343. /**
  96344. * Specifies if the skeleton should be serialized
  96345. */
  96346. doNotSerialize: boolean;
  96347. private _useTextureToStoreBoneMatrices;
  96348. /**
  96349. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96350. * Please note that this option is not available if the hardware does not support it
  96351. */
  96352. get useTextureToStoreBoneMatrices(): boolean;
  96353. set useTextureToStoreBoneMatrices(value: boolean);
  96354. private _animationPropertiesOverride;
  96355. /**
  96356. * Gets or sets the animation properties override
  96357. */
  96358. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96359. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96360. /**
  96361. * List of inspectable custom properties (used by the Inspector)
  96362. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96363. */
  96364. inspectableCustomProperties: IInspectable[];
  96365. /**
  96366. * An observable triggered before computing the skeleton's matrices
  96367. */
  96368. onBeforeComputeObservable: Observable<Skeleton>;
  96369. /**
  96370. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96371. */
  96372. get isUsingTextureForMatrices(): boolean;
  96373. /**
  96374. * Gets the unique ID of this skeleton
  96375. */
  96376. get uniqueId(): number;
  96377. /**
  96378. * Creates a new skeleton
  96379. * @param name defines the skeleton name
  96380. * @param id defines the skeleton Id
  96381. * @param scene defines the hosting scene
  96382. */
  96383. constructor(
  96384. /** defines the skeleton name */
  96385. name: string,
  96386. /** defines the skeleton Id */
  96387. id: string, scene: Scene);
  96388. /**
  96389. * Gets the current object class name.
  96390. * @return the class name
  96391. */
  96392. getClassName(): string;
  96393. /**
  96394. * Returns an array containing the root bones
  96395. * @returns an array containing the root bones
  96396. */
  96397. getChildren(): Array<Bone>;
  96398. /**
  96399. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96400. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96401. * @returns a Float32Array containing matrices data
  96402. */
  96403. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96404. /**
  96405. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96406. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96407. * @returns a raw texture containing the data
  96408. */
  96409. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96410. /**
  96411. * Gets the current hosting scene
  96412. * @returns a scene object
  96413. */
  96414. getScene(): Scene;
  96415. /**
  96416. * Gets a string representing the current skeleton data
  96417. * @param fullDetails defines a boolean indicating if we want a verbose version
  96418. * @returns a string representing the current skeleton data
  96419. */
  96420. toString(fullDetails?: boolean): string;
  96421. /**
  96422. * Get bone's index searching by name
  96423. * @param name defines bone's name to search for
  96424. * @return the indice of the bone. Returns -1 if not found
  96425. */
  96426. getBoneIndexByName(name: string): number;
  96427. /**
  96428. * Creater a new animation range
  96429. * @param name defines the name of the range
  96430. * @param from defines the start key
  96431. * @param to defines the end key
  96432. */
  96433. createAnimationRange(name: string, from: number, to: number): void;
  96434. /**
  96435. * Delete a specific animation range
  96436. * @param name defines the name of the range
  96437. * @param deleteFrames defines if frames must be removed as well
  96438. */
  96439. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96440. /**
  96441. * Gets a specific animation range
  96442. * @param name defines the name of the range to look for
  96443. * @returns the requested animation range or null if not found
  96444. */
  96445. getAnimationRange(name: string): Nullable<AnimationRange>;
  96446. /**
  96447. * Gets the list of all animation ranges defined on this skeleton
  96448. * @returns an array
  96449. */
  96450. getAnimationRanges(): Nullable<AnimationRange>[];
  96451. /**
  96452. * Copy animation range from a source skeleton.
  96453. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96454. * @param source defines the source skeleton
  96455. * @param name defines the name of the range to copy
  96456. * @param rescaleAsRequired defines if rescaling must be applied if required
  96457. * @returns true if operation was successful
  96458. */
  96459. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96460. /**
  96461. * Forces the skeleton to go to rest pose
  96462. */
  96463. returnToRest(): void;
  96464. private _getHighestAnimationFrame;
  96465. /**
  96466. * Begin a specific animation range
  96467. * @param name defines the name of the range to start
  96468. * @param loop defines if looping must be turned on (false by default)
  96469. * @param speedRatio defines the speed ratio to apply (1 by default)
  96470. * @param onAnimationEnd defines a callback which will be called when animation will end
  96471. * @returns a new animatable
  96472. */
  96473. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96474. /**
  96475. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96476. * @param skeleton defines the Skeleton containing the animation range to convert
  96477. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96478. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96479. * @returns the original skeleton
  96480. */
  96481. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96482. /** @hidden */
  96483. _markAsDirty(): void;
  96484. /** @hidden */
  96485. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96486. /** @hidden */
  96487. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96488. private _computeTransformMatrices;
  96489. /**
  96490. * Build all resources required to render a skeleton
  96491. */
  96492. prepare(): void;
  96493. /**
  96494. * Gets the list of animatables currently running for this skeleton
  96495. * @returns an array of animatables
  96496. */
  96497. getAnimatables(): IAnimatable[];
  96498. /**
  96499. * Clone the current skeleton
  96500. * @param name defines the name of the new skeleton
  96501. * @param id defines the id of the new skeleton
  96502. * @returns the new skeleton
  96503. */
  96504. clone(name: string, id?: string): Skeleton;
  96505. /**
  96506. * Enable animation blending for this skeleton
  96507. * @param blendingSpeed defines the blending speed to apply
  96508. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96509. */
  96510. enableBlending(blendingSpeed?: number): void;
  96511. /**
  96512. * Releases all resources associated with the current skeleton
  96513. */
  96514. dispose(): void;
  96515. /**
  96516. * Serialize the skeleton in a JSON object
  96517. * @returns a JSON object
  96518. */
  96519. serialize(): any;
  96520. /**
  96521. * Creates a new skeleton from serialized data
  96522. * @param parsedSkeleton defines the serialized data
  96523. * @param scene defines the hosting scene
  96524. * @returns a new skeleton
  96525. */
  96526. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96527. /**
  96528. * Compute all node absolute transforms
  96529. * @param forceUpdate defines if computation must be done even if cache is up to date
  96530. */
  96531. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96532. /**
  96533. * Gets the root pose matrix
  96534. * @returns a matrix
  96535. */
  96536. getPoseMatrix(): Nullable<Matrix>;
  96537. /**
  96538. * Sorts bones per internal index
  96539. */
  96540. sortBones(): void;
  96541. private _sortBones;
  96542. /**
  96543. * Set the current local matrix as the restPose for all bones in the skeleton.
  96544. */
  96545. setCurrentPoseAsRest(): void;
  96546. }
  96547. }
  96548. declare module BABYLON {
  96549. /**
  96550. * Creates an instance based on a source mesh.
  96551. */
  96552. export class InstancedMesh extends AbstractMesh {
  96553. private _sourceMesh;
  96554. private _currentLOD;
  96555. /** @hidden */
  96556. _indexInSourceMeshInstanceArray: number;
  96557. constructor(name: string, source: Mesh);
  96558. /**
  96559. * Returns the string "InstancedMesh".
  96560. */
  96561. getClassName(): string;
  96562. /** Gets the list of lights affecting that mesh */
  96563. get lightSources(): Light[];
  96564. _resyncLightSources(): void;
  96565. _resyncLightSource(light: Light): void;
  96566. _removeLightSource(light: Light, dispose: boolean): void;
  96567. /**
  96568. * If the source mesh receives shadows
  96569. */
  96570. get receiveShadows(): boolean;
  96571. /**
  96572. * The material of the source mesh
  96573. */
  96574. get material(): Nullable<Material>;
  96575. /**
  96576. * Visibility of the source mesh
  96577. */
  96578. get visibility(): number;
  96579. /**
  96580. * Skeleton of the source mesh
  96581. */
  96582. get skeleton(): Nullable<Skeleton>;
  96583. /**
  96584. * Rendering ground id of the source mesh
  96585. */
  96586. get renderingGroupId(): number;
  96587. set renderingGroupId(value: number);
  96588. /**
  96589. * Returns the total number of vertices (integer).
  96590. */
  96591. getTotalVertices(): number;
  96592. /**
  96593. * Returns a positive integer : the total number of indices in this mesh geometry.
  96594. * @returns the numner of indices or zero if the mesh has no geometry.
  96595. */
  96596. getTotalIndices(): number;
  96597. /**
  96598. * The source mesh of the instance
  96599. */
  96600. get sourceMesh(): Mesh;
  96601. /**
  96602. * Creates a new InstancedMesh object from the mesh model.
  96603. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96604. * @param name defines the name of the new instance
  96605. * @returns a new InstancedMesh
  96606. */
  96607. createInstance(name: string): InstancedMesh;
  96608. /**
  96609. * Is this node ready to be used/rendered
  96610. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96611. * @return {boolean} is it ready
  96612. */
  96613. isReady(completeCheck?: boolean): boolean;
  96614. /**
  96615. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96616. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96617. * @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.
  96618. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96619. */
  96620. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96621. /**
  96622. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96623. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96624. * The `data` are either a numeric array either a Float32Array.
  96625. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96626. * 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).
  96627. * Note that a new underlying VertexBuffer object is created each call.
  96628. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96629. *
  96630. * Possible `kind` values :
  96631. * - VertexBuffer.PositionKind
  96632. * - VertexBuffer.UVKind
  96633. * - VertexBuffer.UV2Kind
  96634. * - VertexBuffer.UV3Kind
  96635. * - VertexBuffer.UV4Kind
  96636. * - VertexBuffer.UV5Kind
  96637. * - VertexBuffer.UV6Kind
  96638. * - VertexBuffer.ColorKind
  96639. * - VertexBuffer.MatricesIndicesKind
  96640. * - VertexBuffer.MatricesIndicesExtraKind
  96641. * - VertexBuffer.MatricesWeightsKind
  96642. * - VertexBuffer.MatricesWeightsExtraKind
  96643. *
  96644. * Returns the Mesh.
  96645. */
  96646. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96647. /**
  96648. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96649. * If the mesh has no geometry, it is simply returned as it is.
  96650. * The `data` are either a numeric array either a Float32Array.
  96651. * No new underlying VertexBuffer object is created.
  96652. * 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.
  96653. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96654. *
  96655. * Possible `kind` values :
  96656. * - VertexBuffer.PositionKind
  96657. * - VertexBuffer.UVKind
  96658. * - VertexBuffer.UV2Kind
  96659. * - VertexBuffer.UV3Kind
  96660. * - VertexBuffer.UV4Kind
  96661. * - VertexBuffer.UV5Kind
  96662. * - VertexBuffer.UV6Kind
  96663. * - VertexBuffer.ColorKind
  96664. * - VertexBuffer.MatricesIndicesKind
  96665. * - VertexBuffer.MatricesIndicesExtraKind
  96666. * - VertexBuffer.MatricesWeightsKind
  96667. * - VertexBuffer.MatricesWeightsExtraKind
  96668. *
  96669. * Returns the Mesh.
  96670. */
  96671. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96672. /**
  96673. * Sets the mesh indices.
  96674. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96675. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96676. * This method creates a new index buffer each call.
  96677. * Returns the Mesh.
  96678. */
  96679. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96680. /**
  96681. * Boolean : True if the mesh owns the requested kind of data.
  96682. */
  96683. isVerticesDataPresent(kind: string): boolean;
  96684. /**
  96685. * Returns an array of indices (IndicesArray).
  96686. */
  96687. getIndices(): Nullable<IndicesArray>;
  96688. get _positions(): Nullable<Vector3[]>;
  96689. /**
  96690. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96691. * This means the mesh underlying bounding box and sphere are recomputed.
  96692. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96693. * @returns the current mesh
  96694. */
  96695. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96696. /** @hidden */
  96697. _preActivate(): InstancedMesh;
  96698. /** @hidden */
  96699. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96700. /** @hidden */
  96701. _postActivate(): void;
  96702. getWorldMatrix(): Matrix;
  96703. get isAnInstance(): boolean;
  96704. /**
  96705. * Returns the current associated LOD AbstractMesh.
  96706. */
  96707. getLOD(camera: Camera): AbstractMesh;
  96708. /** @hidden */
  96709. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96710. /** @hidden */
  96711. _syncSubMeshes(): InstancedMesh;
  96712. /** @hidden */
  96713. _generatePointsArray(): boolean;
  96714. /** @hidden */
  96715. _updateBoundingInfo(): AbstractMesh;
  96716. /**
  96717. * Creates a new InstancedMesh from the current mesh.
  96718. * - name (string) : the cloned mesh name
  96719. * - newParent (optional Node) : the optional Node to parent the clone to.
  96720. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96721. *
  96722. * Returns the clone.
  96723. */
  96724. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96725. /**
  96726. * Disposes the InstancedMesh.
  96727. * Returns nothing.
  96728. */
  96729. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96730. }
  96731. interface Mesh {
  96732. /**
  96733. * Register a custom buffer that will be instanced
  96734. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96735. * @param kind defines the buffer kind
  96736. * @param stride defines the stride in floats
  96737. */
  96738. registerInstancedBuffer(kind: string, stride: number): void;
  96739. /**
  96740. * true to use the edge renderer for all instances of this mesh
  96741. */
  96742. edgesShareWithInstances: boolean;
  96743. /** @hidden */
  96744. _userInstancedBuffersStorage: {
  96745. data: {
  96746. [key: string]: Float32Array;
  96747. };
  96748. sizes: {
  96749. [key: string]: number;
  96750. };
  96751. vertexBuffers: {
  96752. [key: string]: Nullable<VertexBuffer>;
  96753. };
  96754. strides: {
  96755. [key: string]: number;
  96756. };
  96757. };
  96758. }
  96759. interface AbstractMesh {
  96760. /**
  96761. * Object used to store instanced buffers defined by user
  96762. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96763. */
  96764. instancedBuffers: {
  96765. [key: string]: any;
  96766. };
  96767. }
  96768. }
  96769. declare module BABYLON {
  96770. /**
  96771. * Defines the options associated with the creation of a shader material.
  96772. */
  96773. export interface IShaderMaterialOptions {
  96774. /**
  96775. * Does the material work in alpha blend mode
  96776. */
  96777. needAlphaBlending: boolean;
  96778. /**
  96779. * Does the material work in alpha test mode
  96780. */
  96781. needAlphaTesting: boolean;
  96782. /**
  96783. * The list of attribute names used in the shader
  96784. */
  96785. attributes: string[];
  96786. /**
  96787. * The list of unifrom names used in the shader
  96788. */
  96789. uniforms: string[];
  96790. /**
  96791. * The list of UBO names used in the shader
  96792. */
  96793. uniformBuffers: string[];
  96794. /**
  96795. * The list of sampler names used in the shader
  96796. */
  96797. samplers: string[];
  96798. /**
  96799. * The list of defines used in the shader
  96800. */
  96801. defines: string[];
  96802. }
  96803. /**
  96804. * 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.
  96805. *
  96806. * This returned material effects how the mesh will look based on the code in the shaders.
  96807. *
  96808. * @see https://doc.babylonjs.com/how_to/shader_material
  96809. */
  96810. export class ShaderMaterial extends Material {
  96811. private _shaderPath;
  96812. private _options;
  96813. private _textures;
  96814. private _textureArrays;
  96815. private _floats;
  96816. private _ints;
  96817. private _floatsArrays;
  96818. private _colors3;
  96819. private _colors3Arrays;
  96820. private _colors4;
  96821. private _colors4Arrays;
  96822. private _vectors2;
  96823. private _vectors3;
  96824. private _vectors4;
  96825. private _matrices;
  96826. private _matrixArrays;
  96827. private _matrices3x3;
  96828. private _matrices2x2;
  96829. private _vectors2Arrays;
  96830. private _vectors3Arrays;
  96831. private _vectors4Arrays;
  96832. private _cachedWorldViewMatrix;
  96833. private _cachedWorldViewProjectionMatrix;
  96834. private _renderId;
  96835. private _multiview;
  96836. private _cachedDefines;
  96837. /** Define the Url to load snippets */
  96838. static SnippetUrl: string;
  96839. /** Snippet ID if the material was created from the snippet server */
  96840. snippetId: string;
  96841. /**
  96842. * Instantiate a new shader material.
  96843. * 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.
  96844. * This returned material effects how the mesh will look based on the code in the shaders.
  96845. * @see https://doc.babylonjs.com/how_to/shader_material
  96846. * @param name Define the name of the material in the scene
  96847. * @param scene Define the scene the material belongs to
  96848. * @param shaderPath Defines the route to the shader code in one of three ways:
  96849. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  96850. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  96851. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  96852. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  96853. * @param options Define the options used to create the shader
  96854. */
  96855. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  96856. /**
  96857. * Gets the shader path used to define the shader code
  96858. * It can be modified to trigger a new compilation
  96859. */
  96860. get shaderPath(): any;
  96861. /**
  96862. * Sets the shader path used to define the shader code
  96863. * It can be modified to trigger a new compilation
  96864. */
  96865. set shaderPath(shaderPath: any);
  96866. /**
  96867. * Gets the options used to compile the shader.
  96868. * They can be modified to trigger a new compilation
  96869. */
  96870. get options(): IShaderMaterialOptions;
  96871. /**
  96872. * Gets the current class name of the material e.g. "ShaderMaterial"
  96873. * Mainly use in serialization.
  96874. * @returns the class name
  96875. */
  96876. getClassName(): string;
  96877. /**
  96878. * Specifies if the material will require alpha blending
  96879. * @returns a boolean specifying if alpha blending is needed
  96880. */
  96881. needAlphaBlending(): boolean;
  96882. /**
  96883. * Specifies if this material should be rendered in alpha test mode
  96884. * @returns a boolean specifying if an alpha test is needed.
  96885. */
  96886. needAlphaTesting(): boolean;
  96887. private _checkUniform;
  96888. /**
  96889. * Set a texture in the shader.
  96890. * @param name Define the name of the uniform samplers as defined in the shader
  96891. * @param texture Define the texture to bind to this sampler
  96892. * @return the material itself allowing "fluent" like uniform updates
  96893. */
  96894. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  96895. /**
  96896. * Set a texture array in the shader.
  96897. * @param name Define the name of the uniform sampler array as defined in the shader
  96898. * @param textures Define the list of textures to bind to this sampler
  96899. * @return the material itself allowing "fluent" like uniform updates
  96900. */
  96901. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  96902. /**
  96903. * Set a float in the shader.
  96904. * @param name Define the name of the uniform as defined in the shader
  96905. * @param value Define the value to give to the uniform
  96906. * @return the material itself allowing "fluent" like uniform updates
  96907. */
  96908. setFloat(name: string, value: number): ShaderMaterial;
  96909. /**
  96910. * Set a int in the shader.
  96911. * @param name Define the name of the uniform as defined in the shader
  96912. * @param value Define the value to give to the uniform
  96913. * @return the material itself allowing "fluent" like uniform updates
  96914. */
  96915. setInt(name: string, value: number): ShaderMaterial;
  96916. /**
  96917. * Set an array of floats in the shader.
  96918. * @param name Define the name of the uniform as defined in the shader
  96919. * @param value Define the value to give to the uniform
  96920. * @return the material itself allowing "fluent" like uniform updates
  96921. */
  96922. setFloats(name: string, value: number[]): ShaderMaterial;
  96923. /**
  96924. * Set a vec3 in the shader from a Color3.
  96925. * @param name Define the name of the uniform as defined in the shader
  96926. * @param value Define the value to give to the uniform
  96927. * @return the material itself allowing "fluent" like uniform updates
  96928. */
  96929. setColor3(name: string, value: Color3): ShaderMaterial;
  96930. /**
  96931. * Set a vec3 array in the shader from a Color3 array.
  96932. * @param name Define the name of the uniform as defined in the shader
  96933. * @param value Define the value to give to the uniform
  96934. * @return the material itself allowing "fluent" like uniform updates
  96935. */
  96936. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  96937. /**
  96938. * Set a vec4 in the shader from a Color4.
  96939. * @param name Define the name of the uniform as defined in the shader
  96940. * @param value Define the value to give to the uniform
  96941. * @return the material itself allowing "fluent" like uniform updates
  96942. */
  96943. setColor4(name: string, value: Color4): ShaderMaterial;
  96944. /**
  96945. * Set a vec4 array in the shader from a Color4 array.
  96946. * @param name Define the name of the uniform as defined in the shader
  96947. * @param value Define the value to give to the uniform
  96948. * @return the material itself allowing "fluent" like uniform updates
  96949. */
  96950. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  96951. /**
  96952. * Set a vec2 in the shader from a Vector2.
  96953. * @param name Define the name of the uniform as defined in the shader
  96954. * @param value Define the value to give to the uniform
  96955. * @return the material itself allowing "fluent" like uniform updates
  96956. */
  96957. setVector2(name: string, value: Vector2): ShaderMaterial;
  96958. /**
  96959. * Set a vec3 in the shader from a Vector3.
  96960. * @param name Define the name of the uniform as defined in the shader
  96961. * @param value Define the value to give to the uniform
  96962. * @return the material itself allowing "fluent" like uniform updates
  96963. */
  96964. setVector3(name: string, value: Vector3): ShaderMaterial;
  96965. /**
  96966. * Set a vec4 in the shader from a Vector4.
  96967. * @param name Define the name of the uniform as defined in the shader
  96968. * @param value Define the value to give to the uniform
  96969. * @return the material itself allowing "fluent" like uniform updates
  96970. */
  96971. setVector4(name: string, value: Vector4): ShaderMaterial;
  96972. /**
  96973. * Set a mat4 in the shader from a Matrix.
  96974. * @param name Define the name of the uniform as defined in the shader
  96975. * @param value Define the value to give to the uniform
  96976. * @return the material itself allowing "fluent" like uniform updates
  96977. */
  96978. setMatrix(name: string, value: Matrix): ShaderMaterial;
  96979. /**
  96980. * Set a float32Array in the shader from a matrix array.
  96981. * @param name Define the name of the uniform as defined in the shader
  96982. * @param value Define the value to give to the uniform
  96983. * @return the material itself allowing "fluent" like uniform updates
  96984. */
  96985. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  96986. /**
  96987. * Set a mat3 in the shader from a Float32Array.
  96988. * @param name Define the name of the uniform as defined in the shader
  96989. * @param value Define the value to give to the uniform
  96990. * @return the material itself allowing "fluent" like uniform updates
  96991. */
  96992. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  96993. /**
  96994. * Set a mat2 in the shader from a Float32Array.
  96995. * @param name Define the name of the uniform as defined in the shader
  96996. * @param value Define the value to give to the uniform
  96997. * @return the material itself allowing "fluent" like uniform updates
  96998. */
  96999. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97000. /**
  97001. * Set a vec2 array in the shader from a number array.
  97002. * @param name Define the name of the uniform as defined in the shader
  97003. * @param value Define the value to give to the uniform
  97004. * @return the material itself allowing "fluent" like uniform updates
  97005. */
  97006. setArray2(name: string, value: number[]): ShaderMaterial;
  97007. /**
  97008. * Set a vec3 array in the shader from a number array.
  97009. * @param name Define the name of the uniform as defined in the shader
  97010. * @param value Define the value to give to the uniform
  97011. * @return the material itself allowing "fluent" like uniform updates
  97012. */
  97013. setArray3(name: string, value: number[]): ShaderMaterial;
  97014. /**
  97015. * Set a vec4 array in the shader from a number array.
  97016. * @param name Define the name of the uniform as defined in the shader
  97017. * @param value Define the value to give to the uniform
  97018. * @return the material itself allowing "fluent" like uniform updates
  97019. */
  97020. setArray4(name: string, value: number[]): ShaderMaterial;
  97021. private _checkCache;
  97022. /**
  97023. * Specifies that the submesh is ready to be used
  97024. * @param mesh defines the mesh to check
  97025. * @param subMesh defines which submesh to check
  97026. * @param useInstances specifies that instances should be used
  97027. * @returns a boolean indicating that the submesh is ready or not
  97028. */
  97029. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97030. /**
  97031. * Checks if the material is ready to render the requested mesh
  97032. * @param mesh Define the mesh to render
  97033. * @param useInstances Define whether or not the material is used with instances
  97034. * @returns true if ready, otherwise false
  97035. */
  97036. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97037. /**
  97038. * Binds the world matrix to the material
  97039. * @param world defines the world transformation matrix
  97040. * @param effectOverride - If provided, use this effect instead of internal effect
  97041. */
  97042. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97043. /**
  97044. * Binds the submesh to this material by preparing the effect and shader to draw
  97045. * @param world defines the world transformation matrix
  97046. * @param mesh defines the mesh containing the submesh
  97047. * @param subMesh defines the submesh to bind the material to
  97048. */
  97049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97050. /**
  97051. * Binds the material to the mesh
  97052. * @param world defines the world transformation matrix
  97053. * @param mesh defines the mesh to bind the material to
  97054. * @param effectOverride - If provided, use this effect instead of internal effect
  97055. */
  97056. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97057. protected _afterBind(mesh?: Mesh): void;
  97058. /**
  97059. * Gets the active textures from the material
  97060. * @returns an array of textures
  97061. */
  97062. getActiveTextures(): BaseTexture[];
  97063. /**
  97064. * Specifies if the material uses a texture
  97065. * @param texture defines the texture to check against the material
  97066. * @returns a boolean specifying if the material uses the texture
  97067. */
  97068. hasTexture(texture: BaseTexture): boolean;
  97069. /**
  97070. * Makes a duplicate of the material, and gives it a new name
  97071. * @param name defines the new name for the duplicated material
  97072. * @returns the cloned material
  97073. */
  97074. clone(name: string): ShaderMaterial;
  97075. /**
  97076. * Disposes the material
  97077. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97078. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97079. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97080. */
  97081. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97082. /**
  97083. * Serializes this material in a JSON representation
  97084. * @returns the serialized material object
  97085. */
  97086. serialize(): any;
  97087. /**
  97088. * Creates a shader material from parsed shader material data
  97089. * @param source defines the JSON represnetation of the material
  97090. * @param scene defines the hosting scene
  97091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97092. * @returns a new material
  97093. */
  97094. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97095. /**
  97096. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97097. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97098. * @param url defines the url to load from
  97099. * @param scene defines the hosting scene
  97100. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97101. * @returns a promise that will resolve to the new ShaderMaterial
  97102. */
  97103. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97104. /**
  97105. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97106. * @param snippetId defines the snippet to load
  97107. * @param scene defines the hosting scene
  97108. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97109. * @returns a promise that will resolve to the new ShaderMaterial
  97110. */
  97111. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97112. }
  97113. }
  97114. declare module BABYLON {
  97115. /** @hidden */
  97116. export var colorPixelShader: {
  97117. name: string;
  97118. shader: string;
  97119. };
  97120. }
  97121. declare module BABYLON {
  97122. /** @hidden */
  97123. export var colorVertexShader: {
  97124. name: string;
  97125. shader: string;
  97126. };
  97127. }
  97128. declare module BABYLON {
  97129. /**
  97130. * Line mesh
  97131. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97132. */
  97133. export class LinesMesh extends Mesh {
  97134. /**
  97135. * If vertex color should be applied to the mesh
  97136. */
  97137. readonly useVertexColor?: boolean | undefined;
  97138. /**
  97139. * If vertex alpha should be applied to the mesh
  97140. */
  97141. readonly useVertexAlpha?: boolean | undefined;
  97142. /**
  97143. * Color of the line (Default: White)
  97144. */
  97145. color: Color3;
  97146. /**
  97147. * Alpha of the line (Default: 1)
  97148. */
  97149. alpha: number;
  97150. /**
  97151. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97152. * This margin is expressed in world space coordinates, so its value may vary.
  97153. * Default value is 0.1
  97154. */
  97155. intersectionThreshold: number;
  97156. private _colorShader;
  97157. private color4;
  97158. /**
  97159. * Creates a new LinesMesh
  97160. * @param name defines the name
  97161. * @param scene defines the hosting scene
  97162. * @param parent defines the parent mesh if any
  97163. * @param source defines the optional source LinesMesh used to clone data from
  97164. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97165. * When false, achieved by calling a clone(), also passing False.
  97166. * This will make creation of children, recursive.
  97167. * @param useVertexColor defines if this LinesMesh supports vertex color
  97168. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97169. */
  97170. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97171. /**
  97172. * If vertex color should be applied to the mesh
  97173. */
  97174. useVertexColor?: boolean | undefined,
  97175. /**
  97176. * If vertex alpha should be applied to the mesh
  97177. */
  97178. useVertexAlpha?: boolean | undefined);
  97179. private _addClipPlaneDefine;
  97180. private _removeClipPlaneDefine;
  97181. isReady(): boolean;
  97182. /**
  97183. * Returns the string "LineMesh"
  97184. */
  97185. getClassName(): string;
  97186. /**
  97187. * @hidden
  97188. */
  97189. get material(): Material;
  97190. /**
  97191. * @hidden
  97192. */
  97193. set material(value: Material);
  97194. /**
  97195. * @hidden
  97196. */
  97197. get checkCollisions(): boolean;
  97198. /** @hidden */
  97199. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97200. /** @hidden */
  97201. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97202. /**
  97203. * Disposes of the line mesh
  97204. * @param doNotRecurse If children should be disposed
  97205. */
  97206. dispose(doNotRecurse?: boolean): void;
  97207. /**
  97208. * Returns a new LineMesh object cloned from the current one.
  97209. */
  97210. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97211. /**
  97212. * Creates a new InstancedLinesMesh object from the mesh model.
  97213. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97214. * @param name defines the name of the new instance
  97215. * @returns a new InstancedLinesMesh
  97216. */
  97217. createInstance(name: string): InstancedLinesMesh;
  97218. }
  97219. /**
  97220. * Creates an instance based on a source LinesMesh
  97221. */
  97222. export class InstancedLinesMesh extends InstancedMesh {
  97223. /**
  97224. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97225. * This margin is expressed in world space coordinates, so its value may vary.
  97226. * Initilized with the intersectionThreshold value of the source LinesMesh
  97227. */
  97228. intersectionThreshold: number;
  97229. constructor(name: string, source: LinesMesh);
  97230. /**
  97231. * Returns the string "InstancedLinesMesh".
  97232. */
  97233. getClassName(): string;
  97234. }
  97235. }
  97236. declare module BABYLON {
  97237. /** @hidden */
  97238. export var linePixelShader: {
  97239. name: string;
  97240. shader: string;
  97241. };
  97242. }
  97243. declare module BABYLON {
  97244. /** @hidden */
  97245. export var lineVertexShader: {
  97246. name: string;
  97247. shader: string;
  97248. };
  97249. }
  97250. declare module BABYLON {
  97251. interface Scene {
  97252. /** @hidden */
  97253. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97254. }
  97255. interface AbstractMesh {
  97256. /**
  97257. * Gets the edgesRenderer associated with the mesh
  97258. */
  97259. edgesRenderer: Nullable<EdgesRenderer>;
  97260. }
  97261. interface LinesMesh {
  97262. /**
  97263. * Enables the edge rendering mode on the mesh.
  97264. * This mode makes the mesh edges visible
  97265. * @param epsilon defines the maximal distance between two angles to detect a face
  97266. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97267. * @returns the currentAbstractMesh
  97268. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97269. */
  97270. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97271. }
  97272. interface InstancedLinesMesh {
  97273. /**
  97274. * Enables the edge rendering mode on the mesh.
  97275. * This mode makes the mesh edges visible
  97276. * @param epsilon defines the maximal distance between two angles to detect a face
  97277. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97278. * @returns the current InstancedLinesMesh
  97279. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97280. */
  97281. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97282. }
  97283. /**
  97284. * Defines the minimum contract an Edges renderer should follow.
  97285. */
  97286. export interface IEdgesRenderer extends IDisposable {
  97287. /**
  97288. * Gets or sets a boolean indicating if the edgesRenderer is active
  97289. */
  97290. isEnabled: boolean;
  97291. /**
  97292. * Renders the edges of the attached mesh,
  97293. */
  97294. render(): void;
  97295. /**
  97296. * Checks wether or not the edges renderer is ready to render.
  97297. * @return true if ready, otherwise false.
  97298. */
  97299. isReady(): boolean;
  97300. /**
  97301. * List of instances to render in case the source mesh has instances
  97302. */
  97303. customInstances: SmartArray<Matrix>;
  97304. }
  97305. /**
  97306. * Defines the additional options of the edges renderer
  97307. */
  97308. export interface IEdgesRendererOptions {
  97309. /**
  97310. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97311. * If not defined, the default value is true
  97312. */
  97313. useAlternateEdgeFinder?: boolean;
  97314. /**
  97315. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97316. * If not defined, the default value is true.
  97317. * You should normally leave it undefined (or set it to true), except if you see some artifacts in the edges rendering (can happen with complex geometries)
  97318. * This option is used only if useAlternateEdgeFinder = true
  97319. */
  97320. useFastVertexMerger?: boolean;
  97321. /**
  97322. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97323. * The default value is 1e-6
  97324. * This option is used only if useAlternateEdgeFinder = true
  97325. */
  97326. epsilonVertexMerge?: number;
  97327. /**
  97328. * Gets or sets a boolean indicating that tessellation should be applied before finding the edges. You may need to activate this option if your geometry is a bit
  97329. * unusual, like having a vertex of a triangle in-between two vertices of an edge of another triangle. It happens often when using CSG to construct meshes.
  97330. * This option is used only if useAlternateEdgeFinder = true
  97331. */
  97332. applyTessellation?: boolean;
  97333. /**
  97334. * The limit under which 3 vertices are considered to be aligned. 3 vertices PQR are considered aligned if distance(PQ) + distance(QR) - distance(PR) < epsilonVertexAligned
  97335. * The default value is 1e-6
  97336. * This option is used only if useAlternateEdgeFinder = true
  97337. */
  97338. epsilonVertexAligned?: number;
  97339. }
  97340. /**
  97341. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97342. */
  97343. export class EdgesRenderer implements IEdgesRenderer {
  97344. /**
  97345. * Define the size of the edges with an orthographic camera
  97346. */
  97347. edgesWidthScalerForOrthographic: number;
  97348. /**
  97349. * Define the size of the edges with a perspective camera
  97350. */
  97351. edgesWidthScalerForPerspective: number;
  97352. protected _source: AbstractMesh;
  97353. protected _linesPositions: number[];
  97354. protected _linesNormals: number[];
  97355. protected _linesIndices: number[];
  97356. protected _epsilon: number;
  97357. protected _indicesCount: number;
  97358. protected _lineShader: ShaderMaterial;
  97359. protected _ib: DataBuffer;
  97360. protected _buffers: {
  97361. [key: string]: Nullable<VertexBuffer>;
  97362. };
  97363. protected _buffersForInstances: {
  97364. [key: string]: Nullable<VertexBuffer>;
  97365. };
  97366. protected _checkVerticesInsteadOfIndices: boolean;
  97367. protected _options: Nullable<IEdgesRendererOptions>;
  97368. private _meshRebuildObserver;
  97369. private _meshDisposeObserver;
  97370. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97371. isEnabled: boolean;
  97372. /**
  97373. * List of instances to render in case the source mesh has instances
  97374. */
  97375. customInstances: SmartArray<Matrix>;
  97376. private static GetShader;
  97377. /**
  97378. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97379. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97380. * @param source Mesh used to create edges
  97381. * @param epsilon sum of angles in adjacency to check for edge
  97382. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97383. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97384. * @param options The options to apply when generating the edges
  97385. */
  97386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97387. protected _prepareRessources(): void;
  97388. /** @hidden */
  97389. _rebuild(): void;
  97390. /**
  97391. * Releases the required resources for the edges renderer
  97392. */
  97393. dispose(): void;
  97394. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97395. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97396. /**
  97397. * Checks if the pair of p0 and p1 is en edge
  97398. * @param faceIndex
  97399. * @param edge
  97400. * @param faceNormals
  97401. * @param p0
  97402. * @param p1
  97403. * @private
  97404. */
  97405. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97406. /**
  97407. * push line into the position, normal and index buffer
  97408. * @protected
  97409. */
  97410. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97411. /**
  97412. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97413. */
  97414. private _tessellateTriangle;
  97415. private _generateEdgesLinesAlternate;
  97416. /**
  97417. * Generates lines edges from adjacencjes
  97418. * @private
  97419. */
  97420. _generateEdgesLines(): void;
  97421. /**
  97422. * Checks wether or not the edges renderer is ready to render.
  97423. * @return true if ready, otherwise false.
  97424. */
  97425. isReady(): boolean;
  97426. /**
  97427. * Renders the edges of the attached mesh,
  97428. */
  97429. render(): void;
  97430. }
  97431. /**
  97432. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97433. */
  97434. export class LineEdgesRenderer extends EdgesRenderer {
  97435. /**
  97436. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97437. * @param source LineMesh used to generate edges
  97438. * @param epsilon not important (specified angle for edge detection)
  97439. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97440. */
  97441. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97442. /**
  97443. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97444. */
  97445. _generateEdgesLines(): void;
  97446. }
  97447. }
  97448. declare module BABYLON {
  97449. /**
  97450. * This represents the object necessary to create a rendering group.
  97451. * This is exclusively used and created by the rendering manager.
  97452. * To modify the behavior, you use the available helpers in your scene or meshes.
  97453. * @hidden
  97454. */
  97455. export class RenderingGroup {
  97456. index: number;
  97457. private static _zeroVector;
  97458. private _scene;
  97459. private _opaqueSubMeshes;
  97460. private _transparentSubMeshes;
  97461. private _alphaTestSubMeshes;
  97462. private _depthOnlySubMeshes;
  97463. private _particleSystems;
  97464. private _spriteManagers;
  97465. private _opaqueSortCompareFn;
  97466. private _alphaTestSortCompareFn;
  97467. private _transparentSortCompareFn;
  97468. private _renderOpaque;
  97469. private _renderAlphaTest;
  97470. private _renderTransparent;
  97471. /** @hidden */
  97472. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97473. onBeforeTransparentRendering: () => void;
  97474. /**
  97475. * Set the opaque sort comparison function.
  97476. * If null the sub meshes will be render in the order they were created
  97477. */
  97478. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97479. /**
  97480. * Set the alpha test sort comparison function.
  97481. * If null the sub meshes will be render in the order they were created
  97482. */
  97483. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97484. /**
  97485. * Set the transparent sort comparison function.
  97486. * If null the sub meshes will be render in the order they were created
  97487. */
  97488. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97489. /**
  97490. * Creates a new rendering group.
  97491. * @param index The rendering group index
  97492. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97493. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97494. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97495. */
  97496. 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>);
  97497. /**
  97498. * Render all the sub meshes contained in the group.
  97499. * @param customRenderFunction Used to override the default render behaviour of the group.
  97500. * @returns true if rendered some submeshes.
  97501. */
  97502. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97503. /**
  97504. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97505. * @param subMeshes The submeshes to render
  97506. */
  97507. private renderOpaqueSorted;
  97508. /**
  97509. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97510. * @param subMeshes The submeshes to render
  97511. */
  97512. private renderAlphaTestSorted;
  97513. /**
  97514. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97515. * @param subMeshes The submeshes to render
  97516. */
  97517. private renderTransparentSorted;
  97518. /**
  97519. * Renders the submeshes in a specified order.
  97520. * @param subMeshes The submeshes to sort before render
  97521. * @param sortCompareFn The comparison function use to sort
  97522. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97523. * @param transparent Specifies to activate blending if true
  97524. */
  97525. private static renderSorted;
  97526. /**
  97527. * Renders the submeshes in the order they were dispatched (no sort applied).
  97528. * @param subMeshes The submeshes to render
  97529. */
  97530. private static renderUnsorted;
  97531. /**
  97532. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97533. * are rendered back to front if in the same alpha index.
  97534. *
  97535. * @param a The first submesh
  97536. * @param b The second submesh
  97537. * @returns The result of the comparison
  97538. */
  97539. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97540. /**
  97541. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97542. * are rendered back to front.
  97543. *
  97544. * @param a The first submesh
  97545. * @param b The second submesh
  97546. * @returns The result of the comparison
  97547. */
  97548. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97549. /**
  97550. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97551. * are rendered front to back (prevent overdraw).
  97552. *
  97553. * @param a The first submesh
  97554. * @param b The second submesh
  97555. * @returns The result of the comparison
  97556. */
  97557. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97558. /**
  97559. * Resets the different lists of submeshes to prepare a new frame.
  97560. */
  97561. prepare(): void;
  97562. dispose(): void;
  97563. /**
  97564. * Inserts the submesh in its correct queue depending on its material.
  97565. * @param subMesh The submesh to dispatch
  97566. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97567. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97568. */
  97569. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97570. dispatchSprites(spriteManager: ISpriteManager): void;
  97571. dispatchParticles(particleSystem: IParticleSystem): void;
  97572. private _renderParticles;
  97573. private _renderSprites;
  97574. }
  97575. }
  97576. declare module BABYLON {
  97577. /**
  97578. * Interface describing the different options available in the rendering manager
  97579. * regarding Auto Clear between groups.
  97580. */
  97581. export interface IRenderingManagerAutoClearSetup {
  97582. /**
  97583. * Defines whether or not autoclear is enable.
  97584. */
  97585. autoClear: boolean;
  97586. /**
  97587. * Defines whether or not to autoclear the depth buffer.
  97588. */
  97589. depth: boolean;
  97590. /**
  97591. * Defines whether or not to autoclear the stencil buffer.
  97592. */
  97593. stencil: boolean;
  97594. }
  97595. /**
  97596. * This class is used by the onRenderingGroupObservable
  97597. */
  97598. export class RenderingGroupInfo {
  97599. /**
  97600. * The Scene that being rendered
  97601. */
  97602. scene: Scene;
  97603. /**
  97604. * The camera currently used for the rendering pass
  97605. */
  97606. camera: Nullable<Camera>;
  97607. /**
  97608. * The ID of the renderingGroup being processed
  97609. */
  97610. renderingGroupId: number;
  97611. }
  97612. /**
  97613. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97614. * It is enable to manage the different groups as well as the different necessary sort functions.
  97615. * This should not be used directly aside of the few static configurations
  97616. */
  97617. export class RenderingManager {
  97618. /**
  97619. * The max id used for rendering groups (not included)
  97620. */
  97621. static MAX_RENDERINGGROUPS: number;
  97622. /**
  97623. * The min id used for rendering groups (included)
  97624. */
  97625. static MIN_RENDERINGGROUPS: number;
  97626. /**
  97627. * Used to globally prevent autoclearing scenes.
  97628. */
  97629. static AUTOCLEAR: boolean;
  97630. /**
  97631. * @hidden
  97632. */
  97633. _useSceneAutoClearSetup: boolean;
  97634. private _scene;
  97635. private _renderingGroups;
  97636. private _depthStencilBufferAlreadyCleaned;
  97637. private _autoClearDepthStencil;
  97638. private _customOpaqueSortCompareFn;
  97639. private _customAlphaTestSortCompareFn;
  97640. private _customTransparentSortCompareFn;
  97641. private _renderingGroupInfo;
  97642. /**
  97643. * Instantiates a new rendering group for a particular scene
  97644. * @param scene Defines the scene the groups belongs to
  97645. */
  97646. constructor(scene: Scene);
  97647. private _clearDepthStencilBuffer;
  97648. /**
  97649. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97650. * @hidden
  97651. */
  97652. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97653. /**
  97654. * Resets the different information of the group to prepare a new frame
  97655. * @hidden
  97656. */
  97657. reset(): void;
  97658. /**
  97659. * Dispose and release the group and its associated resources.
  97660. * @hidden
  97661. */
  97662. dispose(): void;
  97663. /**
  97664. * Clear the info related to rendering groups preventing retention points during dispose.
  97665. */
  97666. freeRenderingGroups(): void;
  97667. private _prepareRenderingGroup;
  97668. /**
  97669. * Add a sprite manager to the rendering manager in order to render it this frame.
  97670. * @param spriteManager Define the sprite manager to render
  97671. */
  97672. dispatchSprites(spriteManager: ISpriteManager): void;
  97673. /**
  97674. * Add a particle system to the rendering manager in order to render it this frame.
  97675. * @param particleSystem Define the particle system to render
  97676. */
  97677. dispatchParticles(particleSystem: IParticleSystem): void;
  97678. /**
  97679. * Add a submesh to the manager in order to render it this frame
  97680. * @param subMesh The submesh to dispatch
  97681. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97682. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97683. */
  97684. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97685. /**
  97686. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97687. * This allowed control for front to back rendering or reversly depending of the special needs.
  97688. *
  97689. * @param renderingGroupId The rendering group id corresponding to its index
  97690. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97691. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97692. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97693. */
  97694. 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;
  97695. /**
  97696. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97697. *
  97698. * @param renderingGroupId The rendering group id corresponding to its index
  97699. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97700. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97701. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97702. */
  97703. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97704. /**
  97705. * Gets the current auto clear configuration for one rendering group of the rendering
  97706. * manager.
  97707. * @param index the rendering group index to get the information for
  97708. * @returns The auto clear setup for the requested rendering group
  97709. */
  97710. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97711. }
  97712. }
  97713. declare module BABYLON {
  97714. /**
  97715. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97716. */
  97717. export interface ICustomShaderOptions {
  97718. /**
  97719. * Gets or sets the custom shader name to use
  97720. */
  97721. shaderName: string;
  97722. /**
  97723. * The list of attribute names used in the shader
  97724. */
  97725. attributes?: string[];
  97726. /**
  97727. * The list of unifrom names used in the shader
  97728. */
  97729. uniforms?: string[];
  97730. /**
  97731. * The list of sampler names used in the shader
  97732. */
  97733. samplers?: string[];
  97734. /**
  97735. * The list of defines used in the shader
  97736. */
  97737. defines?: string[];
  97738. }
  97739. /**
  97740. * Interface to implement to create a shadow generator compatible with BJS.
  97741. */
  97742. export interface IShadowGenerator {
  97743. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97744. id: string;
  97745. /**
  97746. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97747. * @returns The render target texture if present otherwise, null
  97748. */
  97749. getShadowMap(): Nullable<RenderTargetTexture>;
  97750. /**
  97751. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97752. * @param subMesh The submesh we want to render in the shadow map
  97753. * @param useInstances Defines wether will draw in the map using instances
  97754. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97755. * @returns true if ready otherwise, false
  97756. */
  97757. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  97758. /**
  97759. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  97760. * @param defines Defines of the material we want to update
  97761. * @param lightIndex Index of the light in the enabled light list of the material
  97762. */
  97763. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  97764. /**
  97765. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  97766. * defined in the generator but impacting the effect).
  97767. * It implies the unifroms available on the materials are the standard BJS ones.
  97768. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  97769. * @param effect The effect we are binfing the information for
  97770. */
  97771. bindShadowLight(lightIndex: string, effect: Effect): void;
  97772. /**
  97773. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  97774. * (eq to shadow prjection matrix * light transform matrix)
  97775. * @returns The transform matrix used to create the shadow map
  97776. */
  97777. getTransformMatrix(): Matrix;
  97778. /**
  97779. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  97780. * Cube and 2D textures for instance.
  97781. */
  97782. recreateShadowMap(): void;
  97783. /**
  97784. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97785. * @param onCompiled Callback triggered at the and of the effects compilation
  97786. * @param options Sets of optional options forcing the compilation with different modes
  97787. */
  97788. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  97789. useInstances: boolean;
  97790. }>): void;
  97791. /**
  97792. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  97793. * @param options Sets of optional options forcing the compilation with different modes
  97794. * @returns A promise that resolves when the compilation completes
  97795. */
  97796. forceCompilationAsync(options?: Partial<{
  97797. useInstances: boolean;
  97798. }>): Promise<void>;
  97799. /**
  97800. * Serializes the shadow generator setup to a json object.
  97801. * @returns The serialized JSON object
  97802. */
  97803. serialize(): any;
  97804. /**
  97805. * Disposes the Shadow map and related Textures and effects.
  97806. */
  97807. dispose(): void;
  97808. }
  97809. /**
  97810. * Default implementation IShadowGenerator.
  97811. * This is the main object responsible of generating shadows in the framework.
  97812. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  97813. */
  97814. export class ShadowGenerator implements IShadowGenerator {
  97815. /**
  97816. * Name of the shadow generator class
  97817. */
  97818. static CLASSNAME: string;
  97819. /**
  97820. * Shadow generator mode None: no filtering applied.
  97821. */
  97822. static readonly FILTER_NONE: number;
  97823. /**
  97824. * Shadow generator mode ESM: Exponential Shadow Mapping.
  97825. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97826. */
  97827. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  97828. /**
  97829. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  97830. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  97831. */
  97832. static readonly FILTER_POISSONSAMPLING: number;
  97833. /**
  97834. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  97835. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97836. */
  97837. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  97838. /**
  97839. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  97840. * edge artifacts on steep falloff.
  97841. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97842. */
  97843. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  97844. /**
  97845. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  97846. * edge artifacts on steep falloff.
  97847. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  97848. */
  97849. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  97850. /**
  97851. * Shadow generator mode PCF: Percentage Closer Filtering
  97852. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97853. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  97854. */
  97855. static readonly FILTER_PCF: number;
  97856. /**
  97857. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  97858. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  97859. * Contact Hardening
  97860. */
  97861. static readonly FILTER_PCSS: number;
  97862. /**
  97863. * Reserved for PCF and PCSS
  97864. * Highest Quality.
  97865. *
  97866. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  97867. *
  97868. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  97869. */
  97870. static readonly QUALITY_HIGH: number;
  97871. /**
  97872. * Reserved for PCF and PCSS
  97873. * Good tradeoff for quality/perf cross devices
  97874. *
  97875. * Execute PCF on a 3*3 kernel.
  97876. *
  97877. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  97878. */
  97879. static readonly QUALITY_MEDIUM: number;
  97880. /**
  97881. * Reserved for PCF and PCSS
  97882. * The lowest quality but the fastest.
  97883. *
  97884. * Execute PCF on a 1*1 kernel.
  97885. *
  97886. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  97887. */
  97888. static readonly QUALITY_LOW: number;
  97889. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97890. id: string;
  97891. /** Gets or sets the custom shader name to use */
  97892. customShaderOptions: ICustomShaderOptions;
  97893. /**
  97894. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  97895. */
  97896. onBeforeShadowMapRenderObservable: Observable<Effect>;
  97897. /**
  97898. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  97899. */
  97900. onAfterShadowMapRenderObservable: Observable<Effect>;
  97901. /**
  97902. * Observable triggered before a mesh is rendered in the shadow map.
  97903. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  97904. */
  97905. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  97906. /**
  97907. * Observable triggered after a mesh is rendered in the shadow map.
  97908. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  97909. */
  97910. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  97911. protected _bias: number;
  97912. /**
  97913. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  97914. */
  97915. get bias(): number;
  97916. /**
  97917. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  97918. */
  97919. set bias(bias: number);
  97920. protected _normalBias: number;
  97921. /**
  97922. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97923. */
  97924. get normalBias(): number;
  97925. /**
  97926. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  97927. */
  97928. set normalBias(normalBias: number);
  97929. protected _blurBoxOffset: number;
  97930. /**
  97931. * Gets the blur box offset: offset applied during the blur pass.
  97932. * Only useful if useKernelBlur = false
  97933. */
  97934. get blurBoxOffset(): number;
  97935. /**
  97936. * Sets the blur box offset: offset applied during the blur pass.
  97937. * Only useful if useKernelBlur = false
  97938. */
  97939. set blurBoxOffset(value: number);
  97940. protected _blurScale: number;
  97941. /**
  97942. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  97943. * 2 means half of the size.
  97944. */
  97945. get blurScale(): number;
  97946. /**
  97947. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  97948. * 2 means half of the size.
  97949. */
  97950. set blurScale(value: number);
  97951. protected _blurKernel: number;
  97952. /**
  97953. * Gets the blur kernel: kernel size of the blur pass.
  97954. * Only useful if useKernelBlur = true
  97955. */
  97956. get blurKernel(): number;
  97957. /**
  97958. * Sets the blur kernel: kernel size of the blur pass.
  97959. * Only useful if useKernelBlur = true
  97960. */
  97961. set blurKernel(value: number);
  97962. protected _useKernelBlur: boolean;
  97963. /**
  97964. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  97965. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97966. */
  97967. get useKernelBlur(): boolean;
  97968. /**
  97969. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  97970. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  97971. */
  97972. set useKernelBlur(value: boolean);
  97973. protected _depthScale: number;
  97974. /**
  97975. * Gets the depth scale used in ESM mode.
  97976. */
  97977. get depthScale(): number;
  97978. /**
  97979. * Sets the depth scale used in ESM mode.
  97980. * This can override the scale stored on the light.
  97981. */
  97982. set depthScale(value: number);
  97983. protected _validateFilter(filter: number): number;
  97984. protected _filter: number;
  97985. /**
  97986. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  97987. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97988. */
  97989. get filter(): number;
  97990. /**
  97991. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  97992. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  97993. */
  97994. set filter(value: number);
  97995. /**
  97996. * Gets if the current filter is set to Poisson Sampling.
  97997. */
  97998. get usePoissonSampling(): boolean;
  97999. /**
  98000. * Sets the current filter to Poisson Sampling.
  98001. */
  98002. set usePoissonSampling(value: boolean);
  98003. /**
  98004. * Gets if the current filter is set to ESM.
  98005. */
  98006. get useExponentialShadowMap(): boolean;
  98007. /**
  98008. * Sets the current filter is to ESM.
  98009. */
  98010. set useExponentialShadowMap(value: boolean);
  98011. /**
  98012. * Gets if the current filter is set to filtered ESM.
  98013. */
  98014. get useBlurExponentialShadowMap(): boolean;
  98015. /**
  98016. * Gets if the current filter is set to filtered ESM.
  98017. */
  98018. set useBlurExponentialShadowMap(value: boolean);
  98019. /**
  98020. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98021. * exponential to prevent steep falloff artifacts).
  98022. */
  98023. get useCloseExponentialShadowMap(): boolean;
  98024. /**
  98025. * Sets the current filter to "close ESM" (using the inverse of the
  98026. * exponential to prevent steep falloff artifacts).
  98027. */
  98028. set useCloseExponentialShadowMap(value: boolean);
  98029. /**
  98030. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98031. * exponential to prevent steep falloff artifacts).
  98032. */
  98033. get useBlurCloseExponentialShadowMap(): boolean;
  98034. /**
  98035. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98036. * exponential to prevent steep falloff artifacts).
  98037. */
  98038. set useBlurCloseExponentialShadowMap(value: boolean);
  98039. /**
  98040. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98041. */
  98042. get usePercentageCloserFiltering(): boolean;
  98043. /**
  98044. * Sets the current filter to "PCF" (percentage closer filtering).
  98045. */
  98046. set usePercentageCloserFiltering(value: boolean);
  98047. protected _filteringQuality: number;
  98048. /**
  98049. * Gets the PCF or PCSS Quality.
  98050. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98051. */
  98052. get filteringQuality(): number;
  98053. /**
  98054. * Sets the PCF or PCSS Quality.
  98055. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98056. */
  98057. set filteringQuality(filteringQuality: number);
  98058. /**
  98059. * Gets if the current filter is set to "PCSS" (contact hardening).
  98060. */
  98061. get useContactHardeningShadow(): boolean;
  98062. /**
  98063. * Sets the current filter to "PCSS" (contact hardening).
  98064. */
  98065. set useContactHardeningShadow(value: boolean);
  98066. protected _contactHardeningLightSizeUVRatio: number;
  98067. /**
  98068. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98069. * Using a ratio helps keeping shape stability independently of the map size.
  98070. *
  98071. * It does not account for the light projection as it was having too much
  98072. * instability during the light setup or during light position changes.
  98073. *
  98074. * Only valid if useContactHardeningShadow is true.
  98075. */
  98076. get contactHardeningLightSizeUVRatio(): number;
  98077. /**
  98078. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98079. * Using a ratio helps keeping shape stability independently of the map size.
  98080. *
  98081. * It does not account for the light projection as it was having too much
  98082. * instability during the light setup or during light position changes.
  98083. *
  98084. * Only valid if useContactHardeningShadow is true.
  98085. */
  98086. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98087. protected _darkness: number;
  98088. /** Gets or sets the actual darkness of a shadow */
  98089. get darkness(): number;
  98090. set darkness(value: number);
  98091. /**
  98092. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98093. * 0 means strongest and 1 would means no shadow.
  98094. * @returns the darkness.
  98095. */
  98096. getDarkness(): number;
  98097. /**
  98098. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98099. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98100. * @returns the shadow generator allowing fluent coding.
  98101. */
  98102. setDarkness(darkness: number): ShadowGenerator;
  98103. protected _transparencyShadow: boolean;
  98104. /** Gets or sets the ability to have transparent shadow */
  98105. get transparencyShadow(): boolean;
  98106. set transparencyShadow(value: boolean);
  98107. /**
  98108. * Sets the ability to have transparent shadow (boolean).
  98109. * @param transparent True if transparent else False
  98110. * @returns the shadow generator allowing fluent coding
  98111. */
  98112. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98113. /**
  98114. * Enables or disables shadows with varying strength based on the transparency
  98115. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98116. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98117. * mesh.visibility * alphaTexture.a
  98118. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98119. */
  98120. enableSoftTransparentShadow: boolean;
  98121. protected _shadowMap: Nullable<RenderTargetTexture>;
  98122. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98123. /**
  98124. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98125. * @returns The render target texture if present otherwise, null
  98126. */
  98127. getShadowMap(): Nullable<RenderTargetTexture>;
  98128. /**
  98129. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98130. * @returns The render target texture if the shadow map is present otherwise, null
  98131. */
  98132. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98133. /**
  98134. * Gets the class name of that object
  98135. * @returns "ShadowGenerator"
  98136. */
  98137. getClassName(): string;
  98138. /**
  98139. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98140. * @param mesh Mesh to add
  98141. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98142. * @returns the Shadow Generator itself
  98143. */
  98144. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98145. /**
  98146. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98147. * @param mesh Mesh to remove
  98148. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98149. * @returns the Shadow Generator itself
  98150. */
  98151. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98152. /**
  98153. * Controls the extent to which the shadows fade out at the edge of the frustum
  98154. */
  98155. frustumEdgeFalloff: number;
  98156. protected _light: IShadowLight;
  98157. /**
  98158. * Returns the associated light object.
  98159. * @returns the light generating the shadow
  98160. */
  98161. getLight(): IShadowLight;
  98162. /**
  98163. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98164. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98165. * It might on the other hand introduce peter panning.
  98166. */
  98167. forceBackFacesOnly: boolean;
  98168. protected _scene: Scene;
  98169. protected _lightDirection: Vector3;
  98170. protected _effect: Effect;
  98171. protected _viewMatrix: Matrix;
  98172. protected _projectionMatrix: Matrix;
  98173. protected _transformMatrix: Matrix;
  98174. protected _cachedPosition: Vector3;
  98175. protected _cachedDirection: Vector3;
  98176. protected _cachedDefines: string;
  98177. protected _currentRenderID: number;
  98178. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98179. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98180. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98181. protected _blurPostProcesses: PostProcess[];
  98182. protected _mapSize: number;
  98183. protected _currentFaceIndex: number;
  98184. protected _currentFaceIndexCache: number;
  98185. protected _textureType: number;
  98186. protected _defaultTextureMatrix: Matrix;
  98187. protected _storedUniqueId: Nullable<number>;
  98188. /** @hidden */
  98189. static _SceneComponentInitialization: (scene: Scene) => void;
  98190. /**
  98191. * Creates a ShadowGenerator object.
  98192. * A ShadowGenerator is the required tool to use the shadows.
  98193. * Each light casting shadows needs to use its own ShadowGenerator.
  98194. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98195. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98196. * @param light The light object generating the shadows.
  98197. * @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.
  98198. */
  98199. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98200. protected _initializeGenerator(): void;
  98201. protected _createTargetRenderTexture(): void;
  98202. protected _initializeShadowMap(): void;
  98203. protected _initializeBlurRTTAndPostProcesses(): void;
  98204. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98205. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98206. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98207. protected _applyFilterValues(): void;
  98208. /**
  98209. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98210. * @param onCompiled Callback triggered at the and of the effects compilation
  98211. * @param options Sets of optional options forcing the compilation with different modes
  98212. */
  98213. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98214. useInstances: boolean;
  98215. }>): void;
  98216. /**
  98217. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98218. * @param options Sets of optional options forcing the compilation with different modes
  98219. * @returns A promise that resolves when the compilation completes
  98220. */
  98221. forceCompilationAsync(options?: Partial<{
  98222. useInstances: boolean;
  98223. }>): Promise<void>;
  98224. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98225. private _prepareShadowDefines;
  98226. /**
  98227. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98228. * @param subMesh The submesh we want to render in the shadow map
  98229. * @param useInstances Defines wether will draw in the map using instances
  98230. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98231. * @returns true if ready otherwise, false
  98232. */
  98233. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98234. /**
  98235. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98236. * @param defines Defines of the material we want to update
  98237. * @param lightIndex Index of the light in the enabled light list of the material
  98238. */
  98239. prepareDefines(defines: any, lightIndex: number): void;
  98240. /**
  98241. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98242. * defined in the generator but impacting the effect).
  98243. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98244. * @param effect The effect we are binfing the information for
  98245. */
  98246. bindShadowLight(lightIndex: string, effect: Effect): void;
  98247. /**
  98248. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98249. * (eq to shadow prjection matrix * light transform matrix)
  98250. * @returns The transform matrix used to create the shadow map
  98251. */
  98252. getTransformMatrix(): Matrix;
  98253. /**
  98254. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98255. * Cube and 2D textures for instance.
  98256. */
  98257. recreateShadowMap(): void;
  98258. protected _disposeBlurPostProcesses(): void;
  98259. protected _disposeRTTandPostProcesses(): void;
  98260. /**
  98261. * Disposes the ShadowGenerator.
  98262. * Returns nothing.
  98263. */
  98264. dispose(): void;
  98265. /**
  98266. * Serializes the shadow generator setup to a json object.
  98267. * @returns The serialized JSON object
  98268. */
  98269. serialize(): any;
  98270. /**
  98271. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98272. * @param parsedShadowGenerator The JSON object to parse
  98273. * @param scene The scene to create the shadow map for
  98274. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98275. * @returns The parsed shadow generator
  98276. */
  98277. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98278. }
  98279. }
  98280. declare module BABYLON {
  98281. /**
  98282. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98283. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98284. * 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.
  98285. */
  98286. export abstract class Light extends Node {
  98287. /**
  98288. * Falloff Default: light is falling off following the material specification:
  98289. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98290. */
  98291. static readonly FALLOFF_DEFAULT: number;
  98292. /**
  98293. * Falloff Physical: light is falling off following the inverse squared distance law.
  98294. */
  98295. static readonly FALLOFF_PHYSICAL: number;
  98296. /**
  98297. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98298. * to enhance interoperability with other engines.
  98299. */
  98300. static readonly FALLOFF_GLTF: number;
  98301. /**
  98302. * Falloff Standard: light is falling off like in the standard material
  98303. * to enhance interoperability with other materials.
  98304. */
  98305. static readonly FALLOFF_STANDARD: number;
  98306. /**
  98307. * If every light affecting the material is in this lightmapMode,
  98308. * material.lightmapTexture adds or multiplies
  98309. * (depends on material.useLightmapAsShadowmap)
  98310. * after every other light calculations.
  98311. */
  98312. static readonly LIGHTMAP_DEFAULT: number;
  98313. /**
  98314. * material.lightmapTexture as only diffuse lighting from this light
  98315. * adds only specular lighting from this light
  98316. * adds dynamic shadows
  98317. */
  98318. static readonly LIGHTMAP_SPECULAR: number;
  98319. /**
  98320. * material.lightmapTexture as only lighting
  98321. * no light calculation from this light
  98322. * only adds dynamic shadows from this light
  98323. */
  98324. static readonly LIGHTMAP_SHADOWSONLY: number;
  98325. /**
  98326. * Each light type uses the default quantity according to its type:
  98327. * point/spot lights use luminous intensity
  98328. * directional lights use illuminance
  98329. */
  98330. static readonly INTENSITYMODE_AUTOMATIC: number;
  98331. /**
  98332. * lumen (lm)
  98333. */
  98334. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98335. /**
  98336. * candela (lm/sr)
  98337. */
  98338. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98339. /**
  98340. * lux (lm/m^2)
  98341. */
  98342. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98343. /**
  98344. * nit (cd/m^2)
  98345. */
  98346. static readonly INTENSITYMODE_LUMINANCE: number;
  98347. /**
  98348. * Light type const id of the point light.
  98349. */
  98350. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98351. /**
  98352. * Light type const id of the directional light.
  98353. */
  98354. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98355. /**
  98356. * Light type const id of the spot light.
  98357. */
  98358. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98359. /**
  98360. * Light type const id of the hemispheric light.
  98361. */
  98362. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98363. /**
  98364. * Diffuse gives the basic color to an object.
  98365. */
  98366. diffuse: Color3;
  98367. /**
  98368. * Specular produces a highlight color on an object.
  98369. * Note: This is note affecting PBR materials.
  98370. */
  98371. specular: Color3;
  98372. /**
  98373. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98374. * falling off base on range or angle.
  98375. * This can be set to any values in Light.FALLOFF_x.
  98376. *
  98377. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98378. * other types of materials.
  98379. */
  98380. falloffType: number;
  98381. /**
  98382. * Strength of the light.
  98383. * Note: By default it is define in the framework own unit.
  98384. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98385. */
  98386. intensity: number;
  98387. private _range;
  98388. protected _inverseSquaredRange: number;
  98389. /**
  98390. * Defines how far from the source the light is impacting in scene units.
  98391. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98392. */
  98393. get range(): number;
  98394. /**
  98395. * Defines how far from the source the light is impacting in scene units.
  98396. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98397. */
  98398. set range(value: number);
  98399. /**
  98400. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98401. * of light.
  98402. */
  98403. private _photometricScale;
  98404. private _intensityMode;
  98405. /**
  98406. * Gets the photometric scale used to interpret the intensity.
  98407. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98408. */
  98409. get intensityMode(): number;
  98410. /**
  98411. * Sets the photometric scale used to interpret the intensity.
  98412. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98413. */
  98414. set intensityMode(value: number);
  98415. private _radius;
  98416. /**
  98417. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98418. */
  98419. get radius(): number;
  98420. /**
  98421. * sets the light radius used by PBR Materials to simulate soft area lights.
  98422. */
  98423. set radius(value: number);
  98424. private _renderPriority;
  98425. /**
  98426. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98427. * exceeding the number allowed of the materials.
  98428. */
  98429. renderPriority: number;
  98430. private _shadowEnabled;
  98431. /**
  98432. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98433. * the current shadow generator.
  98434. */
  98435. get shadowEnabled(): boolean;
  98436. /**
  98437. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98438. * the current shadow generator.
  98439. */
  98440. set shadowEnabled(value: boolean);
  98441. private _includedOnlyMeshes;
  98442. /**
  98443. * Gets the only meshes impacted by this light.
  98444. */
  98445. get includedOnlyMeshes(): AbstractMesh[];
  98446. /**
  98447. * Sets the only meshes impacted by this light.
  98448. */
  98449. set includedOnlyMeshes(value: AbstractMesh[]);
  98450. private _excludedMeshes;
  98451. /**
  98452. * Gets the meshes not impacted by this light.
  98453. */
  98454. get excludedMeshes(): AbstractMesh[];
  98455. /**
  98456. * Sets the meshes not impacted by this light.
  98457. */
  98458. set excludedMeshes(value: AbstractMesh[]);
  98459. private _excludeWithLayerMask;
  98460. /**
  98461. * Gets the layer id use to find what meshes are not impacted by the light.
  98462. * Inactive if 0
  98463. */
  98464. get excludeWithLayerMask(): number;
  98465. /**
  98466. * Sets the layer id use to find what meshes are not impacted by the light.
  98467. * Inactive if 0
  98468. */
  98469. set excludeWithLayerMask(value: number);
  98470. private _includeOnlyWithLayerMask;
  98471. /**
  98472. * Gets the layer id use to find what meshes are impacted by the light.
  98473. * Inactive if 0
  98474. */
  98475. get includeOnlyWithLayerMask(): number;
  98476. /**
  98477. * Sets the layer id use to find what meshes are impacted by the light.
  98478. * Inactive if 0
  98479. */
  98480. set includeOnlyWithLayerMask(value: number);
  98481. private _lightmapMode;
  98482. /**
  98483. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98484. */
  98485. get lightmapMode(): number;
  98486. /**
  98487. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98488. */
  98489. set lightmapMode(value: number);
  98490. /**
  98491. * Shadow generator associted to the light.
  98492. * @hidden Internal use only.
  98493. */
  98494. _shadowGenerator: Nullable<IShadowGenerator>;
  98495. /**
  98496. * @hidden Internal use only.
  98497. */
  98498. _excludedMeshesIds: string[];
  98499. /**
  98500. * @hidden Internal use only.
  98501. */
  98502. _includedOnlyMeshesIds: string[];
  98503. /**
  98504. * The current light unifom buffer.
  98505. * @hidden Internal use only.
  98506. */
  98507. _uniformBuffer: UniformBuffer;
  98508. /** @hidden */
  98509. _renderId: number;
  98510. /**
  98511. * Creates a Light object in the scene.
  98512. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98513. * @param name The firendly name of the light
  98514. * @param scene The scene the light belongs too
  98515. */
  98516. constructor(name: string, scene: Scene);
  98517. protected abstract _buildUniformLayout(): void;
  98518. /**
  98519. * Sets the passed Effect "effect" with the Light information.
  98520. * @param effect The effect to update
  98521. * @param lightIndex The index of the light in the effect to update
  98522. * @returns The light
  98523. */
  98524. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98525. /**
  98526. * Sets the passed Effect "effect" with the Light textures.
  98527. * @param effect The effect to update
  98528. * @param lightIndex The index of the light in the effect to update
  98529. * @returns The light
  98530. */
  98531. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98532. /**
  98533. * Binds the lights information from the scene to the effect for the given mesh.
  98534. * @param lightIndex Light index
  98535. * @param scene The scene where the light belongs to
  98536. * @param effect The effect we are binding the data to
  98537. * @param useSpecular Defines if specular is supported
  98538. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98539. */
  98540. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98541. /**
  98542. * Sets the passed Effect "effect" with the Light information.
  98543. * @param effect The effect to update
  98544. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98545. * @returns The light
  98546. */
  98547. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98548. /**
  98549. * Returns the string "Light".
  98550. * @returns the class name
  98551. */
  98552. getClassName(): string;
  98553. /** @hidden */
  98554. readonly _isLight: boolean;
  98555. /**
  98556. * Converts the light information to a readable string for debug purpose.
  98557. * @param fullDetails Supports for multiple levels of logging within scene loading
  98558. * @returns the human readable light info
  98559. */
  98560. toString(fullDetails?: boolean): string;
  98561. /** @hidden */
  98562. protected _syncParentEnabledState(): void;
  98563. /**
  98564. * Set the enabled state of this node.
  98565. * @param value - the new enabled state
  98566. */
  98567. setEnabled(value: boolean): void;
  98568. /**
  98569. * Returns the Light associated shadow generator if any.
  98570. * @return the associated shadow generator.
  98571. */
  98572. getShadowGenerator(): Nullable<IShadowGenerator>;
  98573. /**
  98574. * Returns a Vector3, the absolute light position in the World.
  98575. * @returns the world space position of the light
  98576. */
  98577. getAbsolutePosition(): Vector3;
  98578. /**
  98579. * Specifies if the light will affect the passed mesh.
  98580. * @param mesh The mesh to test against the light
  98581. * @return true the mesh is affected otherwise, false.
  98582. */
  98583. canAffectMesh(mesh: AbstractMesh): boolean;
  98584. /**
  98585. * Sort function to order lights for rendering.
  98586. * @param a First Light object to compare to second.
  98587. * @param b Second Light object to compare first.
  98588. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98589. */
  98590. static CompareLightsPriority(a: Light, b: Light): number;
  98591. /**
  98592. * Releases resources associated with this node.
  98593. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98594. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98595. */
  98596. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98597. /**
  98598. * Returns the light type ID (integer).
  98599. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98600. */
  98601. getTypeID(): number;
  98602. /**
  98603. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98604. * @returns the scaled intensity in intensity mode unit
  98605. */
  98606. getScaledIntensity(): number;
  98607. /**
  98608. * Returns a new Light object, named "name", from the current one.
  98609. * @param name The name of the cloned light
  98610. * @param newParent The parent of this light, if it has one
  98611. * @returns the new created light
  98612. */
  98613. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98614. /**
  98615. * Serializes the current light into a Serialization object.
  98616. * @returns the serialized object.
  98617. */
  98618. serialize(): any;
  98619. /**
  98620. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98621. * This new light is named "name" and added to the passed scene.
  98622. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98623. * @param name The friendly name of the light
  98624. * @param scene The scene the new light will belong to
  98625. * @returns the constructor function
  98626. */
  98627. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98628. /**
  98629. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98630. * @param parsedLight The JSON representation of the light
  98631. * @param scene The scene to create the parsed light in
  98632. * @returns the created light after parsing
  98633. */
  98634. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98635. private _hookArrayForExcluded;
  98636. private _hookArrayForIncludedOnly;
  98637. private _resyncMeshes;
  98638. /**
  98639. * Forces the meshes to update their light related information in their rendering used effects
  98640. * @hidden Internal Use Only
  98641. */
  98642. _markMeshesAsLightDirty(): void;
  98643. /**
  98644. * Recomputes the cached photometric scale if needed.
  98645. */
  98646. private _computePhotometricScale;
  98647. /**
  98648. * Returns the Photometric Scale according to the light type and intensity mode.
  98649. */
  98650. private _getPhotometricScale;
  98651. /**
  98652. * Reorder the light in the scene according to their defined priority.
  98653. * @hidden Internal Use Only
  98654. */
  98655. _reorderLightsInScene(): void;
  98656. /**
  98657. * Prepares the list of defines specific to the light type.
  98658. * @param defines the list of defines
  98659. * @param lightIndex defines the index of the light for the effect
  98660. */
  98661. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98662. }
  98663. }
  98664. declare module BABYLON {
  98665. /**
  98666. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98667. * This is the base of the follow, arc rotate cameras and Free camera
  98668. * @see https://doc.babylonjs.com/features/cameras
  98669. */
  98670. export class TargetCamera extends Camera {
  98671. private static _RigCamTransformMatrix;
  98672. private static _TargetTransformMatrix;
  98673. private static _TargetFocalPoint;
  98674. private _tmpUpVector;
  98675. private _tmpTargetVector;
  98676. /**
  98677. * Define the current direction the camera is moving to
  98678. */
  98679. cameraDirection: Vector3;
  98680. /**
  98681. * Define the current rotation the camera is rotating to
  98682. */
  98683. cameraRotation: Vector2;
  98684. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98685. ignoreParentScaling: boolean;
  98686. /**
  98687. * When set, the up vector of the camera will be updated by the rotation of the camera
  98688. */
  98689. updateUpVectorFromRotation: boolean;
  98690. private _tmpQuaternion;
  98691. /**
  98692. * Define the current rotation of the camera
  98693. */
  98694. rotation: Vector3;
  98695. /**
  98696. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98697. */
  98698. rotationQuaternion: Quaternion;
  98699. /**
  98700. * Define the current speed of the camera
  98701. */
  98702. speed: number;
  98703. /**
  98704. * Add constraint to the camera to prevent it to move freely in all directions and
  98705. * around all axis.
  98706. */
  98707. noRotationConstraint: boolean;
  98708. /**
  98709. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98710. * panning
  98711. */
  98712. invertRotation: boolean;
  98713. /**
  98714. * Speed multiplier for inverse camera panning
  98715. */
  98716. inverseRotationSpeed: number;
  98717. /**
  98718. * Define the current target of the camera as an object or a position.
  98719. */
  98720. lockedTarget: any;
  98721. /** @hidden */
  98722. _currentTarget: Vector3;
  98723. /** @hidden */
  98724. _initialFocalDistance: number;
  98725. /** @hidden */
  98726. _viewMatrix: Matrix;
  98727. /** @hidden */
  98728. _camMatrix: Matrix;
  98729. /** @hidden */
  98730. _cameraTransformMatrix: Matrix;
  98731. /** @hidden */
  98732. _cameraRotationMatrix: Matrix;
  98733. /** @hidden */
  98734. _referencePoint: Vector3;
  98735. /** @hidden */
  98736. _transformedReferencePoint: Vector3;
  98737. /** @hidden */
  98738. _reset: () => void;
  98739. private _defaultUp;
  98740. /**
  98741. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  98742. * This is the base of the follow, arc rotate cameras and Free camera
  98743. * @see https://doc.babylonjs.com/features/cameras
  98744. * @param name Defines the name of the camera in the scene
  98745. * @param position Defines the start position of the camera in the scene
  98746. * @param scene Defines the scene the camera belongs to
  98747. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  98748. */
  98749. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98750. /**
  98751. * Gets the position in front of the camera at a given distance.
  98752. * @param distance The distance from the camera we want the position to be
  98753. * @returns the position
  98754. */
  98755. getFrontPosition(distance: number): Vector3;
  98756. /** @hidden */
  98757. _getLockedTargetPosition(): Nullable<Vector3>;
  98758. private _storedPosition;
  98759. private _storedRotation;
  98760. private _storedRotationQuaternion;
  98761. /**
  98762. * Store current camera state of the camera (fov, position, rotation, etc..)
  98763. * @returns the camera
  98764. */
  98765. storeState(): Camera;
  98766. /**
  98767. * Restored camera state. You must call storeState() first
  98768. * @returns whether it was successful or not
  98769. * @hidden
  98770. */
  98771. _restoreStateValues(): boolean;
  98772. /** @hidden */
  98773. _initCache(): void;
  98774. /** @hidden */
  98775. _updateCache(ignoreParentClass?: boolean): void;
  98776. /** @hidden */
  98777. _isSynchronizedViewMatrix(): boolean;
  98778. /** @hidden */
  98779. _computeLocalCameraSpeed(): number;
  98780. /**
  98781. * Defines the target the camera should look at.
  98782. * @param target Defines the new target as a Vector or a mesh
  98783. */
  98784. setTarget(target: Vector3): void;
  98785. /**
  98786. * Defines the target point of the camera.
  98787. * The camera looks towards it form the radius distance.
  98788. */
  98789. get target(): Vector3;
  98790. set target(value: Vector3);
  98791. /**
  98792. * Return the current target position of the camera. This value is expressed in local space.
  98793. * @returns the target position
  98794. */
  98795. getTarget(): Vector3;
  98796. /** @hidden */
  98797. _decideIfNeedsToMove(): boolean;
  98798. /** @hidden */
  98799. _updatePosition(): void;
  98800. /** @hidden */
  98801. _checkInputs(): void;
  98802. protected _updateCameraRotationMatrix(): void;
  98803. /**
  98804. * 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)
  98805. * @returns the current camera
  98806. */
  98807. private _rotateUpVectorWithCameraRotationMatrix;
  98808. private _cachedRotationZ;
  98809. private _cachedQuaternionRotationZ;
  98810. /** @hidden */
  98811. _getViewMatrix(): Matrix;
  98812. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  98813. /**
  98814. * @hidden
  98815. */
  98816. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  98817. /**
  98818. * @hidden
  98819. */
  98820. _updateRigCameras(): void;
  98821. private _getRigCamPositionAndTarget;
  98822. /**
  98823. * Gets the current object class name.
  98824. * @return the class name
  98825. */
  98826. getClassName(): string;
  98827. }
  98828. }
  98829. declare module BABYLON {
  98830. /**
  98831. * Gather the list of keyboard event types as constants.
  98832. */
  98833. export class KeyboardEventTypes {
  98834. /**
  98835. * The keydown event is fired when a key becomes active (pressed).
  98836. */
  98837. static readonly KEYDOWN: number;
  98838. /**
  98839. * The keyup event is fired when a key has been released.
  98840. */
  98841. static readonly KEYUP: number;
  98842. }
  98843. /**
  98844. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98845. */
  98846. export class KeyboardInfo {
  98847. /**
  98848. * Defines the type of event (KeyboardEventTypes)
  98849. */
  98850. type: number;
  98851. /**
  98852. * Defines the related dom event
  98853. */
  98854. event: KeyboardEvent;
  98855. /**
  98856. * Instantiates a new keyboard info.
  98857. * This class is used to store keyboard related info for the onKeyboardObservable event.
  98858. * @param type Defines the type of event (KeyboardEventTypes)
  98859. * @param event Defines the related dom event
  98860. */
  98861. constructor(
  98862. /**
  98863. * Defines the type of event (KeyboardEventTypes)
  98864. */
  98865. type: number,
  98866. /**
  98867. * Defines the related dom event
  98868. */
  98869. event: KeyboardEvent);
  98870. }
  98871. /**
  98872. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98873. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  98874. */
  98875. export class KeyboardInfoPre extends KeyboardInfo {
  98876. /**
  98877. * Defines the type of event (KeyboardEventTypes)
  98878. */
  98879. type: number;
  98880. /**
  98881. * Defines the related dom event
  98882. */
  98883. event: KeyboardEvent;
  98884. /**
  98885. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  98886. */
  98887. skipOnPointerObservable: boolean;
  98888. /**
  98889. * Instantiates a new keyboard pre info.
  98890. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  98891. * @param type Defines the type of event (KeyboardEventTypes)
  98892. * @param event Defines the related dom event
  98893. */
  98894. constructor(
  98895. /**
  98896. * Defines the type of event (KeyboardEventTypes)
  98897. */
  98898. type: number,
  98899. /**
  98900. * Defines the related dom event
  98901. */
  98902. event: KeyboardEvent);
  98903. }
  98904. }
  98905. declare module BABYLON {
  98906. /**
  98907. * Manage the keyboard inputs to control the movement of a free camera.
  98908. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  98909. */
  98910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  98911. /**
  98912. * Defines the camera the input is attached to.
  98913. */
  98914. camera: FreeCamera;
  98915. /**
  98916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  98917. */
  98918. keysUp: number[];
  98919. /**
  98920. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  98921. */
  98922. keysUpward: number[];
  98923. /**
  98924. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  98925. */
  98926. keysDown: number[];
  98927. /**
  98928. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  98929. */
  98930. keysDownward: number[];
  98931. /**
  98932. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  98933. */
  98934. keysLeft: number[];
  98935. /**
  98936. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  98937. */
  98938. keysRight: number[];
  98939. private _keys;
  98940. private _onCanvasBlurObserver;
  98941. private _onKeyboardObserver;
  98942. private _engine;
  98943. private _scene;
  98944. /**
  98945. * Attach the input controls to a specific dom element to get the input from.
  98946. * @param element Defines the element the controls should be listened from
  98947. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98948. */
  98949. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98950. /**
  98951. * Detach the current controls from the specified dom element.
  98952. * @param element Defines the element to stop listening the inputs from
  98953. */
  98954. detachControl(element: Nullable<HTMLElement>): void;
  98955. /**
  98956. * Update the current camera state depending on the inputs that have been used this frame.
  98957. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98958. */
  98959. checkInputs(): void;
  98960. /**
  98961. * Gets the class name of the current intput.
  98962. * @returns the class name
  98963. */
  98964. getClassName(): string;
  98965. /** @hidden */
  98966. _onLostFocus(): void;
  98967. /**
  98968. * Get the friendly name associated with the input class.
  98969. * @returns the input friendly name
  98970. */
  98971. getSimpleName(): string;
  98972. }
  98973. }
  98974. declare module BABYLON {
  98975. /**
  98976. * Gather the list of pointer event types as constants.
  98977. */
  98978. export class PointerEventTypes {
  98979. /**
  98980. * 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.
  98981. */
  98982. static readonly POINTERDOWN: number;
  98983. /**
  98984. * The pointerup event is fired when a pointer is no longer active.
  98985. */
  98986. static readonly POINTERUP: number;
  98987. /**
  98988. * The pointermove event is fired when a pointer changes coordinates.
  98989. */
  98990. static readonly POINTERMOVE: number;
  98991. /**
  98992. * The pointerwheel event is fired when a mouse wheel has been rotated.
  98993. */
  98994. static readonly POINTERWHEEL: number;
  98995. /**
  98996. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  98997. */
  98998. static readonly POINTERPICK: number;
  98999. /**
  99000. * The pointertap event is fired when a the object has been touched and released without drag.
  99001. */
  99002. static readonly POINTERTAP: number;
  99003. /**
  99004. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99005. */
  99006. static readonly POINTERDOUBLETAP: number;
  99007. }
  99008. /**
  99009. * Base class of pointer info types.
  99010. */
  99011. export class PointerInfoBase {
  99012. /**
  99013. * Defines the type of event (PointerEventTypes)
  99014. */
  99015. type: number;
  99016. /**
  99017. * Defines the related dom event
  99018. */
  99019. event: PointerEvent | MouseWheelEvent;
  99020. /**
  99021. * Instantiates the base class of pointers info.
  99022. * @param type Defines the type of event (PointerEventTypes)
  99023. * @param event Defines the related dom event
  99024. */
  99025. constructor(
  99026. /**
  99027. * Defines the type of event (PointerEventTypes)
  99028. */
  99029. type: number,
  99030. /**
  99031. * Defines the related dom event
  99032. */
  99033. event: PointerEvent | MouseWheelEvent);
  99034. }
  99035. /**
  99036. * This class is used to store pointer related info for the onPrePointerObservable event.
  99037. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99038. */
  99039. export class PointerInfoPre extends PointerInfoBase {
  99040. /**
  99041. * Ray from a pointer if availible (eg. 6dof controller)
  99042. */
  99043. ray: Nullable<Ray>;
  99044. /**
  99045. * Defines the local position of the pointer on the canvas.
  99046. */
  99047. localPosition: Vector2;
  99048. /**
  99049. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99050. */
  99051. skipOnPointerObservable: boolean;
  99052. /**
  99053. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99054. * @param type Defines the type of event (PointerEventTypes)
  99055. * @param event Defines the related dom event
  99056. * @param localX Defines the local x coordinates of the pointer when the event occured
  99057. * @param localY Defines the local y coordinates of the pointer when the event occured
  99058. */
  99059. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99060. }
  99061. /**
  99062. * This type contains all the data related to a pointer event in Babylon.js.
  99063. * 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.
  99064. */
  99065. export class PointerInfo extends PointerInfoBase {
  99066. /**
  99067. * Defines the picking info associated to the info (if any)\
  99068. */
  99069. pickInfo: Nullable<PickingInfo>;
  99070. /**
  99071. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99072. * @param type Defines the type of event (PointerEventTypes)
  99073. * @param event Defines the related dom event
  99074. * @param pickInfo Defines the picking info associated to the info (if any)\
  99075. */
  99076. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99077. /**
  99078. * Defines the picking info associated to the info (if any)\
  99079. */
  99080. pickInfo: Nullable<PickingInfo>);
  99081. }
  99082. /**
  99083. * Data relating to a touch event on the screen.
  99084. */
  99085. export interface PointerTouch {
  99086. /**
  99087. * X coordinate of touch.
  99088. */
  99089. x: number;
  99090. /**
  99091. * Y coordinate of touch.
  99092. */
  99093. y: number;
  99094. /**
  99095. * Id of touch. Unique for each finger.
  99096. */
  99097. pointerId: number;
  99098. /**
  99099. * Event type passed from DOM.
  99100. */
  99101. type: any;
  99102. }
  99103. }
  99104. declare module BABYLON {
  99105. /**
  99106. * Manage the mouse inputs to control the movement of a free camera.
  99107. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99108. */
  99109. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99110. /**
  99111. * Define if touch is enabled in the mouse input
  99112. */
  99113. touchEnabled: boolean;
  99114. /**
  99115. * Defines the camera the input is attached to.
  99116. */
  99117. camera: FreeCamera;
  99118. /**
  99119. * Defines the buttons associated with the input to handle camera move.
  99120. */
  99121. buttons: number[];
  99122. /**
  99123. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99124. */
  99125. angularSensibility: number;
  99126. private _pointerInput;
  99127. private _onMouseMove;
  99128. private _observer;
  99129. private previousPosition;
  99130. /**
  99131. * Observable for when a pointer move event occurs containing the move offset
  99132. */
  99133. onPointerMovedObservable: Observable<{
  99134. offsetX: number;
  99135. offsetY: number;
  99136. }>;
  99137. /**
  99138. * @hidden
  99139. * If the camera should be rotated automatically based on pointer movement
  99140. */
  99141. _allowCameraRotation: boolean;
  99142. /**
  99143. * Manage the mouse inputs to control the movement of a free camera.
  99144. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99145. * @param touchEnabled Defines if touch is enabled or not
  99146. */
  99147. constructor(
  99148. /**
  99149. * Define if touch is enabled in the mouse input
  99150. */
  99151. touchEnabled?: boolean);
  99152. /**
  99153. * Attach the input controls to a specific dom element to get the input from.
  99154. * @param element Defines the element the controls should be listened from
  99155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99156. */
  99157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99158. /**
  99159. * Called on JS contextmenu event.
  99160. * Override this method to provide functionality.
  99161. */
  99162. protected onContextMenu(evt: PointerEvent): void;
  99163. /**
  99164. * Detach the current controls from the specified dom element.
  99165. * @param element Defines the element to stop listening the inputs from
  99166. */
  99167. detachControl(element: Nullable<HTMLElement>): void;
  99168. /**
  99169. * Gets the class name of the current intput.
  99170. * @returns the class name
  99171. */
  99172. getClassName(): string;
  99173. /**
  99174. * Get the friendly name associated with the input class.
  99175. * @returns the input friendly name
  99176. */
  99177. getSimpleName(): string;
  99178. }
  99179. }
  99180. declare module BABYLON {
  99181. /**
  99182. * Manage the touch inputs to control the movement of a free camera.
  99183. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99184. */
  99185. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99186. /**
  99187. * Define if mouse events can be treated as touch events
  99188. */
  99189. allowMouse: boolean;
  99190. /**
  99191. * Defines the camera the input is attached to.
  99192. */
  99193. camera: FreeCamera;
  99194. /**
  99195. * Defines the touch sensibility for rotation.
  99196. * The higher the faster.
  99197. */
  99198. touchAngularSensibility: number;
  99199. /**
  99200. * Defines the touch sensibility for move.
  99201. * The higher the faster.
  99202. */
  99203. touchMoveSensibility: number;
  99204. private _offsetX;
  99205. private _offsetY;
  99206. private _pointerPressed;
  99207. private _pointerInput;
  99208. private _observer;
  99209. private _onLostFocus;
  99210. /**
  99211. * Manage the touch inputs to control the movement of a free camera.
  99212. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99213. * @param allowMouse Defines if mouse events can be treated as touch events
  99214. */
  99215. constructor(
  99216. /**
  99217. * Define if mouse events can be treated as touch events
  99218. */
  99219. allowMouse?: boolean);
  99220. /**
  99221. * Attach the input controls to a specific dom element to get the input from.
  99222. * @param element Defines the element the controls should be listened from
  99223. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99224. */
  99225. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99226. /**
  99227. * Detach the current controls from the specified dom element.
  99228. * @param element Defines the element to stop listening the inputs from
  99229. */
  99230. detachControl(element: Nullable<HTMLElement>): void;
  99231. /**
  99232. * Update the current camera state depending on the inputs that have been used this frame.
  99233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99234. */
  99235. checkInputs(): void;
  99236. /**
  99237. * Gets the class name of the current intput.
  99238. * @returns the class name
  99239. */
  99240. getClassName(): string;
  99241. /**
  99242. * Get the friendly name associated with the input class.
  99243. * @returns the input friendly name
  99244. */
  99245. getSimpleName(): string;
  99246. }
  99247. }
  99248. declare module BABYLON {
  99249. /**
  99250. * Default Inputs manager for the FreeCamera.
  99251. * It groups all the default supported inputs for ease of use.
  99252. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99253. */
  99254. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99255. /**
  99256. * @hidden
  99257. */
  99258. _mouseInput: Nullable<FreeCameraMouseInput>;
  99259. /**
  99260. * Instantiates a new FreeCameraInputsManager.
  99261. * @param camera Defines the camera the inputs belong to
  99262. */
  99263. constructor(camera: FreeCamera);
  99264. /**
  99265. * Add keyboard input support to the input manager.
  99266. * @returns the current input manager
  99267. */
  99268. addKeyboard(): FreeCameraInputsManager;
  99269. /**
  99270. * Add mouse input support to the input manager.
  99271. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99272. * @returns the current input manager
  99273. */
  99274. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99275. /**
  99276. * Removes the mouse input support from the manager
  99277. * @returns the current input manager
  99278. */
  99279. removeMouse(): FreeCameraInputsManager;
  99280. /**
  99281. * Add touch input support to the input manager.
  99282. * @returns the current input manager
  99283. */
  99284. addTouch(): FreeCameraInputsManager;
  99285. /**
  99286. * Remove all attached input methods from a camera
  99287. */
  99288. clear(): void;
  99289. }
  99290. }
  99291. declare module BABYLON {
  99292. /**
  99293. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99294. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99295. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99296. */
  99297. export class FreeCamera extends TargetCamera {
  99298. /**
  99299. * Define the collision ellipsoid of the camera.
  99300. * This is helpful to simulate a camera body like the player body around the camera
  99301. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99302. */
  99303. ellipsoid: Vector3;
  99304. /**
  99305. * Define an offset for the position of the ellipsoid around the camera.
  99306. * This can be helpful to determine the center of the body near the gravity center of the body
  99307. * instead of its head.
  99308. */
  99309. ellipsoidOffset: Vector3;
  99310. /**
  99311. * Enable or disable collisions of the camera with the rest of the scene objects.
  99312. */
  99313. checkCollisions: boolean;
  99314. /**
  99315. * Enable or disable gravity on the camera.
  99316. */
  99317. applyGravity: boolean;
  99318. /**
  99319. * Define the input manager associated to the camera.
  99320. */
  99321. inputs: FreeCameraInputsManager;
  99322. /**
  99323. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99324. * Higher values reduce sensitivity.
  99325. */
  99326. get angularSensibility(): number;
  99327. /**
  99328. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99329. * Higher values reduce sensitivity.
  99330. */
  99331. set angularSensibility(value: number);
  99332. /**
  99333. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99334. */
  99335. get keysUp(): number[];
  99336. set keysUp(value: number[]);
  99337. /**
  99338. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99339. */
  99340. get keysUpward(): number[];
  99341. set keysUpward(value: number[]);
  99342. /**
  99343. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99344. */
  99345. get keysDown(): number[];
  99346. set keysDown(value: number[]);
  99347. /**
  99348. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99349. */
  99350. get keysDownward(): number[];
  99351. set keysDownward(value: number[]);
  99352. /**
  99353. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99354. */
  99355. get keysLeft(): number[];
  99356. set keysLeft(value: number[]);
  99357. /**
  99358. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99359. */
  99360. get keysRight(): number[];
  99361. set keysRight(value: number[]);
  99362. /**
  99363. * Event raised when the camera collide with a mesh in the scene.
  99364. */
  99365. onCollide: (collidedMesh: AbstractMesh) => void;
  99366. private _collider;
  99367. private _needMoveForGravity;
  99368. private _oldPosition;
  99369. private _diffPosition;
  99370. private _newPosition;
  99371. /** @hidden */
  99372. _localDirection: Vector3;
  99373. /** @hidden */
  99374. _transformedDirection: Vector3;
  99375. /**
  99376. * Instantiates a Free Camera.
  99377. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99378. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99379. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99380. * @param name Define the name of the camera in the scene
  99381. * @param position Define the start position of the camera in the scene
  99382. * @param scene Define the scene the camera belongs to
  99383. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99384. */
  99385. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99386. /**
  99387. * Attached controls to the current camera.
  99388. * @param element Defines the element the controls should be listened from
  99389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99390. */
  99391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99392. /**
  99393. * Detach the current controls from the camera.
  99394. * The camera will stop reacting to inputs.
  99395. * @param element Defines the element to stop listening the inputs from
  99396. */
  99397. detachControl(element: HTMLElement): void;
  99398. private _collisionMask;
  99399. /**
  99400. * Define a collision mask to limit the list of object the camera can collide with
  99401. */
  99402. get collisionMask(): number;
  99403. set collisionMask(mask: number);
  99404. /** @hidden */
  99405. _collideWithWorld(displacement: Vector3): void;
  99406. private _onCollisionPositionChange;
  99407. /** @hidden */
  99408. _checkInputs(): void;
  99409. /** @hidden */
  99410. _decideIfNeedsToMove(): boolean;
  99411. /** @hidden */
  99412. _updatePosition(): void;
  99413. /**
  99414. * Destroy the camera and release the current resources hold by it.
  99415. */
  99416. dispose(): void;
  99417. /**
  99418. * Gets the current object class name.
  99419. * @return the class name
  99420. */
  99421. getClassName(): string;
  99422. }
  99423. }
  99424. declare module BABYLON {
  99425. /**
  99426. * Represents a gamepad control stick position
  99427. */
  99428. export class StickValues {
  99429. /**
  99430. * The x component of the control stick
  99431. */
  99432. x: number;
  99433. /**
  99434. * The y component of the control stick
  99435. */
  99436. y: number;
  99437. /**
  99438. * Initializes the gamepad x and y control stick values
  99439. * @param x The x component of the gamepad control stick value
  99440. * @param y The y component of the gamepad control stick value
  99441. */
  99442. constructor(
  99443. /**
  99444. * The x component of the control stick
  99445. */
  99446. x: number,
  99447. /**
  99448. * The y component of the control stick
  99449. */
  99450. y: number);
  99451. }
  99452. /**
  99453. * An interface which manages callbacks for gamepad button changes
  99454. */
  99455. export interface GamepadButtonChanges {
  99456. /**
  99457. * Called when a gamepad has been changed
  99458. */
  99459. changed: boolean;
  99460. /**
  99461. * Called when a gamepad press event has been triggered
  99462. */
  99463. pressChanged: boolean;
  99464. /**
  99465. * Called when a touch event has been triggered
  99466. */
  99467. touchChanged: boolean;
  99468. /**
  99469. * Called when a value has changed
  99470. */
  99471. valueChanged: boolean;
  99472. }
  99473. /**
  99474. * Represents a gamepad
  99475. */
  99476. export class Gamepad {
  99477. /**
  99478. * The id of the gamepad
  99479. */
  99480. id: string;
  99481. /**
  99482. * The index of the gamepad
  99483. */
  99484. index: number;
  99485. /**
  99486. * The browser gamepad
  99487. */
  99488. browserGamepad: any;
  99489. /**
  99490. * Specifies what type of gamepad this represents
  99491. */
  99492. type: number;
  99493. private _leftStick;
  99494. private _rightStick;
  99495. /** @hidden */
  99496. _isConnected: boolean;
  99497. private _leftStickAxisX;
  99498. private _leftStickAxisY;
  99499. private _rightStickAxisX;
  99500. private _rightStickAxisY;
  99501. /**
  99502. * Triggered when the left control stick has been changed
  99503. */
  99504. private _onleftstickchanged;
  99505. /**
  99506. * Triggered when the right control stick has been changed
  99507. */
  99508. private _onrightstickchanged;
  99509. /**
  99510. * Represents a gamepad controller
  99511. */
  99512. static GAMEPAD: number;
  99513. /**
  99514. * Represents a generic controller
  99515. */
  99516. static GENERIC: number;
  99517. /**
  99518. * Represents an XBox controller
  99519. */
  99520. static XBOX: number;
  99521. /**
  99522. * Represents a pose-enabled controller
  99523. */
  99524. static POSE_ENABLED: number;
  99525. /**
  99526. * Represents an Dual Shock controller
  99527. */
  99528. static DUALSHOCK: number;
  99529. /**
  99530. * Specifies whether the left control stick should be Y-inverted
  99531. */
  99532. protected _invertLeftStickY: boolean;
  99533. /**
  99534. * Specifies if the gamepad has been connected
  99535. */
  99536. get isConnected(): boolean;
  99537. /**
  99538. * Initializes the gamepad
  99539. * @param id The id of the gamepad
  99540. * @param index The index of the gamepad
  99541. * @param browserGamepad The browser gamepad
  99542. * @param leftStickX The x component of the left joystick
  99543. * @param leftStickY The y component of the left joystick
  99544. * @param rightStickX The x component of the right joystick
  99545. * @param rightStickY The y component of the right joystick
  99546. */
  99547. constructor(
  99548. /**
  99549. * The id of the gamepad
  99550. */
  99551. id: string,
  99552. /**
  99553. * The index of the gamepad
  99554. */
  99555. index: number,
  99556. /**
  99557. * The browser gamepad
  99558. */
  99559. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99560. /**
  99561. * Callback triggered when the left joystick has changed
  99562. * @param callback
  99563. */
  99564. onleftstickchanged(callback: (values: StickValues) => void): void;
  99565. /**
  99566. * Callback triggered when the right joystick has changed
  99567. * @param callback
  99568. */
  99569. onrightstickchanged(callback: (values: StickValues) => void): void;
  99570. /**
  99571. * Gets the left joystick
  99572. */
  99573. get leftStick(): StickValues;
  99574. /**
  99575. * Sets the left joystick values
  99576. */
  99577. set leftStick(newValues: StickValues);
  99578. /**
  99579. * Gets the right joystick
  99580. */
  99581. get rightStick(): StickValues;
  99582. /**
  99583. * Sets the right joystick value
  99584. */
  99585. set rightStick(newValues: StickValues);
  99586. /**
  99587. * Updates the gamepad joystick positions
  99588. */
  99589. update(): void;
  99590. /**
  99591. * Disposes the gamepad
  99592. */
  99593. dispose(): void;
  99594. }
  99595. /**
  99596. * Represents a generic gamepad
  99597. */
  99598. export class GenericPad extends Gamepad {
  99599. private _buttons;
  99600. private _onbuttondown;
  99601. private _onbuttonup;
  99602. /**
  99603. * Observable triggered when a button has been pressed
  99604. */
  99605. onButtonDownObservable: Observable<number>;
  99606. /**
  99607. * Observable triggered when a button has been released
  99608. */
  99609. onButtonUpObservable: Observable<number>;
  99610. /**
  99611. * Callback triggered when a button has been pressed
  99612. * @param callback Called when a button has been pressed
  99613. */
  99614. onbuttondown(callback: (buttonPressed: number) => void): void;
  99615. /**
  99616. * Callback triggered when a button has been released
  99617. * @param callback Called when a button has been released
  99618. */
  99619. onbuttonup(callback: (buttonReleased: number) => void): void;
  99620. /**
  99621. * Initializes the generic gamepad
  99622. * @param id The id of the generic gamepad
  99623. * @param index The index of the generic gamepad
  99624. * @param browserGamepad The browser gamepad
  99625. */
  99626. constructor(id: string, index: number, browserGamepad: any);
  99627. private _setButtonValue;
  99628. /**
  99629. * Updates the generic gamepad
  99630. */
  99631. update(): void;
  99632. /**
  99633. * Disposes the generic gamepad
  99634. */
  99635. dispose(): void;
  99636. }
  99637. }
  99638. declare module BABYLON {
  99639. /**
  99640. * Defines the types of pose enabled controllers that are supported
  99641. */
  99642. export enum PoseEnabledControllerType {
  99643. /**
  99644. * HTC Vive
  99645. */
  99646. VIVE = 0,
  99647. /**
  99648. * Oculus Rift
  99649. */
  99650. OCULUS = 1,
  99651. /**
  99652. * Windows mixed reality
  99653. */
  99654. WINDOWS = 2,
  99655. /**
  99656. * Samsung gear VR
  99657. */
  99658. GEAR_VR = 3,
  99659. /**
  99660. * Google Daydream
  99661. */
  99662. DAYDREAM = 4,
  99663. /**
  99664. * Generic
  99665. */
  99666. GENERIC = 5
  99667. }
  99668. /**
  99669. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99670. */
  99671. export interface MutableGamepadButton {
  99672. /**
  99673. * Value of the button/trigger
  99674. */
  99675. value: number;
  99676. /**
  99677. * If the button/trigger is currently touched
  99678. */
  99679. touched: boolean;
  99680. /**
  99681. * If the button/trigger is currently pressed
  99682. */
  99683. pressed: boolean;
  99684. }
  99685. /**
  99686. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99687. * @hidden
  99688. */
  99689. export interface ExtendedGamepadButton extends GamepadButton {
  99690. /**
  99691. * If the button/trigger is currently pressed
  99692. */
  99693. readonly pressed: boolean;
  99694. /**
  99695. * If the button/trigger is currently touched
  99696. */
  99697. readonly touched: boolean;
  99698. /**
  99699. * Value of the button/trigger
  99700. */
  99701. readonly value: number;
  99702. }
  99703. /** @hidden */
  99704. export interface _GamePadFactory {
  99705. /**
  99706. * Returns whether or not the current gamepad can be created for this type of controller.
  99707. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99708. * @returns true if it can be created, otherwise false
  99709. */
  99710. canCreate(gamepadInfo: any): boolean;
  99711. /**
  99712. * Creates a new instance of the Gamepad.
  99713. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99714. * @returns the new gamepad instance
  99715. */
  99716. create(gamepadInfo: any): Gamepad;
  99717. }
  99718. /**
  99719. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99720. */
  99721. export class PoseEnabledControllerHelper {
  99722. /** @hidden */
  99723. static _ControllerFactories: _GamePadFactory[];
  99724. /** @hidden */
  99725. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  99726. /**
  99727. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  99728. * @param vrGamepad the gamepad to initialized
  99729. * @returns a vr controller of the type the gamepad identified as
  99730. */
  99731. static InitiateController(vrGamepad: any): Gamepad;
  99732. }
  99733. /**
  99734. * Defines the PoseEnabledController object that contains state of a vr capable controller
  99735. */
  99736. export class PoseEnabledController extends Gamepad implements PoseControlled {
  99737. /**
  99738. * If the controller is used in a webXR session
  99739. */
  99740. isXR: boolean;
  99741. private _deviceRoomPosition;
  99742. private _deviceRoomRotationQuaternion;
  99743. /**
  99744. * The device position in babylon space
  99745. */
  99746. devicePosition: Vector3;
  99747. /**
  99748. * The device rotation in babylon space
  99749. */
  99750. deviceRotationQuaternion: Quaternion;
  99751. /**
  99752. * The scale factor of the device in babylon space
  99753. */
  99754. deviceScaleFactor: number;
  99755. /**
  99756. * (Likely devicePosition should be used instead) The device position in its room space
  99757. */
  99758. position: Vector3;
  99759. /**
  99760. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  99761. */
  99762. rotationQuaternion: Quaternion;
  99763. /**
  99764. * The type of controller (Eg. Windows mixed reality)
  99765. */
  99766. controllerType: PoseEnabledControllerType;
  99767. protected _calculatedPosition: Vector3;
  99768. private _calculatedRotation;
  99769. /**
  99770. * The raw pose from the device
  99771. */
  99772. rawPose: DevicePose;
  99773. private _trackPosition;
  99774. private _maxRotationDistFromHeadset;
  99775. private _draggedRoomRotation;
  99776. /**
  99777. * @hidden
  99778. */
  99779. _disableTrackPosition(fixedPosition: Vector3): void;
  99780. /**
  99781. * Internal, the mesh attached to the controller
  99782. * @hidden
  99783. */
  99784. _mesh: Nullable<AbstractMesh>;
  99785. private _poseControlledCamera;
  99786. private _leftHandSystemQuaternion;
  99787. /**
  99788. * Internal, matrix used to convert room space to babylon space
  99789. * @hidden
  99790. */
  99791. _deviceToWorld: Matrix;
  99792. /**
  99793. * Node to be used when casting a ray from the controller
  99794. * @hidden
  99795. */
  99796. _pointingPoseNode: Nullable<TransformNode>;
  99797. /**
  99798. * Name of the child mesh that can be used to cast a ray from the controller
  99799. */
  99800. static readonly POINTING_POSE: string;
  99801. /**
  99802. * Creates a new PoseEnabledController from a gamepad
  99803. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  99804. */
  99805. constructor(browserGamepad: any);
  99806. private _workingMatrix;
  99807. /**
  99808. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  99809. */
  99810. update(): void;
  99811. /**
  99812. * Updates only the pose device and mesh without doing any button event checking
  99813. */
  99814. protected _updatePoseAndMesh(): void;
  99815. /**
  99816. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  99817. * @param poseData raw pose fromthe device
  99818. */
  99819. updateFromDevice(poseData: DevicePose): void;
  99820. /**
  99821. * @hidden
  99822. */
  99823. _meshAttachedObservable: Observable<AbstractMesh>;
  99824. /**
  99825. * Attaches a mesh to the controller
  99826. * @param mesh the mesh to be attached
  99827. */
  99828. attachToMesh(mesh: AbstractMesh): void;
  99829. /**
  99830. * Attaches the controllers mesh to a camera
  99831. * @param camera the camera the mesh should be attached to
  99832. */
  99833. attachToPoseControlledCamera(camera: TargetCamera): void;
  99834. /**
  99835. * Disposes of the controller
  99836. */
  99837. dispose(): void;
  99838. /**
  99839. * The mesh that is attached to the controller
  99840. */
  99841. get mesh(): Nullable<AbstractMesh>;
  99842. /**
  99843. * Gets the ray of the controller in the direction the controller is pointing
  99844. * @param length the length the resulting ray should be
  99845. * @returns a ray in the direction the controller is pointing
  99846. */
  99847. getForwardRay(length?: number): Ray;
  99848. }
  99849. }
  99850. declare module BABYLON {
  99851. /**
  99852. * Defines the WebVRController object that represents controllers tracked in 3D space
  99853. */
  99854. export abstract class WebVRController extends PoseEnabledController {
  99855. /**
  99856. * Internal, the default controller model for the controller
  99857. */
  99858. protected _defaultModel: Nullable<AbstractMesh>;
  99859. /**
  99860. * Fired when the trigger state has changed
  99861. */
  99862. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  99863. /**
  99864. * Fired when the main button state has changed
  99865. */
  99866. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99867. /**
  99868. * Fired when the secondary button state has changed
  99869. */
  99870. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  99871. /**
  99872. * Fired when the pad state has changed
  99873. */
  99874. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  99875. /**
  99876. * Fired when controllers stick values have changed
  99877. */
  99878. onPadValuesChangedObservable: Observable<StickValues>;
  99879. /**
  99880. * Array of button availible on the controller
  99881. */
  99882. protected _buttons: Array<MutableGamepadButton>;
  99883. private _onButtonStateChange;
  99884. /**
  99885. * Fired when a controller button's state has changed
  99886. * @param callback the callback containing the button that was modified
  99887. */
  99888. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  99889. /**
  99890. * X and Y axis corresponding to the controllers joystick
  99891. */
  99892. pad: StickValues;
  99893. /**
  99894. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  99895. */
  99896. hand: string;
  99897. /**
  99898. * The default controller model for the controller
  99899. */
  99900. get defaultModel(): Nullable<AbstractMesh>;
  99901. /**
  99902. * Creates a new WebVRController from a gamepad
  99903. * @param vrGamepad the gamepad that the WebVRController should be created from
  99904. */
  99905. constructor(vrGamepad: any);
  99906. /**
  99907. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  99908. */
  99909. update(): void;
  99910. /**
  99911. * Function to be called when a button is modified
  99912. */
  99913. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  99914. /**
  99915. * Loads a mesh and attaches it to the controller
  99916. * @param scene the scene the mesh should be added to
  99917. * @param meshLoaded callback for when the mesh has been loaded
  99918. */
  99919. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  99920. private _setButtonValue;
  99921. private _changes;
  99922. private _checkChanges;
  99923. /**
  99924. * Disposes of th webVRCOntroller
  99925. */
  99926. dispose(): void;
  99927. }
  99928. }
  99929. declare module BABYLON {
  99930. /**
  99931. * The HemisphericLight simulates the ambient environment light,
  99932. * so the passed direction is the light reflection direction, not the incoming direction.
  99933. */
  99934. export class HemisphericLight extends Light {
  99935. /**
  99936. * The groundColor is the light in the opposite direction to the one specified during creation.
  99937. * 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.
  99938. */
  99939. groundColor: Color3;
  99940. /**
  99941. * The light reflection direction, not the incoming direction.
  99942. */
  99943. direction: Vector3;
  99944. /**
  99945. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  99946. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  99947. * The HemisphericLight can't cast shadows.
  99948. * Documentation : https://doc.babylonjs.com/babylon101/lights
  99949. * @param name The friendly name of the light
  99950. * @param direction The direction of the light reflection
  99951. * @param scene The scene the light belongs to
  99952. */
  99953. constructor(name: string, direction: Vector3, scene: Scene);
  99954. protected _buildUniformLayout(): void;
  99955. /**
  99956. * Returns the string "HemisphericLight".
  99957. * @return The class name
  99958. */
  99959. getClassName(): string;
  99960. /**
  99961. * Sets the HemisphericLight direction towards the passed target (Vector3).
  99962. * Returns the updated direction.
  99963. * @param target The target the direction should point to
  99964. * @return The computed direction
  99965. */
  99966. setDirectionToTarget(target: Vector3): Vector3;
  99967. /**
  99968. * Returns the shadow generator associated to the light.
  99969. * @returns Always null for hemispheric lights because it does not support shadows.
  99970. */
  99971. getShadowGenerator(): Nullable<IShadowGenerator>;
  99972. /**
  99973. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  99974. * @param effect The effect to update
  99975. * @param lightIndex The index of the light in the effect to update
  99976. * @returns The hemispheric light
  99977. */
  99978. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  99979. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  99980. /**
  99981. * Computes the world matrix of the node
  99982. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  99983. * @param useWasUpdatedFlag defines a reserved property
  99984. * @returns the world matrix
  99985. */
  99986. computeWorldMatrix(): Matrix;
  99987. /**
  99988. * Returns the integer 3.
  99989. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  99990. */
  99991. getTypeID(): number;
  99992. /**
  99993. * Prepares the list of defines specific to the light type.
  99994. * @param defines the list of defines
  99995. * @param lightIndex defines the index of the light for the effect
  99996. */
  99997. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  99998. }
  99999. }
  100000. declare module BABYLON {
  100001. /** @hidden */
  100002. export var vrMultiviewToSingleviewPixelShader: {
  100003. name: string;
  100004. shader: string;
  100005. };
  100006. }
  100007. declare module BABYLON {
  100008. /**
  100009. * Renders to multiple views with a single draw call
  100010. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100011. */
  100012. export class MultiviewRenderTarget extends RenderTargetTexture {
  100013. /**
  100014. * Creates a multiview render target
  100015. * @param scene scene used with the render target
  100016. * @param size the size of the render target (used for each view)
  100017. */
  100018. constructor(scene: Scene, size?: number | {
  100019. width: number;
  100020. height: number;
  100021. } | {
  100022. ratio: number;
  100023. });
  100024. /**
  100025. * @hidden
  100026. * @param faceIndex the face index, if its a cube texture
  100027. */
  100028. _bindFrameBuffer(faceIndex?: number): void;
  100029. /**
  100030. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100031. * @returns the view count
  100032. */
  100033. getViewCount(): number;
  100034. }
  100035. }
  100036. declare module BABYLON {
  100037. interface Engine {
  100038. /**
  100039. * Creates a new multiview render target
  100040. * @param width defines the width of the texture
  100041. * @param height defines the height of the texture
  100042. * @returns the created multiview texture
  100043. */
  100044. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100045. /**
  100046. * Binds a multiview framebuffer to be drawn to
  100047. * @param multiviewTexture texture to bind
  100048. */
  100049. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100050. }
  100051. interface Camera {
  100052. /**
  100053. * @hidden
  100054. * 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)
  100055. */
  100056. _useMultiviewToSingleView: boolean;
  100057. /**
  100058. * @hidden
  100059. * 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)
  100060. */
  100061. _multiviewTexture: Nullable<RenderTargetTexture>;
  100062. /**
  100063. * @hidden
  100064. * ensures the multiview texture of the camera exists and has the specified width/height
  100065. * @param width height to set on the multiview texture
  100066. * @param height width to set on the multiview texture
  100067. */
  100068. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100069. }
  100070. interface Scene {
  100071. /** @hidden */
  100072. _transformMatrixR: Matrix;
  100073. /** @hidden */
  100074. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100075. /** @hidden */
  100076. _createMultiviewUbo(): void;
  100077. /** @hidden */
  100078. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100079. /** @hidden */
  100080. _renderMultiviewToSingleView(camera: Camera): void;
  100081. }
  100082. }
  100083. declare module BABYLON {
  100084. /**
  100085. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100086. * This will not be used for webXR as it supports displaying texture arrays directly
  100087. */
  100088. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100089. /**
  100090. * Gets a string identifying the name of the class
  100091. * @returns "VRMultiviewToSingleviewPostProcess" string
  100092. */
  100093. getClassName(): string;
  100094. /**
  100095. * Initializes a VRMultiviewToSingleview
  100096. * @param name name of the post process
  100097. * @param camera camera to be applied to
  100098. * @param scaleFactor scaling factor to the size of the output texture
  100099. */
  100100. constructor(name: string, camera: Camera, scaleFactor: number);
  100101. }
  100102. }
  100103. declare module BABYLON {
  100104. /**
  100105. * Interface used to define additional presentation attributes
  100106. */
  100107. export interface IVRPresentationAttributes {
  100108. /**
  100109. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100110. */
  100111. highRefreshRate: boolean;
  100112. /**
  100113. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100114. */
  100115. foveationLevel: number;
  100116. }
  100117. interface Engine {
  100118. /** @hidden */
  100119. _vrDisplay: any;
  100120. /** @hidden */
  100121. _vrSupported: boolean;
  100122. /** @hidden */
  100123. _oldSize: Size;
  100124. /** @hidden */
  100125. _oldHardwareScaleFactor: number;
  100126. /** @hidden */
  100127. _vrExclusivePointerMode: boolean;
  100128. /** @hidden */
  100129. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100130. /** @hidden */
  100131. _onVRDisplayPointerRestricted: () => void;
  100132. /** @hidden */
  100133. _onVRDisplayPointerUnrestricted: () => void;
  100134. /** @hidden */
  100135. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100136. /** @hidden */
  100137. _onVrDisplayDisconnect: Nullable<() => void>;
  100138. /** @hidden */
  100139. _onVrDisplayPresentChange: Nullable<() => void>;
  100140. /**
  100141. * Observable signaled when VR display mode changes
  100142. */
  100143. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100144. /**
  100145. * Observable signaled when VR request present is complete
  100146. */
  100147. onVRRequestPresentComplete: Observable<boolean>;
  100148. /**
  100149. * Observable signaled when VR request present starts
  100150. */
  100151. onVRRequestPresentStart: Observable<Engine>;
  100152. /**
  100153. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100154. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100155. */
  100156. isInVRExclusivePointerMode: boolean;
  100157. /**
  100158. * Gets a boolean indicating if a webVR device was detected
  100159. * @returns true if a webVR device was detected
  100160. */
  100161. isVRDevicePresent(): boolean;
  100162. /**
  100163. * Gets the current webVR device
  100164. * @returns the current webVR device (or null)
  100165. */
  100166. getVRDevice(): any;
  100167. /**
  100168. * Initializes a webVR display and starts listening to display change events
  100169. * The onVRDisplayChangedObservable will be notified upon these changes
  100170. * @returns A promise containing a VRDisplay and if vr is supported
  100171. */
  100172. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100173. /** @hidden */
  100174. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100175. /**
  100176. * Gets or sets the presentation attributes used to configure VR rendering
  100177. */
  100178. vrPresentationAttributes?: IVRPresentationAttributes;
  100179. /**
  100180. * Call this function to switch to webVR mode
  100181. * Will do nothing if webVR is not supported or if there is no webVR device
  100182. * @param options the webvr options provided to the camera. mainly used for multiview
  100183. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100184. */
  100185. enableVR(options: WebVROptions): void;
  100186. /** @hidden */
  100187. _onVRFullScreenTriggered(): void;
  100188. }
  100189. }
  100190. declare module BABYLON {
  100191. /**
  100192. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100193. * IMPORTANT!! The data is right-hand data.
  100194. * @export
  100195. * @interface DevicePose
  100196. */
  100197. export interface DevicePose {
  100198. /**
  100199. * The position of the device, values in array are [x,y,z].
  100200. */
  100201. readonly position: Nullable<Float32Array>;
  100202. /**
  100203. * The linearVelocity of the device, values in array are [x,y,z].
  100204. */
  100205. readonly linearVelocity: Nullable<Float32Array>;
  100206. /**
  100207. * The linearAcceleration of the device, values in array are [x,y,z].
  100208. */
  100209. readonly linearAcceleration: Nullable<Float32Array>;
  100210. /**
  100211. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100212. */
  100213. readonly orientation: Nullable<Float32Array>;
  100214. /**
  100215. * The angularVelocity of the device, values in array are [x,y,z].
  100216. */
  100217. readonly angularVelocity: Nullable<Float32Array>;
  100218. /**
  100219. * The angularAcceleration of the device, values in array are [x,y,z].
  100220. */
  100221. readonly angularAcceleration: Nullable<Float32Array>;
  100222. }
  100223. /**
  100224. * Interface representing a pose controlled object in Babylon.
  100225. * A pose controlled object has both regular pose values as well as pose values
  100226. * from an external device such as a VR head mounted display
  100227. */
  100228. export interface PoseControlled {
  100229. /**
  100230. * The position of the object in babylon space.
  100231. */
  100232. position: Vector3;
  100233. /**
  100234. * The rotation quaternion of the object in babylon space.
  100235. */
  100236. rotationQuaternion: Quaternion;
  100237. /**
  100238. * The position of the device in babylon space.
  100239. */
  100240. devicePosition?: Vector3;
  100241. /**
  100242. * The rotation quaternion of the device in babylon space.
  100243. */
  100244. deviceRotationQuaternion: Quaternion;
  100245. /**
  100246. * The raw pose coming from the device.
  100247. */
  100248. rawPose: Nullable<DevicePose>;
  100249. /**
  100250. * The scale of the device to be used when translating from device space to babylon space.
  100251. */
  100252. deviceScaleFactor: number;
  100253. /**
  100254. * Updates the poseControlled values based on the input device pose.
  100255. * @param poseData the pose data to update the object with
  100256. */
  100257. updateFromDevice(poseData: DevicePose): void;
  100258. }
  100259. /**
  100260. * Set of options to customize the webVRCamera
  100261. */
  100262. export interface WebVROptions {
  100263. /**
  100264. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100265. */
  100266. trackPosition?: boolean;
  100267. /**
  100268. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100269. */
  100270. positionScale?: number;
  100271. /**
  100272. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100273. */
  100274. displayName?: string;
  100275. /**
  100276. * Should the native controller meshes be initialized. (default: true)
  100277. */
  100278. controllerMeshes?: boolean;
  100279. /**
  100280. * Creating a default HemiLight only on controllers. (default: true)
  100281. */
  100282. defaultLightingOnControllers?: boolean;
  100283. /**
  100284. * If you don't want to use the default VR button of the helper. (default: false)
  100285. */
  100286. useCustomVRButton?: boolean;
  100287. /**
  100288. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100289. */
  100290. customVRButton?: HTMLButtonElement;
  100291. /**
  100292. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100293. */
  100294. rayLength?: number;
  100295. /**
  100296. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100297. */
  100298. defaultHeight?: number;
  100299. /**
  100300. * If multiview should be used if availible (default: false)
  100301. */
  100302. useMultiview?: boolean;
  100303. }
  100304. /**
  100305. * This represents a WebVR camera.
  100306. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100307. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100308. */
  100309. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100310. private webVROptions;
  100311. /**
  100312. * @hidden
  100313. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100314. */
  100315. _vrDevice: any;
  100316. /**
  100317. * The rawPose of the vrDevice.
  100318. */
  100319. rawPose: Nullable<DevicePose>;
  100320. private _onVREnabled;
  100321. private _specsVersion;
  100322. private _attached;
  100323. private _frameData;
  100324. protected _descendants: Array<Node>;
  100325. private _deviceRoomPosition;
  100326. /** @hidden */
  100327. _deviceRoomRotationQuaternion: Quaternion;
  100328. private _standingMatrix;
  100329. /**
  100330. * Represents device position in babylon space.
  100331. */
  100332. devicePosition: Vector3;
  100333. /**
  100334. * Represents device rotation in babylon space.
  100335. */
  100336. deviceRotationQuaternion: Quaternion;
  100337. /**
  100338. * The scale of the device to be used when translating from device space to babylon space.
  100339. */
  100340. deviceScaleFactor: number;
  100341. private _deviceToWorld;
  100342. private _worldToDevice;
  100343. /**
  100344. * References to the webVR controllers for the vrDevice.
  100345. */
  100346. controllers: Array<WebVRController>;
  100347. /**
  100348. * Emits an event when a controller is attached.
  100349. */
  100350. onControllersAttachedObservable: Observable<WebVRController[]>;
  100351. /**
  100352. * Emits an event when a controller's mesh has been loaded;
  100353. */
  100354. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100355. /**
  100356. * Emits an event when the HMD's pose has been updated.
  100357. */
  100358. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100359. private _poseSet;
  100360. /**
  100361. * If the rig cameras be used as parent instead of this camera.
  100362. */
  100363. rigParenting: boolean;
  100364. private _lightOnControllers;
  100365. private _defaultHeight?;
  100366. /**
  100367. * Instantiates a WebVRFreeCamera.
  100368. * @param name The name of the WebVRFreeCamera
  100369. * @param position The starting anchor position for the camera
  100370. * @param scene The scene the camera belongs to
  100371. * @param webVROptions a set of customizable options for the webVRCamera
  100372. */
  100373. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100374. /**
  100375. * Gets the device distance from the ground in meters.
  100376. * @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.
  100377. */
  100378. deviceDistanceToRoomGround(): number;
  100379. /**
  100380. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100381. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100382. */
  100383. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100384. /**
  100385. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100386. * @returns A promise with a boolean set to if the standing matrix is supported.
  100387. */
  100388. useStandingMatrixAsync(): Promise<boolean>;
  100389. /**
  100390. * Disposes the camera
  100391. */
  100392. dispose(): void;
  100393. /**
  100394. * Gets a vrController by name.
  100395. * @param name The name of the controller to retreive
  100396. * @returns the controller matching the name specified or null if not found
  100397. */
  100398. getControllerByName(name: string): Nullable<WebVRController>;
  100399. private _leftController;
  100400. /**
  100401. * The controller corresponding to the users left hand.
  100402. */
  100403. get leftController(): Nullable<WebVRController>;
  100404. private _rightController;
  100405. /**
  100406. * The controller corresponding to the users right hand.
  100407. */
  100408. get rightController(): Nullable<WebVRController>;
  100409. /**
  100410. * Casts a ray forward from the vrCamera's gaze.
  100411. * @param length Length of the ray (default: 100)
  100412. * @returns the ray corresponding to the gaze
  100413. */
  100414. getForwardRay(length?: number): Ray;
  100415. /**
  100416. * @hidden
  100417. * Updates the camera based on device's frame data
  100418. */
  100419. _checkInputs(): void;
  100420. /**
  100421. * Updates the poseControlled values based on the input device pose.
  100422. * @param poseData Pose coming from the device
  100423. */
  100424. updateFromDevice(poseData: DevicePose): void;
  100425. private _htmlElementAttached;
  100426. private _detachIfAttached;
  100427. /**
  100428. * WebVR's attach control will start broadcasting frames to the device.
  100429. * Note that in certain browsers (chrome for example) this function must be called
  100430. * within a user-interaction callback. Example:
  100431. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100432. *
  100433. * @param element html element to attach the vrDevice to
  100434. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100435. */
  100436. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100437. /**
  100438. * Detaches the camera from the html element and disables VR
  100439. *
  100440. * @param element html element to detach from
  100441. */
  100442. detachControl(element: HTMLElement): void;
  100443. /**
  100444. * @returns the name of this class
  100445. */
  100446. getClassName(): string;
  100447. /**
  100448. * Calls resetPose on the vrDisplay
  100449. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100450. */
  100451. resetToCurrentRotation(): void;
  100452. /**
  100453. * @hidden
  100454. * Updates the rig cameras (left and right eye)
  100455. */
  100456. _updateRigCameras(): void;
  100457. private _workingVector;
  100458. private _oneVector;
  100459. private _workingMatrix;
  100460. private updateCacheCalled;
  100461. private _correctPositionIfNotTrackPosition;
  100462. /**
  100463. * @hidden
  100464. * Updates the cached values of the camera
  100465. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100466. */
  100467. _updateCache(ignoreParentClass?: boolean): void;
  100468. /**
  100469. * @hidden
  100470. * Get current device position in babylon world
  100471. */
  100472. _computeDevicePosition(): void;
  100473. /**
  100474. * Updates the current device position and rotation in the babylon world
  100475. */
  100476. update(): void;
  100477. /**
  100478. * @hidden
  100479. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100480. * @returns an identity matrix
  100481. */
  100482. _getViewMatrix(): Matrix;
  100483. private _tmpMatrix;
  100484. /**
  100485. * This function is called by the two RIG cameras.
  100486. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100487. * @hidden
  100488. */
  100489. _getWebVRViewMatrix(): Matrix;
  100490. /** @hidden */
  100491. _getWebVRProjectionMatrix(): Matrix;
  100492. private _onGamepadConnectedObserver;
  100493. private _onGamepadDisconnectedObserver;
  100494. private _updateCacheWhenTrackingDisabledObserver;
  100495. /**
  100496. * Initializes the controllers and their meshes
  100497. */
  100498. initControllers(): void;
  100499. }
  100500. }
  100501. declare module BABYLON {
  100502. /**
  100503. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100504. *
  100505. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100506. *
  100507. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100508. */
  100509. export class MaterialHelper {
  100510. /**
  100511. * Bind the current view position to an effect.
  100512. * @param effect The effect to be bound
  100513. * @param scene The scene the eyes position is used from
  100514. * @param variableName name of the shader variable that will hold the eye position
  100515. */
  100516. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100517. /**
  100518. * Helps preparing the defines values about the UVs in used in the effect.
  100519. * UVs are shared as much as we can accross channels in the shaders.
  100520. * @param texture The texture we are preparing the UVs for
  100521. * @param defines The defines to update
  100522. * @param key The channel key "diffuse", "specular"... used in the shader
  100523. */
  100524. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100525. /**
  100526. * Binds a texture matrix value to its corrsponding uniform
  100527. * @param texture The texture to bind the matrix for
  100528. * @param uniformBuffer The uniform buffer receivin the data
  100529. * @param key The channel key "diffuse", "specular"... used in the shader
  100530. */
  100531. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100532. /**
  100533. * Gets the current status of the fog (should it be enabled?)
  100534. * @param mesh defines the mesh to evaluate for fog support
  100535. * @param scene defines the hosting scene
  100536. * @returns true if fog must be enabled
  100537. */
  100538. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100539. /**
  100540. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100541. * @param mesh defines the current mesh
  100542. * @param scene defines the current scene
  100543. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100544. * @param pointsCloud defines if point cloud rendering has to be turned on
  100545. * @param fogEnabled defines if fog has to be turned on
  100546. * @param alphaTest defines if alpha testing has to be turned on
  100547. * @param defines defines the current list of defines
  100548. */
  100549. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100550. /**
  100551. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100552. * @param scene defines the current scene
  100553. * @param engine defines the current engine
  100554. * @param defines specifies the list of active defines
  100555. * @param useInstances defines if instances have to be turned on
  100556. * @param useClipPlane defines if clip plane have to be turned on
  100557. * @param useInstances defines if instances have to be turned on
  100558. * @param useThinInstances defines if thin instances have to be turned on
  100559. */
  100560. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100561. /**
  100562. * Prepares the defines for bones
  100563. * @param mesh The mesh containing the geometry data we will draw
  100564. * @param defines The defines to update
  100565. */
  100566. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100567. /**
  100568. * Prepares the defines for morph targets
  100569. * @param mesh The mesh containing the geometry data we will draw
  100570. * @param defines The defines to update
  100571. */
  100572. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100573. /**
  100574. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100575. * @param mesh The mesh containing the geometry data we will draw
  100576. * @param defines The defines to update
  100577. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100578. * @param useBones Precise whether bones should be used or not (override mesh info)
  100579. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100580. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100581. * @returns false if defines are considered not dirty and have not been checked
  100582. */
  100583. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100584. /**
  100585. * Prepares the defines related to multiview
  100586. * @param scene The scene we are intending to draw
  100587. * @param defines The defines to update
  100588. */
  100589. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100590. /**
  100591. * Prepares the defines related to the prepass
  100592. * @param scene The scene we are intending to draw
  100593. * @param defines The defines to update
  100594. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100595. */
  100596. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100597. /**
  100598. * Prepares the defines related to the light information passed in parameter
  100599. * @param scene The scene we are intending to draw
  100600. * @param mesh The mesh the effect is compiling for
  100601. * @param light The light the effect is compiling for
  100602. * @param lightIndex The index of the light
  100603. * @param defines The defines to update
  100604. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100605. * @param state Defines the current state regarding what is needed (normals, etc...)
  100606. */
  100607. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100608. needNormals: boolean;
  100609. needRebuild: boolean;
  100610. shadowEnabled: boolean;
  100611. specularEnabled: boolean;
  100612. lightmapMode: boolean;
  100613. }): void;
  100614. /**
  100615. * Prepares the defines related to the light information passed in parameter
  100616. * @param scene The scene we are intending to draw
  100617. * @param mesh The mesh the effect is compiling for
  100618. * @param defines The defines to update
  100619. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100620. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100621. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100622. * @returns true if normals will be required for the rest of the effect
  100623. */
  100624. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100625. /**
  100626. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100627. * @param lightIndex defines the light index
  100628. * @param uniformsList The uniform list
  100629. * @param samplersList The sampler list
  100630. * @param projectedLightTexture defines if projected texture must be used
  100631. * @param uniformBuffersList defines an optional list of uniform buffers
  100632. */
  100633. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100634. /**
  100635. * Prepares the uniforms and samplers list to be used in the effect
  100636. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100637. * @param samplersList The sampler list
  100638. * @param defines The defines helping in the list generation
  100639. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100640. */
  100641. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100642. /**
  100643. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100644. * @param defines The defines to update while falling back
  100645. * @param fallbacks The authorized effect fallbacks
  100646. * @param maxSimultaneousLights The maximum number of lights allowed
  100647. * @param rank the current rank of the Effect
  100648. * @returns The newly affected rank
  100649. */
  100650. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100651. private static _TmpMorphInfluencers;
  100652. /**
  100653. * Prepares the list of attributes required for morph targets according to the effect defines.
  100654. * @param attribs The current list of supported attribs
  100655. * @param mesh The mesh to prepare the morph targets attributes for
  100656. * @param influencers The number of influencers
  100657. */
  100658. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100659. /**
  100660. * Prepares the list of attributes required for morph targets according to the effect defines.
  100661. * @param attribs The current list of supported attribs
  100662. * @param mesh The mesh to prepare the morph targets attributes for
  100663. * @param defines The current Defines of the effect
  100664. */
  100665. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100666. /**
  100667. * Prepares the list of attributes required for bones according to the effect defines.
  100668. * @param attribs The current list of supported attribs
  100669. * @param mesh The mesh to prepare the bones attributes for
  100670. * @param defines The current Defines of the effect
  100671. * @param fallbacks The current efffect fallback strategy
  100672. */
  100673. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100674. /**
  100675. * Check and prepare the list of attributes required for instances according to the effect defines.
  100676. * @param attribs The current list of supported attribs
  100677. * @param defines The current MaterialDefines of the effect
  100678. */
  100679. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100680. /**
  100681. * Add the list of attributes required for instances to the attribs array.
  100682. * @param attribs The current list of supported attribs
  100683. */
  100684. static PushAttributesForInstances(attribs: string[]): void;
  100685. /**
  100686. * Binds the light information to the effect.
  100687. * @param light The light containing the generator
  100688. * @param effect The effect we are binding the data to
  100689. * @param lightIndex The light index in the effect used to render
  100690. */
  100691. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100692. /**
  100693. * Binds the lights information from the scene to the effect for the given mesh.
  100694. * @param light Light to bind
  100695. * @param lightIndex Light index
  100696. * @param scene The scene where the light belongs to
  100697. * @param effect The effect we are binding the data to
  100698. * @param useSpecular Defines if specular is supported
  100699. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100700. */
  100701. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100702. /**
  100703. * Binds the lights information from the scene to the effect for the given mesh.
  100704. * @param scene The scene the lights belongs to
  100705. * @param mesh The mesh we are binding the information to render
  100706. * @param effect The effect we are binding the data to
  100707. * @param defines The generated defines for the effect
  100708. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100709. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100710. */
  100711. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  100712. private static _tempFogColor;
  100713. /**
  100714. * Binds the fog information from the scene to the effect for the given mesh.
  100715. * @param scene The scene the lights belongs to
  100716. * @param mesh The mesh we are binding the information to render
  100717. * @param effect The effect we are binding the data to
  100718. * @param linearSpace Defines if the fog effect is applied in linear space
  100719. */
  100720. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  100721. /**
  100722. * Binds the bones information from the mesh to the effect.
  100723. * @param mesh The mesh we are binding the information to render
  100724. * @param effect The effect we are binding the data to
  100725. */
  100726. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  100727. /**
  100728. * Binds the morph targets information from the mesh to the effect.
  100729. * @param abstractMesh The mesh we are binding the information to render
  100730. * @param effect The effect we are binding the data to
  100731. */
  100732. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  100733. /**
  100734. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  100735. * @param defines The generated defines used in the effect
  100736. * @param effect The effect we are binding the data to
  100737. * @param scene The scene we are willing to render with logarithmic scale for
  100738. */
  100739. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  100740. /**
  100741. * Binds the clip plane information from the scene to the effect.
  100742. * @param scene The scene the clip plane information are extracted from
  100743. * @param effect The effect we are binding the data to
  100744. */
  100745. static BindClipPlane(effect: Effect, scene: Scene): void;
  100746. }
  100747. }
  100748. declare module BABYLON {
  100749. /**
  100750. * Block used to expose an input value
  100751. */
  100752. export class InputBlock extends NodeMaterialBlock {
  100753. private _mode;
  100754. private _associatedVariableName;
  100755. private _storedValue;
  100756. private _valueCallback;
  100757. private _type;
  100758. private _animationType;
  100759. /** Gets or set a value used to limit the range of float values */
  100760. min: number;
  100761. /** Gets or set a value used to limit the range of float values */
  100762. max: number;
  100763. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  100764. isBoolean: boolean;
  100765. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  100766. matrixMode: number;
  100767. /** @hidden */
  100768. _systemValue: Nullable<NodeMaterialSystemValues>;
  100769. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  100770. isConstant: boolean;
  100771. /** Gets or sets the group to use to display this block in the Inspector */
  100772. groupInInspector: string;
  100773. /** Gets an observable raised when the value is changed */
  100774. onValueChangedObservable: Observable<InputBlock>;
  100775. /**
  100776. * Gets or sets the connection point type (default is float)
  100777. */
  100778. get type(): NodeMaterialBlockConnectionPointTypes;
  100779. /**
  100780. * Creates a new InputBlock
  100781. * @param name defines the block name
  100782. * @param target defines the target of that block (Vertex by default)
  100783. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  100784. */
  100785. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  100786. /**
  100787. * Validates if a name is a reserve word.
  100788. * @param newName the new name to be given to the node.
  100789. * @returns false if the name is a reserve word, else true.
  100790. */
  100791. validateBlockName(newName: string): boolean;
  100792. /**
  100793. * Gets the output component
  100794. */
  100795. get output(): NodeMaterialConnectionPoint;
  100796. /**
  100797. * Set the source of this connection point to a vertex attribute
  100798. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  100799. * @returns the current connection point
  100800. */
  100801. setAsAttribute(attributeName?: string): InputBlock;
  100802. /**
  100803. * Set the source of this connection point to a system value
  100804. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  100805. * @returns the current connection point
  100806. */
  100807. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  100808. /**
  100809. * Gets or sets the value of that point.
  100810. * Please note that this value will be ignored if valueCallback is defined
  100811. */
  100812. get value(): any;
  100813. set value(value: any);
  100814. /**
  100815. * Gets or sets a callback used to get the value of that point.
  100816. * Please note that setting this value will force the connection point to ignore the value property
  100817. */
  100818. get valueCallback(): () => any;
  100819. set valueCallback(value: () => any);
  100820. /**
  100821. * Gets or sets the associated variable name in the shader
  100822. */
  100823. get associatedVariableName(): string;
  100824. set associatedVariableName(value: string);
  100825. /** Gets or sets the type of animation applied to the input */
  100826. get animationType(): AnimatedInputBlockTypes;
  100827. set animationType(value: AnimatedInputBlockTypes);
  100828. /**
  100829. * Gets a boolean indicating that this connection point not defined yet
  100830. */
  100831. get isUndefined(): boolean;
  100832. /**
  100833. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  100834. * In this case the connection point name must be the name of the uniform to use.
  100835. * Can only be set on inputs
  100836. */
  100837. get isUniform(): boolean;
  100838. set isUniform(value: boolean);
  100839. /**
  100840. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  100841. * In this case the connection point name must be the name of the attribute to use
  100842. * Can only be set on inputs
  100843. */
  100844. get isAttribute(): boolean;
  100845. set isAttribute(value: boolean);
  100846. /**
  100847. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  100848. * Can only be set on exit points
  100849. */
  100850. get isVarying(): boolean;
  100851. set isVarying(value: boolean);
  100852. /**
  100853. * Gets a boolean indicating that the current connection point is a system value
  100854. */
  100855. get isSystemValue(): boolean;
  100856. /**
  100857. * Gets or sets the current well known value or null if not defined as a system value
  100858. */
  100859. get systemValue(): Nullable<NodeMaterialSystemValues>;
  100860. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  100861. /**
  100862. * Gets the current class name
  100863. * @returns the class name
  100864. */
  100865. getClassName(): string;
  100866. /**
  100867. * Animate the input if animationType !== None
  100868. * @param scene defines the rendering scene
  100869. */
  100870. animate(scene: Scene): void;
  100871. private _emitDefine;
  100872. initialize(state: NodeMaterialBuildState): void;
  100873. /**
  100874. * Set the input block to its default value (based on its type)
  100875. */
  100876. setDefaultValue(): void;
  100877. private _emitConstant;
  100878. /** @hidden */
  100879. get _noContextSwitch(): boolean;
  100880. private _emit;
  100881. /** @hidden */
  100882. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  100883. /** @hidden */
  100884. _transmit(effect: Effect, scene: Scene): void;
  100885. protected _buildBlock(state: NodeMaterialBuildState): void;
  100886. protected _dumpPropertiesCode(): string;
  100887. dispose(): void;
  100888. serialize(): any;
  100889. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  100890. }
  100891. }
  100892. declare module BABYLON {
  100893. /**
  100894. * Enum used to define the compatibility state between two connection points
  100895. */
  100896. export enum NodeMaterialConnectionPointCompatibilityStates {
  100897. /** Points are compatibles */
  100898. Compatible = 0,
  100899. /** Points are incompatible because of their types */
  100900. TypeIncompatible = 1,
  100901. /** Points are incompatible because of their targets (vertex vs fragment) */
  100902. TargetIncompatible = 2
  100903. }
  100904. /**
  100905. * Defines the direction of a connection point
  100906. */
  100907. export enum NodeMaterialConnectionPointDirection {
  100908. /** Input */
  100909. Input = 0,
  100910. /** Output */
  100911. Output = 1
  100912. }
  100913. /**
  100914. * Defines a connection point for a block
  100915. */
  100916. export class NodeMaterialConnectionPoint {
  100917. /** @hidden */
  100918. _ownerBlock: NodeMaterialBlock;
  100919. /** @hidden */
  100920. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  100921. private _endpoints;
  100922. private _associatedVariableName;
  100923. private _direction;
  100924. /** @hidden */
  100925. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100926. /** @hidden */
  100927. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  100928. private _type;
  100929. /** @hidden */
  100930. _enforceAssociatedVariableName: boolean;
  100931. /** Gets the direction of the point */
  100932. get direction(): NodeMaterialConnectionPointDirection;
  100933. /** Indicates that this connection point needs dual validation before being connected to another point */
  100934. needDualDirectionValidation: boolean;
  100935. /**
  100936. * Gets or sets the additional types supported by this connection point
  100937. */
  100938. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100939. /**
  100940. * Gets or sets the additional types excluded by this connection point
  100941. */
  100942. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  100943. /**
  100944. * Observable triggered when this point is connected
  100945. */
  100946. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  100947. /**
  100948. * Gets or sets the associated variable name in the shader
  100949. */
  100950. get associatedVariableName(): string;
  100951. set associatedVariableName(value: string);
  100952. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  100953. get innerType(): NodeMaterialBlockConnectionPointTypes;
  100954. /**
  100955. * Gets or sets the connection point type (default is float)
  100956. */
  100957. get type(): NodeMaterialBlockConnectionPointTypes;
  100958. set type(value: NodeMaterialBlockConnectionPointTypes);
  100959. /**
  100960. * Gets or sets the connection point name
  100961. */
  100962. name: string;
  100963. /**
  100964. * Gets or sets the connection point name
  100965. */
  100966. displayName: string;
  100967. /**
  100968. * Gets or sets a boolean indicating that this connection point can be omitted
  100969. */
  100970. isOptional: boolean;
  100971. /**
  100972. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  100973. */
  100974. isExposedOnFrame: boolean;
  100975. /**
  100976. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  100977. */
  100978. define: string;
  100979. /** @hidden */
  100980. _prioritizeVertex: boolean;
  100981. private _target;
  100982. /** Gets or sets the target of that connection point */
  100983. get target(): NodeMaterialBlockTargets;
  100984. set target(value: NodeMaterialBlockTargets);
  100985. /**
  100986. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  100987. */
  100988. get isConnected(): boolean;
  100989. /**
  100990. * Gets a boolean indicating that the current point is connected to an input block
  100991. */
  100992. get isConnectedToInputBlock(): boolean;
  100993. /**
  100994. * Gets a the connected input block (if any)
  100995. */
  100996. get connectInputBlock(): Nullable<InputBlock>;
  100997. /** Get the other side of the connection (if any) */
  100998. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  100999. /** Get the block that owns this connection point */
  101000. get ownerBlock(): NodeMaterialBlock;
  101001. /** Get the block connected on the other side of this connection (if any) */
  101002. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101003. /** Get the block connected on the endpoints of this connection (if any) */
  101004. get connectedBlocks(): Array<NodeMaterialBlock>;
  101005. /** Gets the list of connected endpoints */
  101006. get endpoints(): NodeMaterialConnectionPoint[];
  101007. /** Gets a boolean indicating if that output point is connected to at least one input */
  101008. get hasEndpoints(): boolean;
  101009. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101010. get isConnectedInVertexShader(): boolean;
  101011. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101012. get isConnectedInFragmentShader(): boolean;
  101013. /**
  101014. * Creates a block suitable to be used as an input for this input point.
  101015. * If null is returned, a block based on the point type will be created.
  101016. * @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
  101017. */
  101018. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101019. /**
  101020. * Creates a new connection point
  101021. * @param name defines the connection point name
  101022. * @param ownerBlock defines the block hosting this connection point
  101023. * @param direction defines the direction of the connection point
  101024. */
  101025. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101026. /**
  101027. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101028. * @returns the class name
  101029. */
  101030. getClassName(): string;
  101031. /**
  101032. * Gets a boolean indicating if the current point can be connected to another point
  101033. * @param connectionPoint defines the other connection point
  101034. * @returns a boolean
  101035. */
  101036. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101037. /**
  101038. * Gets a number indicating if the current point can be connected to another point
  101039. * @param connectionPoint defines the other connection point
  101040. * @returns a number defining the compatibility state
  101041. */
  101042. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101043. /**
  101044. * Connect this point to another connection point
  101045. * @param connectionPoint defines the other connection point
  101046. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101047. * @returns the current connection point
  101048. */
  101049. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101050. /**
  101051. * Disconnect this point from one of his endpoint
  101052. * @param endpoint defines the other connection point
  101053. * @returns the current connection point
  101054. */
  101055. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101056. /**
  101057. * Serializes this point in a JSON representation
  101058. * @param isInput defines if the connection point is an input (default is true)
  101059. * @returns the serialized point object
  101060. */
  101061. serialize(isInput?: boolean): any;
  101062. /**
  101063. * Release resources
  101064. */
  101065. dispose(): void;
  101066. }
  101067. }
  101068. declare module BABYLON {
  101069. /**
  101070. * Enum used to define the material modes
  101071. */
  101072. export enum NodeMaterialModes {
  101073. /** Regular material */
  101074. Material = 0,
  101075. /** For post process */
  101076. PostProcess = 1,
  101077. /** For particle system */
  101078. Particle = 2,
  101079. /** For procedural texture */
  101080. ProceduralTexture = 3
  101081. }
  101082. }
  101083. declare module BABYLON {
  101084. /**
  101085. * Block used to read a texture from a sampler
  101086. */
  101087. export class TextureBlock extends NodeMaterialBlock {
  101088. private _defineName;
  101089. private _linearDefineName;
  101090. private _gammaDefineName;
  101091. private _tempTextureRead;
  101092. private _samplerName;
  101093. private _transformedUVName;
  101094. private _textureTransformName;
  101095. private _textureInfoName;
  101096. private _mainUVName;
  101097. private _mainUVDefineName;
  101098. private _fragmentOnly;
  101099. /**
  101100. * Gets or sets the texture associated with the node
  101101. */
  101102. texture: Nullable<Texture>;
  101103. /**
  101104. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101105. */
  101106. convertToGammaSpace: boolean;
  101107. /**
  101108. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101109. */
  101110. convertToLinearSpace: boolean;
  101111. /**
  101112. * Create a new TextureBlock
  101113. * @param name defines the block name
  101114. */
  101115. constructor(name: string, fragmentOnly?: boolean);
  101116. /**
  101117. * Gets the current class name
  101118. * @returns the class name
  101119. */
  101120. getClassName(): string;
  101121. /**
  101122. * Gets the uv input component
  101123. */
  101124. get uv(): NodeMaterialConnectionPoint;
  101125. /**
  101126. * Gets the rgba output component
  101127. */
  101128. get rgba(): NodeMaterialConnectionPoint;
  101129. /**
  101130. * Gets the rgb output component
  101131. */
  101132. get rgb(): NodeMaterialConnectionPoint;
  101133. /**
  101134. * Gets the r output component
  101135. */
  101136. get r(): NodeMaterialConnectionPoint;
  101137. /**
  101138. * Gets the g output component
  101139. */
  101140. get g(): NodeMaterialConnectionPoint;
  101141. /**
  101142. * Gets the b output component
  101143. */
  101144. get b(): NodeMaterialConnectionPoint;
  101145. /**
  101146. * Gets the a output component
  101147. */
  101148. get a(): NodeMaterialConnectionPoint;
  101149. get target(): NodeMaterialBlockTargets;
  101150. autoConfigure(material: NodeMaterial): void;
  101151. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101152. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101153. isReady(): boolean;
  101154. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101155. private get _isMixed();
  101156. private _injectVertexCode;
  101157. private _writeTextureRead;
  101158. private _writeOutput;
  101159. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101160. protected _dumpPropertiesCode(): string;
  101161. serialize(): any;
  101162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101163. }
  101164. }
  101165. declare module BABYLON {
  101166. /** @hidden */
  101167. export var reflectionFunction: {
  101168. name: string;
  101169. shader: string;
  101170. };
  101171. }
  101172. declare module BABYLON {
  101173. /**
  101174. * Base block used to read a reflection texture from a sampler
  101175. */
  101176. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101177. /** @hidden */
  101178. _define3DName: string;
  101179. /** @hidden */
  101180. _defineCubicName: string;
  101181. /** @hidden */
  101182. _defineExplicitName: string;
  101183. /** @hidden */
  101184. _defineProjectionName: string;
  101185. /** @hidden */
  101186. _defineLocalCubicName: string;
  101187. /** @hidden */
  101188. _defineSphericalName: string;
  101189. /** @hidden */
  101190. _definePlanarName: string;
  101191. /** @hidden */
  101192. _defineEquirectangularName: string;
  101193. /** @hidden */
  101194. _defineMirroredEquirectangularFixedName: string;
  101195. /** @hidden */
  101196. _defineEquirectangularFixedName: string;
  101197. /** @hidden */
  101198. _defineSkyboxName: string;
  101199. /** @hidden */
  101200. _defineOppositeZ: string;
  101201. /** @hidden */
  101202. _cubeSamplerName: string;
  101203. /** @hidden */
  101204. _2DSamplerName: string;
  101205. protected _positionUVWName: string;
  101206. protected _directionWName: string;
  101207. protected _reflectionVectorName: string;
  101208. /** @hidden */
  101209. _reflectionCoordsName: string;
  101210. /** @hidden */
  101211. _reflectionMatrixName: string;
  101212. protected _reflectionColorName: string;
  101213. /**
  101214. * Gets or sets the texture associated with the node
  101215. */
  101216. texture: Nullable<BaseTexture>;
  101217. /**
  101218. * Create a new ReflectionTextureBaseBlock
  101219. * @param name defines the block name
  101220. */
  101221. constructor(name: string);
  101222. /**
  101223. * Gets the current class name
  101224. * @returns the class name
  101225. */
  101226. getClassName(): string;
  101227. /**
  101228. * Gets the world position input component
  101229. */
  101230. abstract get position(): NodeMaterialConnectionPoint;
  101231. /**
  101232. * Gets the world position input component
  101233. */
  101234. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101235. /**
  101236. * Gets the world normal input component
  101237. */
  101238. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101239. /**
  101240. * Gets the world input component
  101241. */
  101242. abstract get world(): NodeMaterialConnectionPoint;
  101243. /**
  101244. * Gets the camera (or eye) position component
  101245. */
  101246. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101247. /**
  101248. * Gets the view input component
  101249. */
  101250. abstract get view(): NodeMaterialConnectionPoint;
  101251. protected _getTexture(): Nullable<BaseTexture>;
  101252. autoConfigure(material: NodeMaterial): void;
  101253. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101254. isReady(): boolean;
  101255. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101256. /**
  101257. * Gets the code to inject in the vertex shader
  101258. * @param state current state of the node material building
  101259. * @returns the shader code
  101260. */
  101261. handleVertexSide(state: NodeMaterialBuildState): string;
  101262. /**
  101263. * Handles the inits for the fragment code path
  101264. * @param state node material build state
  101265. */
  101266. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101267. /**
  101268. * Generates the reflection coords code for the fragment code path
  101269. * @param worldNormalVarName name of the world normal variable
  101270. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101271. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101272. * @returns the shader code
  101273. */
  101274. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101275. /**
  101276. * Generates the reflection color code for the fragment code path
  101277. * @param lodVarName name of the lod variable
  101278. * @param swizzleLookupTexture swizzle to use for the final color variable
  101279. * @returns the shader code
  101280. */
  101281. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101282. /**
  101283. * Generates the code corresponding to the connected output points
  101284. * @param state node material build state
  101285. * @param varName name of the variable to output
  101286. * @returns the shader code
  101287. */
  101288. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101289. protected _buildBlock(state: NodeMaterialBuildState): this;
  101290. protected _dumpPropertiesCode(): string;
  101291. serialize(): any;
  101292. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101293. }
  101294. }
  101295. declare module BABYLON {
  101296. /**
  101297. * Defines a connection point to be used for points with a custom object type
  101298. */
  101299. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101300. private _blockType;
  101301. private _blockName;
  101302. private _nameForCheking?;
  101303. /**
  101304. * Creates a new connection point
  101305. * @param name defines the connection point name
  101306. * @param ownerBlock defines the block hosting this connection point
  101307. * @param direction defines the direction of the connection point
  101308. */
  101309. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101310. /**
  101311. * Gets a number indicating if the current point can be connected to another point
  101312. * @param connectionPoint defines the other connection point
  101313. * @returns a number defining the compatibility state
  101314. */
  101315. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101316. /**
  101317. * Creates a block suitable to be used as an input for this input point.
  101318. * If null is returned, a block based on the point type will be created.
  101319. * @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
  101320. */
  101321. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101322. }
  101323. }
  101324. declare module BABYLON {
  101325. /**
  101326. * Enum defining the type of properties that can be edited in the property pages in the NME
  101327. */
  101328. export enum PropertyTypeForEdition {
  101329. /** property is a boolean */
  101330. Boolean = 0,
  101331. /** property is a float */
  101332. Float = 1,
  101333. /** property is a Vector2 */
  101334. Vector2 = 2,
  101335. /** property is a list of values */
  101336. List = 3
  101337. }
  101338. /**
  101339. * Interface that defines an option in a variable of type list
  101340. */
  101341. export interface IEditablePropertyListOption {
  101342. /** label of the option */
  101343. "label": string;
  101344. /** value of the option */
  101345. "value": number;
  101346. }
  101347. /**
  101348. * Interface that defines the options available for an editable property
  101349. */
  101350. export interface IEditablePropertyOption {
  101351. /** min value */
  101352. "min"?: number;
  101353. /** max value */
  101354. "max"?: number;
  101355. /** notifiers: indicates which actions to take when the property is changed */
  101356. "notifiers"?: {
  101357. /** the material should be rebuilt */
  101358. "rebuild"?: boolean;
  101359. /** the preview should be updated */
  101360. "update"?: boolean;
  101361. };
  101362. /** list of the options for a variable of type list */
  101363. "options"?: IEditablePropertyListOption[];
  101364. }
  101365. /**
  101366. * Interface that describes an editable property
  101367. */
  101368. export interface IPropertyDescriptionForEdition {
  101369. /** name of the property */
  101370. "propertyName": string;
  101371. /** display name of the property */
  101372. "displayName": string;
  101373. /** type of the property */
  101374. "type": PropertyTypeForEdition;
  101375. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101376. "groupName": string;
  101377. /** options for the property */
  101378. "options": IEditablePropertyOption;
  101379. }
  101380. /**
  101381. * Decorator that flags a property in a node material block as being editable
  101382. */
  101383. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101384. }
  101385. declare module BABYLON {
  101386. /**
  101387. * Block used to implement the refraction part of the sub surface module of the PBR material
  101388. */
  101389. export class RefractionBlock extends NodeMaterialBlock {
  101390. /** @hidden */
  101391. _define3DName: string;
  101392. /** @hidden */
  101393. _refractionMatrixName: string;
  101394. /** @hidden */
  101395. _defineLODRefractionAlpha: string;
  101396. /** @hidden */
  101397. _defineLinearSpecularRefraction: string;
  101398. /** @hidden */
  101399. _defineOppositeZ: string;
  101400. /** @hidden */
  101401. _cubeSamplerName: string;
  101402. /** @hidden */
  101403. _2DSamplerName: string;
  101404. /** @hidden */
  101405. _vRefractionMicrosurfaceInfosName: string;
  101406. /** @hidden */
  101407. _vRefractionInfosName: string;
  101408. private _scene;
  101409. /**
  101410. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101411. * Materials half opaque for instance using refraction could benefit from this control.
  101412. */
  101413. linkRefractionWithTransparency: boolean;
  101414. /**
  101415. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101416. */
  101417. invertRefractionY: boolean;
  101418. /**
  101419. * Gets or sets the texture associated with the node
  101420. */
  101421. texture: Nullable<BaseTexture>;
  101422. /**
  101423. * Create a new RefractionBlock
  101424. * @param name defines the block name
  101425. */
  101426. constructor(name: string);
  101427. /**
  101428. * Gets the current class name
  101429. * @returns the class name
  101430. */
  101431. getClassName(): string;
  101432. /**
  101433. * Gets the intensity input component
  101434. */
  101435. get intensity(): NodeMaterialConnectionPoint;
  101436. /**
  101437. * Gets the index of refraction input component
  101438. */
  101439. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101440. /**
  101441. * Gets the tint at distance input component
  101442. */
  101443. get tintAtDistance(): NodeMaterialConnectionPoint;
  101444. /**
  101445. * Gets the view input component
  101446. */
  101447. get view(): NodeMaterialConnectionPoint;
  101448. /**
  101449. * Gets the refraction object output component
  101450. */
  101451. get refraction(): NodeMaterialConnectionPoint;
  101452. /**
  101453. * Returns true if the block has a texture
  101454. */
  101455. get hasTexture(): boolean;
  101456. protected _getTexture(): Nullable<BaseTexture>;
  101457. autoConfigure(material: NodeMaterial): void;
  101458. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101459. isReady(): boolean;
  101460. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101461. /**
  101462. * Gets the main code of the block (fragment side)
  101463. * @param state current state of the node material building
  101464. * @returns the shader code
  101465. */
  101466. getCode(state: NodeMaterialBuildState): string;
  101467. protected _buildBlock(state: NodeMaterialBuildState): this;
  101468. protected _dumpPropertiesCode(): string;
  101469. serialize(): any;
  101470. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101471. }
  101472. }
  101473. declare module BABYLON {
  101474. /**
  101475. * Base block used as input for post process
  101476. */
  101477. export class CurrentScreenBlock extends NodeMaterialBlock {
  101478. private _samplerName;
  101479. private _linearDefineName;
  101480. private _gammaDefineName;
  101481. private _mainUVName;
  101482. private _tempTextureRead;
  101483. /**
  101484. * Gets or sets the texture associated with the node
  101485. */
  101486. texture: Nullable<BaseTexture>;
  101487. /**
  101488. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101489. */
  101490. convertToGammaSpace: boolean;
  101491. /**
  101492. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101493. */
  101494. convertToLinearSpace: boolean;
  101495. /**
  101496. * Create a new CurrentScreenBlock
  101497. * @param name defines the block name
  101498. */
  101499. constructor(name: string);
  101500. /**
  101501. * Gets the current class name
  101502. * @returns the class name
  101503. */
  101504. getClassName(): string;
  101505. /**
  101506. * Gets the uv input component
  101507. */
  101508. get uv(): NodeMaterialConnectionPoint;
  101509. /**
  101510. * Gets the rgba output component
  101511. */
  101512. get rgba(): NodeMaterialConnectionPoint;
  101513. /**
  101514. * Gets the rgb output component
  101515. */
  101516. get rgb(): NodeMaterialConnectionPoint;
  101517. /**
  101518. * Gets the r output component
  101519. */
  101520. get r(): NodeMaterialConnectionPoint;
  101521. /**
  101522. * Gets the g output component
  101523. */
  101524. get g(): NodeMaterialConnectionPoint;
  101525. /**
  101526. * Gets the b output component
  101527. */
  101528. get b(): NodeMaterialConnectionPoint;
  101529. /**
  101530. * Gets the a output component
  101531. */
  101532. get a(): NodeMaterialConnectionPoint;
  101533. /**
  101534. * Initialize the block and prepare the context for build
  101535. * @param state defines the state that will be used for the build
  101536. */
  101537. initialize(state: NodeMaterialBuildState): void;
  101538. get target(): NodeMaterialBlockTargets;
  101539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101540. isReady(): boolean;
  101541. private _injectVertexCode;
  101542. private _writeTextureRead;
  101543. private _writeOutput;
  101544. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101545. serialize(): any;
  101546. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101547. }
  101548. }
  101549. declare module BABYLON {
  101550. /**
  101551. * Base block used for the particle texture
  101552. */
  101553. export class ParticleTextureBlock extends NodeMaterialBlock {
  101554. private _samplerName;
  101555. private _linearDefineName;
  101556. private _gammaDefineName;
  101557. private _tempTextureRead;
  101558. /**
  101559. * Gets or sets the texture associated with the node
  101560. */
  101561. texture: Nullable<BaseTexture>;
  101562. /**
  101563. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101564. */
  101565. convertToGammaSpace: boolean;
  101566. /**
  101567. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101568. */
  101569. convertToLinearSpace: boolean;
  101570. /**
  101571. * Create a new ParticleTextureBlock
  101572. * @param name defines the block name
  101573. */
  101574. constructor(name: string);
  101575. /**
  101576. * Gets the current class name
  101577. * @returns the class name
  101578. */
  101579. getClassName(): string;
  101580. /**
  101581. * Gets the uv input component
  101582. */
  101583. get uv(): NodeMaterialConnectionPoint;
  101584. /**
  101585. * Gets the rgba output component
  101586. */
  101587. get rgba(): NodeMaterialConnectionPoint;
  101588. /**
  101589. * Gets the rgb output component
  101590. */
  101591. get rgb(): NodeMaterialConnectionPoint;
  101592. /**
  101593. * Gets the r output component
  101594. */
  101595. get r(): NodeMaterialConnectionPoint;
  101596. /**
  101597. * Gets the g output component
  101598. */
  101599. get g(): NodeMaterialConnectionPoint;
  101600. /**
  101601. * Gets the b output component
  101602. */
  101603. get b(): NodeMaterialConnectionPoint;
  101604. /**
  101605. * Gets the a output component
  101606. */
  101607. get a(): NodeMaterialConnectionPoint;
  101608. /**
  101609. * Initialize the block and prepare the context for build
  101610. * @param state defines the state that will be used for the build
  101611. */
  101612. initialize(state: NodeMaterialBuildState): void;
  101613. autoConfigure(material: NodeMaterial): void;
  101614. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101615. isReady(): boolean;
  101616. private _writeOutput;
  101617. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101618. serialize(): any;
  101619. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101620. }
  101621. }
  101622. declare module BABYLON {
  101623. /**
  101624. * Class used to store shared data between 2 NodeMaterialBuildState
  101625. */
  101626. export class NodeMaterialBuildStateSharedData {
  101627. /**
  101628. * Gets the list of emitted varyings
  101629. */
  101630. temps: string[];
  101631. /**
  101632. * Gets the list of emitted varyings
  101633. */
  101634. varyings: string[];
  101635. /**
  101636. * Gets the varying declaration string
  101637. */
  101638. varyingDeclaration: string;
  101639. /**
  101640. * Input blocks
  101641. */
  101642. inputBlocks: InputBlock[];
  101643. /**
  101644. * Input blocks
  101645. */
  101646. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101647. /**
  101648. * Bindable blocks (Blocks that need to set data to the effect)
  101649. */
  101650. bindableBlocks: NodeMaterialBlock[];
  101651. /**
  101652. * List of blocks that can provide a compilation fallback
  101653. */
  101654. blocksWithFallbacks: NodeMaterialBlock[];
  101655. /**
  101656. * List of blocks that can provide a define update
  101657. */
  101658. blocksWithDefines: NodeMaterialBlock[];
  101659. /**
  101660. * List of blocks that can provide a repeatable content
  101661. */
  101662. repeatableContentBlocks: NodeMaterialBlock[];
  101663. /**
  101664. * List of blocks that can provide a dynamic list of uniforms
  101665. */
  101666. dynamicUniformBlocks: NodeMaterialBlock[];
  101667. /**
  101668. * List of blocks that can block the isReady function for the material
  101669. */
  101670. blockingBlocks: NodeMaterialBlock[];
  101671. /**
  101672. * Gets the list of animated inputs
  101673. */
  101674. animatedInputs: InputBlock[];
  101675. /**
  101676. * Build Id used to avoid multiple recompilations
  101677. */
  101678. buildId: number;
  101679. /** List of emitted variables */
  101680. variableNames: {
  101681. [key: string]: number;
  101682. };
  101683. /** List of emitted defines */
  101684. defineNames: {
  101685. [key: string]: number;
  101686. };
  101687. /** Should emit comments? */
  101688. emitComments: boolean;
  101689. /** Emit build activity */
  101690. verbose: boolean;
  101691. /** Gets or sets the hosting scene */
  101692. scene: Scene;
  101693. /**
  101694. * Gets the compilation hints emitted at compilation time
  101695. */
  101696. hints: {
  101697. needWorldViewMatrix: boolean;
  101698. needWorldViewProjectionMatrix: boolean;
  101699. needAlphaBlending: boolean;
  101700. needAlphaTesting: boolean;
  101701. };
  101702. /**
  101703. * List of compilation checks
  101704. */
  101705. checks: {
  101706. emitVertex: boolean;
  101707. emitFragment: boolean;
  101708. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  101709. };
  101710. /**
  101711. * Is vertex program allowed to be empty?
  101712. */
  101713. allowEmptyVertexProgram: boolean;
  101714. /** Creates a new shared data */
  101715. constructor();
  101716. /**
  101717. * Emits console errors and exceptions if there is a failing check
  101718. */
  101719. emitErrors(): void;
  101720. }
  101721. }
  101722. declare module BABYLON {
  101723. /**
  101724. * Class used to store node based material build state
  101725. */
  101726. export class NodeMaterialBuildState {
  101727. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  101728. supportUniformBuffers: boolean;
  101729. /**
  101730. * Gets the list of emitted attributes
  101731. */
  101732. attributes: string[];
  101733. /**
  101734. * Gets the list of emitted uniforms
  101735. */
  101736. uniforms: string[];
  101737. /**
  101738. * Gets the list of emitted constants
  101739. */
  101740. constants: string[];
  101741. /**
  101742. * Gets the list of emitted samplers
  101743. */
  101744. samplers: string[];
  101745. /**
  101746. * Gets the list of emitted functions
  101747. */
  101748. functions: {
  101749. [key: string]: string;
  101750. };
  101751. /**
  101752. * Gets the list of emitted extensions
  101753. */
  101754. extensions: {
  101755. [key: string]: string;
  101756. };
  101757. /**
  101758. * Gets the target of the compilation state
  101759. */
  101760. target: NodeMaterialBlockTargets;
  101761. /**
  101762. * Gets the list of emitted counters
  101763. */
  101764. counters: {
  101765. [key: string]: number;
  101766. };
  101767. /**
  101768. * Shared data between multiple NodeMaterialBuildState instances
  101769. */
  101770. sharedData: NodeMaterialBuildStateSharedData;
  101771. /** @hidden */
  101772. _vertexState: NodeMaterialBuildState;
  101773. /** @hidden */
  101774. _attributeDeclaration: string;
  101775. /** @hidden */
  101776. _uniformDeclaration: string;
  101777. /** @hidden */
  101778. _constantDeclaration: string;
  101779. /** @hidden */
  101780. _samplerDeclaration: string;
  101781. /** @hidden */
  101782. _varyingTransfer: string;
  101783. /** @hidden */
  101784. _injectAtEnd: string;
  101785. private _repeatableContentAnchorIndex;
  101786. /** @hidden */
  101787. _builtCompilationString: string;
  101788. /**
  101789. * Gets the emitted compilation strings
  101790. */
  101791. compilationString: string;
  101792. /**
  101793. * Finalize the compilation strings
  101794. * @param state defines the current compilation state
  101795. */
  101796. finalize(state: NodeMaterialBuildState): void;
  101797. /** @hidden */
  101798. get _repeatableContentAnchor(): string;
  101799. /** @hidden */
  101800. _getFreeVariableName(prefix: string): string;
  101801. /** @hidden */
  101802. _getFreeDefineName(prefix: string): string;
  101803. /** @hidden */
  101804. _excludeVariableName(name: string): void;
  101805. /** @hidden */
  101806. _emit2DSampler(name: string): void;
  101807. /** @hidden */
  101808. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  101809. /** @hidden */
  101810. _emitExtension(name: string, extension: string, define?: string): void;
  101811. /** @hidden */
  101812. _emitFunction(name: string, code: string, comments: string): void;
  101813. /** @hidden */
  101814. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  101815. replaceStrings?: {
  101816. search: RegExp;
  101817. replace: string;
  101818. }[];
  101819. repeatKey?: string;
  101820. }): string;
  101821. /** @hidden */
  101822. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  101823. repeatKey?: string;
  101824. removeAttributes?: boolean;
  101825. removeUniforms?: boolean;
  101826. removeVaryings?: boolean;
  101827. removeIfDef?: boolean;
  101828. replaceStrings?: {
  101829. search: RegExp;
  101830. replace: string;
  101831. }[];
  101832. }, storeKey?: string): void;
  101833. /** @hidden */
  101834. _registerTempVariable(name: string): boolean;
  101835. /** @hidden */
  101836. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  101837. /** @hidden */
  101838. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  101839. /** @hidden */
  101840. _emitFloat(value: number): string;
  101841. }
  101842. }
  101843. declare module BABYLON {
  101844. /**
  101845. * Helper class used to generate session unique ID
  101846. */
  101847. export class UniqueIdGenerator {
  101848. private static _UniqueIdCounter;
  101849. /**
  101850. * Gets an unique (relatively to the current scene) Id
  101851. */
  101852. static get UniqueId(): number;
  101853. }
  101854. }
  101855. declare module BABYLON {
  101856. /**
  101857. * Defines a block that can be used inside a node based material
  101858. */
  101859. export class NodeMaterialBlock {
  101860. private _buildId;
  101861. private _buildTarget;
  101862. private _target;
  101863. private _isFinalMerger;
  101864. private _isInput;
  101865. private _name;
  101866. protected _isUnique: boolean;
  101867. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  101868. inputsAreExclusive: boolean;
  101869. /** @hidden */
  101870. _codeVariableName: string;
  101871. /** @hidden */
  101872. _inputs: NodeMaterialConnectionPoint[];
  101873. /** @hidden */
  101874. _outputs: NodeMaterialConnectionPoint[];
  101875. /** @hidden */
  101876. _preparationId: number;
  101877. /**
  101878. * Gets the name of the block
  101879. */
  101880. get name(): string;
  101881. /**
  101882. * Sets the name of the block. Will check if the name is valid.
  101883. */
  101884. set name(newName: string);
  101885. /**
  101886. * Gets or sets the unique id of the node
  101887. */
  101888. uniqueId: number;
  101889. /**
  101890. * Gets or sets the comments associated with this block
  101891. */
  101892. comments: string;
  101893. /**
  101894. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  101895. */
  101896. get isUnique(): boolean;
  101897. /**
  101898. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  101899. */
  101900. get isFinalMerger(): boolean;
  101901. /**
  101902. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  101903. */
  101904. get isInput(): boolean;
  101905. /**
  101906. * Gets or sets the build Id
  101907. */
  101908. get buildId(): number;
  101909. set buildId(value: number);
  101910. /**
  101911. * Gets or sets the target of the block
  101912. */
  101913. get target(): NodeMaterialBlockTargets;
  101914. set target(value: NodeMaterialBlockTargets);
  101915. /**
  101916. * Gets the list of input points
  101917. */
  101918. get inputs(): NodeMaterialConnectionPoint[];
  101919. /** Gets the list of output points */
  101920. get outputs(): NodeMaterialConnectionPoint[];
  101921. /**
  101922. * Find an input by its name
  101923. * @param name defines the name of the input to look for
  101924. * @returns the input or null if not found
  101925. */
  101926. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101927. /**
  101928. * Find an output by its name
  101929. * @param name defines the name of the outputto look for
  101930. * @returns the output or null if not found
  101931. */
  101932. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  101933. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  101934. visibleInInspector: boolean;
  101935. /**
  101936. * Creates a new NodeMaterialBlock
  101937. * @param name defines the block name
  101938. * @param target defines the target of that block (Vertex by default)
  101939. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  101940. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  101941. */
  101942. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  101943. /**
  101944. * Initialize the block and prepare the context for build
  101945. * @param state defines the state that will be used for the build
  101946. */
  101947. initialize(state: NodeMaterialBuildState): void;
  101948. /**
  101949. * Bind data to effect. Will only be called for blocks with isBindable === true
  101950. * @param effect defines the effect to bind data to
  101951. * @param nodeMaterial defines the hosting NodeMaterial
  101952. * @param mesh defines the mesh that will be rendered
  101953. * @param subMesh defines the submesh that will be rendered
  101954. */
  101955. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101956. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  101957. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  101958. protected _writeFloat(value: number): string;
  101959. /**
  101960. * Gets the current class name e.g. "NodeMaterialBlock"
  101961. * @returns the class name
  101962. */
  101963. getClassName(): string;
  101964. /**
  101965. * Register a new input. Must be called inside a block constructor
  101966. * @param name defines the connection point name
  101967. * @param type defines the connection point type
  101968. * @param isOptional defines a boolean indicating that this input can be omitted
  101969. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101970. * @param point an already created connection point. If not provided, create a new one
  101971. * @returns the current block
  101972. */
  101973. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101974. /**
  101975. * Register a new output. Must be called inside a block constructor
  101976. * @param name defines the connection point name
  101977. * @param type defines the connection point type
  101978. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  101979. * @param point an already created connection point. If not provided, create a new one
  101980. * @returns the current block
  101981. */
  101982. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  101983. /**
  101984. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  101985. * @param forOutput defines an optional connection point to check compatibility with
  101986. * @returns the first available input or null
  101987. */
  101988. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  101989. /**
  101990. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  101991. * @param forBlock defines an optional block to check compatibility with
  101992. * @returns the first available input or null
  101993. */
  101994. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  101995. /**
  101996. * Gets the sibling of the given output
  101997. * @param current defines the current output
  101998. * @returns the next output in the list or null
  101999. */
  102000. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102001. /**
  102002. * Connect current block with another block
  102003. * @param other defines the block to connect with
  102004. * @param options define the various options to help pick the right connections
  102005. * @returns the current block
  102006. */
  102007. connectTo(other: NodeMaterialBlock, options?: {
  102008. input?: string;
  102009. output?: string;
  102010. outputSwizzle?: string;
  102011. }): this | undefined;
  102012. protected _buildBlock(state: NodeMaterialBuildState): void;
  102013. /**
  102014. * Add uniforms, samplers and uniform buffers at compilation time
  102015. * @param state defines the state to update
  102016. * @param nodeMaterial defines the node material requesting the update
  102017. * @param defines defines the material defines to update
  102018. * @param uniformBuffers defines the list of uniform buffer names
  102019. */
  102020. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102021. /**
  102022. * Add potential fallbacks if shader compilation fails
  102023. * @param mesh defines the mesh to be rendered
  102024. * @param fallbacks defines the current prioritized list of fallbacks
  102025. */
  102026. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102027. /**
  102028. * Initialize defines for shader compilation
  102029. * @param mesh defines the mesh to be rendered
  102030. * @param nodeMaterial defines the node material requesting the update
  102031. * @param defines defines the material defines to update
  102032. * @param useInstances specifies that instances should be used
  102033. */
  102034. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102035. /**
  102036. * Update defines for shader compilation
  102037. * @param mesh defines the mesh to be rendered
  102038. * @param nodeMaterial defines the node material requesting the update
  102039. * @param defines defines the material defines to update
  102040. * @param useInstances specifies that instances should be used
  102041. * @param subMesh defines which submesh to render
  102042. */
  102043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102044. /**
  102045. * Lets the block try to connect some inputs automatically
  102046. * @param material defines the hosting NodeMaterial
  102047. */
  102048. autoConfigure(material: NodeMaterial): void;
  102049. /**
  102050. * Function called when a block is declared as repeatable content generator
  102051. * @param vertexShaderState defines the current compilation state for the vertex shader
  102052. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102053. * @param mesh defines the mesh to be rendered
  102054. * @param defines defines the material defines to update
  102055. */
  102056. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102057. /**
  102058. * Checks if the block is ready
  102059. * @param mesh defines the mesh to be rendered
  102060. * @param nodeMaterial defines the node material requesting the update
  102061. * @param defines defines the material defines to update
  102062. * @param useInstances specifies that instances should be used
  102063. * @returns true if the block is ready
  102064. */
  102065. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102066. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102067. private _processBuild;
  102068. /**
  102069. * Validates the new name for the block node.
  102070. * @param newName the new name to be given to the node.
  102071. * @returns false if the name is a reserve word, else true.
  102072. */
  102073. validateBlockName(newName: string): boolean;
  102074. /**
  102075. * Compile the current node and generate the shader code
  102076. * @param state defines the current compilation state (uniforms, samplers, current string)
  102077. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102078. * @returns true if already built
  102079. */
  102080. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102081. protected _inputRename(name: string): string;
  102082. protected _outputRename(name: string): string;
  102083. protected _dumpPropertiesCode(): string;
  102084. /** @hidden */
  102085. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102086. /** @hidden */
  102087. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102088. /**
  102089. * Clone the current block to a new identical block
  102090. * @param scene defines the hosting scene
  102091. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102092. * @returns a copy of the current block
  102093. */
  102094. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102095. /**
  102096. * Serializes this block in a JSON representation
  102097. * @returns the serialized block object
  102098. */
  102099. serialize(): any;
  102100. /** @hidden */
  102101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102102. private _deserializePortDisplayNamesAndExposedOnFrame;
  102103. /**
  102104. * Release resources
  102105. */
  102106. dispose(): void;
  102107. }
  102108. }
  102109. declare module BABYLON {
  102110. /**
  102111. * Base class of materials working in push mode in babylon JS
  102112. * @hidden
  102113. */
  102114. export class PushMaterial extends Material {
  102115. protected _activeEffect: Effect;
  102116. protected _normalMatrix: Matrix;
  102117. constructor(name: string, scene: Scene);
  102118. getEffect(): Effect;
  102119. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102120. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102121. /**
  102122. * Binds the given world matrix to the active effect
  102123. *
  102124. * @param world the matrix to bind
  102125. */
  102126. bindOnlyWorldMatrix(world: Matrix): void;
  102127. /**
  102128. * Binds the given normal matrix to the active effect
  102129. *
  102130. * @param normalMatrix the matrix to bind
  102131. */
  102132. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102133. bind(world: Matrix, mesh?: Mesh): void;
  102134. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102135. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102136. }
  102137. }
  102138. declare module BABYLON {
  102139. /**
  102140. * Root class for all node material optimizers
  102141. */
  102142. export class NodeMaterialOptimizer {
  102143. /**
  102144. * Function used to optimize a NodeMaterial graph
  102145. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102146. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102147. */
  102148. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102149. }
  102150. }
  102151. declare module BABYLON {
  102152. /**
  102153. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102154. */
  102155. export class TransformBlock extends NodeMaterialBlock {
  102156. /**
  102157. * Defines the value to use to complement W value to transform it to a Vector4
  102158. */
  102159. complementW: number;
  102160. /**
  102161. * Defines the value to use to complement z value to transform it to a Vector4
  102162. */
  102163. complementZ: number;
  102164. /**
  102165. * Creates a new TransformBlock
  102166. * @param name defines the block name
  102167. */
  102168. constructor(name: string);
  102169. /**
  102170. * Gets the current class name
  102171. * @returns the class name
  102172. */
  102173. getClassName(): string;
  102174. /**
  102175. * Gets the vector input
  102176. */
  102177. get vector(): NodeMaterialConnectionPoint;
  102178. /**
  102179. * Gets the output component
  102180. */
  102181. get output(): NodeMaterialConnectionPoint;
  102182. /**
  102183. * Gets the xyz output component
  102184. */
  102185. get xyz(): NodeMaterialConnectionPoint;
  102186. /**
  102187. * Gets the matrix transform input
  102188. */
  102189. get transform(): NodeMaterialConnectionPoint;
  102190. protected _buildBlock(state: NodeMaterialBuildState): this;
  102191. /**
  102192. * Update defines for shader compilation
  102193. * @param mesh defines the mesh to be rendered
  102194. * @param nodeMaterial defines the node material requesting the update
  102195. * @param defines defines the material defines to update
  102196. * @param useInstances specifies that instances should be used
  102197. * @param subMesh defines which submesh to render
  102198. */
  102199. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102200. serialize(): any;
  102201. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102202. protected _dumpPropertiesCode(): string;
  102203. }
  102204. }
  102205. declare module BABYLON {
  102206. /**
  102207. * Block used to output the vertex position
  102208. */
  102209. export class VertexOutputBlock extends NodeMaterialBlock {
  102210. /**
  102211. * Creates a new VertexOutputBlock
  102212. * @param name defines the block name
  102213. */
  102214. constructor(name: string);
  102215. /**
  102216. * Gets the current class name
  102217. * @returns the class name
  102218. */
  102219. getClassName(): string;
  102220. /**
  102221. * Gets the vector input component
  102222. */
  102223. get vector(): NodeMaterialConnectionPoint;
  102224. protected _buildBlock(state: NodeMaterialBuildState): this;
  102225. }
  102226. }
  102227. declare module BABYLON {
  102228. /**
  102229. * Block used to output the final color
  102230. */
  102231. export class FragmentOutputBlock extends NodeMaterialBlock {
  102232. /**
  102233. * Create a new FragmentOutputBlock
  102234. * @param name defines the block name
  102235. */
  102236. constructor(name: string);
  102237. /**
  102238. * Gets the current class name
  102239. * @returns the class name
  102240. */
  102241. getClassName(): string;
  102242. /**
  102243. * Gets the rgba input component
  102244. */
  102245. get rgba(): NodeMaterialConnectionPoint;
  102246. /**
  102247. * Gets the rgb input component
  102248. */
  102249. get rgb(): NodeMaterialConnectionPoint;
  102250. /**
  102251. * Gets the a input component
  102252. */
  102253. get a(): NodeMaterialConnectionPoint;
  102254. protected _buildBlock(state: NodeMaterialBuildState): this;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /**
  102259. * Block used for the particle ramp gradient section
  102260. */
  102261. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102262. /**
  102263. * Create a new ParticleRampGradientBlock
  102264. * @param name defines the block name
  102265. */
  102266. constructor(name: string);
  102267. /**
  102268. * Gets the current class name
  102269. * @returns the class name
  102270. */
  102271. getClassName(): string;
  102272. /**
  102273. * Gets the color input component
  102274. */
  102275. get color(): NodeMaterialConnectionPoint;
  102276. /**
  102277. * Gets the rampColor output component
  102278. */
  102279. get rampColor(): NodeMaterialConnectionPoint;
  102280. /**
  102281. * Initialize the block and prepare the context for build
  102282. * @param state defines the state that will be used for the build
  102283. */
  102284. initialize(state: NodeMaterialBuildState): void;
  102285. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102286. }
  102287. }
  102288. declare module BABYLON {
  102289. /**
  102290. * Block used for the particle blend multiply section
  102291. */
  102292. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102293. /**
  102294. * Create a new ParticleBlendMultiplyBlock
  102295. * @param name defines the block name
  102296. */
  102297. constructor(name: string);
  102298. /**
  102299. * Gets the current class name
  102300. * @returns the class name
  102301. */
  102302. getClassName(): string;
  102303. /**
  102304. * Gets the color input component
  102305. */
  102306. get color(): NodeMaterialConnectionPoint;
  102307. /**
  102308. * Gets the alphaTexture input component
  102309. */
  102310. get alphaTexture(): NodeMaterialConnectionPoint;
  102311. /**
  102312. * Gets the alphaColor input component
  102313. */
  102314. get alphaColor(): NodeMaterialConnectionPoint;
  102315. /**
  102316. * Gets the blendColor output component
  102317. */
  102318. get blendColor(): NodeMaterialConnectionPoint;
  102319. /**
  102320. * Initialize the block and prepare the context for build
  102321. * @param state defines the state that will be used for the build
  102322. */
  102323. initialize(state: NodeMaterialBuildState): void;
  102324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102325. }
  102326. }
  102327. declare module BABYLON {
  102328. /**
  102329. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102330. */
  102331. export class VectorMergerBlock extends NodeMaterialBlock {
  102332. /**
  102333. * Create a new VectorMergerBlock
  102334. * @param name defines the block name
  102335. */
  102336. constructor(name: string);
  102337. /**
  102338. * Gets the current class name
  102339. * @returns the class name
  102340. */
  102341. getClassName(): string;
  102342. /**
  102343. * Gets the xyz component (input)
  102344. */
  102345. get xyzIn(): NodeMaterialConnectionPoint;
  102346. /**
  102347. * Gets the xy component (input)
  102348. */
  102349. get xyIn(): NodeMaterialConnectionPoint;
  102350. /**
  102351. * Gets the x component (input)
  102352. */
  102353. get x(): NodeMaterialConnectionPoint;
  102354. /**
  102355. * Gets the y component (input)
  102356. */
  102357. get y(): NodeMaterialConnectionPoint;
  102358. /**
  102359. * Gets the z component (input)
  102360. */
  102361. get z(): NodeMaterialConnectionPoint;
  102362. /**
  102363. * Gets the w component (input)
  102364. */
  102365. get w(): NodeMaterialConnectionPoint;
  102366. /**
  102367. * Gets the xyzw component (output)
  102368. */
  102369. get xyzw(): NodeMaterialConnectionPoint;
  102370. /**
  102371. * Gets the xyz component (output)
  102372. */
  102373. get xyzOut(): NodeMaterialConnectionPoint;
  102374. /**
  102375. * Gets the xy component (output)
  102376. */
  102377. get xyOut(): NodeMaterialConnectionPoint;
  102378. /**
  102379. * Gets the xy component (output)
  102380. * @deprecated Please use xyOut instead.
  102381. */
  102382. get xy(): NodeMaterialConnectionPoint;
  102383. /**
  102384. * Gets the xyz component (output)
  102385. * @deprecated Please use xyzOut instead.
  102386. */
  102387. get xyz(): NodeMaterialConnectionPoint;
  102388. protected _buildBlock(state: NodeMaterialBuildState): this;
  102389. }
  102390. }
  102391. declare module BABYLON {
  102392. /**
  102393. * Block used to remap a float from a range to a new one
  102394. */
  102395. export class RemapBlock extends NodeMaterialBlock {
  102396. /**
  102397. * Gets or sets the source range
  102398. */
  102399. sourceRange: Vector2;
  102400. /**
  102401. * Gets or sets the target range
  102402. */
  102403. targetRange: Vector2;
  102404. /**
  102405. * Creates a new RemapBlock
  102406. * @param name defines the block name
  102407. */
  102408. constructor(name: string);
  102409. /**
  102410. * Gets the current class name
  102411. * @returns the class name
  102412. */
  102413. getClassName(): string;
  102414. /**
  102415. * Gets the input component
  102416. */
  102417. get input(): NodeMaterialConnectionPoint;
  102418. /**
  102419. * Gets the source min input component
  102420. */
  102421. get sourceMin(): NodeMaterialConnectionPoint;
  102422. /**
  102423. * Gets the source max input component
  102424. */
  102425. get sourceMax(): NodeMaterialConnectionPoint;
  102426. /**
  102427. * Gets the target min input component
  102428. */
  102429. get targetMin(): NodeMaterialConnectionPoint;
  102430. /**
  102431. * Gets the target max input component
  102432. */
  102433. get targetMax(): NodeMaterialConnectionPoint;
  102434. /**
  102435. * Gets the output component
  102436. */
  102437. get output(): NodeMaterialConnectionPoint;
  102438. protected _buildBlock(state: NodeMaterialBuildState): this;
  102439. protected _dumpPropertiesCode(): string;
  102440. serialize(): any;
  102441. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102442. }
  102443. }
  102444. declare module BABYLON {
  102445. /**
  102446. * Block used to multiply 2 values
  102447. */
  102448. export class MultiplyBlock extends NodeMaterialBlock {
  102449. /**
  102450. * Creates a new MultiplyBlock
  102451. * @param name defines the block name
  102452. */
  102453. constructor(name: string);
  102454. /**
  102455. * Gets the current class name
  102456. * @returns the class name
  102457. */
  102458. getClassName(): string;
  102459. /**
  102460. * Gets the left operand input component
  102461. */
  102462. get left(): NodeMaterialConnectionPoint;
  102463. /**
  102464. * Gets the right operand input component
  102465. */
  102466. get right(): NodeMaterialConnectionPoint;
  102467. /**
  102468. * Gets the output component
  102469. */
  102470. get output(): NodeMaterialConnectionPoint;
  102471. protected _buildBlock(state: NodeMaterialBuildState): this;
  102472. }
  102473. }
  102474. declare module BABYLON {
  102475. /**
  102476. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102477. */
  102478. export class ColorSplitterBlock extends NodeMaterialBlock {
  102479. /**
  102480. * Create a new ColorSplitterBlock
  102481. * @param name defines the block name
  102482. */
  102483. constructor(name: string);
  102484. /**
  102485. * Gets the current class name
  102486. * @returns the class name
  102487. */
  102488. getClassName(): string;
  102489. /**
  102490. * Gets the rgba component (input)
  102491. */
  102492. get rgba(): NodeMaterialConnectionPoint;
  102493. /**
  102494. * Gets the rgb component (input)
  102495. */
  102496. get rgbIn(): NodeMaterialConnectionPoint;
  102497. /**
  102498. * Gets the rgb component (output)
  102499. */
  102500. get rgbOut(): NodeMaterialConnectionPoint;
  102501. /**
  102502. * Gets the r component (output)
  102503. */
  102504. get r(): NodeMaterialConnectionPoint;
  102505. /**
  102506. * Gets the g component (output)
  102507. */
  102508. get g(): NodeMaterialConnectionPoint;
  102509. /**
  102510. * Gets the b component (output)
  102511. */
  102512. get b(): NodeMaterialConnectionPoint;
  102513. /**
  102514. * Gets the a component (output)
  102515. */
  102516. get a(): NodeMaterialConnectionPoint;
  102517. protected _inputRename(name: string): string;
  102518. protected _outputRename(name: string): string;
  102519. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102520. }
  102521. }
  102522. declare module BABYLON {
  102523. /**
  102524. * Operations supported by the Trigonometry block
  102525. */
  102526. export enum TrigonometryBlockOperations {
  102527. /** Cos */
  102528. Cos = 0,
  102529. /** Sin */
  102530. Sin = 1,
  102531. /** Abs */
  102532. Abs = 2,
  102533. /** Exp */
  102534. Exp = 3,
  102535. /** Exp2 */
  102536. Exp2 = 4,
  102537. /** Round */
  102538. Round = 5,
  102539. /** Floor */
  102540. Floor = 6,
  102541. /** Ceiling */
  102542. Ceiling = 7,
  102543. /** Square root */
  102544. Sqrt = 8,
  102545. /** Log */
  102546. Log = 9,
  102547. /** Tangent */
  102548. Tan = 10,
  102549. /** Arc tangent */
  102550. ArcTan = 11,
  102551. /** Arc cosinus */
  102552. ArcCos = 12,
  102553. /** Arc sinus */
  102554. ArcSin = 13,
  102555. /** Fraction */
  102556. Fract = 14,
  102557. /** Sign */
  102558. Sign = 15,
  102559. /** To radians (from degrees) */
  102560. Radians = 16,
  102561. /** To degrees (from radians) */
  102562. Degrees = 17
  102563. }
  102564. /**
  102565. * Block used to apply trigonometry operation to floats
  102566. */
  102567. export class TrigonometryBlock extends NodeMaterialBlock {
  102568. /**
  102569. * Gets or sets the operation applied by the block
  102570. */
  102571. operation: TrigonometryBlockOperations;
  102572. /**
  102573. * Creates a new TrigonometryBlock
  102574. * @param name defines the block name
  102575. */
  102576. constructor(name: string);
  102577. /**
  102578. * Gets the current class name
  102579. * @returns the class name
  102580. */
  102581. getClassName(): string;
  102582. /**
  102583. * Gets the input component
  102584. */
  102585. get input(): NodeMaterialConnectionPoint;
  102586. /**
  102587. * Gets the output component
  102588. */
  102589. get output(): NodeMaterialConnectionPoint;
  102590. protected _buildBlock(state: NodeMaterialBuildState): this;
  102591. serialize(): any;
  102592. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102593. protected _dumpPropertiesCode(): string;
  102594. }
  102595. }
  102596. declare module BABYLON {
  102597. /**
  102598. * Interface used to configure the node material editor
  102599. */
  102600. export interface INodeMaterialEditorOptions {
  102601. /** Define the URl to load node editor script */
  102602. editorURL?: string;
  102603. }
  102604. /** @hidden */
  102605. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102606. NORMAL: boolean;
  102607. TANGENT: boolean;
  102608. UV1: boolean;
  102609. /** BONES */
  102610. NUM_BONE_INFLUENCERS: number;
  102611. BonesPerMesh: number;
  102612. BONETEXTURE: boolean;
  102613. /** MORPH TARGETS */
  102614. MORPHTARGETS: boolean;
  102615. MORPHTARGETS_NORMAL: boolean;
  102616. MORPHTARGETS_TANGENT: boolean;
  102617. MORPHTARGETS_UV: boolean;
  102618. NUM_MORPH_INFLUENCERS: number;
  102619. /** IMAGE PROCESSING */
  102620. IMAGEPROCESSING: boolean;
  102621. VIGNETTE: boolean;
  102622. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102623. VIGNETTEBLENDMODEOPAQUE: boolean;
  102624. TONEMAPPING: boolean;
  102625. TONEMAPPING_ACES: boolean;
  102626. CONTRAST: boolean;
  102627. EXPOSURE: boolean;
  102628. COLORCURVES: boolean;
  102629. COLORGRADING: boolean;
  102630. COLORGRADING3D: boolean;
  102631. SAMPLER3DGREENDEPTH: boolean;
  102632. SAMPLER3DBGRMAP: boolean;
  102633. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102634. /** MISC. */
  102635. BUMPDIRECTUV: number;
  102636. constructor();
  102637. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102638. }
  102639. /**
  102640. * Class used to configure NodeMaterial
  102641. */
  102642. export interface INodeMaterialOptions {
  102643. /**
  102644. * Defines if blocks should emit comments
  102645. */
  102646. emitComments: boolean;
  102647. }
  102648. /**
  102649. * Class used to create a node based material built by assembling shader blocks
  102650. */
  102651. export class NodeMaterial extends PushMaterial {
  102652. private static _BuildIdGenerator;
  102653. private _options;
  102654. private _vertexCompilationState;
  102655. private _fragmentCompilationState;
  102656. private _sharedData;
  102657. private _buildId;
  102658. private _buildWasSuccessful;
  102659. private _cachedWorldViewMatrix;
  102660. private _cachedWorldViewProjectionMatrix;
  102661. private _optimizers;
  102662. private _animationFrame;
  102663. /** Define the Url to load node editor script */
  102664. static EditorURL: string;
  102665. /** Define the Url to load snippets */
  102666. static SnippetUrl: string;
  102667. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102668. static IgnoreTexturesAtLoadTime: boolean;
  102669. private BJSNODEMATERIALEDITOR;
  102670. /** Get the inspector from bundle or global */
  102671. private _getGlobalNodeMaterialEditor;
  102672. /**
  102673. * Snippet ID if the material was created from the snippet server
  102674. */
  102675. snippetId: string;
  102676. /**
  102677. * Gets or sets data used by visual editor
  102678. * @see https://nme.babylonjs.com
  102679. */
  102680. editorData: any;
  102681. /**
  102682. * 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)
  102683. */
  102684. ignoreAlpha: boolean;
  102685. /**
  102686. * Defines the maximum number of lights that can be used in the material
  102687. */
  102688. maxSimultaneousLights: number;
  102689. /**
  102690. * Observable raised when the material is built
  102691. */
  102692. onBuildObservable: Observable<NodeMaterial>;
  102693. /**
  102694. * Gets or sets the root nodes of the material vertex shader
  102695. */
  102696. _vertexOutputNodes: NodeMaterialBlock[];
  102697. /**
  102698. * Gets or sets the root nodes of the material fragment (pixel) shader
  102699. */
  102700. _fragmentOutputNodes: NodeMaterialBlock[];
  102701. /** Gets or sets options to control the node material overall behavior */
  102702. get options(): INodeMaterialOptions;
  102703. set options(options: INodeMaterialOptions);
  102704. /**
  102705. * Default configuration related to image processing available in the standard Material.
  102706. */
  102707. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102708. /**
  102709. * Gets the image processing configuration used either in this material.
  102710. */
  102711. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  102712. /**
  102713. * Sets the Default image processing configuration used either in the this material.
  102714. *
  102715. * If sets to null, the scene one is in use.
  102716. */
  102717. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  102718. /**
  102719. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  102720. */
  102721. attachedBlocks: NodeMaterialBlock[];
  102722. /**
  102723. * Specifies the mode of the node material
  102724. * @hidden
  102725. */
  102726. _mode: NodeMaterialModes;
  102727. /**
  102728. * Gets the mode property
  102729. */
  102730. get mode(): NodeMaterialModes;
  102731. /**
  102732. * Create a new node based material
  102733. * @param name defines the material name
  102734. * @param scene defines the hosting scene
  102735. * @param options defines creation option
  102736. */
  102737. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  102738. /**
  102739. * Gets the current class name of the material e.g. "NodeMaterial"
  102740. * @returns the class name
  102741. */
  102742. getClassName(): string;
  102743. /**
  102744. * Keep track of the image processing observer to allow dispose and replace.
  102745. */
  102746. private _imageProcessingObserver;
  102747. /**
  102748. * Attaches a new image processing configuration to the Standard Material.
  102749. * @param configuration
  102750. */
  102751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102752. /**
  102753. * Get a block by its name
  102754. * @param name defines the name of the block to retrieve
  102755. * @returns the required block or null if not found
  102756. */
  102757. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  102758. /**
  102759. * Get a block by its name
  102760. * @param predicate defines the predicate used to find the good candidate
  102761. * @returns the required block or null if not found
  102762. */
  102763. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  102764. /**
  102765. * Get an input block by its name
  102766. * @param predicate defines the predicate used to find the good candidate
  102767. * @returns the required input block or null if not found
  102768. */
  102769. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  102770. /**
  102771. * Gets the list of input blocks attached to this material
  102772. * @returns an array of InputBlocks
  102773. */
  102774. getInputBlocks(): InputBlock[];
  102775. /**
  102776. * Adds a new optimizer to the list of optimizers
  102777. * @param optimizer defines the optimizers to add
  102778. * @returns the current material
  102779. */
  102780. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102781. /**
  102782. * Remove an optimizer from the list of optimizers
  102783. * @param optimizer defines the optimizers to remove
  102784. * @returns the current material
  102785. */
  102786. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  102787. /**
  102788. * Add a new block to the list of output nodes
  102789. * @param node defines the node to add
  102790. * @returns the current material
  102791. */
  102792. addOutputNode(node: NodeMaterialBlock): this;
  102793. /**
  102794. * Remove a block from the list of root nodes
  102795. * @param node defines the node to remove
  102796. * @returns the current material
  102797. */
  102798. removeOutputNode(node: NodeMaterialBlock): this;
  102799. private _addVertexOutputNode;
  102800. private _removeVertexOutputNode;
  102801. private _addFragmentOutputNode;
  102802. private _removeFragmentOutputNode;
  102803. /**
  102804. * Specifies if the material will require alpha blending
  102805. * @returns a boolean specifying if alpha blending is needed
  102806. */
  102807. needAlphaBlending(): boolean;
  102808. /**
  102809. * Specifies if this material should be rendered in alpha test mode
  102810. * @returns a boolean specifying if an alpha test is needed.
  102811. */
  102812. needAlphaTesting(): boolean;
  102813. private _initializeBlock;
  102814. private _resetDualBlocks;
  102815. /**
  102816. * Remove a block from the current node material
  102817. * @param block defines the block to remove
  102818. */
  102819. removeBlock(block: NodeMaterialBlock): void;
  102820. /**
  102821. * Build the material and generates the inner effect
  102822. * @param verbose defines if the build should log activity
  102823. */
  102824. build(verbose?: boolean): void;
  102825. /**
  102826. * Runs an otpimization phase to try to improve the shader code
  102827. */
  102828. optimize(): void;
  102829. private _prepareDefinesForAttributes;
  102830. /**
  102831. * Create a post process from the material
  102832. * @param camera The camera to apply the render pass to.
  102833. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  102834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  102835. * @param engine The engine which the post process will be applied. (default: current engine)
  102836. * @param reusable If the post process can be reused on the same frame. (default: false)
  102837. * @param textureType Type of textures used when performing the post process. (default: 0)
  102838. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  102839. * @returns the post process created
  102840. */
  102841. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  102842. /**
  102843. * Create the post process effect from the material
  102844. * @param postProcess The post process to create the effect for
  102845. */
  102846. createEffectForPostProcess(postProcess: PostProcess): void;
  102847. private _createEffectForPostProcess;
  102848. /**
  102849. * Create a new procedural texture based on this node material
  102850. * @param size defines the size of the texture
  102851. * @param scene defines the hosting scene
  102852. * @returns the new procedural texture attached to this node material
  102853. */
  102854. createProceduralTexture(size: number | {
  102855. width: number;
  102856. height: number;
  102857. layers?: number;
  102858. }, scene: Scene): Nullable<ProceduralTexture>;
  102859. private _createEffectForParticles;
  102860. private _checkInternals;
  102861. /**
  102862. * Create the effect to be used as the custom effect for a particle system
  102863. * @param particleSystem Particle system to create the effect for
  102864. * @param onCompiled defines a function to call when the effect creation is successful
  102865. * @param onError defines a function to call when the effect creation has failed
  102866. */
  102867. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  102868. private _processDefines;
  102869. /**
  102870. * Get if the submesh is ready to be used and all its information available.
  102871. * Child classes can use it to update shaders
  102872. * @param mesh defines the mesh to check
  102873. * @param subMesh defines which submesh to check
  102874. * @param useInstances specifies that instances should be used
  102875. * @returns a boolean indicating that the submesh is ready or not
  102876. */
  102877. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102878. /**
  102879. * Get a string representing the shaders built by the current node graph
  102880. */
  102881. get compiledShaders(): string;
  102882. /**
  102883. * Binds the world matrix to the material
  102884. * @param world defines the world transformation matrix
  102885. */
  102886. bindOnlyWorldMatrix(world: Matrix): void;
  102887. /**
  102888. * Binds the submesh to this material by preparing the effect and shader to draw
  102889. * @param world defines the world transformation matrix
  102890. * @param mesh defines the mesh containing the submesh
  102891. * @param subMesh defines the submesh to bind the material to
  102892. */
  102893. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102894. /**
  102895. * Gets the active textures from the material
  102896. * @returns an array of textures
  102897. */
  102898. getActiveTextures(): BaseTexture[];
  102899. /**
  102900. * Gets the list of texture blocks
  102901. * @returns an array of texture blocks
  102902. */
  102903. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  102904. /**
  102905. * Specifies if the material uses a texture
  102906. * @param texture defines the texture to check against the material
  102907. * @returns a boolean specifying if the material uses the texture
  102908. */
  102909. hasTexture(texture: BaseTexture): boolean;
  102910. /**
  102911. * Disposes the material
  102912. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  102913. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  102914. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  102915. */
  102916. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  102917. /** Creates the node editor window. */
  102918. private _createNodeEditor;
  102919. /**
  102920. * Launch the node material editor
  102921. * @param config Define the configuration of the editor
  102922. * @return a promise fulfilled when the node editor is visible
  102923. */
  102924. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  102925. /**
  102926. * Clear the current material
  102927. */
  102928. clear(): void;
  102929. /**
  102930. * Clear the current material and set it to a default state
  102931. */
  102932. setToDefault(): void;
  102933. /**
  102934. * Clear the current material and set it to a default state for post process
  102935. */
  102936. setToDefaultPostProcess(): void;
  102937. /**
  102938. * Clear the current material and set it to a default state for procedural texture
  102939. */
  102940. setToDefaultProceduralTexture(): void;
  102941. /**
  102942. * Clear the current material and set it to a default state for particle
  102943. */
  102944. setToDefaultParticle(): void;
  102945. /**
  102946. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  102947. * @param url defines the url to load from
  102948. * @returns a promise that will fullfil when the material is fully loaded
  102949. */
  102950. loadAsync(url: string): Promise<void>;
  102951. private _gatherBlocks;
  102952. /**
  102953. * Generate a string containing the code declaration required to create an equivalent of this material
  102954. * @returns a string
  102955. */
  102956. generateCode(): string;
  102957. /**
  102958. * Serializes this material in a JSON representation
  102959. * @returns the serialized material object
  102960. */
  102961. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  102962. private _restoreConnections;
  102963. /**
  102964. * Clear the current graph and load a new one from a serialization object
  102965. * @param source defines the JSON representation of the material
  102966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102967. * @param merge defines whether or not the source must be merged or replace the current content
  102968. */
  102969. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  102970. /**
  102971. * Makes a duplicate of the current material.
  102972. * @param name - name to use for the new material.
  102973. */
  102974. clone(name: string): NodeMaterial;
  102975. /**
  102976. * Creates a node material from parsed material data
  102977. * @param source defines the JSON representation of the material
  102978. * @param scene defines the hosting scene
  102979. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102980. * @returns a new node material
  102981. */
  102982. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  102983. /**
  102984. * Creates a node material from a snippet saved in a remote file
  102985. * @param name defines the name of the material to create
  102986. * @param url defines the url to load from
  102987. * @param scene defines the hosting scene
  102988. * @returns a promise that will resolve to the new node material
  102989. */
  102990. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  102991. /**
  102992. * Creates a node material from a snippet saved by the node material editor
  102993. * @param snippetId defines the snippet to load
  102994. * @param scene defines the hosting scene
  102995. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102996. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  102997. * @returns a promise that will resolve to the new node material
  102998. */
  102999. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103000. /**
  103001. * Creates a new node material set to default basic configuration
  103002. * @param name defines the name of the material
  103003. * @param scene defines the hosting scene
  103004. * @returns a new NodeMaterial
  103005. */
  103006. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103007. }
  103008. }
  103009. declare module BABYLON {
  103010. /**
  103011. * Size options for a post process
  103012. */
  103013. export type PostProcessOptions = {
  103014. width: number;
  103015. height: number;
  103016. };
  103017. /**
  103018. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103019. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103020. */
  103021. export class PostProcess {
  103022. /**
  103023. * Gets or sets the unique id of the post process
  103024. */
  103025. uniqueId: number;
  103026. /** Name of the PostProcess. */
  103027. name: string;
  103028. /**
  103029. * Width of the texture to apply the post process on
  103030. */
  103031. width: number;
  103032. /**
  103033. * Height of the texture to apply the post process on
  103034. */
  103035. height: number;
  103036. /**
  103037. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103038. */
  103039. nodeMaterialSource: Nullable<NodeMaterial>;
  103040. /**
  103041. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103042. * @hidden
  103043. */
  103044. _outputTexture: Nullable<InternalTexture>;
  103045. /**
  103046. * Sampling mode used by the shader
  103047. * See https://doc.babylonjs.com/classes/3.1/texture
  103048. */
  103049. renderTargetSamplingMode: number;
  103050. /**
  103051. * Clear color to use when screen clearing
  103052. */
  103053. clearColor: Color4;
  103054. /**
  103055. * If the buffer needs to be cleared before applying the post process. (default: true)
  103056. * Should be set to false if shader will overwrite all previous pixels.
  103057. */
  103058. autoClear: boolean;
  103059. /**
  103060. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103061. */
  103062. alphaMode: number;
  103063. /**
  103064. * Sets the setAlphaBlendConstants of the babylon engine
  103065. */
  103066. alphaConstants: Color4;
  103067. /**
  103068. * Animations to be used for the post processing
  103069. */
  103070. animations: Animation[];
  103071. /**
  103072. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103073. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103074. */
  103075. enablePixelPerfectMode: boolean;
  103076. /**
  103077. * Force the postprocess to be applied without taking in account viewport
  103078. */
  103079. forceFullscreenViewport: boolean;
  103080. /**
  103081. * List of inspectable custom properties (used by the Inspector)
  103082. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103083. */
  103084. inspectableCustomProperties: IInspectable[];
  103085. /**
  103086. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103087. *
  103088. * | Value | Type | Description |
  103089. * | ----- | ----------------------------------- | ----------- |
  103090. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103091. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103092. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103093. *
  103094. */
  103095. scaleMode: number;
  103096. /**
  103097. * Force textures to be a power of two (default: false)
  103098. */
  103099. alwaysForcePOT: boolean;
  103100. private _samples;
  103101. /**
  103102. * Number of sample textures (default: 1)
  103103. */
  103104. get samples(): number;
  103105. set samples(n: number);
  103106. /**
  103107. * Modify the scale of the post process to be the same as the viewport (default: false)
  103108. */
  103109. adaptScaleToCurrentViewport: boolean;
  103110. private _camera;
  103111. protected _scene: Scene;
  103112. private _engine;
  103113. private _options;
  103114. private _reusable;
  103115. private _textureType;
  103116. private _textureFormat;
  103117. /**
  103118. * Smart array of input and output textures for the post process.
  103119. * @hidden
  103120. */
  103121. _textures: SmartArray<InternalTexture>;
  103122. /**
  103123. * The index in _textures that corresponds to the output texture.
  103124. * @hidden
  103125. */
  103126. _currentRenderTextureInd: number;
  103127. private _effect;
  103128. private _samplers;
  103129. private _fragmentUrl;
  103130. private _vertexUrl;
  103131. private _parameters;
  103132. private _scaleRatio;
  103133. protected _indexParameters: any;
  103134. private _shareOutputWithPostProcess;
  103135. private _texelSize;
  103136. private _forcedOutputTexture;
  103137. /**
  103138. * Returns the fragment url or shader name used in the post process.
  103139. * @returns the fragment url or name in the shader store.
  103140. */
  103141. getEffectName(): string;
  103142. /**
  103143. * An event triggered when the postprocess is activated.
  103144. */
  103145. onActivateObservable: Observable<Camera>;
  103146. private _onActivateObserver;
  103147. /**
  103148. * A function that is added to the onActivateObservable
  103149. */
  103150. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103151. /**
  103152. * An event triggered when the postprocess changes its size.
  103153. */
  103154. onSizeChangedObservable: Observable<PostProcess>;
  103155. private _onSizeChangedObserver;
  103156. /**
  103157. * A function that is added to the onSizeChangedObservable
  103158. */
  103159. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103160. /**
  103161. * An event triggered when the postprocess applies its effect.
  103162. */
  103163. onApplyObservable: Observable<Effect>;
  103164. private _onApplyObserver;
  103165. /**
  103166. * A function that is added to the onApplyObservable
  103167. */
  103168. set onApply(callback: (effect: Effect) => void);
  103169. /**
  103170. * An event triggered before rendering the postprocess
  103171. */
  103172. onBeforeRenderObservable: Observable<Effect>;
  103173. private _onBeforeRenderObserver;
  103174. /**
  103175. * A function that is added to the onBeforeRenderObservable
  103176. */
  103177. set onBeforeRender(callback: (effect: Effect) => void);
  103178. /**
  103179. * An event triggered after rendering the postprocess
  103180. */
  103181. onAfterRenderObservable: Observable<Effect>;
  103182. private _onAfterRenderObserver;
  103183. /**
  103184. * A function that is added to the onAfterRenderObservable
  103185. */
  103186. set onAfterRender(callback: (efect: Effect) => void);
  103187. /**
  103188. * 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
  103189. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103190. */
  103191. get inputTexture(): InternalTexture;
  103192. set inputTexture(value: InternalTexture);
  103193. /**
  103194. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103195. * the only way to unset it is to use this function to restore its internal state
  103196. */
  103197. restoreDefaultInputTexture(): void;
  103198. /**
  103199. * Gets the camera which post process is applied to.
  103200. * @returns The camera the post process is applied to.
  103201. */
  103202. getCamera(): Camera;
  103203. /**
  103204. * Gets the texel size of the postprocess.
  103205. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  103206. */
  103207. get texelSize(): Vector2;
  103208. /**
  103209. * Creates a new instance PostProcess
  103210. * @param name The name of the PostProcess.
  103211. * @param fragmentUrl The url of the fragment shader to be used.
  103212. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  103213. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  103214. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103215. * @param camera The camera to apply the render pass to.
  103216. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103217. * @param engine The engine which the post process will be applied. (default: current engine)
  103218. * @param reusable If the post process can be reused on the same frame. (default: false)
  103219. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  103220. * @param textureType Type of textures used when performing the post process. (default: 0)
  103221. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  103222. * @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
  103223. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  103224. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103225. */
  103226. constructor(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);
  103227. /**
  103228. * Gets a string identifying the name of the class
  103229. * @returns "PostProcess" string
  103230. */
  103231. getClassName(): string;
  103232. /**
  103233. * Gets the engine which this post process belongs to.
  103234. * @returns The engine the post process was enabled with.
  103235. */
  103236. getEngine(): Engine;
  103237. /**
  103238. * The effect that is created when initializing the post process.
  103239. * @returns The created effect corresponding the the postprocess.
  103240. */
  103241. getEffect(): Effect;
  103242. /**
  103243. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  103244. * @param postProcess The post process to share the output with.
  103245. * @returns This post process.
  103246. */
  103247. shareOutputWith(postProcess: PostProcess): PostProcess;
  103248. /**
  103249. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  103250. * This should be called if the post process that shares output with this post process is disabled/disposed.
  103251. */
  103252. useOwnOutput(): void;
  103253. /**
  103254. * Updates the effect with the current post process compile time values and recompiles the shader.
  103255. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103256. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103257. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103258. * @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
  103259. * @param onCompiled Called when the shader has been compiled.
  103260. * @param onError Called if there is an error when compiling a shader.
  103261. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  103262. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  103263. */
  103264. 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;
  103265. /**
  103266. * The post process is reusable if it can be used multiple times within one frame.
  103267. * @returns If the post process is reusable
  103268. */
  103269. isReusable(): boolean;
  103270. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  103271. markTextureDirty(): void;
  103272. /**
  103273. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  103274. * 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.
  103275. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  103276. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  103277. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  103278. * @returns The target texture that was bound to be written to.
  103279. */
  103280. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  103281. /**
  103282. * If the post process is supported.
  103283. */
  103284. get isSupported(): boolean;
  103285. /**
  103286. * The aspect ratio of the output texture.
  103287. */
  103288. get aspectRatio(): number;
  103289. /**
  103290. * Get a value indicating if the post-process is ready to be used
  103291. * @returns true if the post-process is ready (shader is compiled)
  103292. */
  103293. isReady(): boolean;
  103294. /**
  103295. * Binds all textures and uniforms to the shader, this will be run on every pass.
  103296. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  103297. */
  103298. apply(): Nullable<Effect>;
  103299. private _disposeTextures;
  103300. /**
  103301. * Disposes the post process.
  103302. * @param camera The camera to dispose the post process on.
  103303. */
  103304. dispose(camera?: Camera): void;
  103305. /**
  103306. * Serializes the particle system to a JSON object
  103307. * @returns the JSON object
  103308. */
  103309. serialize(): any;
  103310. /**
  103311. * Creates a material from parsed material data
  103312. * @param parsedPostProcess defines parsed post process data
  103313. * @param scene defines the hosting scene
  103314. * @param rootUrl defines the root URL to use to load textures
  103315. * @returns a new post process
  103316. */
  103317. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  103318. }
  103319. }
  103320. declare module BABYLON {
  103321. /** @hidden */
  103322. export var kernelBlurVaryingDeclaration: {
  103323. name: string;
  103324. shader: string;
  103325. };
  103326. }
  103327. declare module BABYLON {
  103328. /** @hidden */
  103329. export var kernelBlurFragment: {
  103330. name: string;
  103331. shader: string;
  103332. };
  103333. }
  103334. declare module BABYLON {
  103335. /** @hidden */
  103336. export var kernelBlurFragment2: {
  103337. name: string;
  103338. shader: string;
  103339. };
  103340. }
  103341. declare module BABYLON {
  103342. /** @hidden */
  103343. export var kernelBlurPixelShader: {
  103344. name: string;
  103345. shader: string;
  103346. };
  103347. }
  103348. declare module BABYLON {
  103349. /** @hidden */
  103350. export var kernelBlurVertex: {
  103351. name: string;
  103352. shader: string;
  103353. };
  103354. }
  103355. declare module BABYLON {
  103356. /** @hidden */
  103357. export var kernelBlurVertexShader: {
  103358. name: string;
  103359. shader: string;
  103360. };
  103361. }
  103362. declare module BABYLON {
  103363. /**
  103364. * The Blur Post Process which blurs an image based on a kernel and direction.
  103365. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  103366. */
  103367. export class BlurPostProcess extends PostProcess {
  103368. private blockCompilation;
  103369. protected _kernel: number;
  103370. protected _idealKernel: number;
  103371. protected _packedFloat: boolean;
  103372. private _staticDefines;
  103373. /** The direction in which to blur the image. */
  103374. direction: Vector2;
  103375. /**
  103376. * Sets the length in pixels of the blur sample region
  103377. */
  103378. set kernel(v: number);
  103379. /**
  103380. * Gets the length in pixels of the blur sample region
  103381. */
  103382. get kernel(): number;
  103383. /**
  103384. * Sets wether or not the blur needs to unpack/repack floats
  103385. */
  103386. set packedFloat(v: boolean);
  103387. /**
  103388. * Gets wether or not the blur is unpacking/repacking floats
  103389. */
  103390. get packedFloat(): boolean;
  103391. /**
  103392. * Gets a string identifying the name of the class
  103393. * @returns "BlurPostProcess" string
  103394. */
  103395. getClassName(): string;
  103396. /**
  103397. * Creates a new instance BlurPostProcess
  103398. * @param name The name of the effect.
  103399. * @param direction The direction in which to blur the image.
  103400. * @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.
  103401. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103402. * @param camera The camera to apply the render pass to.
  103403. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103404. * @param engine The engine which the post process will be applied. (default: current engine)
  103405. * @param reusable If the post process can be reused on the same frame. (default: false)
  103406. * @param textureType Type of textures used when performing the post process. (default: 0)
  103407. * @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)
  103408. */
  103409. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  103410. /**
  103411. * Updates the effect with the current post process compile time values and recompiles the shader.
  103412. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  103413. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  103414. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  103415. * @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
  103416. * @param onCompiled Called when the shader has been compiled.
  103417. * @param onError Called if there is an error when compiling a shader.
  103418. */
  103419. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103420. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103421. /**
  103422. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  103423. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  103424. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  103425. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  103426. * The gaps between physical kernels are compensated for in the weighting of the samples
  103427. * @param idealKernel Ideal blur kernel.
  103428. * @return Nearest best kernel.
  103429. */
  103430. protected _nearestBestKernel(idealKernel: number): number;
  103431. /**
  103432. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  103433. * @param x The point on the Gaussian distribution to sample.
  103434. * @return the value of the Gaussian function at x.
  103435. */
  103436. protected _gaussianWeight(x: number): number;
  103437. /**
  103438. * Generates a string that can be used as a floating point number in GLSL.
  103439. * @param x Value to print.
  103440. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  103441. * @return GLSL float string.
  103442. */
  103443. protected _glslFloat(x: number, decimalFigures?: number): string;
  103444. /** @hidden */
  103445. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  103446. }
  103447. }
  103448. declare module BABYLON {
  103449. /**
  103450. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103451. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103452. * You can then easily use it as a reflectionTexture on a flat surface.
  103453. * In case the surface is not a plane, please consider relying on reflection probes.
  103454. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103455. */
  103456. export class MirrorTexture extends RenderTargetTexture {
  103457. private scene;
  103458. /**
  103459. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  103460. * 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.
  103461. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103462. */
  103463. mirrorPlane: Plane;
  103464. /**
  103465. * Define the blur ratio used to blur the reflection if needed.
  103466. */
  103467. set blurRatio(value: number);
  103468. get blurRatio(): number;
  103469. /**
  103470. * Define the adaptive blur kernel used to blur the reflection if needed.
  103471. * This will autocompute the closest best match for the `blurKernel`
  103472. */
  103473. set adaptiveBlurKernel(value: number);
  103474. /**
  103475. * Define the blur kernel used to blur the reflection if needed.
  103476. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103477. */
  103478. set blurKernel(value: number);
  103479. /**
  103480. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  103481. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103482. */
  103483. set blurKernelX(value: number);
  103484. get blurKernelX(): number;
  103485. /**
  103486. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  103487. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  103488. */
  103489. set blurKernelY(value: number);
  103490. get blurKernelY(): number;
  103491. private _autoComputeBlurKernel;
  103492. protected _onRatioRescale(): void;
  103493. private _updateGammaSpace;
  103494. private _imageProcessingConfigChangeObserver;
  103495. private _transformMatrix;
  103496. private _mirrorMatrix;
  103497. private _savedViewMatrix;
  103498. private _blurX;
  103499. private _blurY;
  103500. private _adaptiveBlurKernel;
  103501. private _blurKernelX;
  103502. private _blurKernelY;
  103503. private _blurRatio;
  103504. /**
  103505. * Instantiates a Mirror Texture.
  103506. * Mirror texture can be used to simulate the view from a mirror in a scene.
  103507. * It will dynamically be rendered every frame to adapt to the camera point of view.
  103508. * You can then easily use it as a reflectionTexture on a flat surface.
  103509. * In case the surface is not a plane, please consider relying on reflection probes.
  103510. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  103511. * @param name
  103512. * @param size
  103513. * @param scene
  103514. * @param generateMipMaps
  103515. * @param type
  103516. * @param samplingMode
  103517. * @param generateDepthBuffer
  103518. */
  103519. constructor(name: string, size: number | {
  103520. width: number;
  103521. height: number;
  103522. } | {
  103523. ratio: number;
  103524. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  103525. private _preparePostProcesses;
  103526. /**
  103527. * Clone the mirror texture.
  103528. * @returns the cloned texture
  103529. */
  103530. clone(): MirrorTexture;
  103531. /**
  103532. * Serialize the texture to a JSON representation you could use in Parse later on
  103533. * @returns the serialized JSON representation
  103534. */
  103535. serialize(): any;
  103536. /**
  103537. * Dispose the texture and release its associated resources.
  103538. */
  103539. dispose(): void;
  103540. }
  103541. }
  103542. declare module BABYLON {
  103543. /**
  103544. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103545. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103546. */
  103547. export class Texture extends BaseTexture {
  103548. /**
  103549. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  103550. */
  103551. static SerializeBuffers: boolean;
  103552. /** @hidden */
  103553. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  103554. /** @hidden */
  103555. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  103556. /** @hidden */
  103557. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  103558. /** nearest is mag = nearest and min = nearest and mip = linear */
  103559. static readonly NEAREST_SAMPLINGMODE: number;
  103560. /** nearest is mag = nearest and min = nearest and mip = linear */
  103561. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  103562. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103563. static readonly BILINEAR_SAMPLINGMODE: number;
  103564. /** Bilinear is mag = linear and min = linear and mip = nearest */
  103565. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  103566. /** Trilinear is mag = linear and min = linear and mip = linear */
  103567. static readonly TRILINEAR_SAMPLINGMODE: number;
  103568. /** Trilinear is mag = linear and min = linear and mip = linear */
  103569. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  103570. /** mag = nearest and min = nearest and mip = nearest */
  103571. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  103572. /** mag = nearest and min = linear and mip = nearest */
  103573. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  103574. /** mag = nearest and min = linear and mip = linear */
  103575. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  103576. /** mag = nearest and min = linear and mip = none */
  103577. static readonly NEAREST_LINEAR: number;
  103578. /** mag = nearest and min = nearest and mip = none */
  103579. static readonly NEAREST_NEAREST: number;
  103580. /** mag = linear and min = nearest and mip = nearest */
  103581. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  103582. /** mag = linear and min = nearest and mip = linear */
  103583. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  103584. /** mag = linear and min = linear and mip = none */
  103585. static readonly LINEAR_LINEAR: number;
  103586. /** mag = linear and min = nearest and mip = none */
  103587. static readonly LINEAR_NEAREST: number;
  103588. /** Explicit coordinates mode */
  103589. static readonly EXPLICIT_MODE: number;
  103590. /** Spherical coordinates mode */
  103591. static readonly SPHERICAL_MODE: number;
  103592. /** Planar coordinates mode */
  103593. static readonly PLANAR_MODE: number;
  103594. /** Cubic coordinates mode */
  103595. static readonly CUBIC_MODE: number;
  103596. /** Projection coordinates mode */
  103597. static readonly PROJECTION_MODE: number;
  103598. /** Inverse Cubic coordinates mode */
  103599. static readonly SKYBOX_MODE: number;
  103600. /** Inverse Cubic coordinates mode */
  103601. static readonly INVCUBIC_MODE: number;
  103602. /** Equirectangular coordinates mode */
  103603. static readonly EQUIRECTANGULAR_MODE: number;
  103604. /** Equirectangular Fixed coordinates mode */
  103605. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  103606. /** Equirectangular Fixed Mirrored coordinates mode */
  103607. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  103608. /** Texture is not repeating outside of 0..1 UVs */
  103609. static readonly CLAMP_ADDRESSMODE: number;
  103610. /** Texture is repeating outside of 0..1 UVs */
  103611. static readonly WRAP_ADDRESSMODE: number;
  103612. /** Texture is repeating and mirrored */
  103613. static readonly MIRROR_ADDRESSMODE: number;
  103614. /**
  103615. * 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
  103616. */
  103617. static UseSerializedUrlIfAny: boolean;
  103618. /**
  103619. * Define the url of the texture.
  103620. */
  103621. url: Nullable<string>;
  103622. /**
  103623. * Define an offset on the texture to offset the u coordinates of the UVs
  103624. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103625. */
  103626. uOffset: number;
  103627. /**
  103628. * Define an offset on the texture to offset the v coordinates of the UVs
  103629. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  103630. */
  103631. vOffset: number;
  103632. /**
  103633. * Define an offset on the texture to scale the u coordinates of the UVs
  103634. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103635. */
  103636. uScale: number;
  103637. /**
  103638. * Define an offset on the texture to scale the v coordinates of the UVs
  103639. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  103640. */
  103641. vScale: number;
  103642. /**
  103643. * Define an offset on the texture to rotate around the u coordinates of the UVs
  103644. * @see https://doc.babylonjs.com/how_to/more_materials
  103645. */
  103646. uAng: number;
  103647. /**
  103648. * Define an offset on the texture to rotate around the v coordinates of the UVs
  103649. * @see https://doc.babylonjs.com/how_to/more_materials
  103650. */
  103651. vAng: number;
  103652. /**
  103653. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  103654. * @see https://doc.babylonjs.com/how_to/more_materials
  103655. */
  103656. wAng: number;
  103657. /**
  103658. * Defines the center of rotation (U)
  103659. */
  103660. uRotationCenter: number;
  103661. /**
  103662. * Defines the center of rotation (V)
  103663. */
  103664. vRotationCenter: number;
  103665. /**
  103666. * Defines the center of rotation (W)
  103667. */
  103668. wRotationCenter: number;
  103669. /**
  103670. * Are mip maps generated for this texture or not.
  103671. */
  103672. get noMipmap(): boolean;
  103673. /**
  103674. * List of inspectable custom properties (used by the Inspector)
  103675. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103676. */
  103677. inspectableCustomProperties: Nullable<IInspectable[]>;
  103678. private _noMipmap;
  103679. /** @hidden */
  103680. _invertY: boolean;
  103681. private _rowGenerationMatrix;
  103682. private _cachedTextureMatrix;
  103683. private _projectionModeMatrix;
  103684. private _t0;
  103685. private _t1;
  103686. private _t2;
  103687. private _cachedUOffset;
  103688. private _cachedVOffset;
  103689. private _cachedUScale;
  103690. private _cachedVScale;
  103691. private _cachedUAng;
  103692. private _cachedVAng;
  103693. private _cachedWAng;
  103694. private _cachedProjectionMatrixId;
  103695. private _cachedCoordinatesMode;
  103696. /** @hidden */
  103697. protected _initialSamplingMode: number;
  103698. /** @hidden */
  103699. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  103700. private _deleteBuffer;
  103701. protected _format: Nullable<number>;
  103702. private _delayedOnLoad;
  103703. private _delayedOnError;
  103704. private _mimeType?;
  103705. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  103706. get mimeType(): string | undefined;
  103707. /**
  103708. * Observable triggered once the texture has been loaded.
  103709. */
  103710. onLoadObservable: Observable<Texture>;
  103711. protected _isBlocking: boolean;
  103712. /**
  103713. * Is the texture preventing material to render while loading.
  103714. * If false, a default texture will be used instead of the loading one during the preparation step.
  103715. */
  103716. set isBlocking(value: boolean);
  103717. get isBlocking(): boolean;
  103718. /**
  103719. * Get the current sampling mode associated with the texture.
  103720. */
  103721. get samplingMode(): number;
  103722. /**
  103723. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  103724. */
  103725. get invertY(): boolean;
  103726. /**
  103727. * Instantiates a new texture.
  103728. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  103729. * @see https://doc.babylonjs.com/babylon101/materials#texture
  103730. * @param url defines the url of the picture to load as a texture
  103731. * @param sceneOrEngine defines the scene or engine the texture will belong to
  103732. * @param noMipmap defines if the texture will require mip maps or not
  103733. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  103734. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103735. * @param onLoad defines a callback triggered when the texture has been loaded
  103736. * @param onError defines a callback triggered when an error occurred during the loading session
  103737. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  103738. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  103739. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103740. * @param mimeType defines an optional mime type information
  103741. */
  103742. 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);
  103743. /**
  103744. * Update the url (and optional buffer) of this texture if url was null during construction.
  103745. * @param url the url of the texture
  103746. * @param buffer the buffer of the texture (defaults to null)
  103747. * @param onLoad callback called when the texture is loaded (defaults to null)
  103748. */
  103749. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  103750. /**
  103751. * Finish the loading sequence of a texture flagged as delayed load.
  103752. * @hidden
  103753. */
  103754. delayLoad(): void;
  103755. private _prepareRowForTextureGeneration;
  103756. /**
  103757. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  103758. * @returns the transform matrix of the texture.
  103759. */
  103760. getTextureMatrix(uBase?: number): Matrix;
  103761. /**
  103762. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  103763. * @returns The reflection texture transform
  103764. */
  103765. getReflectionTextureMatrix(): Matrix;
  103766. /**
  103767. * Clones the texture.
  103768. * @returns the cloned texture
  103769. */
  103770. clone(): Texture;
  103771. /**
  103772. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  103773. * @returns The JSON representation of the texture
  103774. */
  103775. serialize(): any;
  103776. /**
  103777. * Get the current class name of the texture useful for serialization or dynamic coding.
  103778. * @returns "Texture"
  103779. */
  103780. getClassName(): string;
  103781. /**
  103782. * Dispose the texture and release its associated resources.
  103783. */
  103784. dispose(): void;
  103785. /**
  103786. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  103787. * @param parsedTexture Define the JSON representation of the texture
  103788. * @param scene Define the scene the parsed texture should be instantiated in
  103789. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  103790. * @returns The parsed texture if successful
  103791. */
  103792. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  103793. /**
  103794. * Creates a texture from its base 64 representation.
  103795. * @param data Define the base64 payload without the data: prefix
  103796. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103797. * @param scene Define the scene the texture should belong to
  103798. * @param noMipmap Forces the texture to not create mip map information if true
  103799. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103800. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103801. * @param onLoad define a callback triggered when the texture has been loaded
  103802. * @param onError define a callback triggered when an error occurred during the loading session
  103803. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103804. * @returns the created texture
  103805. */
  103806. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  103807. /**
  103808. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  103809. * @param data Define the base64 payload without the data: prefix
  103810. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  103811. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  103812. * @param scene Define the scene the texture should belong to
  103813. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  103814. * @param noMipmap Forces the texture to not create mip map information if true
  103815. * @param invertY define if the texture needs to be inverted on the y axis during loading
  103816. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  103817. * @param onLoad define a callback triggered when the texture has been loaded
  103818. * @param onError define a callback triggered when an error occurred during the loading session
  103819. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  103820. * @returns the created texture
  103821. */
  103822. 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;
  103823. }
  103824. }
  103825. declare module BABYLON {
  103826. /**
  103827. * PostProcessManager is used to manage one or more post processes or post process pipelines
  103828. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103829. */
  103830. export class PostProcessManager {
  103831. private _scene;
  103832. private _indexBuffer;
  103833. private _vertexBuffers;
  103834. /**
  103835. * Creates a new instance PostProcess
  103836. * @param scene The scene that the post process is associated with.
  103837. */
  103838. constructor(scene: Scene);
  103839. private _prepareBuffers;
  103840. private _buildIndexBuffer;
  103841. /**
  103842. * Rebuilds the vertex buffers of the manager.
  103843. * @hidden
  103844. */
  103845. _rebuild(): void;
  103846. /**
  103847. * Prepares a frame to be run through a post process.
  103848. * @param sourceTexture The input texture to the post procesess. (default: null)
  103849. * @param postProcesses An array of post processes to be run. (default: null)
  103850. * @returns True if the post processes were able to be run.
  103851. * @hidden
  103852. */
  103853. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  103854. /**
  103855. * Manually render a set of post processes to a texture.
  103856. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  103857. * @param postProcesses An array of post processes to be run.
  103858. * @param targetTexture The target texture to render to.
  103859. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  103860. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  103861. * @param lodLevel defines which lod of the texture to render to
  103862. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  103863. */
  103864. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  103865. /**
  103866. * Finalize the result of the output of the postprocesses.
  103867. * @param doNotPresent If true the result will not be displayed to the screen.
  103868. * @param targetTexture The target texture to render to.
  103869. * @param faceIndex The index of the face to bind the target texture to.
  103870. * @param postProcesses The array of post processes to render.
  103871. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  103872. * @hidden
  103873. */
  103874. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  103875. /**
  103876. * Disposes of the post process manager.
  103877. */
  103878. dispose(): void;
  103879. }
  103880. }
  103881. declare module BABYLON {
  103882. /**
  103883. * This Helps creating a texture that will be created from a camera in your scene.
  103884. * It is basically a dynamic texture that could be used to create special effects for instance.
  103885. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  103886. */
  103887. export class RenderTargetTexture extends Texture {
  103888. /**
  103889. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  103890. */
  103891. static readonly REFRESHRATE_RENDER_ONCE: number;
  103892. /**
  103893. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  103894. */
  103895. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  103896. /**
  103897. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  103898. * the central point of your effect and can save a lot of performances.
  103899. */
  103900. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  103901. /**
  103902. * Use this predicate to dynamically define the list of mesh you want to render.
  103903. * If set, the renderList property will be overwritten.
  103904. */
  103905. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  103906. private _renderList;
  103907. /**
  103908. * Use this list to define the list of mesh you want to render.
  103909. */
  103910. get renderList(): Nullable<Array<AbstractMesh>>;
  103911. set renderList(value: Nullable<Array<AbstractMesh>>);
  103912. /**
  103913. * Use this function to overload the renderList array at rendering time.
  103914. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  103915. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  103916. * the cube (if the RTT is a cube, else layerOrFace=0).
  103917. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  103918. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  103919. * hold dummy elements!
  103920. */
  103921. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  103922. private _hookArray;
  103923. /**
  103924. * Define if particles should be rendered in your texture.
  103925. */
  103926. renderParticles: boolean;
  103927. /**
  103928. * Define if sprites should be rendered in your texture.
  103929. */
  103930. renderSprites: boolean;
  103931. /**
  103932. * Define the camera used to render the texture.
  103933. */
  103934. activeCamera: Nullable<Camera>;
  103935. /**
  103936. * Override the mesh isReady function with your own one.
  103937. */
  103938. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  103939. /**
  103940. * Override the render function of the texture with your own one.
  103941. */
  103942. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  103943. /**
  103944. * Define if camera post processes should be use while rendering the texture.
  103945. */
  103946. useCameraPostProcesses: boolean;
  103947. /**
  103948. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  103949. */
  103950. ignoreCameraViewport: boolean;
  103951. private _postProcessManager;
  103952. private _postProcesses;
  103953. private _resizeObserver;
  103954. /**
  103955. * An event triggered when the texture is unbind.
  103956. */
  103957. onBeforeBindObservable: Observable<RenderTargetTexture>;
  103958. /**
  103959. * An event triggered when the texture is unbind.
  103960. */
  103961. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  103962. private _onAfterUnbindObserver;
  103963. /**
  103964. * Set a after unbind callback in the texture.
  103965. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  103966. */
  103967. set onAfterUnbind(callback: () => void);
  103968. /**
  103969. * An event triggered before rendering the texture
  103970. */
  103971. onBeforeRenderObservable: Observable<number>;
  103972. private _onBeforeRenderObserver;
  103973. /**
  103974. * Set a before render callback in the texture.
  103975. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  103976. */
  103977. set onBeforeRender(callback: (faceIndex: number) => void);
  103978. /**
  103979. * An event triggered after rendering the texture
  103980. */
  103981. onAfterRenderObservable: Observable<number>;
  103982. private _onAfterRenderObserver;
  103983. /**
  103984. * Set a after render callback in the texture.
  103985. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  103986. */
  103987. set onAfterRender(callback: (faceIndex: number) => void);
  103988. /**
  103989. * An event triggered after the texture clear
  103990. */
  103991. onClearObservable: Observable<Engine>;
  103992. private _onClearObserver;
  103993. /**
  103994. * Set a clear callback in the texture.
  103995. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  103996. */
  103997. set onClear(callback: (Engine: Engine) => void);
  103998. /**
  103999. * An event triggered when the texture is resized.
  104000. */
  104001. onResizeObservable: Observable<RenderTargetTexture>;
  104002. /**
  104003. * Define the clear color of the Render Target if it should be different from the scene.
  104004. */
  104005. clearColor: Color4;
  104006. protected _size: number | {
  104007. width: number;
  104008. height: number;
  104009. layers?: number;
  104010. };
  104011. protected _initialSizeParameter: number | {
  104012. width: number;
  104013. height: number;
  104014. } | {
  104015. ratio: number;
  104016. };
  104017. protected _sizeRatio: Nullable<number>;
  104018. /** @hidden */
  104019. _generateMipMaps: boolean;
  104020. protected _renderingManager: RenderingManager;
  104021. /** @hidden */
  104022. _waitingRenderList?: string[];
  104023. protected _doNotChangeAspectRatio: boolean;
  104024. protected _currentRefreshId: number;
  104025. protected _refreshRate: number;
  104026. protected _textureMatrix: Matrix;
  104027. protected _samples: number;
  104028. protected _renderTargetOptions: RenderTargetCreationOptions;
  104029. /**
  104030. * Gets render target creation options that were used.
  104031. */
  104032. get renderTargetOptions(): RenderTargetCreationOptions;
  104033. protected _onRatioRescale(): void;
  104034. /**
  104035. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104036. * It must define where the camera used to render the texture is set
  104037. */
  104038. boundingBoxPosition: Vector3;
  104039. private _boundingBoxSize;
  104040. /**
  104041. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104042. * When defined, the cubemap will switch to local mode
  104043. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104044. * @example https://www.babylonjs-playground.com/#RNASML
  104045. */
  104046. set boundingBoxSize(value: Vector3);
  104047. get boundingBoxSize(): Vector3;
  104048. /**
  104049. * In case the RTT has been created with a depth texture, get the associated
  104050. * depth texture.
  104051. * Otherwise, return null.
  104052. */
  104053. get depthStencilTexture(): Nullable<InternalTexture>;
  104054. /**
  104055. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104056. * or used a shadow, depth texture...
  104057. * @param name The friendly name of the texture
  104058. * @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)
  104059. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104060. * @param generateMipMaps True if mip maps need to be generated after render.
  104061. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104062. * @param type The type of the buffer in the RTT (int, half float, float...)
  104063. * @param isCube True if a cube texture needs to be created
  104064. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104065. * @param generateDepthBuffer True to generate a depth buffer
  104066. * @param generateStencilBuffer True to generate a stencil buffer
  104067. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104068. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104069. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104070. */
  104071. constructor(name: string, size: number | {
  104072. width: number;
  104073. height: number;
  104074. layers?: number;
  104075. } | {
  104076. ratio: number;
  104077. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104078. /**
  104079. * Creates a depth stencil texture.
  104080. * This is only available in WebGL 2 or with the depth texture extension available.
  104081. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104082. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104083. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104084. */
  104085. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104086. private _processSizeParameter;
  104087. /**
  104088. * Define the number of samples to use in case of MSAA.
  104089. * It defaults to one meaning no MSAA has been enabled.
  104090. */
  104091. get samples(): number;
  104092. set samples(value: number);
  104093. /**
  104094. * Resets the refresh counter of the texture and start bak from scratch.
  104095. * Could be useful to regenerate the texture if it is setup to render only once.
  104096. */
  104097. resetRefreshCounter(): void;
  104098. /**
  104099. * Define the refresh rate of the texture or the rendering frequency.
  104100. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104101. */
  104102. get refreshRate(): number;
  104103. set refreshRate(value: number);
  104104. /**
  104105. * Adds a post process to the render target rendering passes.
  104106. * @param postProcess define the post process to add
  104107. */
  104108. addPostProcess(postProcess: PostProcess): void;
  104109. /**
  104110. * Clear all the post processes attached to the render target
  104111. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104112. */
  104113. clearPostProcesses(dispose?: boolean): void;
  104114. /**
  104115. * Remove one of the post process from the list of attached post processes to the texture
  104116. * @param postProcess define the post process to remove from the list
  104117. */
  104118. removePostProcess(postProcess: PostProcess): void;
  104119. /** @hidden */
  104120. _shouldRender(): boolean;
  104121. /**
  104122. * Gets the actual render size of the texture.
  104123. * @returns the width of the render size
  104124. */
  104125. getRenderSize(): number;
  104126. /**
  104127. * Gets the actual render width of the texture.
  104128. * @returns the width of the render size
  104129. */
  104130. getRenderWidth(): number;
  104131. /**
  104132. * Gets the actual render height of the texture.
  104133. * @returns the height of the render size
  104134. */
  104135. getRenderHeight(): number;
  104136. /**
  104137. * Gets the actual number of layers of the texture.
  104138. * @returns the number of layers
  104139. */
  104140. getRenderLayers(): number;
  104141. /**
  104142. * Get if the texture can be rescaled or not.
  104143. */
  104144. get canRescale(): boolean;
  104145. /**
  104146. * Resize the texture using a ratio.
  104147. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104148. */
  104149. scale(ratio: number): void;
  104150. /**
  104151. * Get the texture reflection matrix used to rotate/transform the reflection.
  104152. * @returns the reflection matrix
  104153. */
  104154. getReflectionTextureMatrix(): Matrix;
  104155. /**
  104156. * Resize the texture to a new desired size.
  104157. * Be carrefull as it will recreate all the data in the new texture.
  104158. * @param size Define the new size. It can be:
  104159. * - a number for squared texture,
  104160. * - an object containing { width: number, height: number }
  104161. * - or an object containing a ratio { ratio: number }
  104162. */
  104163. resize(size: number | {
  104164. width: number;
  104165. height: number;
  104166. } | {
  104167. ratio: number;
  104168. }): void;
  104169. private _defaultRenderListPrepared;
  104170. /**
  104171. * Renders all the objects from the render list into the texture.
  104172. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104173. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104174. */
  104175. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104176. private _bestReflectionRenderTargetDimension;
  104177. private _prepareRenderingManager;
  104178. /**
  104179. * @hidden
  104180. * @param faceIndex face index to bind to if this is a cubetexture
  104181. * @param layer defines the index of the texture to bind in the array
  104182. */
  104183. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104184. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104185. private renderToTarget;
  104186. /**
  104187. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104188. * This allowed control for front to back rendering or reversly depending of the special needs.
  104189. *
  104190. * @param renderingGroupId The rendering group id corresponding to its index
  104191. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  104192. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  104193. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  104194. */
  104195. 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;
  104196. /**
  104197. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  104198. *
  104199. * @param renderingGroupId The rendering group id corresponding to its index
  104200. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  104201. */
  104202. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  104203. /**
  104204. * Clones the texture.
  104205. * @returns the cloned texture
  104206. */
  104207. clone(): RenderTargetTexture;
  104208. /**
  104209. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104210. * @returns The JSON representation of the texture
  104211. */
  104212. serialize(): any;
  104213. /**
  104214. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  104215. */
  104216. disposeFramebufferObjects(): void;
  104217. /**
  104218. * Dispose the texture and release its associated resources.
  104219. */
  104220. dispose(): void;
  104221. /** @hidden */
  104222. _rebuild(): void;
  104223. /**
  104224. * Clear the info related to rendering groups preventing retention point in material dispose.
  104225. */
  104226. freeRenderingGroups(): void;
  104227. /**
  104228. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  104229. * @returns the view count
  104230. */
  104231. getViewCount(): number;
  104232. }
  104233. }
  104234. declare module BABYLON {
  104235. /**
  104236. * Class used to manipulate GUIDs
  104237. */
  104238. export class GUID {
  104239. /**
  104240. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104241. * Be aware Math.random() could cause collisions, but:
  104242. * "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"
  104243. * @returns a pseudo random id
  104244. */
  104245. static RandomId(): string;
  104246. }
  104247. }
  104248. declare module BABYLON {
  104249. /**
  104250. * Options to be used when creating a shadow depth material
  104251. */
  104252. export interface IIOptionShadowDepthMaterial {
  104253. /** Variables in the vertex shader code that need to have their names remapped.
  104254. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  104255. * "var_name" should be either: worldPos or vNormalW
  104256. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  104257. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  104258. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  104259. */
  104260. remappedVariables?: string[];
  104261. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  104262. standalone?: boolean;
  104263. }
  104264. /**
  104265. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  104266. */
  104267. export class ShadowDepthWrapper {
  104268. private _scene;
  104269. private _options?;
  104270. private _baseMaterial;
  104271. private _onEffectCreatedObserver;
  104272. private _subMeshToEffect;
  104273. private _subMeshToDepthEffect;
  104274. private _meshes;
  104275. /** @hidden */
  104276. _matriceNames: any;
  104277. /** Gets the standalone status of the wrapper */
  104278. get standalone(): boolean;
  104279. /** Gets the base material the wrapper is built upon */
  104280. get baseMaterial(): Material;
  104281. /**
  104282. * Instantiate a new shadow depth wrapper.
  104283. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  104284. * generate the shadow depth map. For more information, please refer to the documentation:
  104285. * https://doc.babylonjs.com/babylon101/shadows
  104286. * @param baseMaterial Material to wrap
  104287. * @param scene Define the scene the material belongs to
  104288. * @param options Options used to create the wrapper
  104289. */
  104290. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  104291. /**
  104292. * Gets the effect to use to generate the depth map
  104293. * @param subMesh subMesh to get the effect for
  104294. * @param shadowGenerator shadow generator to get the effect for
  104295. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  104296. */
  104297. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  104298. /**
  104299. * Specifies that the submesh is ready to be used for depth rendering
  104300. * @param subMesh submesh to check
  104301. * @param defines the list of defines to take into account when checking the effect
  104302. * @param shadowGenerator combined with subMesh, it defines the effect to check
  104303. * @param useInstances specifies that instances should be used
  104304. * @returns a boolean indicating that the submesh is ready or not
  104305. */
  104306. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  104307. /**
  104308. * Disposes the resources
  104309. */
  104310. dispose(): void;
  104311. private _makeEffect;
  104312. }
  104313. }
  104314. declare module BABYLON {
  104315. interface ThinEngine {
  104316. /**
  104317. * Unbind a list of render target textures from the webGL context
  104318. * This is used only when drawBuffer extension or webGL2 are active
  104319. * @param textures defines the render target textures to unbind
  104320. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104321. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104322. */
  104323. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104324. /**
  104325. * Create a multi render target texture
  104326. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  104327. * @param size defines the size of the texture
  104328. * @param options defines the creation options
  104329. * @returns the cube texture as an InternalTexture
  104330. */
  104331. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104332. /**
  104333. * Update the sample count for a given multiple render target texture
  104334. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104335. * @param textures defines the textures to update
  104336. * @param samples defines the sample count to set
  104337. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104338. */
  104339. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104340. /**
  104341. * Select a subsets of attachments to draw to.
  104342. * @param attachments gl attachments
  104343. */
  104344. bindAttachments(attachments: number[]): void;
  104345. }
  104346. }
  104347. declare module BABYLON {
  104348. /**
  104349. * Creation options of the multi render target texture.
  104350. */
  104351. export interface IMultiRenderTargetOptions {
  104352. /**
  104353. * Define if the texture needs to create mip maps after render.
  104354. */
  104355. generateMipMaps?: boolean;
  104356. /**
  104357. * Define the types of all the draw buffers we want to create
  104358. */
  104359. types?: number[];
  104360. /**
  104361. * Define the sampling modes of all the draw buffers we want to create
  104362. */
  104363. samplingModes?: number[];
  104364. /**
  104365. * Define if a depth buffer is required
  104366. */
  104367. generateDepthBuffer?: boolean;
  104368. /**
  104369. * Define if a stencil buffer is required
  104370. */
  104371. generateStencilBuffer?: boolean;
  104372. /**
  104373. * Define if a depth texture is required instead of a depth buffer
  104374. */
  104375. generateDepthTexture?: boolean;
  104376. /**
  104377. * Define the number of desired draw buffers
  104378. */
  104379. textureCount?: number;
  104380. /**
  104381. * Define if aspect ratio should be adapted to the texture or stay the scene one
  104382. */
  104383. doNotChangeAspectRatio?: boolean;
  104384. /**
  104385. * Define the default type of the buffers we are creating
  104386. */
  104387. defaultType?: number;
  104388. }
  104389. /**
  104390. * A multi render target, like a render target provides the ability to render to a texture.
  104391. * Unlike the render target, it can render to several draw buffers in one draw.
  104392. * This is specially interesting in deferred rendering or for any effects requiring more than
  104393. * just one color from a single pass.
  104394. */
  104395. export class MultiRenderTarget extends RenderTargetTexture {
  104396. private _internalTextures;
  104397. private _textures;
  104398. private _multiRenderTargetOptions;
  104399. private _count;
  104400. /**
  104401. * Get if draw buffers are currently supported by the used hardware and browser.
  104402. */
  104403. get isSupported(): boolean;
  104404. /**
  104405. * Get the list of textures generated by the multi render target.
  104406. */
  104407. get textures(): Texture[];
  104408. /**
  104409. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  104410. */
  104411. get count(): number;
  104412. /**
  104413. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104414. */
  104415. get depthTexture(): Texture;
  104416. /**
  104417. * Set the wrapping mode on U of all the textures we are rendering to.
  104418. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104419. */
  104420. set wrapU(wrap: number);
  104421. /**
  104422. * Set the wrapping mode on V of all the textures we are rendering to.
  104423. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104424. */
  104425. set wrapV(wrap: number);
  104426. /**
  104427. * Instantiate a new multi render target texture.
  104428. * A multi render target, like a render target provides the ability to render to a texture.
  104429. * Unlike the render target, it can render to several draw buffers in one draw.
  104430. * This is specially interesting in deferred rendering or for any effects requiring more than
  104431. * just one color from a single pass.
  104432. * @param name Define the name of the texture
  104433. * @param size Define the size of the buffers to render to
  104434. * @param count Define the number of target we are rendering into
  104435. * @param scene Define the scene the texture belongs to
  104436. * @param options Define the options used to create the multi render target
  104437. */
  104438. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104439. private _initTypes;
  104440. /** @hidden */
  104441. _rebuild(forceFullRebuild?: boolean): void;
  104442. private _createInternalTextures;
  104443. private _createTextures;
  104444. /**
  104445. * Define the number of samples used if MSAA is enabled.
  104446. */
  104447. get samples(): number;
  104448. set samples(value: number);
  104449. /**
  104450. * Resize all the textures in the multi render target.
  104451. * Be careful as it will recreate all the data in the new texture.
  104452. * @param size Define the new size
  104453. */
  104454. resize(size: any): void;
  104455. /**
  104456. * Changes the number of render targets in this MRT
  104457. * Be careful as it will recreate all the data in the new texture.
  104458. * @param count new texture count
  104459. * @param options Specifies texture types and sampling modes for new textures
  104460. */
  104461. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  104462. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104463. /**
  104464. * Dispose the render targets and their associated resources
  104465. */
  104466. dispose(): void;
  104467. /**
  104468. * Release all the underlying texture used as draw buffers.
  104469. */
  104470. releaseInternalTextures(): void;
  104471. }
  104472. }
  104473. declare module BABYLON {
  104474. /** @hidden */
  104475. export var imageProcessingPixelShader: {
  104476. name: string;
  104477. shader: string;
  104478. };
  104479. }
  104480. declare module BABYLON {
  104481. /**
  104482. * ImageProcessingPostProcess
  104483. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  104484. */
  104485. export class ImageProcessingPostProcess extends PostProcess {
  104486. /**
  104487. * Default configuration related to image processing available in the PBR Material.
  104488. */
  104489. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104490. /**
  104491. * Gets the image processing configuration used either in this material.
  104492. */
  104493. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  104494. /**
  104495. * Sets the Default image processing configuration used either in the this material.
  104496. *
  104497. * If sets to null, the scene one is in use.
  104498. */
  104499. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  104500. /**
  104501. * Keep track of the image processing observer to allow dispose and replace.
  104502. */
  104503. private _imageProcessingObserver;
  104504. /**
  104505. * Attaches a new image processing configuration to the PBR Material.
  104506. * @param configuration
  104507. */
  104508. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  104509. /**
  104510. * If the post process is supported.
  104511. */
  104512. get isSupported(): boolean;
  104513. /**
  104514. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104515. */
  104516. get colorCurves(): Nullable<ColorCurves>;
  104517. /**
  104518. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  104519. */
  104520. set colorCurves(value: Nullable<ColorCurves>);
  104521. /**
  104522. * Gets wether the color curves effect is enabled.
  104523. */
  104524. get colorCurvesEnabled(): boolean;
  104525. /**
  104526. * Sets wether the color curves effect is enabled.
  104527. */
  104528. set colorCurvesEnabled(value: boolean);
  104529. /**
  104530. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104531. */
  104532. get colorGradingTexture(): Nullable<BaseTexture>;
  104533. /**
  104534. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  104535. */
  104536. set colorGradingTexture(value: Nullable<BaseTexture>);
  104537. /**
  104538. * Gets wether the color grading effect is enabled.
  104539. */
  104540. get colorGradingEnabled(): boolean;
  104541. /**
  104542. * Gets wether the color grading effect is enabled.
  104543. */
  104544. set colorGradingEnabled(value: boolean);
  104545. /**
  104546. * Gets exposure used in the effect.
  104547. */
  104548. get exposure(): number;
  104549. /**
  104550. * Sets exposure used in the effect.
  104551. */
  104552. set exposure(value: number);
  104553. /**
  104554. * Gets wether tonemapping is enabled or not.
  104555. */
  104556. get toneMappingEnabled(): boolean;
  104557. /**
  104558. * Sets wether tonemapping is enabled or not
  104559. */
  104560. set toneMappingEnabled(value: boolean);
  104561. /**
  104562. * Gets the type of tone mapping effect.
  104563. */
  104564. get toneMappingType(): number;
  104565. /**
  104566. * Sets the type of tone mapping effect.
  104567. */
  104568. set toneMappingType(value: number);
  104569. /**
  104570. * Gets contrast used in the effect.
  104571. */
  104572. get contrast(): number;
  104573. /**
  104574. * Sets contrast used in the effect.
  104575. */
  104576. set contrast(value: number);
  104577. /**
  104578. * Gets Vignette stretch size.
  104579. */
  104580. get vignetteStretch(): number;
  104581. /**
  104582. * Sets Vignette stretch size.
  104583. */
  104584. set vignetteStretch(value: number);
  104585. /**
  104586. * Gets Vignette centre X Offset.
  104587. */
  104588. get vignetteCentreX(): number;
  104589. /**
  104590. * Sets Vignette centre X Offset.
  104591. */
  104592. set vignetteCentreX(value: number);
  104593. /**
  104594. * Gets Vignette centre Y Offset.
  104595. */
  104596. get vignetteCentreY(): number;
  104597. /**
  104598. * Sets Vignette centre Y Offset.
  104599. */
  104600. set vignetteCentreY(value: number);
  104601. /**
  104602. * Gets Vignette weight or intensity of the vignette effect.
  104603. */
  104604. get vignetteWeight(): number;
  104605. /**
  104606. * Sets Vignette weight or intensity of the vignette effect.
  104607. */
  104608. set vignetteWeight(value: number);
  104609. /**
  104610. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104611. * if vignetteEnabled is set to true.
  104612. */
  104613. get vignetteColor(): Color4;
  104614. /**
  104615. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  104616. * if vignetteEnabled is set to true.
  104617. */
  104618. set vignetteColor(value: Color4);
  104619. /**
  104620. * Gets Camera field of view used by the Vignette effect.
  104621. */
  104622. get vignetteCameraFov(): number;
  104623. /**
  104624. * Sets Camera field of view used by the Vignette effect.
  104625. */
  104626. set vignetteCameraFov(value: number);
  104627. /**
  104628. * Gets the vignette blend mode allowing different kind of effect.
  104629. */
  104630. get vignetteBlendMode(): number;
  104631. /**
  104632. * Sets the vignette blend mode allowing different kind of effect.
  104633. */
  104634. set vignetteBlendMode(value: number);
  104635. /**
  104636. * Gets wether the vignette effect is enabled.
  104637. */
  104638. get vignetteEnabled(): boolean;
  104639. /**
  104640. * Sets wether the vignette effect is enabled.
  104641. */
  104642. set vignetteEnabled(value: boolean);
  104643. private _fromLinearSpace;
  104644. /**
  104645. * Gets wether the input of the processing is in Gamma or Linear Space.
  104646. */
  104647. get fromLinearSpace(): boolean;
  104648. /**
  104649. * Sets wether the input of the processing is in Gamma or Linear Space.
  104650. */
  104651. set fromLinearSpace(value: boolean);
  104652. /**
  104653. * Defines cache preventing GC.
  104654. */
  104655. private _defines;
  104656. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  104657. /**
  104658. * "ImageProcessingPostProcess"
  104659. * @returns "ImageProcessingPostProcess"
  104660. */
  104661. getClassName(): string;
  104662. /**
  104663. * @hidden
  104664. */
  104665. _updateParameters(): void;
  104666. dispose(camera?: Camera): void;
  104667. }
  104668. }
  104669. declare module BABYLON {
  104670. /**
  104671. * Interface for defining prepass effects in the prepass post-process pipeline
  104672. */
  104673. export interface PrePassEffectConfiguration {
  104674. /**
  104675. * Name of the effect
  104676. */
  104677. name: string;
  104678. /**
  104679. * Post process to attach for this effect
  104680. */
  104681. postProcess?: PostProcess;
  104682. /**
  104683. * Textures required in the MRT
  104684. */
  104685. texturesRequired: number[];
  104686. /**
  104687. * Is the effect enabled
  104688. */
  104689. enabled: boolean;
  104690. /**
  104691. * Disposes the effect configuration
  104692. */
  104693. dispose(): void;
  104694. /**
  104695. * Creates the associated post process
  104696. */
  104697. createPostProcess?: () => PostProcess;
  104698. }
  104699. }
  104700. declare module BABYLON {
  104701. /**
  104702. * Renders a pre pass of the scene
  104703. * This means every mesh in the scene will be rendered to a render target texture
  104704. * And then this texture will be composited to the rendering canvas with post processes
  104705. * It is necessary for effects like subsurface scattering or deferred shading
  104706. */
  104707. export class PrePassRenderer {
  104708. /** @hidden */
  104709. static _SceneComponentInitialization: (scene: Scene) => void;
  104710. private _textureFormats;
  104711. private _textureIndices;
  104712. private _scene;
  104713. private _engine;
  104714. private _isDirty;
  104715. /**
  104716. * Number of textures in the multi render target texture where the scene is directly rendered
  104717. */
  104718. mrtCount: number;
  104719. /**
  104720. * The render target where the scene is directly rendered
  104721. */
  104722. prePassRT: MultiRenderTarget;
  104723. private _multiRenderAttachments;
  104724. private _defaultAttachments;
  104725. private _clearAttachments;
  104726. private _postProcesses;
  104727. private readonly _clearColor;
  104728. /**
  104729. * Image processing post process for composition
  104730. */
  104731. imageProcessingPostProcess: ImageProcessingPostProcess;
  104732. /**
  104733. * Configuration for prepass effects
  104734. */
  104735. private _effectConfigurations;
  104736. /**
  104737. * Should materials render their geometry on the MRT
  104738. */
  104739. materialsShouldRenderGeometry: boolean;
  104740. /**
  104741. * Should materials render the irradiance information on the MRT
  104742. */
  104743. materialsShouldRenderIrradiance: boolean;
  104744. private _mrtFormats;
  104745. private _mrtLayout;
  104746. private _enabled;
  104747. /**
  104748. * Indicates if the prepass is enabled
  104749. */
  104750. get enabled(): boolean;
  104751. /**
  104752. * How many samples are used for MSAA of the scene render target
  104753. */
  104754. get samples(): number;
  104755. set samples(n: number);
  104756. /**
  104757. * Instanciates a prepass renderer
  104758. * @param scene The scene
  104759. */
  104760. constructor(scene: Scene);
  104761. private _initializeAttachments;
  104762. private _createCompositionEffect;
  104763. /**
  104764. * Indicates if rendering a prepass is supported
  104765. */
  104766. get isSupported(): boolean;
  104767. /**
  104768. * Sets the proper output textures to draw in the engine.
  104769. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  104770. */
  104771. bindAttachmentsForEffect(effect: Effect): void;
  104772. /**
  104773. * @hidden
  104774. */
  104775. _beforeCameraDraw(): void;
  104776. /**
  104777. * @hidden
  104778. */
  104779. _afterCameraDraw(): void;
  104780. private _checkRTSize;
  104781. private _bindFrameBuffer;
  104782. /**
  104783. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  104784. */
  104785. clear(): void;
  104786. private _setState;
  104787. private _checkTextureType;
  104788. /**
  104789. * Adds an effect configuration to the prepass.
  104790. * If an effect has already been added, it won't add it twice and will return the configuration
  104791. * already present.
  104792. * @param cfg the effect configuration
  104793. * @return the effect configuration now used by the prepass
  104794. */
  104795. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  104796. /**
  104797. * Returns the index of a texture in the multi render target texture array.
  104798. * @param type Texture type
  104799. * @return The index
  104800. */
  104801. getIndex(type: number): number;
  104802. private _enable;
  104803. private _disable;
  104804. private _resetLayout;
  104805. private _resetPostProcessChain;
  104806. private _bindPostProcessChain;
  104807. /**
  104808. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  104809. */
  104810. markAsDirty(): void;
  104811. /**
  104812. * Enables a texture on the MultiRenderTarget for prepass
  104813. */
  104814. private _enableTextures;
  104815. private _update;
  104816. /**
  104817. * Disposes the prepass renderer.
  104818. */
  104819. dispose(): void;
  104820. }
  104821. }
  104822. declare module BABYLON {
  104823. /**
  104824. * Options for compiling materials.
  104825. */
  104826. export interface IMaterialCompilationOptions {
  104827. /**
  104828. * Defines whether clip planes are enabled.
  104829. */
  104830. clipPlane: boolean;
  104831. /**
  104832. * Defines whether instances are enabled.
  104833. */
  104834. useInstances: boolean;
  104835. }
  104836. /**
  104837. * Options passed when calling customShaderNameResolve
  104838. */
  104839. export interface ICustomShaderNameResolveOptions {
  104840. /**
  104841. * 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
  104842. */
  104843. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  104844. }
  104845. /**
  104846. * Base class for the main features of a material in Babylon.js
  104847. */
  104848. export class Material implements IAnimatable {
  104849. /**
  104850. * Returns the triangle fill mode
  104851. */
  104852. static readonly TriangleFillMode: number;
  104853. /**
  104854. * Returns the wireframe mode
  104855. */
  104856. static readonly WireFrameFillMode: number;
  104857. /**
  104858. * Returns the point fill mode
  104859. */
  104860. static readonly PointFillMode: number;
  104861. /**
  104862. * Returns the point list draw mode
  104863. */
  104864. static readonly PointListDrawMode: number;
  104865. /**
  104866. * Returns the line list draw mode
  104867. */
  104868. static readonly LineListDrawMode: number;
  104869. /**
  104870. * Returns the line loop draw mode
  104871. */
  104872. static readonly LineLoopDrawMode: number;
  104873. /**
  104874. * Returns the line strip draw mode
  104875. */
  104876. static readonly LineStripDrawMode: number;
  104877. /**
  104878. * Returns the triangle strip draw mode
  104879. */
  104880. static readonly TriangleStripDrawMode: number;
  104881. /**
  104882. * Returns the triangle fan draw mode
  104883. */
  104884. static readonly TriangleFanDrawMode: number;
  104885. /**
  104886. * Stores the clock-wise side orientation
  104887. */
  104888. static readonly ClockWiseSideOrientation: number;
  104889. /**
  104890. * Stores the counter clock-wise side orientation
  104891. */
  104892. static readonly CounterClockWiseSideOrientation: number;
  104893. /**
  104894. * The dirty texture flag value
  104895. */
  104896. static readonly TextureDirtyFlag: number;
  104897. /**
  104898. * The dirty light flag value
  104899. */
  104900. static readonly LightDirtyFlag: number;
  104901. /**
  104902. * The dirty fresnel flag value
  104903. */
  104904. static readonly FresnelDirtyFlag: number;
  104905. /**
  104906. * The dirty attribute flag value
  104907. */
  104908. static readonly AttributesDirtyFlag: number;
  104909. /**
  104910. * The dirty misc flag value
  104911. */
  104912. static readonly MiscDirtyFlag: number;
  104913. /**
  104914. * The all dirty flag value
  104915. */
  104916. static readonly AllDirtyFlag: number;
  104917. /**
  104918. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104919. */
  104920. static readonly MATERIAL_OPAQUE: number;
  104921. /**
  104922. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104923. */
  104924. static readonly MATERIAL_ALPHATEST: number;
  104925. /**
  104926. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104927. */
  104928. static readonly MATERIAL_ALPHABLEND: number;
  104929. /**
  104930. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104931. * They are also discarded below the alpha cutoff threshold to improve performances.
  104932. */
  104933. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  104934. /**
  104935. * The Whiteout method is used to blend normals.
  104936. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104937. */
  104938. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  104939. /**
  104940. * The Reoriented Normal Mapping method is used to blend normals.
  104941. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  104942. */
  104943. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  104944. /**
  104945. * Custom callback helping to override the default shader used in the material.
  104946. */
  104947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  104948. /**
  104949. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  104950. */
  104951. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  104952. /**
  104953. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  104954. * This means that the material can keep using a previous shader while a new one is being compiled.
  104955. * This is mostly used when shader parallel compilation is supported (true by default)
  104956. */
  104957. allowShaderHotSwapping: boolean;
  104958. /**
  104959. * The ID of the material
  104960. */
  104961. id: string;
  104962. /**
  104963. * Gets or sets the unique id of the material
  104964. */
  104965. uniqueId: number;
  104966. /**
  104967. * The name of the material
  104968. */
  104969. name: string;
  104970. /**
  104971. * Gets or sets user defined metadata
  104972. */
  104973. metadata: any;
  104974. /**
  104975. * For internal use only. Please do not use.
  104976. */
  104977. reservedDataStore: any;
  104978. /**
  104979. * Specifies if the ready state should be checked on each call
  104980. */
  104981. checkReadyOnEveryCall: boolean;
  104982. /**
  104983. * Specifies if the ready state should be checked once
  104984. */
  104985. checkReadyOnlyOnce: boolean;
  104986. /**
  104987. * The state of the material
  104988. */
  104989. state: string;
  104990. /**
  104991. * If the material can be rendered to several textures with MRT extension
  104992. */
  104993. get canRenderToMRT(): boolean;
  104994. /**
  104995. * The alpha value of the material
  104996. */
  104997. protected _alpha: number;
  104998. /**
  104999. * List of inspectable custom properties (used by the Inspector)
  105000. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105001. */
  105002. inspectableCustomProperties: IInspectable[];
  105003. /**
  105004. * Sets the alpha value of the material
  105005. */
  105006. set alpha(value: number);
  105007. /**
  105008. * Gets the alpha value of the material
  105009. */
  105010. get alpha(): number;
  105011. /**
  105012. * Specifies if back face culling is enabled
  105013. */
  105014. protected _backFaceCulling: boolean;
  105015. /**
  105016. * Sets the back-face culling state
  105017. */
  105018. set backFaceCulling(value: boolean);
  105019. /**
  105020. * Gets the back-face culling state
  105021. */
  105022. get backFaceCulling(): boolean;
  105023. /**
  105024. * Stores the value for side orientation
  105025. */
  105026. sideOrientation: number;
  105027. /**
  105028. * Callback triggered when the material is compiled
  105029. */
  105030. onCompiled: Nullable<(effect: Effect) => void>;
  105031. /**
  105032. * Callback triggered when an error occurs
  105033. */
  105034. onError: Nullable<(effect: Effect, errors: string) => void>;
  105035. /**
  105036. * Callback triggered to get the render target textures
  105037. */
  105038. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105039. /**
  105040. * Gets a boolean indicating that current material needs to register RTT
  105041. */
  105042. get hasRenderTargetTextures(): boolean;
  105043. /**
  105044. * Specifies if the material should be serialized
  105045. */
  105046. doNotSerialize: boolean;
  105047. /**
  105048. * @hidden
  105049. */
  105050. _storeEffectOnSubMeshes: boolean;
  105051. /**
  105052. * Stores the animations for the material
  105053. */
  105054. animations: Nullable<Array<Animation>>;
  105055. /**
  105056. * An event triggered when the material is disposed
  105057. */
  105058. onDisposeObservable: Observable<Material>;
  105059. /**
  105060. * An observer which watches for dispose events
  105061. */
  105062. private _onDisposeObserver;
  105063. private _onUnBindObservable;
  105064. /**
  105065. * Called during a dispose event
  105066. */
  105067. set onDispose(callback: () => void);
  105068. private _onBindObservable;
  105069. /**
  105070. * An event triggered when the material is bound
  105071. */
  105072. get onBindObservable(): Observable<AbstractMesh>;
  105073. /**
  105074. * An observer which watches for bind events
  105075. */
  105076. private _onBindObserver;
  105077. /**
  105078. * Called during a bind event
  105079. */
  105080. set onBind(callback: (Mesh: AbstractMesh) => void);
  105081. /**
  105082. * An event triggered when the material is unbound
  105083. */
  105084. get onUnBindObservable(): Observable<Material>;
  105085. protected _onEffectCreatedObservable: Nullable<Observable<{
  105086. effect: Effect;
  105087. subMesh: Nullable<SubMesh>;
  105088. }>>;
  105089. /**
  105090. * An event triggered when the effect is (re)created
  105091. */
  105092. get onEffectCreatedObservable(): Observable<{
  105093. effect: Effect;
  105094. subMesh: Nullable<SubMesh>;
  105095. }>;
  105096. /**
  105097. * Stores the value of the alpha mode
  105098. */
  105099. private _alphaMode;
  105100. /**
  105101. * Sets the value of the alpha mode.
  105102. *
  105103. * | Value | Type | Description |
  105104. * | --- | --- | --- |
  105105. * | 0 | ALPHA_DISABLE | |
  105106. * | 1 | ALPHA_ADD | |
  105107. * | 2 | ALPHA_COMBINE | |
  105108. * | 3 | ALPHA_SUBTRACT | |
  105109. * | 4 | ALPHA_MULTIPLY | |
  105110. * | 5 | ALPHA_MAXIMIZED | |
  105111. * | 6 | ALPHA_ONEONE | |
  105112. * | 7 | ALPHA_PREMULTIPLIED | |
  105113. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105114. * | 9 | ALPHA_INTERPOLATE | |
  105115. * | 10 | ALPHA_SCREENMODE | |
  105116. *
  105117. */
  105118. set alphaMode(value: number);
  105119. /**
  105120. * Gets the value of the alpha mode
  105121. */
  105122. get alphaMode(): number;
  105123. /**
  105124. * Stores the state of the need depth pre-pass value
  105125. */
  105126. private _needDepthPrePass;
  105127. /**
  105128. * Sets the need depth pre-pass value
  105129. */
  105130. set needDepthPrePass(value: boolean);
  105131. /**
  105132. * Gets the depth pre-pass value
  105133. */
  105134. get needDepthPrePass(): boolean;
  105135. /**
  105136. * Specifies if depth writing should be disabled
  105137. */
  105138. disableDepthWrite: boolean;
  105139. /**
  105140. * Specifies if color writing should be disabled
  105141. */
  105142. disableColorWrite: boolean;
  105143. /**
  105144. * Specifies if depth writing should be forced
  105145. */
  105146. forceDepthWrite: boolean;
  105147. /**
  105148. * Specifies the depth function that should be used. 0 means the default engine function
  105149. */
  105150. depthFunction: number;
  105151. /**
  105152. * Specifies if there should be a separate pass for culling
  105153. */
  105154. separateCullingPass: boolean;
  105155. /**
  105156. * Stores the state specifing if fog should be enabled
  105157. */
  105158. private _fogEnabled;
  105159. /**
  105160. * Sets the state for enabling fog
  105161. */
  105162. set fogEnabled(value: boolean);
  105163. /**
  105164. * Gets the value of the fog enabled state
  105165. */
  105166. get fogEnabled(): boolean;
  105167. /**
  105168. * Stores the size of points
  105169. */
  105170. pointSize: number;
  105171. /**
  105172. * Stores the z offset value
  105173. */
  105174. zOffset: number;
  105175. get wireframe(): boolean;
  105176. /**
  105177. * Sets the state of wireframe mode
  105178. */
  105179. set wireframe(value: boolean);
  105180. /**
  105181. * Gets the value specifying if point clouds are enabled
  105182. */
  105183. get pointsCloud(): boolean;
  105184. /**
  105185. * Sets the state of point cloud mode
  105186. */
  105187. set pointsCloud(value: boolean);
  105188. /**
  105189. * Gets the material fill mode
  105190. */
  105191. get fillMode(): number;
  105192. /**
  105193. * Sets the material fill mode
  105194. */
  105195. set fillMode(value: number);
  105196. /**
  105197. * @hidden
  105198. * Stores the effects for the material
  105199. */
  105200. _effect: Nullable<Effect>;
  105201. /**
  105202. * Specifies if uniform buffers should be used
  105203. */
  105204. private _useUBO;
  105205. /**
  105206. * Stores a reference to the scene
  105207. */
  105208. private _scene;
  105209. /**
  105210. * Stores the fill mode state
  105211. */
  105212. private _fillMode;
  105213. /**
  105214. * Specifies if the depth write state should be cached
  105215. */
  105216. private _cachedDepthWriteState;
  105217. /**
  105218. * Specifies if the color write state should be cached
  105219. */
  105220. private _cachedColorWriteState;
  105221. /**
  105222. * Specifies if the depth function state should be cached
  105223. */
  105224. private _cachedDepthFunctionState;
  105225. /**
  105226. * Stores the uniform buffer
  105227. */
  105228. protected _uniformBuffer: UniformBuffer;
  105229. /** @hidden */
  105230. _indexInSceneMaterialArray: number;
  105231. /** @hidden */
  105232. meshMap: Nullable<{
  105233. [id: string]: AbstractMesh | undefined;
  105234. }>;
  105235. /**
  105236. * Creates a material instance
  105237. * @param name defines the name of the material
  105238. * @param scene defines the scene to reference
  105239. * @param doNotAdd specifies if the material should be added to the scene
  105240. */
  105241. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105242. /**
  105243. * Returns a string representation of the current material
  105244. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105245. * @returns a string with material information
  105246. */
  105247. toString(fullDetails?: boolean): string;
  105248. /**
  105249. * Gets the class name of the material
  105250. * @returns a string with the class name of the material
  105251. */
  105252. getClassName(): string;
  105253. /**
  105254. * Specifies if updates for the material been locked
  105255. */
  105256. get isFrozen(): boolean;
  105257. /**
  105258. * Locks updates for the material
  105259. */
  105260. freeze(): void;
  105261. /**
  105262. * Unlocks updates for the material
  105263. */
  105264. unfreeze(): void;
  105265. /**
  105266. * Specifies if the material is ready to be used
  105267. * @param mesh defines the mesh to check
  105268. * @param useInstances specifies if instances should be used
  105269. * @returns a boolean indicating if the material is ready to be used
  105270. */
  105271. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105272. /**
  105273. * Specifies that the submesh is ready to be used
  105274. * @param mesh defines the mesh to check
  105275. * @param subMesh defines which submesh to check
  105276. * @param useInstances specifies that instances should be used
  105277. * @returns a boolean indicating that the submesh is ready or not
  105278. */
  105279. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105280. /**
  105281. * Returns the material effect
  105282. * @returns the effect associated with the material
  105283. */
  105284. getEffect(): Nullable<Effect>;
  105285. /**
  105286. * Returns the current scene
  105287. * @returns a Scene
  105288. */
  105289. getScene(): Scene;
  105290. /**
  105291. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105292. */
  105293. protected _forceAlphaTest: boolean;
  105294. /**
  105295. * The transparency mode of the material.
  105296. */
  105297. protected _transparencyMode: Nullable<number>;
  105298. /**
  105299. * Gets the current transparency mode.
  105300. */
  105301. get transparencyMode(): Nullable<number>;
  105302. /**
  105303. * Sets the transparency mode of the material.
  105304. *
  105305. * | Value | Type | Description |
  105306. * | ----- | ----------------------------------- | ----------- |
  105307. * | 0 | OPAQUE | |
  105308. * | 1 | ALPHATEST | |
  105309. * | 2 | ALPHABLEND | |
  105310. * | 3 | ALPHATESTANDBLEND | |
  105311. *
  105312. */
  105313. set transparencyMode(value: Nullable<number>);
  105314. /**
  105315. * Returns true if alpha blending should be disabled.
  105316. */
  105317. protected get _disableAlphaBlending(): boolean;
  105318. /**
  105319. * Specifies whether or not this material should be rendered in alpha blend mode.
  105320. * @returns a boolean specifying if alpha blending is needed
  105321. */
  105322. needAlphaBlending(): boolean;
  105323. /**
  105324. * Specifies if the mesh will require alpha blending
  105325. * @param mesh defines the mesh to check
  105326. * @returns a boolean specifying if alpha blending is needed for the mesh
  105327. */
  105328. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105329. /**
  105330. * Specifies whether or not this material should be rendered in alpha test mode.
  105331. * @returns a boolean specifying if an alpha test is needed.
  105332. */
  105333. needAlphaTesting(): boolean;
  105334. /**
  105335. * Specifies if material alpha testing should be turned on for the mesh
  105336. * @param mesh defines the mesh to check
  105337. */
  105338. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105339. /**
  105340. * Gets the texture used for the alpha test
  105341. * @returns the texture to use for alpha testing
  105342. */
  105343. getAlphaTestTexture(): Nullable<BaseTexture>;
  105344. /**
  105345. * Marks the material to indicate that it needs to be re-calculated
  105346. */
  105347. markDirty(): void;
  105348. /** @hidden */
  105349. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105350. /**
  105351. * Binds the material to the mesh
  105352. * @param world defines the world transformation matrix
  105353. * @param mesh defines the mesh to bind the material to
  105354. */
  105355. bind(world: Matrix, mesh?: Mesh): void;
  105356. /**
  105357. * Binds the submesh to the material
  105358. * @param world defines the world transformation matrix
  105359. * @param mesh defines the mesh containing the submesh
  105360. * @param subMesh defines the submesh to bind the material to
  105361. */
  105362. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105363. /**
  105364. * Binds the world matrix to the material
  105365. * @param world defines the world transformation matrix
  105366. */
  105367. bindOnlyWorldMatrix(world: Matrix): void;
  105368. /**
  105369. * Binds the scene's uniform buffer to the effect.
  105370. * @param effect defines the effect to bind to the scene uniform buffer
  105371. * @param sceneUbo defines the uniform buffer storing scene data
  105372. */
  105373. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105374. /**
  105375. * Binds the view matrix to the effect
  105376. * @param effect defines the effect to bind the view matrix to
  105377. */
  105378. bindView(effect: Effect): void;
  105379. /**
  105380. * Binds the view projection matrix to the effect
  105381. * @param effect defines the effect to bind the view projection matrix to
  105382. */
  105383. bindViewProjection(effect: Effect): void;
  105384. /**
  105385. * Processes to execute after binding the material to a mesh
  105386. * @param mesh defines the rendered mesh
  105387. */
  105388. protected _afterBind(mesh?: Mesh): void;
  105389. /**
  105390. * Unbinds the material from the mesh
  105391. */
  105392. unbind(): void;
  105393. /**
  105394. * Gets the active textures from the material
  105395. * @returns an array of textures
  105396. */
  105397. getActiveTextures(): BaseTexture[];
  105398. /**
  105399. * Specifies if the material uses a texture
  105400. * @param texture defines the texture to check against the material
  105401. * @returns a boolean specifying if the material uses the texture
  105402. */
  105403. hasTexture(texture: BaseTexture): boolean;
  105404. /**
  105405. * Makes a duplicate of the material, and gives it a new name
  105406. * @param name defines the new name for the duplicated material
  105407. * @returns the cloned material
  105408. */
  105409. clone(name: string): Nullable<Material>;
  105410. /**
  105411. * Gets the meshes bound to the material
  105412. * @returns an array of meshes bound to the material
  105413. */
  105414. getBindedMeshes(): AbstractMesh[];
  105415. /**
  105416. * Force shader compilation
  105417. * @param mesh defines the mesh associated with this material
  105418. * @param onCompiled defines a function to execute once the material is compiled
  105419. * @param options defines the options to configure the compilation
  105420. * @param onError defines a function to execute if the material fails compiling
  105421. */
  105422. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105423. /**
  105424. * Force shader compilation
  105425. * @param mesh defines the mesh that will use this material
  105426. * @param options defines additional options for compiling the shaders
  105427. * @returns a promise that resolves when the compilation completes
  105428. */
  105429. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105430. private static readonly _AllDirtyCallBack;
  105431. private static readonly _ImageProcessingDirtyCallBack;
  105432. private static readonly _TextureDirtyCallBack;
  105433. private static readonly _FresnelDirtyCallBack;
  105434. private static readonly _MiscDirtyCallBack;
  105435. private static readonly _LightsDirtyCallBack;
  105436. private static readonly _AttributeDirtyCallBack;
  105437. private static _FresnelAndMiscDirtyCallBack;
  105438. private static _TextureAndMiscDirtyCallBack;
  105439. private static readonly _DirtyCallbackArray;
  105440. private static readonly _RunDirtyCallBacks;
  105441. /**
  105442. * Marks a define in the material to indicate that it needs to be re-computed
  105443. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105444. */
  105445. markAsDirty(flag: number): void;
  105446. /**
  105447. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105448. * @param func defines a function which checks material defines against the submeshes
  105449. */
  105450. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105451. /**
  105452. * Indicates that the scene should check if the rendering now needs a prepass
  105453. */
  105454. protected _markScenePrePassDirty(): void;
  105455. /**
  105456. * Indicates that we need to re-calculated for all submeshes
  105457. */
  105458. protected _markAllSubMeshesAsAllDirty(): void;
  105459. /**
  105460. * Indicates that image processing needs to be re-calculated for all submeshes
  105461. */
  105462. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105463. /**
  105464. * Indicates that textures need to be re-calculated for all submeshes
  105465. */
  105466. protected _markAllSubMeshesAsTexturesDirty(): void;
  105467. /**
  105468. * Indicates that fresnel needs to be re-calculated for all submeshes
  105469. */
  105470. protected _markAllSubMeshesAsFresnelDirty(): void;
  105471. /**
  105472. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105473. */
  105474. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105475. /**
  105476. * Indicates that lights need to be re-calculated for all submeshes
  105477. */
  105478. protected _markAllSubMeshesAsLightsDirty(): void;
  105479. /**
  105480. * Indicates that attributes need to be re-calculated for all submeshes
  105481. */
  105482. protected _markAllSubMeshesAsAttributesDirty(): void;
  105483. /**
  105484. * Indicates that misc needs to be re-calculated for all submeshes
  105485. */
  105486. protected _markAllSubMeshesAsMiscDirty(): void;
  105487. /**
  105488. * Indicates that textures and misc need to be re-calculated for all submeshes
  105489. */
  105490. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105491. /**
  105492. * Sets the required values to the prepass renderer.
  105493. * @param prePassRenderer defines the prepass renderer to setup.
  105494. * @returns true if the pre pass is needed.
  105495. */
  105496. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105497. /**
  105498. * Disposes the material
  105499. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105500. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105501. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105502. */
  105503. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105504. /** @hidden */
  105505. private releaseVertexArrayObject;
  105506. /**
  105507. * Serializes this material
  105508. * @returns the serialized material object
  105509. */
  105510. serialize(): any;
  105511. /**
  105512. * Creates a material from parsed material data
  105513. * @param parsedMaterial defines parsed material data
  105514. * @param scene defines the hosting scene
  105515. * @param rootUrl defines the root URL to use to load textures
  105516. * @returns a new material
  105517. */
  105518. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105519. }
  105520. }
  105521. declare module BABYLON {
  105522. /**
  105523. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105524. * separate meshes. This can be use to improve performances.
  105525. * @see https://doc.babylonjs.com/how_to/multi_materials
  105526. */
  105527. export class MultiMaterial extends Material {
  105528. private _subMaterials;
  105529. /**
  105530. * Gets or Sets the list of Materials used within the multi material.
  105531. * They need to be ordered according to the submeshes order in the associated mesh
  105532. */
  105533. get subMaterials(): Nullable<Material>[];
  105534. set subMaterials(value: Nullable<Material>[]);
  105535. /**
  105536. * Function used to align with Node.getChildren()
  105537. * @returns the list of Materials used within the multi material
  105538. */
  105539. getChildren(): Nullable<Material>[];
  105540. /**
  105541. * Instantiates a new Multi Material
  105542. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105543. * separate meshes. This can be use to improve performances.
  105544. * @see https://doc.babylonjs.com/how_to/multi_materials
  105545. * @param name Define the name in the scene
  105546. * @param scene Define the scene the material belongs to
  105547. */
  105548. constructor(name: string, scene: Scene);
  105549. private _hookArray;
  105550. /**
  105551. * Get one of the submaterial by its index in the submaterials array
  105552. * @param index The index to look the sub material at
  105553. * @returns The Material if the index has been defined
  105554. */
  105555. getSubMaterial(index: number): Nullable<Material>;
  105556. /**
  105557. * Get the list of active textures for the whole sub materials list.
  105558. * @returns All the textures that will be used during the rendering
  105559. */
  105560. getActiveTextures(): BaseTexture[];
  105561. /**
  105562. * Gets the current class name of the material e.g. "MultiMaterial"
  105563. * Mainly use in serialization.
  105564. * @returns the class name
  105565. */
  105566. getClassName(): string;
  105567. /**
  105568. * Checks if the material is ready to render the requested sub mesh
  105569. * @param mesh Define the mesh the submesh belongs to
  105570. * @param subMesh Define the sub mesh to look readyness for
  105571. * @param useInstances Define whether or not the material is used with instances
  105572. * @returns true if ready, otherwise false
  105573. */
  105574. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105575. /**
  105576. * Clones the current material and its related sub materials
  105577. * @param name Define the name of the newly cloned material
  105578. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105579. * @returns the cloned material
  105580. */
  105581. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105582. /**
  105583. * Serializes the materials into a JSON representation.
  105584. * @returns the JSON representation
  105585. */
  105586. serialize(): any;
  105587. /**
  105588. * Dispose the material and release its associated resources
  105589. * @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)
  105590. * @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)
  105591. * @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)
  105592. */
  105593. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105594. /**
  105595. * Creates a MultiMaterial from parsed MultiMaterial data.
  105596. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105597. * @param scene defines the hosting scene
  105598. * @returns a new MultiMaterial
  105599. */
  105600. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105601. }
  105602. }
  105603. declare module BABYLON {
  105604. /**
  105605. * Defines a subdivision inside a mesh
  105606. */
  105607. export class SubMesh implements ICullable {
  105608. /** the material index to use */
  105609. materialIndex: number;
  105610. /** vertex index start */
  105611. verticesStart: number;
  105612. /** vertices count */
  105613. verticesCount: number;
  105614. /** index start */
  105615. indexStart: number;
  105616. /** indices count */
  105617. indexCount: number;
  105618. /** @hidden */
  105619. _materialDefines: Nullable<MaterialDefines>;
  105620. /** @hidden */
  105621. _materialEffect: Nullable<Effect>;
  105622. /** @hidden */
  105623. _effectOverride: Nullable<Effect>;
  105624. /**
  105625. * Gets material defines used by the effect associated to the sub mesh
  105626. */
  105627. get materialDefines(): Nullable<MaterialDefines>;
  105628. /**
  105629. * Sets material defines used by the effect associated to the sub mesh
  105630. */
  105631. set materialDefines(defines: Nullable<MaterialDefines>);
  105632. /**
  105633. * Gets associated effect
  105634. */
  105635. get effect(): Nullable<Effect>;
  105636. /**
  105637. * Sets associated effect (effect used to render this submesh)
  105638. * @param effect defines the effect to associate with
  105639. * @param defines defines the set of defines used to compile this effect
  105640. */
  105641. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105642. /** @hidden */
  105643. _linesIndexCount: number;
  105644. private _mesh;
  105645. private _renderingMesh;
  105646. private _boundingInfo;
  105647. private _linesIndexBuffer;
  105648. /** @hidden */
  105649. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105650. /** @hidden */
  105651. _trianglePlanes: Plane[];
  105652. /** @hidden */
  105653. _lastColliderTransformMatrix: Nullable<Matrix>;
  105654. /** @hidden */
  105655. _renderId: number;
  105656. /** @hidden */
  105657. _alphaIndex: number;
  105658. /** @hidden */
  105659. _distanceToCamera: number;
  105660. /** @hidden */
  105661. _id: number;
  105662. private _currentMaterial;
  105663. /**
  105664. * Add a new submesh to a mesh
  105665. * @param materialIndex defines the material index to use
  105666. * @param verticesStart defines vertex index start
  105667. * @param verticesCount defines vertices count
  105668. * @param indexStart defines index start
  105669. * @param indexCount defines indices count
  105670. * @param mesh defines the parent mesh
  105671. * @param renderingMesh defines an optional rendering mesh
  105672. * @param createBoundingBox defines if bounding box should be created for this submesh
  105673. * @returns the new submesh
  105674. */
  105675. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105676. /**
  105677. * Creates a new submesh
  105678. * @param materialIndex defines the material index to use
  105679. * @param verticesStart defines vertex index start
  105680. * @param verticesCount defines vertices count
  105681. * @param indexStart defines index start
  105682. * @param indexCount defines indices count
  105683. * @param mesh defines the parent mesh
  105684. * @param renderingMesh defines an optional rendering mesh
  105685. * @param createBoundingBox defines if bounding box should be created for this submesh
  105686. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105687. */
  105688. constructor(
  105689. /** the material index to use */
  105690. materialIndex: number,
  105691. /** vertex index start */
  105692. verticesStart: number,
  105693. /** vertices count */
  105694. verticesCount: number,
  105695. /** index start */
  105696. indexStart: number,
  105697. /** indices count */
  105698. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  105699. /**
  105700. * Returns true if this submesh covers the entire parent mesh
  105701. * @ignorenaming
  105702. */
  105703. get IsGlobal(): boolean;
  105704. /**
  105705. * Returns the submesh BoudingInfo object
  105706. * @returns current bounding info (or mesh's one if the submesh is global)
  105707. */
  105708. getBoundingInfo(): BoundingInfo;
  105709. /**
  105710. * Sets the submesh BoundingInfo
  105711. * @param boundingInfo defines the new bounding info to use
  105712. * @returns the SubMesh
  105713. */
  105714. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  105715. /**
  105716. * Returns the mesh of the current submesh
  105717. * @return the parent mesh
  105718. */
  105719. getMesh(): AbstractMesh;
  105720. /**
  105721. * Returns the rendering mesh of the submesh
  105722. * @returns the rendering mesh (could be different from parent mesh)
  105723. */
  105724. getRenderingMesh(): Mesh;
  105725. /**
  105726. * Returns the replacement mesh of the submesh
  105727. * @returns the replacement mesh (could be different from parent mesh)
  105728. */
  105729. getReplacementMesh(): Nullable<AbstractMesh>;
  105730. /**
  105731. * Returns the effective mesh of the submesh
  105732. * @returns the effective mesh (could be different from parent mesh)
  105733. */
  105734. getEffectiveMesh(): AbstractMesh;
  105735. /**
  105736. * Returns the submesh material
  105737. * @returns null or the current material
  105738. */
  105739. getMaterial(): Nullable<Material>;
  105740. private _IsMultiMaterial;
  105741. /**
  105742. * Sets a new updated BoundingInfo object to the submesh
  105743. * @param data defines an optional position array to use to determine the bounding info
  105744. * @returns the SubMesh
  105745. */
  105746. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  105747. /** @hidden */
  105748. _checkCollision(collider: Collider): boolean;
  105749. /**
  105750. * Updates the submesh BoundingInfo
  105751. * @param world defines the world matrix to use to update the bounding info
  105752. * @returns the submesh
  105753. */
  105754. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  105755. /**
  105756. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  105757. * @param frustumPlanes defines the frustum planes
  105758. * @returns true if the submesh is intersecting with the frustum
  105759. */
  105760. isInFrustum(frustumPlanes: Plane[]): boolean;
  105761. /**
  105762. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  105763. * @param frustumPlanes defines the frustum planes
  105764. * @returns true if the submesh is inside the frustum
  105765. */
  105766. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  105767. /**
  105768. * Renders the submesh
  105769. * @param enableAlphaMode defines if alpha needs to be used
  105770. * @returns the submesh
  105771. */
  105772. render(enableAlphaMode: boolean): SubMesh;
  105773. /**
  105774. * @hidden
  105775. */
  105776. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  105777. /**
  105778. * Checks if the submesh intersects with a ray
  105779. * @param ray defines the ray to test
  105780. * @returns true is the passed ray intersects the submesh bounding box
  105781. */
  105782. canIntersects(ray: Ray): boolean;
  105783. /**
  105784. * Intersects current submesh with a ray
  105785. * @param ray defines the ray to test
  105786. * @param positions defines mesh's positions array
  105787. * @param indices defines mesh's indices array
  105788. * @param fastCheck defines if the first intersection will be used (and not the closest)
  105789. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  105790. * @returns intersection info or null if no intersection
  105791. */
  105792. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  105793. /** @hidden */
  105794. private _intersectLines;
  105795. /** @hidden */
  105796. private _intersectUnIndexedLines;
  105797. /** @hidden */
  105798. private _intersectTriangles;
  105799. /** @hidden */
  105800. private _intersectUnIndexedTriangles;
  105801. /** @hidden */
  105802. _rebuild(): void;
  105803. /**
  105804. * Creates a new submesh from the passed mesh
  105805. * @param newMesh defines the new hosting mesh
  105806. * @param newRenderingMesh defines an optional rendering mesh
  105807. * @returns the new submesh
  105808. */
  105809. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  105810. /**
  105811. * Release associated resources
  105812. */
  105813. dispose(): void;
  105814. /**
  105815. * Gets the class name
  105816. * @returns the string "SubMesh".
  105817. */
  105818. getClassName(): string;
  105819. /**
  105820. * Creates a new submesh from indices data
  105821. * @param materialIndex the index of the main mesh material
  105822. * @param startIndex the index where to start the copy in the mesh indices array
  105823. * @param indexCount the number of indices to copy then from the startIndex
  105824. * @param mesh the main mesh to create the submesh from
  105825. * @param renderingMesh the optional rendering mesh
  105826. * @returns a new submesh
  105827. */
  105828. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  105829. }
  105830. }
  105831. declare module BABYLON {
  105832. /**
  105833. * Class used to represent data loading progression
  105834. */
  105835. export class SceneLoaderFlags {
  105836. private static _ForceFullSceneLoadingForIncremental;
  105837. private static _ShowLoadingScreen;
  105838. private static _CleanBoneMatrixWeights;
  105839. private static _loggingLevel;
  105840. /**
  105841. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  105842. */
  105843. static get ForceFullSceneLoadingForIncremental(): boolean;
  105844. static set ForceFullSceneLoadingForIncremental(value: boolean);
  105845. /**
  105846. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  105847. */
  105848. static get ShowLoadingScreen(): boolean;
  105849. static set ShowLoadingScreen(value: boolean);
  105850. /**
  105851. * Defines the current logging level (while loading the scene)
  105852. * @ignorenaming
  105853. */
  105854. static get loggingLevel(): number;
  105855. static set loggingLevel(value: number);
  105856. /**
  105857. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  105858. */
  105859. static get CleanBoneMatrixWeights(): boolean;
  105860. static set CleanBoneMatrixWeights(value: boolean);
  105861. }
  105862. }
  105863. declare module BABYLON {
  105864. /**
  105865. * Class used to store geometry data (vertex buffers + index buffer)
  105866. */
  105867. export class Geometry implements IGetSetVerticesData {
  105868. /**
  105869. * Gets or sets the ID of the geometry
  105870. */
  105871. id: string;
  105872. /**
  105873. * Gets or sets the unique ID of the geometry
  105874. */
  105875. uniqueId: number;
  105876. /**
  105877. * Gets the delay loading state of the geometry (none by default which means not delayed)
  105878. */
  105879. delayLoadState: number;
  105880. /**
  105881. * Gets the file containing the data to load when running in delay load state
  105882. */
  105883. delayLoadingFile: Nullable<string>;
  105884. /**
  105885. * Callback called when the geometry is updated
  105886. */
  105887. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  105888. private _scene;
  105889. private _engine;
  105890. private _meshes;
  105891. private _totalVertices;
  105892. /** @hidden */
  105893. _indices: IndicesArray;
  105894. /** @hidden */
  105895. _vertexBuffers: {
  105896. [key: string]: VertexBuffer;
  105897. };
  105898. private _isDisposed;
  105899. private _extend;
  105900. private _boundingBias;
  105901. /** @hidden */
  105902. _delayInfo: Array<string>;
  105903. private _indexBuffer;
  105904. private _indexBufferIsUpdatable;
  105905. /** @hidden */
  105906. _boundingInfo: Nullable<BoundingInfo>;
  105907. /** @hidden */
  105908. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  105909. /** @hidden */
  105910. _softwareSkinningFrameId: number;
  105911. private _vertexArrayObjects;
  105912. private _updatable;
  105913. /** @hidden */
  105914. _positions: Nullable<Vector3[]>;
  105915. /**
  105916. * 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
  105917. */
  105918. get boundingBias(): Vector2;
  105919. /**
  105920. * 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
  105921. */
  105922. set boundingBias(value: Vector2);
  105923. /**
  105924. * Static function used to attach a new empty geometry to a mesh
  105925. * @param mesh defines the mesh to attach the geometry to
  105926. * @returns the new Geometry
  105927. */
  105928. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  105929. /** Get the list of meshes using this geometry */
  105930. get meshes(): Mesh[];
  105931. /**
  105932. * 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
  105933. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  105934. */
  105935. useBoundingInfoFromGeometry: boolean;
  105936. /**
  105937. * Creates a new geometry
  105938. * @param id defines the unique ID
  105939. * @param scene defines the hosting scene
  105940. * @param vertexData defines the VertexData used to get geometry data
  105941. * @param updatable defines if geometry must be updatable (false by default)
  105942. * @param mesh defines the mesh that will be associated with the geometry
  105943. */
  105944. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  105945. /**
  105946. * Gets the current extend of the geometry
  105947. */
  105948. get extend(): {
  105949. minimum: Vector3;
  105950. maximum: Vector3;
  105951. };
  105952. /**
  105953. * Gets the hosting scene
  105954. * @returns the hosting Scene
  105955. */
  105956. getScene(): Scene;
  105957. /**
  105958. * Gets the hosting engine
  105959. * @returns the hosting Engine
  105960. */
  105961. getEngine(): Engine;
  105962. /**
  105963. * Defines if the geometry is ready to use
  105964. * @returns true if the geometry is ready to be used
  105965. */
  105966. isReady(): boolean;
  105967. /**
  105968. * Gets a value indicating that the geometry should not be serialized
  105969. */
  105970. get doNotSerialize(): boolean;
  105971. /** @hidden */
  105972. _rebuild(): void;
  105973. /**
  105974. * Affects all geometry data in one call
  105975. * @param vertexData defines the geometry data
  105976. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  105977. */
  105978. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  105979. /**
  105980. * Set specific vertex data
  105981. * @param kind defines the data kind (Position, normal, etc...)
  105982. * @param data defines the vertex data to use
  105983. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  105984. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  105985. */
  105986. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  105987. /**
  105988. * Removes a specific vertex data
  105989. * @param kind defines the data kind (Position, normal, etc...)
  105990. */
  105991. removeVerticesData(kind: string): void;
  105992. /**
  105993. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  105994. * @param buffer defines the vertex buffer to use
  105995. * @param totalVertices defines the total number of vertices for position kind (could be null)
  105996. */
  105997. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  105998. /**
  105999. * Update a specific vertex buffer
  106000. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106001. * It will do nothing if the buffer is not updatable
  106002. * @param kind defines the data kind (Position, normal, etc...)
  106003. * @param data defines the data to use
  106004. * @param offset defines the offset in the target buffer where to store the data
  106005. * @param useBytes set to true if the offset is in bytes
  106006. */
  106007. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106008. /**
  106009. * Update a specific vertex buffer
  106010. * This function will create a new buffer if the current one is not updatable
  106011. * @param kind defines the data kind (Position, normal, etc...)
  106012. * @param data defines the data to use
  106013. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106014. */
  106015. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106016. private _updateBoundingInfo;
  106017. /** @hidden */
  106018. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106019. /**
  106020. * Gets total number of vertices
  106021. * @returns the total number of vertices
  106022. */
  106023. getTotalVertices(): number;
  106024. /**
  106025. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106026. * @param kind defines the data kind (Position, normal, etc...)
  106027. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106028. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106029. * @returns a float array containing vertex data
  106030. */
  106031. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106032. /**
  106033. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106034. * @param kind defines the data kind (Position, normal, etc...)
  106035. * @returns true if the vertex buffer with the specified kind is updatable
  106036. */
  106037. isVertexBufferUpdatable(kind: string): boolean;
  106038. /**
  106039. * Gets a specific vertex buffer
  106040. * @param kind defines the data kind (Position, normal, etc...)
  106041. * @returns a VertexBuffer
  106042. */
  106043. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106044. /**
  106045. * Returns all vertex buffers
  106046. * @return an object holding all vertex buffers indexed by kind
  106047. */
  106048. getVertexBuffers(): Nullable<{
  106049. [key: string]: VertexBuffer;
  106050. }>;
  106051. /**
  106052. * Gets a boolean indicating if specific vertex buffer is present
  106053. * @param kind defines the data kind (Position, normal, etc...)
  106054. * @returns true if data is present
  106055. */
  106056. isVerticesDataPresent(kind: string): boolean;
  106057. /**
  106058. * Gets a list of all attached data kinds (Position, normal, etc...)
  106059. * @returns a list of string containing all kinds
  106060. */
  106061. getVerticesDataKinds(): string[];
  106062. /**
  106063. * Update index buffer
  106064. * @param indices defines the indices to store in the index buffer
  106065. * @param offset defines the offset in the target buffer where to store the data
  106066. * @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)
  106067. */
  106068. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106069. /**
  106070. * Creates a new index buffer
  106071. * @param indices defines the indices to store in the index buffer
  106072. * @param totalVertices defines the total number of vertices (could be null)
  106073. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106074. */
  106075. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106076. /**
  106077. * Return the total number of indices
  106078. * @returns the total number of indices
  106079. */
  106080. getTotalIndices(): number;
  106081. /**
  106082. * Gets the index buffer array
  106083. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106084. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106085. * @returns the index buffer array
  106086. */
  106087. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106088. /**
  106089. * Gets the index buffer
  106090. * @return the index buffer
  106091. */
  106092. getIndexBuffer(): Nullable<DataBuffer>;
  106093. /** @hidden */
  106094. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106095. /**
  106096. * Release the associated resources for a specific mesh
  106097. * @param mesh defines the source mesh
  106098. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106099. */
  106100. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106101. /**
  106102. * Apply current geometry to a given mesh
  106103. * @param mesh defines the mesh to apply geometry to
  106104. */
  106105. applyToMesh(mesh: Mesh): void;
  106106. private _updateExtend;
  106107. private _applyToMesh;
  106108. private notifyUpdate;
  106109. /**
  106110. * Load the geometry if it was flagged as delay loaded
  106111. * @param scene defines the hosting scene
  106112. * @param onLoaded defines a callback called when the geometry is loaded
  106113. */
  106114. load(scene: Scene, onLoaded?: () => void): void;
  106115. private _queueLoad;
  106116. /**
  106117. * Invert the geometry to move from a right handed system to a left handed one.
  106118. */
  106119. toLeftHanded(): void;
  106120. /** @hidden */
  106121. _resetPointsArrayCache(): void;
  106122. /** @hidden */
  106123. _generatePointsArray(): boolean;
  106124. /**
  106125. * Gets a value indicating if the geometry is disposed
  106126. * @returns true if the geometry was disposed
  106127. */
  106128. isDisposed(): boolean;
  106129. private _disposeVertexArrayObjects;
  106130. /**
  106131. * Free all associated resources
  106132. */
  106133. dispose(): void;
  106134. /**
  106135. * Clone the current geometry into a new geometry
  106136. * @param id defines the unique ID of the new geometry
  106137. * @returns a new geometry object
  106138. */
  106139. copy(id: string): Geometry;
  106140. /**
  106141. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106142. * @return a JSON representation of the current geometry data (without the vertices data)
  106143. */
  106144. serialize(): any;
  106145. private toNumberArray;
  106146. /**
  106147. * Serialize all vertices data into a JSON oject
  106148. * @returns a JSON representation of the current geometry data
  106149. */
  106150. serializeVerticeData(): any;
  106151. /**
  106152. * Extracts a clone of a mesh geometry
  106153. * @param mesh defines the source mesh
  106154. * @param id defines the unique ID of the new geometry object
  106155. * @returns the new geometry object
  106156. */
  106157. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106158. /**
  106159. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106160. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106161. * Be aware Math.random() could cause collisions, but:
  106162. * "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"
  106163. * @returns a string containing a new GUID
  106164. */
  106165. static RandomId(): string;
  106166. /** @hidden */
  106167. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106168. private static _CleanMatricesWeights;
  106169. /**
  106170. * Create a new geometry from persisted data (Using .babylon file format)
  106171. * @param parsedVertexData defines the persisted data
  106172. * @param scene defines the hosting scene
  106173. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106174. * @returns the new geometry object
  106175. */
  106176. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106177. }
  106178. }
  106179. declare module BABYLON {
  106180. /**
  106181. * Define an interface for all classes that will get and set the data on vertices
  106182. */
  106183. export interface IGetSetVerticesData {
  106184. /**
  106185. * Gets a boolean indicating if specific vertex data is present
  106186. * @param kind defines the vertex data kind to use
  106187. * @returns true is data kind is present
  106188. */
  106189. isVerticesDataPresent(kind: string): boolean;
  106190. /**
  106191. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106192. * @param kind defines the data kind (Position, normal, etc...)
  106193. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106194. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106195. * @returns a float array containing vertex data
  106196. */
  106197. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106198. /**
  106199. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106200. * @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.
  106201. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106202. * @returns the indices array or an empty array if the mesh has no geometry
  106203. */
  106204. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106205. /**
  106206. * Set specific vertex data
  106207. * @param kind defines the data kind (Position, normal, etc...)
  106208. * @param data defines the vertex data to use
  106209. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106210. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106211. */
  106212. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106213. /**
  106214. * Update a specific associated vertex buffer
  106215. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106216. * - VertexBuffer.PositionKind
  106217. * - VertexBuffer.UVKind
  106218. * - VertexBuffer.UV2Kind
  106219. * - VertexBuffer.UV3Kind
  106220. * - VertexBuffer.UV4Kind
  106221. * - VertexBuffer.UV5Kind
  106222. * - VertexBuffer.UV6Kind
  106223. * - VertexBuffer.ColorKind
  106224. * - VertexBuffer.MatricesIndicesKind
  106225. * - VertexBuffer.MatricesIndicesExtraKind
  106226. * - VertexBuffer.MatricesWeightsKind
  106227. * - VertexBuffer.MatricesWeightsExtraKind
  106228. * @param data defines the data source
  106229. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106230. * @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)
  106231. */
  106232. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106233. /**
  106234. * Creates a new index buffer
  106235. * @param indices defines the indices to store in the index buffer
  106236. * @param totalVertices defines the total number of vertices (could be null)
  106237. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106238. */
  106239. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106240. }
  106241. /**
  106242. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106243. */
  106244. export class VertexData {
  106245. /**
  106246. * Mesh side orientation : usually the external or front surface
  106247. */
  106248. static readonly FRONTSIDE: number;
  106249. /**
  106250. * Mesh side orientation : usually the internal or back surface
  106251. */
  106252. static readonly BACKSIDE: number;
  106253. /**
  106254. * Mesh side orientation : both internal and external or front and back surfaces
  106255. */
  106256. static readonly DOUBLESIDE: number;
  106257. /**
  106258. * Mesh side orientation : by default, `FRONTSIDE`
  106259. */
  106260. static readonly DEFAULTSIDE: number;
  106261. /**
  106262. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106263. */
  106264. positions: Nullable<FloatArray>;
  106265. /**
  106266. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106267. */
  106268. normals: Nullable<FloatArray>;
  106269. /**
  106270. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106271. */
  106272. tangents: Nullable<FloatArray>;
  106273. /**
  106274. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106275. */
  106276. uvs: Nullable<FloatArray>;
  106277. /**
  106278. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106279. */
  106280. uvs2: Nullable<FloatArray>;
  106281. /**
  106282. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106283. */
  106284. uvs3: Nullable<FloatArray>;
  106285. /**
  106286. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106287. */
  106288. uvs4: Nullable<FloatArray>;
  106289. /**
  106290. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106291. */
  106292. uvs5: Nullable<FloatArray>;
  106293. /**
  106294. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106295. */
  106296. uvs6: Nullable<FloatArray>;
  106297. /**
  106298. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106299. */
  106300. colors: Nullable<FloatArray>;
  106301. /**
  106302. * 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).
  106303. */
  106304. matricesIndices: Nullable<FloatArray>;
  106305. /**
  106306. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106307. */
  106308. matricesWeights: Nullable<FloatArray>;
  106309. /**
  106310. * An array extending the number of possible indices
  106311. */
  106312. matricesIndicesExtra: Nullable<FloatArray>;
  106313. /**
  106314. * An array extending the number of possible weights when the number of indices is extended
  106315. */
  106316. matricesWeightsExtra: Nullable<FloatArray>;
  106317. /**
  106318. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106319. */
  106320. indices: Nullable<IndicesArray>;
  106321. /**
  106322. * Uses the passed data array to set the set the values for the specified kind of data
  106323. * @param data a linear array of floating numbers
  106324. * @param kind the type of data that is being set, eg positions, colors etc
  106325. */
  106326. set(data: FloatArray, kind: string): void;
  106327. /**
  106328. * Associates the vertexData to the passed Mesh.
  106329. * Sets it as updatable or not (default `false`)
  106330. * @param mesh the mesh the vertexData is applied to
  106331. * @param updatable when used and having the value true allows new data to update the vertexData
  106332. * @returns the VertexData
  106333. */
  106334. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106335. /**
  106336. * Associates the vertexData to the passed Geometry.
  106337. * Sets it as updatable or not (default `false`)
  106338. * @param geometry the geometry the vertexData is applied to
  106339. * @param updatable when used and having the value true allows new data to update the vertexData
  106340. * @returns VertexData
  106341. */
  106342. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106343. /**
  106344. * Updates the associated mesh
  106345. * @param mesh the mesh to be updated
  106346. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106347. * @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
  106348. * @returns VertexData
  106349. */
  106350. updateMesh(mesh: Mesh): VertexData;
  106351. /**
  106352. * Updates the associated geometry
  106353. * @param geometry the geometry to be updated
  106354. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106355. * @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
  106356. * @returns VertexData.
  106357. */
  106358. updateGeometry(geometry: Geometry): VertexData;
  106359. private _applyTo;
  106360. private _update;
  106361. /**
  106362. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106363. * @param matrix the transforming matrix
  106364. * @returns the VertexData
  106365. */
  106366. transform(matrix: Matrix): VertexData;
  106367. /**
  106368. * Merges the passed VertexData into the current one
  106369. * @param other the VertexData to be merged into the current one
  106370. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106371. * @returns the modified VertexData
  106372. */
  106373. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106374. private _mergeElement;
  106375. private _validate;
  106376. /**
  106377. * Serializes the VertexData
  106378. * @returns a serialized object
  106379. */
  106380. serialize(): any;
  106381. /**
  106382. * Extracts the vertexData from a mesh
  106383. * @param mesh the mesh from which to extract the VertexData
  106384. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106385. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106386. * @returns the object VertexData associated to the passed mesh
  106387. */
  106388. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106389. /**
  106390. * Extracts the vertexData from the geometry
  106391. * @param geometry the geometry from which to extract the VertexData
  106392. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106393. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106394. * @returns the object VertexData associated to the passed mesh
  106395. */
  106396. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106397. private static _ExtractFrom;
  106398. /**
  106399. * Creates the VertexData for a Ribbon
  106400. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106401. * * pathArray array of paths, each of which an array of successive Vector3
  106402. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106403. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106404. * * 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
  106405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106406. * * 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)
  106407. * * 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)
  106408. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106409. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106410. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106411. * @returns the VertexData of the ribbon
  106412. */
  106413. static CreateRibbon(options: {
  106414. pathArray: Vector3[][];
  106415. closeArray?: boolean;
  106416. closePath?: boolean;
  106417. offset?: number;
  106418. sideOrientation?: number;
  106419. frontUVs?: Vector4;
  106420. backUVs?: Vector4;
  106421. invertUV?: boolean;
  106422. uvs?: Vector2[];
  106423. colors?: Color4[];
  106424. }): VertexData;
  106425. /**
  106426. * Creates the VertexData for a box
  106427. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106428. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106429. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106430. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106431. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106432. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106433. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106435. * * 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)
  106436. * * 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)
  106437. * @returns the VertexData of the box
  106438. */
  106439. static CreateBox(options: {
  106440. size?: number;
  106441. width?: number;
  106442. height?: number;
  106443. depth?: number;
  106444. faceUV?: Vector4[];
  106445. faceColors?: Color4[];
  106446. sideOrientation?: number;
  106447. frontUVs?: Vector4;
  106448. backUVs?: Vector4;
  106449. }): VertexData;
  106450. /**
  106451. * Creates the VertexData for a tiled box
  106452. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106453. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106454. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106455. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106457. * @returns the VertexData of the box
  106458. */
  106459. static CreateTiledBox(options: {
  106460. pattern?: number;
  106461. width?: number;
  106462. height?: number;
  106463. depth?: number;
  106464. tileSize?: number;
  106465. tileWidth?: number;
  106466. tileHeight?: number;
  106467. alignHorizontal?: number;
  106468. alignVertical?: number;
  106469. faceUV?: Vector4[];
  106470. faceColors?: Color4[];
  106471. sideOrientation?: number;
  106472. }): VertexData;
  106473. /**
  106474. * Creates the VertexData for a tiled plane
  106475. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106476. * * pattern a limited pattern arrangement depending on the number
  106477. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106478. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106479. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106480. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106481. * * 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)
  106482. * * 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)
  106483. * @returns the VertexData of the tiled plane
  106484. */
  106485. static CreateTiledPlane(options: {
  106486. pattern?: number;
  106487. tileSize?: number;
  106488. tileWidth?: number;
  106489. tileHeight?: number;
  106490. size?: number;
  106491. width?: number;
  106492. height?: number;
  106493. alignHorizontal?: number;
  106494. alignVertical?: number;
  106495. sideOrientation?: number;
  106496. frontUVs?: Vector4;
  106497. backUVs?: Vector4;
  106498. }): VertexData;
  106499. /**
  106500. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106501. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106502. * * segments sets the number of horizontal strips optional, default 32
  106503. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106504. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106505. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106506. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106507. * * 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
  106508. * * 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
  106509. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106510. * * 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)
  106511. * * 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)
  106512. * @returns the VertexData of the ellipsoid
  106513. */
  106514. static CreateSphere(options: {
  106515. segments?: number;
  106516. diameter?: number;
  106517. diameterX?: number;
  106518. diameterY?: number;
  106519. diameterZ?: number;
  106520. arc?: number;
  106521. slice?: number;
  106522. sideOrientation?: number;
  106523. frontUVs?: Vector4;
  106524. backUVs?: Vector4;
  106525. }): VertexData;
  106526. /**
  106527. * Creates the VertexData for a cylinder, cone or prism
  106528. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106529. * * height sets the height (y direction) of the cylinder, optional, default 2
  106530. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106531. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106532. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106533. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106534. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106535. * * 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
  106536. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106537. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106538. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106539. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106540. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106541. * * 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)
  106542. * * 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)
  106543. * @returns the VertexData of the cylinder, cone or prism
  106544. */
  106545. static CreateCylinder(options: {
  106546. height?: number;
  106547. diameterTop?: number;
  106548. diameterBottom?: number;
  106549. diameter?: number;
  106550. tessellation?: number;
  106551. subdivisions?: number;
  106552. arc?: number;
  106553. faceColors?: Color4[];
  106554. faceUV?: Vector4[];
  106555. hasRings?: boolean;
  106556. enclose?: boolean;
  106557. sideOrientation?: number;
  106558. frontUVs?: Vector4;
  106559. backUVs?: Vector4;
  106560. }): VertexData;
  106561. /**
  106562. * Creates the VertexData for a torus
  106563. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106564. * * diameter the diameter of the torus, optional default 1
  106565. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106566. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106567. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106568. * * 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)
  106569. * * 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)
  106570. * @returns the VertexData of the torus
  106571. */
  106572. static CreateTorus(options: {
  106573. diameter?: number;
  106574. thickness?: number;
  106575. tessellation?: number;
  106576. sideOrientation?: number;
  106577. frontUVs?: Vector4;
  106578. backUVs?: Vector4;
  106579. }): VertexData;
  106580. /**
  106581. * Creates the VertexData of the LineSystem
  106582. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106583. * - lines an array of lines, each line being an array of successive Vector3
  106584. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106585. * @returns the VertexData of the LineSystem
  106586. */
  106587. static CreateLineSystem(options: {
  106588. lines: Vector3[][];
  106589. colors?: Nullable<Color4[][]>;
  106590. }): VertexData;
  106591. /**
  106592. * Create the VertexData for a DashedLines
  106593. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106594. * - points an array successive Vector3
  106595. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106596. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106597. * - dashNb the intended total number of dashes, optional, default 200
  106598. * @returns the VertexData for the DashedLines
  106599. */
  106600. static CreateDashedLines(options: {
  106601. points: Vector3[];
  106602. dashSize?: number;
  106603. gapSize?: number;
  106604. dashNb?: number;
  106605. }): VertexData;
  106606. /**
  106607. * Creates the VertexData for a Ground
  106608. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106609. * - width the width (x direction) of the ground, optional, default 1
  106610. * - height the height (z direction) of the ground, optional, default 1
  106611. * - subdivisions the number of subdivisions per side, optional, default 1
  106612. * @returns the VertexData of the Ground
  106613. */
  106614. static CreateGround(options: {
  106615. width?: number;
  106616. height?: number;
  106617. subdivisions?: number;
  106618. subdivisionsX?: number;
  106619. subdivisionsY?: number;
  106620. }): VertexData;
  106621. /**
  106622. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106623. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106624. * * xmin the ground minimum X coordinate, optional, default -1
  106625. * * zmin the ground minimum Z coordinate, optional, default -1
  106626. * * xmax the ground maximum X coordinate, optional, default 1
  106627. * * zmax the ground maximum Z coordinate, optional, default 1
  106628. * * 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}
  106629. * * 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}
  106630. * @returns the VertexData of the TiledGround
  106631. */
  106632. static CreateTiledGround(options: {
  106633. xmin: number;
  106634. zmin: number;
  106635. xmax: number;
  106636. zmax: number;
  106637. subdivisions?: {
  106638. w: number;
  106639. h: number;
  106640. };
  106641. precision?: {
  106642. w: number;
  106643. h: number;
  106644. };
  106645. }): VertexData;
  106646. /**
  106647. * Creates the VertexData of the Ground designed from a heightmap
  106648. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106649. * * width the width (x direction) of the ground
  106650. * * height the height (z direction) of the ground
  106651. * * subdivisions the number of subdivisions per side
  106652. * * minHeight the minimum altitude on the ground, optional, default 0
  106653. * * maxHeight the maximum altitude on the ground, optional default 1
  106654. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106655. * * buffer the array holding the image color data
  106656. * * bufferWidth the width of image
  106657. * * bufferHeight the height of image
  106658. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106659. * @returns the VertexData of the Ground designed from a heightmap
  106660. */
  106661. static CreateGroundFromHeightMap(options: {
  106662. width: number;
  106663. height: number;
  106664. subdivisions: number;
  106665. minHeight: number;
  106666. maxHeight: number;
  106667. colorFilter: Color3;
  106668. buffer: Uint8Array;
  106669. bufferWidth: number;
  106670. bufferHeight: number;
  106671. alphaFilter: number;
  106672. }): VertexData;
  106673. /**
  106674. * Creates the VertexData for a Plane
  106675. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106676. * * size sets the width and height of the plane to the value of size, optional default 1
  106677. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106678. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106680. * * 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)
  106681. * * 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)
  106682. * @returns the VertexData of the box
  106683. */
  106684. static CreatePlane(options: {
  106685. size?: number;
  106686. width?: number;
  106687. height?: number;
  106688. sideOrientation?: number;
  106689. frontUVs?: Vector4;
  106690. backUVs?: Vector4;
  106691. }): VertexData;
  106692. /**
  106693. * Creates the VertexData of the Disc or regular Polygon
  106694. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  106695. * * radius the radius of the disc, optional default 0.5
  106696. * * tessellation the number of polygon sides, optional, default 64
  106697. * * 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
  106698. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106699. * * 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)
  106700. * * 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)
  106701. * @returns the VertexData of the box
  106702. */
  106703. static CreateDisc(options: {
  106704. radius?: number;
  106705. tessellation?: number;
  106706. arc?: number;
  106707. sideOrientation?: number;
  106708. frontUVs?: Vector4;
  106709. backUVs?: Vector4;
  106710. }): VertexData;
  106711. /**
  106712. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  106713. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  106714. * @param polygon a mesh built from polygonTriangulation.build()
  106715. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106716. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106717. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106718. * @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)
  106719. * @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)
  106720. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  106721. * @returns the VertexData of the Polygon
  106722. */
  106723. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  106724. /**
  106725. * Creates the VertexData of the IcoSphere
  106726. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  106727. * * radius the radius of the IcoSphere, optional default 1
  106728. * * radiusX allows stretching in the x direction, optional, default radius
  106729. * * radiusY allows stretching in the y direction, optional, default radius
  106730. * * radiusZ allows stretching in the z direction, optional, default radius
  106731. * * flat when true creates a flat shaded mesh, optional, default true
  106732. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106733. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106734. * * 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)
  106735. * * 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)
  106736. * @returns the VertexData of the IcoSphere
  106737. */
  106738. static CreateIcoSphere(options: {
  106739. radius?: number;
  106740. radiusX?: number;
  106741. radiusY?: number;
  106742. radiusZ?: number;
  106743. flat?: boolean;
  106744. subdivisions?: number;
  106745. sideOrientation?: number;
  106746. frontUVs?: Vector4;
  106747. backUVs?: Vector4;
  106748. }): VertexData;
  106749. /**
  106750. * Creates the VertexData for a Polyhedron
  106751. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  106752. * * type provided types are:
  106753. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  106754. * * 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)
  106755. * * size the size of the IcoSphere, optional default 1
  106756. * * sizeX allows stretching in the x direction, optional, default size
  106757. * * sizeY allows stretching in the y direction, optional, default size
  106758. * * sizeZ allows stretching in the z direction, optional, default size
  106759. * * 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
  106760. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106761. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106762. * * flat when true creates a flat shaded mesh, optional, default true
  106763. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  106764. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106765. * * 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)
  106766. * * 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)
  106767. * @returns the VertexData of the Polyhedron
  106768. */
  106769. static CreatePolyhedron(options: {
  106770. type?: number;
  106771. size?: number;
  106772. sizeX?: number;
  106773. sizeY?: number;
  106774. sizeZ?: number;
  106775. custom?: any;
  106776. faceUV?: Vector4[];
  106777. faceColors?: Color4[];
  106778. flat?: boolean;
  106779. sideOrientation?: number;
  106780. frontUVs?: Vector4;
  106781. backUVs?: Vector4;
  106782. }): VertexData;
  106783. /**
  106784. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  106785. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  106786. * @returns the VertexData of the Capsule
  106787. */
  106788. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  106789. /**
  106790. * Creates the VertexData for a TorusKnot
  106791. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  106792. * * radius the radius of the torus knot, optional, default 2
  106793. * * tube the thickness of the tube, optional, default 0.5
  106794. * * radialSegments the number of sides on each tube segments, optional, default 32
  106795. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  106796. * * p the number of windings around the z axis, optional, default 2
  106797. * * q the number of windings around the x axis, optional, default 3
  106798. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106799. * * 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)
  106800. * * 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)
  106801. * @returns the VertexData of the Torus Knot
  106802. */
  106803. static CreateTorusKnot(options: {
  106804. radius?: number;
  106805. tube?: number;
  106806. radialSegments?: number;
  106807. tubularSegments?: number;
  106808. p?: number;
  106809. q?: number;
  106810. sideOrientation?: number;
  106811. frontUVs?: Vector4;
  106812. backUVs?: Vector4;
  106813. }): VertexData;
  106814. /**
  106815. * Compute normals for given positions and indices
  106816. * @param positions an array of vertex positions, [...., x, y, z, ......]
  106817. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  106818. * @param normals an array of vertex normals, [...., x, y, z, ......]
  106819. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  106820. * * facetNormals : optional array of facet normals (vector3)
  106821. * * facetPositions : optional array of facet positions (vector3)
  106822. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  106823. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  106824. * * bInfo : optional bounding info, required for facetPartitioning computation
  106825. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  106826. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  106827. * * useRightHandedSystem: optional boolean to for right handed system computation
  106828. * * depthSort : optional boolean to enable the facet depth sort computation
  106829. * * distanceTo : optional Vector3 to compute the facet depth from this location
  106830. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  106831. */
  106832. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  106833. facetNormals?: any;
  106834. facetPositions?: any;
  106835. facetPartitioning?: any;
  106836. ratio?: number;
  106837. bInfo?: any;
  106838. bbSize?: Vector3;
  106839. subDiv?: any;
  106840. useRightHandedSystem?: boolean;
  106841. depthSort?: boolean;
  106842. distanceTo?: Vector3;
  106843. depthSortedFacets?: any;
  106844. }): void;
  106845. /** @hidden */
  106846. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  106847. /**
  106848. * Applies VertexData created from the imported parameters to the geometry
  106849. * @param parsedVertexData the parsed data from an imported file
  106850. * @param geometry the geometry to apply the VertexData to
  106851. */
  106852. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  106853. }
  106854. }
  106855. declare module BABYLON {
  106856. /**
  106857. * Defines a target to use with MorphTargetManager
  106858. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106859. */
  106860. export class MorphTarget implements IAnimatable {
  106861. /** defines the name of the target */
  106862. name: string;
  106863. /**
  106864. * Gets or sets the list of animations
  106865. */
  106866. animations: Animation[];
  106867. private _scene;
  106868. private _positions;
  106869. private _normals;
  106870. private _tangents;
  106871. private _uvs;
  106872. private _influence;
  106873. private _uniqueId;
  106874. /**
  106875. * Observable raised when the influence changes
  106876. */
  106877. onInfluenceChanged: Observable<boolean>;
  106878. /** @hidden */
  106879. _onDataLayoutChanged: Observable<void>;
  106880. /**
  106881. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  106882. */
  106883. get influence(): number;
  106884. set influence(influence: number);
  106885. /**
  106886. * Gets or sets the id of the morph Target
  106887. */
  106888. id: string;
  106889. private _animationPropertiesOverride;
  106890. /**
  106891. * Gets or sets the animation properties override
  106892. */
  106893. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  106894. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  106895. /**
  106896. * Creates a new MorphTarget
  106897. * @param name defines the name of the target
  106898. * @param influence defines the influence to use
  106899. * @param scene defines the scene the morphtarget belongs to
  106900. */
  106901. constructor(
  106902. /** defines the name of the target */
  106903. name: string, influence?: number, scene?: Nullable<Scene>);
  106904. /**
  106905. * Gets the unique ID of this manager
  106906. */
  106907. get uniqueId(): number;
  106908. /**
  106909. * Gets a boolean defining if the target contains position data
  106910. */
  106911. get hasPositions(): boolean;
  106912. /**
  106913. * Gets a boolean defining if the target contains normal data
  106914. */
  106915. get hasNormals(): boolean;
  106916. /**
  106917. * Gets a boolean defining if the target contains tangent data
  106918. */
  106919. get hasTangents(): boolean;
  106920. /**
  106921. * Gets a boolean defining if the target contains texture coordinates data
  106922. */
  106923. get hasUVs(): boolean;
  106924. /**
  106925. * Affects position data to this target
  106926. * @param data defines the position data to use
  106927. */
  106928. setPositions(data: Nullable<FloatArray>): void;
  106929. /**
  106930. * Gets the position data stored in this target
  106931. * @returns a FloatArray containing the position data (or null if not present)
  106932. */
  106933. getPositions(): Nullable<FloatArray>;
  106934. /**
  106935. * Affects normal data to this target
  106936. * @param data defines the normal data to use
  106937. */
  106938. setNormals(data: Nullable<FloatArray>): void;
  106939. /**
  106940. * Gets the normal data stored in this target
  106941. * @returns a FloatArray containing the normal data (or null if not present)
  106942. */
  106943. getNormals(): Nullable<FloatArray>;
  106944. /**
  106945. * Affects tangent data to this target
  106946. * @param data defines the tangent data to use
  106947. */
  106948. setTangents(data: Nullable<FloatArray>): void;
  106949. /**
  106950. * Gets the tangent data stored in this target
  106951. * @returns a FloatArray containing the tangent data (or null if not present)
  106952. */
  106953. getTangents(): Nullable<FloatArray>;
  106954. /**
  106955. * Affects texture coordinates data to this target
  106956. * @param data defines the texture coordinates data to use
  106957. */
  106958. setUVs(data: Nullable<FloatArray>): void;
  106959. /**
  106960. * Gets the texture coordinates data stored in this target
  106961. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  106962. */
  106963. getUVs(): Nullable<FloatArray>;
  106964. /**
  106965. * Clone the current target
  106966. * @returns a new MorphTarget
  106967. */
  106968. clone(): MorphTarget;
  106969. /**
  106970. * Serializes the current target into a Serialization object
  106971. * @returns the serialized object
  106972. */
  106973. serialize(): any;
  106974. /**
  106975. * Returns the string "MorphTarget"
  106976. * @returns "MorphTarget"
  106977. */
  106978. getClassName(): string;
  106979. /**
  106980. * Creates a new target from serialized data
  106981. * @param serializationObject defines the serialized data to use
  106982. * @returns a new MorphTarget
  106983. */
  106984. static Parse(serializationObject: any): MorphTarget;
  106985. /**
  106986. * Creates a MorphTarget from mesh data
  106987. * @param mesh defines the source mesh
  106988. * @param name defines the name to use for the new target
  106989. * @param influence defines the influence to attach to the target
  106990. * @returns a new MorphTarget
  106991. */
  106992. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  106993. }
  106994. }
  106995. declare module BABYLON {
  106996. /**
  106997. * This class is used to deform meshes using morphing between different targets
  106998. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  106999. */
  107000. export class MorphTargetManager {
  107001. private _targets;
  107002. private _targetInfluenceChangedObservers;
  107003. private _targetDataLayoutChangedObservers;
  107004. private _activeTargets;
  107005. private _scene;
  107006. private _influences;
  107007. private _supportsNormals;
  107008. private _supportsTangents;
  107009. private _supportsUVs;
  107010. private _vertexCount;
  107011. private _uniqueId;
  107012. private _tempInfluences;
  107013. /**
  107014. * Gets or sets a boolean indicating if normals must be morphed
  107015. */
  107016. enableNormalMorphing: boolean;
  107017. /**
  107018. * Gets or sets a boolean indicating if tangents must be morphed
  107019. */
  107020. enableTangentMorphing: boolean;
  107021. /**
  107022. * Gets or sets a boolean indicating if UV must be morphed
  107023. */
  107024. enableUVMorphing: boolean;
  107025. /**
  107026. * Creates a new MorphTargetManager
  107027. * @param scene defines the current scene
  107028. */
  107029. constructor(scene?: Nullable<Scene>);
  107030. /**
  107031. * Gets the unique ID of this manager
  107032. */
  107033. get uniqueId(): number;
  107034. /**
  107035. * Gets the number of vertices handled by this manager
  107036. */
  107037. get vertexCount(): number;
  107038. /**
  107039. * Gets a boolean indicating if this manager supports morphing of normals
  107040. */
  107041. get supportsNormals(): boolean;
  107042. /**
  107043. * Gets a boolean indicating if this manager supports morphing of tangents
  107044. */
  107045. get supportsTangents(): boolean;
  107046. /**
  107047. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107048. */
  107049. get supportsUVs(): boolean;
  107050. /**
  107051. * Gets the number of targets stored in this manager
  107052. */
  107053. get numTargets(): number;
  107054. /**
  107055. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107056. */
  107057. get numInfluencers(): number;
  107058. /**
  107059. * Gets the list of influences (one per target)
  107060. */
  107061. get influences(): Float32Array;
  107062. /**
  107063. * Gets the active target at specified index. An active target is a target with an influence > 0
  107064. * @param index defines the index to check
  107065. * @returns the requested target
  107066. */
  107067. getActiveTarget(index: number): MorphTarget;
  107068. /**
  107069. * Gets the target at specified index
  107070. * @param index defines the index to check
  107071. * @returns the requested target
  107072. */
  107073. getTarget(index: number): MorphTarget;
  107074. /**
  107075. * Add a new target to this manager
  107076. * @param target defines the target to add
  107077. */
  107078. addTarget(target: MorphTarget): void;
  107079. /**
  107080. * Removes a target from the manager
  107081. * @param target defines the target to remove
  107082. */
  107083. removeTarget(target: MorphTarget): void;
  107084. /**
  107085. * Clone the current manager
  107086. * @returns a new MorphTargetManager
  107087. */
  107088. clone(): MorphTargetManager;
  107089. /**
  107090. * Serializes the current manager into a Serialization object
  107091. * @returns the serialized object
  107092. */
  107093. serialize(): any;
  107094. private _syncActiveTargets;
  107095. /**
  107096. * Syncrhonize the targets with all the meshes using this morph target manager
  107097. */
  107098. synchronize(): void;
  107099. /**
  107100. * Creates a new MorphTargetManager from serialized data
  107101. * @param serializationObject defines the serialized data
  107102. * @param scene defines the hosting scene
  107103. * @returns the new MorphTargetManager
  107104. */
  107105. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /**
  107110. * Class used to represent a specific level of detail of a mesh
  107111. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107112. */
  107113. export class MeshLODLevel {
  107114. /** Defines the distance where this level should start being displayed */
  107115. distance: number;
  107116. /** Defines the mesh to use to render this level */
  107117. mesh: Nullable<Mesh>;
  107118. /**
  107119. * Creates a new LOD level
  107120. * @param distance defines the distance where this level should star being displayed
  107121. * @param mesh defines the mesh to use to render this level
  107122. */
  107123. constructor(
  107124. /** Defines the distance where this level should start being displayed */
  107125. distance: number,
  107126. /** Defines the mesh to use to render this level */
  107127. mesh: Nullable<Mesh>);
  107128. }
  107129. }
  107130. declare module BABYLON {
  107131. /**
  107132. * Helper class used to generate a canvas to manipulate images
  107133. */
  107134. export class CanvasGenerator {
  107135. /**
  107136. * Create a new canvas (or offscreen canvas depending on the context)
  107137. * @param width defines the expected width
  107138. * @param height defines the expected height
  107139. * @return a new canvas or offscreen canvas
  107140. */
  107141. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107142. }
  107143. }
  107144. declare module BABYLON {
  107145. /**
  107146. * Mesh representing the gorund
  107147. */
  107148. export class GroundMesh extends Mesh {
  107149. /** If octree should be generated */
  107150. generateOctree: boolean;
  107151. private _heightQuads;
  107152. /** @hidden */
  107153. _subdivisionsX: number;
  107154. /** @hidden */
  107155. _subdivisionsY: number;
  107156. /** @hidden */
  107157. _width: number;
  107158. /** @hidden */
  107159. _height: number;
  107160. /** @hidden */
  107161. _minX: number;
  107162. /** @hidden */
  107163. _maxX: number;
  107164. /** @hidden */
  107165. _minZ: number;
  107166. /** @hidden */
  107167. _maxZ: number;
  107168. constructor(name: string, scene: Scene);
  107169. /**
  107170. * "GroundMesh"
  107171. * @returns "GroundMesh"
  107172. */
  107173. getClassName(): string;
  107174. /**
  107175. * The minimum of x and y subdivisions
  107176. */
  107177. get subdivisions(): number;
  107178. /**
  107179. * X subdivisions
  107180. */
  107181. get subdivisionsX(): number;
  107182. /**
  107183. * Y subdivisions
  107184. */
  107185. get subdivisionsY(): number;
  107186. /**
  107187. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107188. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107189. * @param chunksCount the number of subdivisions for x and y
  107190. * @param octreeBlocksSize (Default: 32)
  107191. */
  107192. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107193. /**
  107194. * Returns a height (y) value in the Worl system :
  107195. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107196. * @param x x coordinate
  107197. * @param z z coordinate
  107198. * @returns the ground y position if (x, z) are outside the ground surface.
  107199. */
  107200. getHeightAtCoordinates(x: number, z: number): number;
  107201. /**
  107202. * Returns a normalized vector (Vector3) orthogonal to the ground
  107203. * at the ground coordinates (x, z) expressed in the World system.
  107204. * @param x x coordinate
  107205. * @param z z coordinate
  107206. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107207. */
  107208. getNormalAtCoordinates(x: number, z: number): Vector3;
  107209. /**
  107210. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107211. * at the ground coordinates (x, z) expressed in the World system.
  107212. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107213. * @param x x coordinate
  107214. * @param z z coordinate
  107215. * @param ref vector to store the result
  107216. * @returns the GroundMesh.
  107217. */
  107218. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107219. /**
  107220. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107221. * if the ground has been updated.
  107222. * This can be used in the render loop.
  107223. * @returns the GroundMesh.
  107224. */
  107225. updateCoordinateHeights(): GroundMesh;
  107226. private _getFacetAt;
  107227. private _initHeightQuads;
  107228. private _computeHeightQuads;
  107229. /**
  107230. * Serializes this ground mesh
  107231. * @param serializationObject object to write serialization to
  107232. */
  107233. serialize(serializationObject: any): void;
  107234. /**
  107235. * Parses a serialized ground mesh
  107236. * @param parsedMesh the serialized mesh
  107237. * @param scene the scene to create the ground mesh in
  107238. * @returns the created ground mesh
  107239. */
  107240. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107241. }
  107242. }
  107243. declare module BABYLON {
  107244. /**
  107245. * Interface for Physics-Joint data
  107246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107247. */
  107248. export interface PhysicsJointData {
  107249. /**
  107250. * The main pivot of the joint
  107251. */
  107252. mainPivot?: Vector3;
  107253. /**
  107254. * The connected pivot of the joint
  107255. */
  107256. connectedPivot?: Vector3;
  107257. /**
  107258. * The main axis of the joint
  107259. */
  107260. mainAxis?: Vector3;
  107261. /**
  107262. * The connected axis of the joint
  107263. */
  107264. connectedAxis?: Vector3;
  107265. /**
  107266. * The collision of the joint
  107267. */
  107268. collision?: boolean;
  107269. /**
  107270. * Native Oimo/Cannon/Energy data
  107271. */
  107272. nativeParams?: any;
  107273. }
  107274. /**
  107275. * This is a holder class for the physics joint created by the physics plugin
  107276. * It holds a set of functions to control the underlying joint
  107277. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107278. */
  107279. export class PhysicsJoint {
  107280. /**
  107281. * The type of the physics joint
  107282. */
  107283. type: number;
  107284. /**
  107285. * The data for the physics joint
  107286. */
  107287. jointData: PhysicsJointData;
  107288. private _physicsJoint;
  107289. protected _physicsPlugin: IPhysicsEnginePlugin;
  107290. /**
  107291. * Initializes the physics joint
  107292. * @param type The type of the physics joint
  107293. * @param jointData The data for the physics joint
  107294. */
  107295. constructor(
  107296. /**
  107297. * The type of the physics joint
  107298. */
  107299. type: number,
  107300. /**
  107301. * The data for the physics joint
  107302. */
  107303. jointData: PhysicsJointData);
  107304. /**
  107305. * Gets the physics joint
  107306. */
  107307. get physicsJoint(): any;
  107308. /**
  107309. * Sets the physics joint
  107310. */
  107311. set physicsJoint(newJoint: any);
  107312. /**
  107313. * Sets the physics plugin
  107314. */
  107315. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107316. /**
  107317. * Execute a function that is physics-plugin specific.
  107318. * @param {Function} func the function that will be executed.
  107319. * It accepts two parameters: the physics world and the physics joint
  107320. */
  107321. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107322. /**
  107323. * Distance-Joint type
  107324. */
  107325. static DistanceJoint: number;
  107326. /**
  107327. * Hinge-Joint type
  107328. */
  107329. static HingeJoint: number;
  107330. /**
  107331. * Ball-and-Socket joint type
  107332. */
  107333. static BallAndSocketJoint: number;
  107334. /**
  107335. * Wheel-Joint type
  107336. */
  107337. static WheelJoint: number;
  107338. /**
  107339. * Slider-Joint type
  107340. */
  107341. static SliderJoint: number;
  107342. /**
  107343. * Prismatic-Joint type
  107344. */
  107345. static PrismaticJoint: number;
  107346. /**
  107347. * Universal-Joint type
  107348. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107349. */
  107350. static UniversalJoint: number;
  107351. /**
  107352. * Hinge-Joint 2 type
  107353. */
  107354. static Hinge2Joint: number;
  107355. /**
  107356. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107357. */
  107358. static PointToPointJoint: number;
  107359. /**
  107360. * Spring-Joint type
  107361. */
  107362. static SpringJoint: number;
  107363. /**
  107364. * Lock-Joint type
  107365. */
  107366. static LockJoint: number;
  107367. }
  107368. /**
  107369. * A class representing a physics distance joint
  107370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107371. */
  107372. export class DistanceJoint extends PhysicsJoint {
  107373. /**
  107374. *
  107375. * @param jointData The data for the Distance-Joint
  107376. */
  107377. constructor(jointData: DistanceJointData);
  107378. /**
  107379. * Update the predefined distance.
  107380. * @param maxDistance The maximum preferred distance
  107381. * @param minDistance The minimum preferred distance
  107382. */
  107383. updateDistance(maxDistance: number, minDistance?: number): void;
  107384. }
  107385. /**
  107386. * Represents a Motor-Enabled Joint
  107387. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107388. */
  107389. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107390. /**
  107391. * Initializes the Motor-Enabled Joint
  107392. * @param type The type of the joint
  107393. * @param jointData The physica joint data for the joint
  107394. */
  107395. constructor(type: number, jointData: PhysicsJointData);
  107396. /**
  107397. * Set the motor values.
  107398. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107399. * @param force the force to apply
  107400. * @param maxForce max force for this motor.
  107401. */
  107402. setMotor(force?: number, maxForce?: number): void;
  107403. /**
  107404. * Set the motor's limits.
  107405. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107406. * @param upperLimit The upper limit of the motor
  107407. * @param lowerLimit The lower limit of the motor
  107408. */
  107409. setLimit(upperLimit: number, lowerLimit?: number): void;
  107410. }
  107411. /**
  107412. * This class represents a single physics Hinge-Joint
  107413. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107414. */
  107415. export class HingeJoint extends MotorEnabledJoint {
  107416. /**
  107417. * Initializes the Hinge-Joint
  107418. * @param jointData The joint data for the Hinge-Joint
  107419. */
  107420. constructor(jointData: PhysicsJointData);
  107421. /**
  107422. * Set the motor values.
  107423. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107424. * @param {number} force the force to apply
  107425. * @param {number} maxForce max force for this motor.
  107426. */
  107427. setMotor(force?: number, maxForce?: number): void;
  107428. /**
  107429. * Set the motor's limits.
  107430. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107431. * @param upperLimit The upper limit of the motor
  107432. * @param lowerLimit The lower limit of the motor
  107433. */
  107434. setLimit(upperLimit: number, lowerLimit?: number): void;
  107435. }
  107436. /**
  107437. * This class represents a dual hinge physics joint (same as wheel joint)
  107438. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107439. */
  107440. export class Hinge2Joint extends MotorEnabledJoint {
  107441. /**
  107442. * Initializes the Hinge2-Joint
  107443. * @param jointData The joint data for the Hinge2-Joint
  107444. */
  107445. constructor(jointData: PhysicsJointData);
  107446. /**
  107447. * Set the motor values.
  107448. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107449. * @param {number} targetSpeed the speed the motor is to reach
  107450. * @param {number} maxForce max force for this motor.
  107451. * @param {motorIndex} the motor's index, 0 or 1.
  107452. */
  107453. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107454. /**
  107455. * Set the motor limits.
  107456. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107457. * @param {number} upperLimit the upper limit
  107458. * @param {number} lowerLimit lower limit
  107459. * @param {motorIndex} the motor's index, 0 or 1.
  107460. */
  107461. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107462. }
  107463. /**
  107464. * Interface for a motor enabled joint
  107465. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107466. */
  107467. export interface IMotorEnabledJoint {
  107468. /**
  107469. * Physics joint
  107470. */
  107471. physicsJoint: any;
  107472. /**
  107473. * Sets the motor of the motor-enabled joint
  107474. * @param force The force of the motor
  107475. * @param maxForce The maximum force of the motor
  107476. * @param motorIndex The index of the motor
  107477. */
  107478. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107479. /**
  107480. * Sets the limit of the motor
  107481. * @param upperLimit The upper limit of the motor
  107482. * @param lowerLimit The lower limit of the motor
  107483. * @param motorIndex The index of the motor
  107484. */
  107485. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107486. }
  107487. /**
  107488. * Joint data for a Distance-Joint
  107489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107490. */
  107491. export interface DistanceJointData extends PhysicsJointData {
  107492. /**
  107493. * Max distance the 2 joint objects can be apart
  107494. */
  107495. maxDistance: number;
  107496. }
  107497. /**
  107498. * Joint data from a spring joint
  107499. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107500. */
  107501. export interface SpringJointData extends PhysicsJointData {
  107502. /**
  107503. * Length of the spring
  107504. */
  107505. length: number;
  107506. /**
  107507. * Stiffness of the spring
  107508. */
  107509. stiffness: number;
  107510. /**
  107511. * Damping of the spring
  107512. */
  107513. damping: number;
  107514. /** this callback will be called when applying the force to the impostors. */
  107515. forceApplicationCallback: () => void;
  107516. }
  107517. }
  107518. declare module BABYLON {
  107519. /**
  107520. * Holds the data for the raycast result
  107521. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107522. */
  107523. export class PhysicsRaycastResult {
  107524. private _hasHit;
  107525. private _hitDistance;
  107526. private _hitNormalWorld;
  107527. private _hitPointWorld;
  107528. private _rayFromWorld;
  107529. private _rayToWorld;
  107530. /**
  107531. * Gets if there was a hit
  107532. */
  107533. get hasHit(): boolean;
  107534. /**
  107535. * Gets the distance from the hit
  107536. */
  107537. get hitDistance(): number;
  107538. /**
  107539. * Gets the hit normal/direction in the world
  107540. */
  107541. get hitNormalWorld(): Vector3;
  107542. /**
  107543. * Gets the hit point in the world
  107544. */
  107545. get hitPointWorld(): Vector3;
  107546. /**
  107547. * Gets the ray "start point" of the ray in the world
  107548. */
  107549. get rayFromWorld(): Vector3;
  107550. /**
  107551. * Gets the ray "end point" of the ray in the world
  107552. */
  107553. get rayToWorld(): Vector3;
  107554. /**
  107555. * Sets the hit data (normal & point in world space)
  107556. * @param hitNormalWorld defines the normal in world space
  107557. * @param hitPointWorld defines the point in world space
  107558. */
  107559. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107560. /**
  107561. * Sets the distance from the start point to the hit point
  107562. * @param distance
  107563. */
  107564. setHitDistance(distance: number): void;
  107565. /**
  107566. * Calculates the distance manually
  107567. */
  107568. calculateHitDistance(): void;
  107569. /**
  107570. * Resets all the values to default
  107571. * @param from The from point on world space
  107572. * @param to The to point on world space
  107573. */
  107574. reset(from?: Vector3, to?: Vector3): void;
  107575. }
  107576. /**
  107577. * Interface for the size containing width and height
  107578. */
  107579. interface IXYZ {
  107580. /**
  107581. * X
  107582. */
  107583. x: number;
  107584. /**
  107585. * Y
  107586. */
  107587. y: number;
  107588. /**
  107589. * Z
  107590. */
  107591. z: number;
  107592. }
  107593. }
  107594. declare module BABYLON {
  107595. /**
  107596. * Interface used to describe a physics joint
  107597. */
  107598. export interface PhysicsImpostorJoint {
  107599. /** Defines the main impostor to which the joint is linked */
  107600. mainImpostor: PhysicsImpostor;
  107601. /** Defines the impostor that is connected to the main impostor using this joint */
  107602. connectedImpostor: PhysicsImpostor;
  107603. /** Defines the joint itself */
  107604. joint: PhysicsJoint;
  107605. }
  107606. /** @hidden */
  107607. export interface IPhysicsEnginePlugin {
  107608. world: any;
  107609. name: string;
  107610. setGravity(gravity: Vector3): void;
  107611. setTimeStep(timeStep: number): void;
  107612. getTimeStep(): number;
  107613. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107614. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107615. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107616. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107617. removePhysicsBody(impostor: PhysicsImpostor): void;
  107618. generateJoint(joint: PhysicsImpostorJoint): void;
  107619. removeJoint(joint: PhysicsImpostorJoint): void;
  107620. isSupported(): boolean;
  107621. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107622. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107623. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107624. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107625. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107626. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107627. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107628. getBodyMass(impostor: PhysicsImpostor): number;
  107629. getBodyFriction(impostor: PhysicsImpostor): number;
  107630. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107631. getBodyRestitution(impostor: PhysicsImpostor): number;
  107632. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107633. getBodyPressure?(impostor: PhysicsImpostor): number;
  107634. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107635. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107636. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107637. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107638. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107639. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107640. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107641. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107642. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107643. sleepBody(impostor: PhysicsImpostor): void;
  107644. wakeUpBody(impostor: PhysicsImpostor): void;
  107645. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107646. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107647. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107648. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107649. getRadius(impostor: PhysicsImpostor): number;
  107650. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107651. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107652. dispose(): void;
  107653. }
  107654. /**
  107655. * Interface used to define a physics engine
  107656. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107657. */
  107658. export interface IPhysicsEngine {
  107659. /**
  107660. * Gets the gravity vector used by the simulation
  107661. */
  107662. gravity: Vector3;
  107663. /**
  107664. * Sets the gravity vector used by the simulation
  107665. * @param gravity defines the gravity vector to use
  107666. */
  107667. setGravity(gravity: Vector3): void;
  107668. /**
  107669. * Set the time step of the physics engine.
  107670. * Default is 1/60.
  107671. * To slow it down, enter 1/600 for example.
  107672. * To speed it up, 1/30
  107673. * @param newTimeStep the new timestep to apply to this world.
  107674. */
  107675. setTimeStep(newTimeStep: number): void;
  107676. /**
  107677. * Get the time step of the physics engine.
  107678. * @returns the current time step
  107679. */
  107680. getTimeStep(): number;
  107681. /**
  107682. * Set the sub time step of the physics engine.
  107683. * Default is 0 meaning there is no sub steps
  107684. * To increase physics resolution precision, set a small value (like 1 ms)
  107685. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107686. */
  107687. setSubTimeStep(subTimeStep: number): void;
  107688. /**
  107689. * Get the sub time step of the physics engine.
  107690. * @returns the current sub time step
  107691. */
  107692. getSubTimeStep(): number;
  107693. /**
  107694. * Release all resources
  107695. */
  107696. dispose(): void;
  107697. /**
  107698. * Gets the name of the current physics plugin
  107699. * @returns the name of the plugin
  107700. */
  107701. getPhysicsPluginName(): string;
  107702. /**
  107703. * Adding a new impostor for the impostor tracking.
  107704. * This will be done by the impostor itself.
  107705. * @param impostor the impostor to add
  107706. */
  107707. addImpostor(impostor: PhysicsImpostor): void;
  107708. /**
  107709. * Remove an impostor from the engine.
  107710. * This impostor and its mesh will not longer be updated by the physics engine.
  107711. * @param impostor the impostor to remove
  107712. */
  107713. removeImpostor(impostor: PhysicsImpostor): void;
  107714. /**
  107715. * Add a joint to the physics engine
  107716. * @param mainImpostor defines the main impostor to which the joint is added.
  107717. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107718. * @param joint defines the joint that will connect both impostors.
  107719. */
  107720. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107721. /**
  107722. * Removes a joint from the simulation
  107723. * @param mainImpostor defines the impostor used with the joint
  107724. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107725. * @param joint defines the joint to remove
  107726. */
  107727. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107728. /**
  107729. * Gets the current plugin used to run the simulation
  107730. * @returns current plugin
  107731. */
  107732. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107733. /**
  107734. * Gets the list of physic impostors
  107735. * @returns an array of PhysicsImpostor
  107736. */
  107737. getImpostors(): Array<PhysicsImpostor>;
  107738. /**
  107739. * Gets the impostor for a physics enabled object
  107740. * @param object defines the object impersonated by the impostor
  107741. * @returns the PhysicsImpostor or null if not found
  107742. */
  107743. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107744. /**
  107745. * Gets the impostor for a physics body object
  107746. * @param body defines physics body used by the impostor
  107747. * @returns the PhysicsImpostor or null if not found
  107748. */
  107749. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107750. /**
  107751. * Does a raycast in the physics world
  107752. * @param from when should the ray start?
  107753. * @param to when should the ray end?
  107754. * @returns PhysicsRaycastResult
  107755. */
  107756. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107757. /**
  107758. * Called by the scene. No need to call it.
  107759. * @param delta defines the timespam between frames
  107760. */
  107761. _step(delta: number): void;
  107762. }
  107763. }
  107764. declare module BABYLON {
  107765. /**
  107766. * The interface for the physics imposter parameters
  107767. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107768. */
  107769. export interface PhysicsImpostorParameters {
  107770. /**
  107771. * The mass of the physics imposter
  107772. */
  107773. mass: number;
  107774. /**
  107775. * The friction of the physics imposter
  107776. */
  107777. friction?: number;
  107778. /**
  107779. * The coefficient of restitution of the physics imposter
  107780. */
  107781. restitution?: number;
  107782. /**
  107783. * The native options of the physics imposter
  107784. */
  107785. nativeOptions?: any;
  107786. /**
  107787. * Specifies if the parent should be ignored
  107788. */
  107789. ignoreParent?: boolean;
  107790. /**
  107791. * Specifies if bi-directional transformations should be disabled
  107792. */
  107793. disableBidirectionalTransformation?: boolean;
  107794. /**
  107795. * The pressure inside the physics imposter, soft object only
  107796. */
  107797. pressure?: number;
  107798. /**
  107799. * The stiffness the physics imposter, soft object only
  107800. */
  107801. stiffness?: number;
  107802. /**
  107803. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  107804. */
  107805. velocityIterations?: number;
  107806. /**
  107807. * The number of iterations used in maintaining consistent vertex positions, soft object only
  107808. */
  107809. positionIterations?: number;
  107810. /**
  107811. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  107812. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  107813. * Add to fix multiple points
  107814. */
  107815. fixedPoints?: number;
  107816. /**
  107817. * The collision margin around a soft object
  107818. */
  107819. margin?: number;
  107820. /**
  107821. * The collision margin around a soft object
  107822. */
  107823. damping?: number;
  107824. /**
  107825. * The path for a rope based on an extrusion
  107826. */
  107827. path?: any;
  107828. /**
  107829. * The shape of an extrusion used for a rope based on an extrusion
  107830. */
  107831. shape?: any;
  107832. }
  107833. /**
  107834. * Interface for a physics-enabled object
  107835. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107836. */
  107837. export interface IPhysicsEnabledObject {
  107838. /**
  107839. * The position of the physics-enabled object
  107840. */
  107841. position: Vector3;
  107842. /**
  107843. * The rotation of the physics-enabled object
  107844. */
  107845. rotationQuaternion: Nullable<Quaternion>;
  107846. /**
  107847. * The scale of the physics-enabled object
  107848. */
  107849. scaling: Vector3;
  107850. /**
  107851. * The rotation of the physics-enabled object
  107852. */
  107853. rotation?: Vector3;
  107854. /**
  107855. * The parent of the physics-enabled object
  107856. */
  107857. parent?: any;
  107858. /**
  107859. * The bounding info of the physics-enabled object
  107860. * @returns The bounding info of the physics-enabled object
  107861. */
  107862. getBoundingInfo(): BoundingInfo;
  107863. /**
  107864. * Computes the world matrix
  107865. * @param force Specifies if the world matrix should be computed by force
  107866. * @returns A world matrix
  107867. */
  107868. computeWorldMatrix(force: boolean): Matrix;
  107869. /**
  107870. * Gets the world matrix
  107871. * @returns A world matrix
  107872. */
  107873. getWorldMatrix?(): Matrix;
  107874. /**
  107875. * Gets the child meshes
  107876. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  107877. * @returns An array of abstract meshes
  107878. */
  107879. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  107880. /**
  107881. * Gets the vertex data
  107882. * @param kind The type of vertex data
  107883. * @returns A nullable array of numbers, or a float32 array
  107884. */
  107885. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  107886. /**
  107887. * Gets the indices from the mesh
  107888. * @returns A nullable array of index arrays
  107889. */
  107890. getIndices?(): Nullable<IndicesArray>;
  107891. /**
  107892. * Gets the scene from the mesh
  107893. * @returns the indices array or null
  107894. */
  107895. getScene?(): Scene;
  107896. /**
  107897. * Gets the absolute position from the mesh
  107898. * @returns the absolute position
  107899. */
  107900. getAbsolutePosition(): Vector3;
  107901. /**
  107902. * Gets the absolute pivot point from the mesh
  107903. * @returns the absolute pivot point
  107904. */
  107905. getAbsolutePivotPoint(): Vector3;
  107906. /**
  107907. * Rotates the mesh
  107908. * @param axis The axis of rotation
  107909. * @param amount The amount of rotation
  107910. * @param space The space of the rotation
  107911. * @returns The rotation transform node
  107912. */
  107913. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  107914. /**
  107915. * Translates the mesh
  107916. * @param axis The axis of translation
  107917. * @param distance The distance of translation
  107918. * @param space The space of the translation
  107919. * @returns The transform node
  107920. */
  107921. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  107922. /**
  107923. * Sets the absolute position of the mesh
  107924. * @param absolutePosition The absolute position of the mesh
  107925. * @returns The transform node
  107926. */
  107927. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  107928. /**
  107929. * Gets the class name of the mesh
  107930. * @returns The class name
  107931. */
  107932. getClassName(): string;
  107933. }
  107934. /**
  107935. * Represents a physics imposter
  107936. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107937. */
  107938. export class PhysicsImpostor {
  107939. /**
  107940. * The physics-enabled object used as the physics imposter
  107941. */
  107942. object: IPhysicsEnabledObject;
  107943. /**
  107944. * The type of the physics imposter
  107945. */
  107946. type: number;
  107947. private _options;
  107948. private _scene?;
  107949. /**
  107950. * The default object size of the imposter
  107951. */
  107952. static DEFAULT_OBJECT_SIZE: Vector3;
  107953. /**
  107954. * The identity quaternion of the imposter
  107955. */
  107956. static IDENTITY_QUATERNION: Quaternion;
  107957. /** @hidden */
  107958. _pluginData: any;
  107959. private _physicsEngine;
  107960. private _physicsBody;
  107961. private _bodyUpdateRequired;
  107962. private _onBeforePhysicsStepCallbacks;
  107963. private _onAfterPhysicsStepCallbacks;
  107964. /** @hidden */
  107965. _onPhysicsCollideCallbacks: Array<{
  107966. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  107967. otherImpostors: Array<PhysicsImpostor>;
  107968. }>;
  107969. private _deltaPosition;
  107970. private _deltaRotation;
  107971. private _deltaRotationConjugated;
  107972. /** @hidden */
  107973. _isFromLine: boolean;
  107974. private _parent;
  107975. private _isDisposed;
  107976. private static _tmpVecs;
  107977. private static _tmpQuat;
  107978. /**
  107979. * Specifies if the physics imposter is disposed
  107980. */
  107981. get isDisposed(): boolean;
  107982. /**
  107983. * Gets the mass of the physics imposter
  107984. */
  107985. get mass(): number;
  107986. set mass(value: number);
  107987. /**
  107988. * Gets the coefficient of friction
  107989. */
  107990. get friction(): number;
  107991. /**
  107992. * Sets the coefficient of friction
  107993. */
  107994. set friction(value: number);
  107995. /**
  107996. * Gets the coefficient of restitution
  107997. */
  107998. get restitution(): number;
  107999. /**
  108000. * Sets the coefficient of restitution
  108001. */
  108002. set restitution(value: number);
  108003. /**
  108004. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108005. */
  108006. get pressure(): number;
  108007. /**
  108008. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108009. */
  108010. set pressure(value: number);
  108011. /**
  108012. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108013. */
  108014. get stiffness(): number;
  108015. /**
  108016. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108017. */
  108018. set stiffness(value: number);
  108019. /**
  108020. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108021. */
  108022. get velocityIterations(): number;
  108023. /**
  108024. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108025. */
  108026. set velocityIterations(value: number);
  108027. /**
  108028. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108029. */
  108030. get positionIterations(): number;
  108031. /**
  108032. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108033. */
  108034. set positionIterations(value: number);
  108035. /**
  108036. * The unique id of the physics imposter
  108037. * set by the physics engine when adding this impostor to the array
  108038. */
  108039. uniqueId: number;
  108040. /**
  108041. * @hidden
  108042. */
  108043. soft: boolean;
  108044. /**
  108045. * @hidden
  108046. */
  108047. segments: number;
  108048. private _joints;
  108049. /**
  108050. * Initializes the physics imposter
  108051. * @param object The physics-enabled object used as the physics imposter
  108052. * @param type The type of the physics imposter
  108053. * @param _options The options for the physics imposter
  108054. * @param _scene The Babylon scene
  108055. */
  108056. constructor(
  108057. /**
  108058. * The physics-enabled object used as the physics imposter
  108059. */
  108060. object: IPhysicsEnabledObject,
  108061. /**
  108062. * The type of the physics imposter
  108063. */
  108064. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108065. /**
  108066. * This function will completly initialize this impostor.
  108067. * It will create a new body - but only if this mesh has no parent.
  108068. * If it has, this impostor will not be used other than to define the impostor
  108069. * of the child mesh.
  108070. * @hidden
  108071. */
  108072. _init(): void;
  108073. private _getPhysicsParent;
  108074. /**
  108075. * Should a new body be generated.
  108076. * @returns boolean specifying if body initialization is required
  108077. */
  108078. isBodyInitRequired(): boolean;
  108079. /**
  108080. * Sets the updated scaling
  108081. * @param updated Specifies if the scaling is updated
  108082. */
  108083. setScalingUpdated(): void;
  108084. /**
  108085. * Force a regeneration of this or the parent's impostor's body.
  108086. * Use under cautious - This will remove all joints already implemented.
  108087. */
  108088. forceUpdate(): void;
  108089. /**
  108090. * Gets the body that holds this impostor. Either its own, or its parent.
  108091. */
  108092. get physicsBody(): any;
  108093. /**
  108094. * Get the parent of the physics imposter
  108095. * @returns Physics imposter or null
  108096. */
  108097. get parent(): Nullable<PhysicsImpostor>;
  108098. /**
  108099. * Sets the parent of the physics imposter
  108100. */
  108101. set parent(value: Nullable<PhysicsImpostor>);
  108102. /**
  108103. * Set the physics body. Used mainly by the physics engine/plugin
  108104. */
  108105. set physicsBody(physicsBody: any);
  108106. /**
  108107. * Resets the update flags
  108108. */
  108109. resetUpdateFlags(): void;
  108110. /**
  108111. * Gets the object extend size
  108112. * @returns the object extend size
  108113. */
  108114. getObjectExtendSize(): Vector3;
  108115. /**
  108116. * Gets the object center
  108117. * @returns The object center
  108118. */
  108119. getObjectCenter(): Vector3;
  108120. /**
  108121. * Get a specific parameter from the options parameters
  108122. * @param paramName The object parameter name
  108123. * @returns The object parameter
  108124. */
  108125. getParam(paramName: string): any;
  108126. /**
  108127. * Sets a specific parameter in the options given to the physics plugin
  108128. * @param paramName The parameter name
  108129. * @param value The value of the parameter
  108130. */
  108131. setParam(paramName: string, value: number): void;
  108132. /**
  108133. * Specifically change the body's mass option. Won't recreate the physics body object
  108134. * @param mass The mass of the physics imposter
  108135. */
  108136. setMass(mass: number): void;
  108137. /**
  108138. * Gets the linear velocity
  108139. * @returns linear velocity or null
  108140. */
  108141. getLinearVelocity(): Nullable<Vector3>;
  108142. /**
  108143. * Sets the linear velocity
  108144. * @param velocity linear velocity or null
  108145. */
  108146. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108147. /**
  108148. * Gets the angular velocity
  108149. * @returns angular velocity or null
  108150. */
  108151. getAngularVelocity(): Nullable<Vector3>;
  108152. /**
  108153. * Sets the angular velocity
  108154. * @param velocity The velocity or null
  108155. */
  108156. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108157. /**
  108158. * Execute a function with the physics plugin native code
  108159. * Provide a function the will have two variables - the world object and the physics body object
  108160. * @param func The function to execute with the physics plugin native code
  108161. */
  108162. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108163. /**
  108164. * Register a function that will be executed before the physics world is stepping forward
  108165. * @param func The function to execute before the physics world is stepped forward
  108166. */
  108167. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108168. /**
  108169. * Unregister a function that will be executed before the physics world is stepping forward
  108170. * @param func The function to execute before the physics world is stepped forward
  108171. */
  108172. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108173. /**
  108174. * Register a function that will be executed after the physics step
  108175. * @param func The function to execute after physics step
  108176. */
  108177. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108178. /**
  108179. * Unregisters a function that will be executed after the physics step
  108180. * @param func The function to execute after physics step
  108181. */
  108182. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108183. /**
  108184. * register a function that will be executed when this impostor collides against a different body
  108185. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108186. * @param func Callback that is executed on collision
  108187. */
  108188. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108189. /**
  108190. * Unregisters the physics imposter on contact
  108191. * @param collideAgainst The physics object to collide against
  108192. * @param func Callback to execute on collision
  108193. */
  108194. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108195. private _tmpQuat;
  108196. private _tmpQuat2;
  108197. /**
  108198. * Get the parent rotation
  108199. * @returns The parent rotation
  108200. */
  108201. getParentsRotation(): Quaternion;
  108202. /**
  108203. * this function is executed by the physics engine.
  108204. */
  108205. beforeStep: () => void;
  108206. /**
  108207. * this function is executed by the physics engine
  108208. */
  108209. afterStep: () => void;
  108210. /**
  108211. * Legacy collision detection event support
  108212. */
  108213. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108214. /**
  108215. * event and body object due to cannon's event-based architecture.
  108216. */
  108217. onCollide: (e: {
  108218. body: any;
  108219. }) => void;
  108220. /**
  108221. * Apply a force
  108222. * @param force The force to apply
  108223. * @param contactPoint The contact point for the force
  108224. * @returns The physics imposter
  108225. */
  108226. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108227. /**
  108228. * Apply an impulse
  108229. * @param force The impulse force
  108230. * @param contactPoint The contact point for the impulse force
  108231. * @returns The physics imposter
  108232. */
  108233. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108234. /**
  108235. * A help function to create a joint
  108236. * @param otherImpostor A physics imposter used to create a joint
  108237. * @param jointType The type of joint
  108238. * @param jointData The data for the joint
  108239. * @returns The physics imposter
  108240. */
  108241. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108242. /**
  108243. * Add a joint to this impostor with a different impostor
  108244. * @param otherImpostor A physics imposter used to add a joint
  108245. * @param joint The joint to add
  108246. * @returns The physics imposter
  108247. */
  108248. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108249. /**
  108250. * Add an anchor to a cloth impostor
  108251. * @param otherImpostor rigid impostor to anchor to
  108252. * @param width ratio across width from 0 to 1
  108253. * @param height ratio up height from 0 to 1
  108254. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108255. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108256. * @returns impostor the soft imposter
  108257. */
  108258. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108259. /**
  108260. * Add a hook to a rope impostor
  108261. * @param otherImpostor rigid impostor to anchor to
  108262. * @param length ratio across rope from 0 to 1
  108263. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108264. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108265. * @returns impostor the rope imposter
  108266. */
  108267. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108268. /**
  108269. * Will keep this body still, in a sleep mode.
  108270. * @returns the physics imposter
  108271. */
  108272. sleep(): PhysicsImpostor;
  108273. /**
  108274. * Wake the body up.
  108275. * @returns The physics imposter
  108276. */
  108277. wakeUp(): PhysicsImpostor;
  108278. /**
  108279. * Clones the physics imposter
  108280. * @param newObject The physics imposter clones to this physics-enabled object
  108281. * @returns A nullable physics imposter
  108282. */
  108283. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108284. /**
  108285. * Disposes the physics imposter
  108286. */
  108287. dispose(): void;
  108288. /**
  108289. * Sets the delta position
  108290. * @param position The delta position amount
  108291. */
  108292. setDeltaPosition(position: Vector3): void;
  108293. /**
  108294. * Sets the delta rotation
  108295. * @param rotation The delta rotation amount
  108296. */
  108297. setDeltaRotation(rotation: Quaternion): void;
  108298. /**
  108299. * Gets the box size of the physics imposter and stores the result in the input parameter
  108300. * @param result Stores the box size
  108301. * @returns The physics imposter
  108302. */
  108303. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108304. /**
  108305. * Gets the radius of the physics imposter
  108306. * @returns Radius of the physics imposter
  108307. */
  108308. getRadius(): number;
  108309. /**
  108310. * Sync a bone with this impostor
  108311. * @param bone The bone to sync to the impostor.
  108312. * @param boneMesh The mesh that the bone is influencing.
  108313. * @param jointPivot The pivot of the joint / bone in local space.
  108314. * @param distToJoint Optional distance from the impostor to the joint.
  108315. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108316. */
  108317. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108318. /**
  108319. * Sync impostor to a bone
  108320. * @param bone The bone that the impostor will be synced to.
  108321. * @param boneMesh The mesh that the bone is influencing.
  108322. * @param jointPivot The pivot of the joint / bone in local space.
  108323. * @param distToJoint Optional distance from the impostor to the joint.
  108324. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108325. * @param boneAxis Optional vector3 axis the bone is aligned with
  108326. */
  108327. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108328. /**
  108329. * No-Imposter type
  108330. */
  108331. static NoImpostor: number;
  108332. /**
  108333. * Sphere-Imposter type
  108334. */
  108335. static SphereImpostor: number;
  108336. /**
  108337. * Box-Imposter type
  108338. */
  108339. static BoxImpostor: number;
  108340. /**
  108341. * Plane-Imposter type
  108342. */
  108343. static PlaneImpostor: number;
  108344. /**
  108345. * Mesh-imposter type
  108346. */
  108347. static MeshImpostor: number;
  108348. /**
  108349. * Capsule-Impostor type (Ammo.js plugin only)
  108350. */
  108351. static CapsuleImpostor: number;
  108352. /**
  108353. * Cylinder-Imposter type
  108354. */
  108355. static CylinderImpostor: number;
  108356. /**
  108357. * Particle-Imposter type
  108358. */
  108359. static ParticleImpostor: number;
  108360. /**
  108361. * Heightmap-Imposter type
  108362. */
  108363. static HeightmapImpostor: number;
  108364. /**
  108365. * ConvexHull-Impostor type (Ammo.js plugin only)
  108366. */
  108367. static ConvexHullImpostor: number;
  108368. /**
  108369. * Custom-Imposter type (Ammo.js plugin only)
  108370. */
  108371. static CustomImpostor: number;
  108372. /**
  108373. * Rope-Imposter type
  108374. */
  108375. static RopeImpostor: number;
  108376. /**
  108377. * Cloth-Imposter type
  108378. */
  108379. static ClothImpostor: number;
  108380. /**
  108381. * Softbody-Imposter type
  108382. */
  108383. static SoftbodyImpostor: number;
  108384. }
  108385. }
  108386. declare module BABYLON {
  108387. /**
  108388. * @hidden
  108389. **/
  108390. export class _CreationDataStorage {
  108391. closePath?: boolean;
  108392. closeArray?: boolean;
  108393. idx: number[];
  108394. dashSize: number;
  108395. gapSize: number;
  108396. path3D: Path3D;
  108397. pathArray: Vector3[][];
  108398. arc: number;
  108399. radius: number;
  108400. cap: number;
  108401. tessellation: number;
  108402. }
  108403. /**
  108404. * @hidden
  108405. **/
  108406. class _InstanceDataStorage {
  108407. visibleInstances: any;
  108408. batchCache: _InstancesBatch;
  108409. instancesBufferSize: number;
  108410. instancesBuffer: Nullable<Buffer>;
  108411. instancesData: Float32Array;
  108412. overridenInstanceCount: number;
  108413. isFrozen: boolean;
  108414. previousBatch: Nullable<_InstancesBatch>;
  108415. hardwareInstancedRendering: boolean;
  108416. sideOrientation: number;
  108417. manualUpdate: boolean;
  108418. previousRenderId: number;
  108419. }
  108420. /**
  108421. * @hidden
  108422. **/
  108423. export class _InstancesBatch {
  108424. mustReturn: boolean;
  108425. visibleInstances: Nullable<InstancedMesh[]>[];
  108426. renderSelf: boolean[];
  108427. hardwareInstancedRendering: boolean[];
  108428. }
  108429. /**
  108430. * @hidden
  108431. **/
  108432. class _ThinInstanceDataStorage {
  108433. instancesCount: number;
  108434. matrixBuffer: Nullable<Buffer>;
  108435. matrixBufferSize: number;
  108436. matrixData: Nullable<Float32Array>;
  108437. boundingVectors: Array<Vector3>;
  108438. worldMatrices: Nullable<Matrix[]>;
  108439. }
  108440. /**
  108441. * Class used to represent renderable models
  108442. */
  108443. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108444. /**
  108445. * Mesh side orientation : usually the external or front surface
  108446. */
  108447. static readonly FRONTSIDE: number;
  108448. /**
  108449. * Mesh side orientation : usually the internal or back surface
  108450. */
  108451. static readonly BACKSIDE: number;
  108452. /**
  108453. * Mesh side orientation : both internal and external or front and back surfaces
  108454. */
  108455. static readonly DOUBLESIDE: number;
  108456. /**
  108457. * Mesh side orientation : by default, `FRONTSIDE`
  108458. */
  108459. static readonly DEFAULTSIDE: number;
  108460. /**
  108461. * Mesh cap setting : no cap
  108462. */
  108463. static readonly NO_CAP: number;
  108464. /**
  108465. * Mesh cap setting : one cap at the beginning of the mesh
  108466. */
  108467. static readonly CAP_START: number;
  108468. /**
  108469. * Mesh cap setting : one cap at the end of the mesh
  108470. */
  108471. static readonly CAP_END: number;
  108472. /**
  108473. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108474. */
  108475. static readonly CAP_ALL: number;
  108476. /**
  108477. * Mesh pattern setting : no flip or rotate
  108478. */
  108479. static readonly NO_FLIP: number;
  108480. /**
  108481. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108482. */
  108483. static readonly FLIP_TILE: number;
  108484. /**
  108485. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108486. */
  108487. static readonly ROTATE_TILE: number;
  108488. /**
  108489. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108490. */
  108491. static readonly FLIP_ROW: number;
  108492. /**
  108493. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108494. */
  108495. static readonly ROTATE_ROW: number;
  108496. /**
  108497. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108498. */
  108499. static readonly FLIP_N_ROTATE_TILE: number;
  108500. /**
  108501. * Mesh pattern setting : rotate pattern and rotate
  108502. */
  108503. static readonly FLIP_N_ROTATE_ROW: number;
  108504. /**
  108505. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108506. */
  108507. static readonly CENTER: number;
  108508. /**
  108509. * Mesh tile positioning : part tiles on left
  108510. */
  108511. static readonly LEFT: number;
  108512. /**
  108513. * Mesh tile positioning : part tiles on right
  108514. */
  108515. static readonly RIGHT: number;
  108516. /**
  108517. * Mesh tile positioning : part tiles on top
  108518. */
  108519. static readonly TOP: number;
  108520. /**
  108521. * Mesh tile positioning : part tiles on bottom
  108522. */
  108523. static readonly BOTTOM: number;
  108524. /**
  108525. * Gets the default side orientation.
  108526. * @param orientation the orientation to value to attempt to get
  108527. * @returns the default orientation
  108528. * @hidden
  108529. */
  108530. static _GetDefaultSideOrientation(orientation?: number): number;
  108531. private _internalMeshDataInfo;
  108532. get computeBonesUsingShaders(): boolean;
  108533. set computeBonesUsingShaders(value: boolean);
  108534. /**
  108535. * An event triggered before rendering the mesh
  108536. */
  108537. get onBeforeRenderObservable(): Observable<Mesh>;
  108538. /**
  108539. * An event triggered before binding the mesh
  108540. */
  108541. get onBeforeBindObservable(): Observable<Mesh>;
  108542. /**
  108543. * An event triggered after rendering the mesh
  108544. */
  108545. get onAfterRenderObservable(): Observable<Mesh>;
  108546. /**
  108547. * An event triggered before drawing the mesh
  108548. */
  108549. get onBeforeDrawObservable(): Observable<Mesh>;
  108550. private _onBeforeDrawObserver;
  108551. /**
  108552. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108553. */
  108554. set onBeforeDraw(callback: () => void);
  108555. get hasInstances(): boolean;
  108556. get hasThinInstances(): boolean;
  108557. /**
  108558. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108559. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108560. */
  108561. delayLoadState: number;
  108562. /**
  108563. * Gets the list of instances created from this mesh
  108564. * it is not supposed to be modified manually.
  108565. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108566. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108567. */
  108568. instances: InstancedMesh[];
  108569. /**
  108570. * Gets the file containing delay loading data for this mesh
  108571. */
  108572. delayLoadingFile: string;
  108573. /** @hidden */
  108574. _binaryInfo: any;
  108575. /**
  108576. * User defined function used to change how LOD level selection is done
  108577. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108578. */
  108579. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108580. /**
  108581. * Gets or sets the morph target manager
  108582. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108583. */
  108584. get morphTargetManager(): Nullable<MorphTargetManager>;
  108585. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108586. /** @hidden */
  108587. _creationDataStorage: Nullable<_CreationDataStorage>;
  108588. /** @hidden */
  108589. _geometry: Nullable<Geometry>;
  108590. /** @hidden */
  108591. _delayInfo: Array<string>;
  108592. /** @hidden */
  108593. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108594. /** @hidden */
  108595. _instanceDataStorage: _InstanceDataStorage;
  108596. /** @hidden */
  108597. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108598. private _effectiveMaterial;
  108599. /** @hidden */
  108600. _shouldGenerateFlatShading: boolean;
  108601. /** @hidden */
  108602. _originalBuilderSideOrientation: number;
  108603. /**
  108604. * Use this property to change the original side orientation defined at construction time
  108605. */
  108606. overrideMaterialSideOrientation: Nullable<number>;
  108607. /**
  108608. * Gets the source mesh (the one used to clone this one from)
  108609. */
  108610. get source(): Nullable<Mesh>;
  108611. /**
  108612. * Gets the list of clones of this mesh
  108613. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108614. * Note that useClonedMeshMap=true is the default setting
  108615. */
  108616. get cloneMeshMap(): Nullable<{
  108617. [id: string]: Mesh | undefined;
  108618. }>;
  108619. /**
  108620. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108621. */
  108622. get isUnIndexed(): boolean;
  108623. set isUnIndexed(value: boolean);
  108624. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108625. get worldMatrixInstancedBuffer(): Float32Array;
  108626. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108627. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108628. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108629. /**
  108630. * @constructor
  108631. * @param name The value used by scene.getMeshByName() to do a lookup.
  108632. * @param scene The scene to add this mesh to.
  108633. * @param parent The parent of this mesh, if it has one
  108634. * @param source An optional Mesh from which geometry is shared, cloned.
  108635. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108636. * When false, achieved by calling a clone(), also passing False.
  108637. * This will make creation of children, recursive.
  108638. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108639. */
  108640. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108641. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108642. doNotInstantiate: boolean;
  108643. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108644. /**
  108645. * Gets the class name
  108646. * @returns the string "Mesh".
  108647. */
  108648. getClassName(): string;
  108649. /** @hidden */
  108650. get _isMesh(): boolean;
  108651. /**
  108652. * Returns a description of this mesh
  108653. * @param fullDetails define if full details about this mesh must be used
  108654. * @returns a descriptive string representing this mesh
  108655. */
  108656. toString(fullDetails?: boolean): string;
  108657. /** @hidden */
  108658. _unBindEffect(): void;
  108659. /**
  108660. * Gets a boolean indicating if this mesh has LOD
  108661. */
  108662. get hasLODLevels(): boolean;
  108663. /**
  108664. * Gets the list of MeshLODLevel associated with the current mesh
  108665. * @returns an array of MeshLODLevel
  108666. */
  108667. getLODLevels(): MeshLODLevel[];
  108668. private _sortLODLevels;
  108669. /**
  108670. * Add a mesh as LOD level triggered at the given distance.
  108671. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108672. * @param distance The distance from the center of the object to show this level
  108673. * @param mesh The mesh to be added as LOD level (can be null)
  108674. * @return This mesh (for chaining)
  108675. */
  108676. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108677. /**
  108678. * Returns the LOD level mesh at the passed distance or null if not found.
  108679. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108680. * @param distance The distance from the center of the object to show this level
  108681. * @returns a Mesh or `null`
  108682. */
  108683. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108684. /**
  108685. * Remove a mesh from the LOD array
  108686. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108687. * @param mesh defines the mesh to be removed
  108688. * @return This mesh (for chaining)
  108689. */
  108690. removeLODLevel(mesh: Mesh): Mesh;
  108691. /**
  108692. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  108693. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108694. * @param camera defines the camera to use to compute distance
  108695. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  108696. * @return This mesh (for chaining)
  108697. */
  108698. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  108699. /**
  108700. * Gets the mesh internal Geometry object
  108701. */
  108702. get geometry(): Nullable<Geometry>;
  108703. /**
  108704. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  108705. * @returns the total number of vertices
  108706. */
  108707. getTotalVertices(): number;
  108708. /**
  108709. * Returns the content of an associated vertex buffer
  108710. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108711. * - VertexBuffer.PositionKind
  108712. * - VertexBuffer.UVKind
  108713. * - VertexBuffer.UV2Kind
  108714. * - VertexBuffer.UV3Kind
  108715. * - VertexBuffer.UV4Kind
  108716. * - VertexBuffer.UV5Kind
  108717. * - VertexBuffer.UV6Kind
  108718. * - VertexBuffer.ColorKind
  108719. * - VertexBuffer.MatricesIndicesKind
  108720. * - VertexBuffer.MatricesIndicesExtraKind
  108721. * - VertexBuffer.MatricesWeightsKind
  108722. * - VertexBuffer.MatricesWeightsExtraKind
  108723. * @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
  108724. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  108725. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  108726. */
  108727. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  108728. /**
  108729. * Returns the mesh VertexBuffer object from the requested `kind`
  108730. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108731. * - VertexBuffer.PositionKind
  108732. * - VertexBuffer.NormalKind
  108733. * - VertexBuffer.UVKind
  108734. * - VertexBuffer.UV2Kind
  108735. * - VertexBuffer.UV3Kind
  108736. * - VertexBuffer.UV4Kind
  108737. * - VertexBuffer.UV5Kind
  108738. * - VertexBuffer.UV6Kind
  108739. * - VertexBuffer.ColorKind
  108740. * - VertexBuffer.MatricesIndicesKind
  108741. * - VertexBuffer.MatricesIndicesExtraKind
  108742. * - VertexBuffer.MatricesWeightsKind
  108743. * - VertexBuffer.MatricesWeightsExtraKind
  108744. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  108745. */
  108746. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  108747. /**
  108748. * Tests if a specific vertex buffer is associated with this mesh
  108749. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108750. * - VertexBuffer.PositionKind
  108751. * - VertexBuffer.NormalKind
  108752. * - VertexBuffer.UVKind
  108753. * - VertexBuffer.UV2Kind
  108754. * - VertexBuffer.UV3Kind
  108755. * - VertexBuffer.UV4Kind
  108756. * - VertexBuffer.UV5Kind
  108757. * - VertexBuffer.UV6Kind
  108758. * - VertexBuffer.ColorKind
  108759. * - VertexBuffer.MatricesIndicesKind
  108760. * - VertexBuffer.MatricesIndicesExtraKind
  108761. * - VertexBuffer.MatricesWeightsKind
  108762. * - VertexBuffer.MatricesWeightsExtraKind
  108763. * @returns a boolean
  108764. */
  108765. isVerticesDataPresent(kind: string): boolean;
  108766. /**
  108767. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  108768. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  108769. * - VertexBuffer.PositionKind
  108770. * - VertexBuffer.UVKind
  108771. * - VertexBuffer.UV2Kind
  108772. * - VertexBuffer.UV3Kind
  108773. * - VertexBuffer.UV4Kind
  108774. * - VertexBuffer.UV5Kind
  108775. * - VertexBuffer.UV6Kind
  108776. * - VertexBuffer.ColorKind
  108777. * - VertexBuffer.MatricesIndicesKind
  108778. * - VertexBuffer.MatricesIndicesExtraKind
  108779. * - VertexBuffer.MatricesWeightsKind
  108780. * - VertexBuffer.MatricesWeightsExtraKind
  108781. * @returns a boolean
  108782. */
  108783. isVertexBufferUpdatable(kind: string): boolean;
  108784. /**
  108785. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  108786. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  108787. * - VertexBuffer.PositionKind
  108788. * - VertexBuffer.NormalKind
  108789. * - VertexBuffer.UVKind
  108790. * - VertexBuffer.UV2Kind
  108791. * - VertexBuffer.UV3Kind
  108792. * - VertexBuffer.UV4Kind
  108793. * - VertexBuffer.UV5Kind
  108794. * - VertexBuffer.UV6Kind
  108795. * - VertexBuffer.ColorKind
  108796. * - VertexBuffer.MatricesIndicesKind
  108797. * - VertexBuffer.MatricesIndicesExtraKind
  108798. * - VertexBuffer.MatricesWeightsKind
  108799. * - VertexBuffer.MatricesWeightsExtraKind
  108800. * @returns an array of strings
  108801. */
  108802. getVerticesDataKinds(): string[];
  108803. /**
  108804. * Returns a positive integer : the total number of indices in this mesh geometry.
  108805. * @returns the numner of indices or zero if the mesh has no geometry.
  108806. */
  108807. getTotalIndices(): number;
  108808. /**
  108809. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  108810. * @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.
  108811. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  108812. * @returns the indices array or an empty array if the mesh has no geometry
  108813. */
  108814. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  108815. get isBlocked(): boolean;
  108816. /**
  108817. * Determine if the current mesh is ready to be rendered
  108818. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  108819. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  108820. * @returns true if all associated assets are ready (material, textures, shaders)
  108821. */
  108822. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  108823. /**
  108824. * 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.
  108825. */
  108826. get areNormalsFrozen(): boolean;
  108827. /**
  108828. * 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.
  108829. * @returns the current mesh
  108830. */
  108831. freezeNormals(): Mesh;
  108832. /**
  108833. * 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
  108834. * @returns the current mesh
  108835. */
  108836. unfreezeNormals(): Mesh;
  108837. /**
  108838. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  108839. */
  108840. set overridenInstanceCount(count: number);
  108841. /** @hidden */
  108842. _preActivate(): Mesh;
  108843. /** @hidden */
  108844. _preActivateForIntermediateRendering(renderId: number): Mesh;
  108845. /** @hidden */
  108846. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  108847. protected _afterComputeWorldMatrix(): void;
  108848. /** @hidden */
  108849. _postActivate(): void;
  108850. /**
  108851. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  108852. * This means the mesh underlying bounding box and sphere are recomputed.
  108853. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  108854. * @returns the current mesh
  108855. */
  108856. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  108857. /** @hidden */
  108858. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  108859. /**
  108860. * This function will subdivide the mesh into multiple submeshes
  108861. * @param count defines the expected number of submeshes
  108862. */
  108863. subdivide(count: number): void;
  108864. /**
  108865. * Copy a FloatArray into a specific associated vertex buffer
  108866. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108867. * - VertexBuffer.PositionKind
  108868. * - VertexBuffer.UVKind
  108869. * - VertexBuffer.UV2Kind
  108870. * - VertexBuffer.UV3Kind
  108871. * - VertexBuffer.UV4Kind
  108872. * - VertexBuffer.UV5Kind
  108873. * - VertexBuffer.UV6Kind
  108874. * - VertexBuffer.ColorKind
  108875. * - VertexBuffer.MatricesIndicesKind
  108876. * - VertexBuffer.MatricesIndicesExtraKind
  108877. * - VertexBuffer.MatricesWeightsKind
  108878. * - VertexBuffer.MatricesWeightsExtraKind
  108879. * @param data defines the data source
  108880. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108881. * @param stride defines the data stride size (can be null)
  108882. * @returns the current mesh
  108883. */
  108884. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  108885. /**
  108886. * Delete a vertex buffer associated with this mesh
  108887. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  108888. * - VertexBuffer.PositionKind
  108889. * - VertexBuffer.UVKind
  108890. * - VertexBuffer.UV2Kind
  108891. * - VertexBuffer.UV3Kind
  108892. * - VertexBuffer.UV4Kind
  108893. * - VertexBuffer.UV5Kind
  108894. * - VertexBuffer.UV6Kind
  108895. * - VertexBuffer.ColorKind
  108896. * - VertexBuffer.MatricesIndicesKind
  108897. * - VertexBuffer.MatricesIndicesExtraKind
  108898. * - VertexBuffer.MatricesWeightsKind
  108899. * - VertexBuffer.MatricesWeightsExtraKind
  108900. */
  108901. removeVerticesData(kind: string): void;
  108902. /**
  108903. * Flags an associated vertex buffer as updatable
  108904. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  108905. * - VertexBuffer.PositionKind
  108906. * - VertexBuffer.UVKind
  108907. * - VertexBuffer.UV2Kind
  108908. * - VertexBuffer.UV3Kind
  108909. * - VertexBuffer.UV4Kind
  108910. * - VertexBuffer.UV5Kind
  108911. * - VertexBuffer.UV6Kind
  108912. * - VertexBuffer.ColorKind
  108913. * - VertexBuffer.MatricesIndicesKind
  108914. * - VertexBuffer.MatricesIndicesExtraKind
  108915. * - VertexBuffer.MatricesWeightsKind
  108916. * - VertexBuffer.MatricesWeightsExtraKind
  108917. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  108918. */
  108919. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  108920. /**
  108921. * Sets the mesh global Vertex Buffer
  108922. * @param buffer defines the buffer to use
  108923. * @returns the current mesh
  108924. */
  108925. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  108926. /**
  108927. * Update a specific associated vertex buffer
  108928. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  108929. * - VertexBuffer.PositionKind
  108930. * - VertexBuffer.UVKind
  108931. * - VertexBuffer.UV2Kind
  108932. * - VertexBuffer.UV3Kind
  108933. * - VertexBuffer.UV4Kind
  108934. * - VertexBuffer.UV5Kind
  108935. * - VertexBuffer.UV6Kind
  108936. * - VertexBuffer.ColorKind
  108937. * - VertexBuffer.MatricesIndicesKind
  108938. * - VertexBuffer.MatricesIndicesExtraKind
  108939. * - VertexBuffer.MatricesWeightsKind
  108940. * - VertexBuffer.MatricesWeightsExtraKind
  108941. * @param data defines the data source
  108942. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  108943. * @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)
  108944. * @returns the current mesh
  108945. */
  108946. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  108947. /**
  108948. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  108949. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  108950. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  108951. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  108952. * @returns the current mesh
  108953. */
  108954. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  108955. /**
  108956. * Creates a un-shared specific occurence of the geometry for the mesh.
  108957. * @returns the current mesh
  108958. */
  108959. makeGeometryUnique(): Mesh;
  108960. /**
  108961. * Set the index buffer of this mesh
  108962. * @param indices defines the source data
  108963. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  108964. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  108965. * @returns the current mesh
  108966. */
  108967. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  108968. /**
  108969. * Update the current index buffer
  108970. * @param indices defines the source data
  108971. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  108972. * @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)
  108973. * @returns the current mesh
  108974. */
  108975. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  108976. /**
  108977. * Invert the geometry to move from a right handed system to a left handed one.
  108978. * @returns the current mesh
  108979. */
  108980. toLeftHanded(): Mesh;
  108981. /** @hidden */
  108982. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  108983. /** @hidden */
  108984. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  108985. /**
  108986. * Registers for this mesh a javascript function called just before the rendering process
  108987. * @param func defines the function to call before rendering this mesh
  108988. * @returns the current mesh
  108989. */
  108990. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108991. /**
  108992. * Disposes a previously registered javascript function called before the rendering
  108993. * @param func defines the function to remove
  108994. * @returns the current mesh
  108995. */
  108996. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  108997. /**
  108998. * Registers for this mesh a javascript function called just after the rendering is complete
  108999. * @param func defines the function to call after rendering this mesh
  109000. * @returns the current mesh
  109001. */
  109002. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109003. /**
  109004. * Disposes a previously registered javascript function called after the rendering.
  109005. * @param func defines the function to remove
  109006. * @returns the current mesh
  109007. */
  109008. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109009. /** @hidden */
  109010. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109011. /** @hidden */
  109012. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109013. /** @hidden */
  109014. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109015. /** @hidden */
  109016. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109017. /** @hidden */
  109018. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109019. /** @hidden */
  109020. _rebuild(): void;
  109021. /** @hidden */
  109022. _freeze(): void;
  109023. /** @hidden */
  109024. _unFreeze(): void;
  109025. /**
  109026. * 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
  109027. * @param subMesh defines the subMesh to render
  109028. * @param enableAlphaMode defines if alpha mode can be changed
  109029. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109030. * @returns the current mesh
  109031. */
  109032. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109033. private _onBeforeDraw;
  109034. /**
  109035. * Renormalize the mesh and patch it up if there are no weights
  109036. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109037. * However in the case of zero weights then we set just a single influence to 1.
  109038. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109039. */
  109040. cleanMatrixWeights(): void;
  109041. private normalizeSkinFourWeights;
  109042. private normalizeSkinWeightsAndExtra;
  109043. /**
  109044. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109045. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109046. * the user know there was an issue with importing the mesh
  109047. * @returns a validation object with skinned, valid and report string
  109048. */
  109049. validateSkinning(): {
  109050. skinned: boolean;
  109051. valid: boolean;
  109052. report: string;
  109053. };
  109054. /** @hidden */
  109055. _checkDelayState(): Mesh;
  109056. private _queueLoad;
  109057. /**
  109058. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109059. * A mesh is in the frustum if its bounding box intersects the frustum
  109060. * @param frustumPlanes defines the frustum to test
  109061. * @returns true if the mesh is in the frustum planes
  109062. */
  109063. isInFrustum(frustumPlanes: Plane[]): boolean;
  109064. /**
  109065. * Sets the mesh material by the material or multiMaterial `id` property
  109066. * @param id is a string identifying the material or the multiMaterial
  109067. * @returns the current mesh
  109068. */
  109069. setMaterialByID(id: string): Mesh;
  109070. /**
  109071. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109072. * @returns an array of IAnimatable
  109073. */
  109074. getAnimatables(): IAnimatable[];
  109075. /**
  109076. * Modifies the mesh geometry according to the passed transformation matrix.
  109077. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109078. * The mesh normals are modified using the same transformation.
  109079. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109080. * @param transform defines the transform matrix to use
  109081. * @see https://doc.babylonjs.com/resources/baking_transformations
  109082. * @returns the current mesh
  109083. */
  109084. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109085. /**
  109086. * Modifies the mesh geometry according to its own current World Matrix.
  109087. * The mesh World Matrix is then reset.
  109088. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109089. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109090. * @see https://doc.babylonjs.com/resources/baking_transformations
  109091. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109092. * @returns the current mesh
  109093. */
  109094. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109095. /** @hidden */
  109096. get _positions(): Nullable<Vector3[]>;
  109097. /** @hidden */
  109098. _resetPointsArrayCache(): Mesh;
  109099. /** @hidden */
  109100. _generatePointsArray(): boolean;
  109101. /**
  109102. * Returns a new Mesh object generated from the current mesh properties.
  109103. * This method must not get confused with createInstance()
  109104. * @param name is a string, the name given to the new mesh
  109105. * @param newParent can be any Node object (default `null`)
  109106. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109107. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109108. * @returns a new mesh
  109109. */
  109110. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109111. /**
  109112. * Releases resources associated with this mesh.
  109113. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109114. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109115. */
  109116. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109117. /** @hidden */
  109118. _disposeInstanceSpecificData(): void;
  109119. /** @hidden */
  109120. _disposeThinInstanceSpecificData(): void;
  109121. /**
  109122. * Modifies the mesh geometry according to a displacement map.
  109123. * 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.
  109124. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109125. * @param url is a string, the URL from the image file is to be downloaded.
  109126. * @param minHeight is the lower limit of the displacement.
  109127. * @param maxHeight is the upper limit of the displacement.
  109128. * @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.
  109129. * @param uvOffset is an optional vector2 used to offset UV.
  109130. * @param uvScale is an optional vector2 used to scale UV.
  109131. * @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.
  109132. * @returns the Mesh.
  109133. */
  109134. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109135. /**
  109136. * Modifies the mesh geometry according to a displacementMap buffer.
  109137. * 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.
  109138. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109139. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109140. * @param heightMapWidth is the width of the buffer image.
  109141. * @param heightMapHeight is the height of the buffer image.
  109142. * @param minHeight is the lower limit of the displacement.
  109143. * @param maxHeight is the upper limit of the displacement.
  109144. * @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.
  109145. * @param uvOffset is an optional vector2 used to offset UV.
  109146. * @param uvScale is an optional vector2 used to scale UV.
  109147. * @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.
  109148. * @returns the Mesh.
  109149. */
  109150. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109151. /**
  109152. * Modify the mesh to get a flat shading rendering.
  109153. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109154. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109155. * @returns current mesh
  109156. */
  109157. convertToFlatShadedMesh(): Mesh;
  109158. /**
  109159. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109160. * In other words, more vertices, no more indices and a single bigger VBO.
  109161. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109162. * @returns current mesh
  109163. */
  109164. convertToUnIndexedMesh(): Mesh;
  109165. /**
  109166. * Inverses facet orientations.
  109167. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109168. * @param flipNormals will also inverts the normals
  109169. * @returns current mesh
  109170. */
  109171. flipFaces(flipNormals?: boolean): Mesh;
  109172. /**
  109173. * Increase the number of facets and hence vertices in a mesh
  109174. * Vertex normals are interpolated from existing vertex normals
  109175. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109176. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109177. */
  109178. increaseVertices(numberPerEdge: number): void;
  109179. /**
  109180. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109181. * This will undo any application of covertToFlatShadedMesh
  109182. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109183. */
  109184. forceSharedVertices(): void;
  109185. /** @hidden */
  109186. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109187. /** @hidden */
  109188. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109189. /**
  109190. * Creates a new InstancedMesh object from the mesh model.
  109191. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109192. * @param name defines the name of the new instance
  109193. * @returns a new InstancedMesh
  109194. */
  109195. createInstance(name: string): InstancedMesh;
  109196. /**
  109197. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109198. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109199. * @returns the current mesh
  109200. */
  109201. synchronizeInstances(): Mesh;
  109202. /**
  109203. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109204. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109205. * This should be used together with the simplification to avoid disappearing triangles.
  109206. * @param successCallback an optional success callback to be called after the optimization finished.
  109207. * @returns the current mesh
  109208. */
  109209. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109210. /**
  109211. * Serialize current mesh
  109212. * @param serializationObject defines the object which will receive the serialization data
  109213. */
  109214. serialize(serializationObject: any): void;
  109215. /** @hidden */
  109216. _syncGeometryWithMorphTargetManager(): void;
  109217. /** @hidden */
  109218. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109219. /**
  109220. * Returns a new Mesh object parsed from the source provided.
  109221. * @param parsedMesh is the source
  109222. * @param scene defines the hosting scene
  109223. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109224. * @returns a new Mesh
  109225. */
  109226. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109227. /**
  109228. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109230. * @param name defines the name of the mesh to create
  109231. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109232. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109233. * @param closePath creates a seam between the first and the last points of each path of the path array
  109234. * @param offset is taken in account only if the `pathArray` is containing a single path
  109235. * @param scene defines the hosting scene
  109236. * @param updatable defines if the mesh must be flagged as updatable
  109237. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109238. * @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)
  109239. * @returns a new Mesh
  109240. */
  109241. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109242. /**
  109243. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109244. * @param name defines the name of the mesh to create
  109245. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109246. * @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
  109247. * @param scene defines the hosting scene
  109248. * @param updatable defines if the mesh must be flagged as updatable
  109249. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109250. * @returns a new Mesh
  109251. */
  109252. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109253. /**
  109254. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109255. * @param name defines the name of the mesh to create
  109256. * @param size sets the size (float) of each box side (default 1)
  109257. * @param scene defines the hosting scene
  109258. * @param updatable defines if the mesh must be flagged as updatable
  109259. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109260. * @returns a new Mesh
  109261. */
  109262. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109263. /**
  109264. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109265. * @param name defines the name of the mesh to create
  109266. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109267. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109268. * @param scene defines the hosting scene
  109269. * @param updatable defines if the mesh must be flagged as updatable
  109270. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109271. * @returns a new Mesh
  109272. */
  109273. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109274. /**
  109275. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109276. * @param name defines the name of the mesh to create
  109277. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109278. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109279. * @param scene defines the hosting scene
  109280. * @returns a new Mesh
  109281. */
  109282. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109283. /**
  109284. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109285. * @param name defines the name of the mesh to create
  109286. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109287. * @param diameterTop set the top cap diameter (floats, default 1)
  109288. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109289. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109290. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109291. * @param scene defines the hosting scene
  109292. * @param updatable defines if the mesh must be flagged as updatable
  109293. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109294. * @returns a new Mesh
  109295. */
  109296. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109297. /**
  109298. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109299. * @param name defines the name of the mesh to create
  109300. * @param diameter sets the diameter size (float) of the torus (default 1)
  109301. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109302. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109303. * @param scene defines the hosting scene
  109304. * @param updatable defines if the mesh must be flagged as updatable
  109305. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109306. * @returns a new Mesh
  109307. */
  109308. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109309. /**
  109310. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109311. * @param name defines the name of the mesh to create
  109312. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109313. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109314. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109315. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109316. * @param p the number of windings on X axis (positive integers, default 2)
  109317. * @param q the number of windings on Y axis (positive integers, default 3)
  109318. * @param scene defines the hosting scene
  109319. * @param updatable defines if the mesh must be flagged as updatable
  109320. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109321. * @returns a new Mesh
  109322. */
  109323. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109324. /**
  109325. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109326. * @param name defines the name of the mesh to create
  109327. * @param points is an array successive Vector3
  109328. * @param scene defines the hosting scene
  109329. * @param updatable defines if the mesh must be flagged as updatable
  109330. * @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).
  109331. * @returns a new Mesh
  109332. */
  109333. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109334. /**
  109335. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109336. * @param name defines the name of the mesh to create
  109337. * @param points is an array successive Vector3
  109338. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109339. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109340. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109341. * @param scene defines the hosting scene
  109342. * @param updatable defines if the mesh must be flagged as updatable
  109343. * @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)
  109344. * @returns a new Mesh
  109345. */
  109346. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109347. /**
  109348. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109349. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109350. * 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.
  109351. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109352. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109353. * Remember you can only change the shape positions, not their number when updating a polygon.
  109354. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109355. * @param name defines the name of the mesh to create
  109356. * @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
  109357. * @param scene defines the hosting scene
  109358. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109359. * @param updatable defines if the mesh must be flagged as updatable
  109360. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109361. * @param earcutInjection can be used to inject your own earcut reference
  109362. * @returns a new Mesh
  109363. */
  109364. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109365. /**
  109366. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109367. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109368. * @param name defines the name of the mesh to create
  109369. * @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
  109370. * @param depth defines the height of extrusion
  109371. * @param scene defines the hosting scene
  109372. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109373. * @param updatable defines if the mesh must be flagged as updatable
  109374. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109375. * @param earcutInjection can be used to inject your own earcut reference
  109376. * @returns a new Mesh
  109377. */
  109378. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109379. /**
  109380. * Creates an extruded shape mesh.
  109381. * 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
  109382. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109384. * @param name defines the name of the mesh to create
  109385. * @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
  109386. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109387. * @param scale is the value to scale the shape
  109388. * @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
  109389. * @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
  109390. * @param scene defines the hosting scene
  109391. * @param updatable defines if the mesh must be flagged as updatable
  109392. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109393. * @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)
  109394. * @returns a new Mesh
  109395. */
  109396. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109397. /**
  109398. * Creates an custom extruded shape mesh.
  109399. * The custom extrusion is a parametric shape.
  109400. * It has no predefined shape. Its final shape will depend on the input parameters.
  109401. * Please consider using the same method from the MeshBuilder class instead
  109402. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109403. * @param name defines the name of the mesh to create
  109404. * @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
  109405. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109406. * @param scaleFunction is a custom Javascript function called on each path point
  109407. * @param rotationFunction is a custom Javascript function called on each path point
  109408. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109409. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109410. * @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
  109411. * @param scene defines the hosting scene
  109412. * @param updatable defines if the mesh must be flagged as updatable
  109413. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109414. * @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)
  109415. * @returns a new Mesh
  109416. */
  109417. 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;
  109418. /**
  109419. * Creates lathe mesh.
  109420. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109421. * Please consider using the same method from the MeshBuilder class instead
  109422. * @param name defines the name of the mesh to create
  109423. * @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
  109424. * @param radius is the radius value of the lathe
  109425. * @param tessellation is the side number of the lathe.
  109426. * @param scene defines the hosting scene
  109427. * @param updatable defines if the mesh must be flagged as updatable
  109428. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109429. * @returns a new Mesh
  109430. */
  109431. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109432. /**
  109433. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109434. * @param name defines the name of the mesh to create
  109435. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109436. * @param scene defines the hosting scene
  109437. * @param updatable defines if the mesh must be flagged as updatable
  109438. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109439. * @returns a new Mesh
  109440. */
  109441. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109442. /**
  109443. * Creates a ground mesh.
  109444. * Please consider using the same method from the MeshBuilder class instead
  109445. * @param name defines the name of the mesh to create
  109446. * @param width set the width of the ground
  109447. * @param height set the height of the ground
  109448. * @param subdivisions sets the number of subdivisions per side
  109449. * @param scene defines the hosting scene
  109450. * @param updatable defines if the mesh must be flagged as updatable
  109451. * @returns a new Mesh
  109452. */
  109453. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109454. /**
  109455. * Creates a tiled ground mesh.
  109456. * Please consider using the same method from the MeshBuilder class instead
  109457. * @param name defines the name of the mesh to create
  109458. * @param xmin set the ground minimum X coordinate
  109459. * @param zmin set the ground minimum Y coordinate
  109460. * @param xmax set the ground maximum X coordinate
  109461. * @param zmax set the ground maximum Z coordinate
  109462. * @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
  109463. * @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
  109464. * @param scene defines the hosting scene
  109465. * @param updatable defines if the mesh must be flagged as updatable
  109466. * @returns a new Mesh
  109467. */
  109468. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109469. w: number;
  109470. h: number;
  109471. }, precision: {
  109472. w: number;
  109473. h: number;
  109474. }, scene: Scene, updatable?: boolean): Mesh;
  109475. /**
  109476. * Creates a ground mesh from a height map.
  109477. * Please consider using the same method from the MeshBuilder class instead
  109478. * @see https://doc.babylonjs.com/babylon101/height_map
  109479. * @param name defines the name of the mesh to create
  109480. * @param url sets the URL of the height map image resource
  109481. * @param width set the ground width size
  109482. * @param height set the ground height size
  109483. * @param subdivisions sets the number of subdivision per side
  109484. * @param minHeight is the minimum altitude on the ground
  109485. * @param maxHeight is the maximum altitude on the ground
  109486. * @param scene defines the hosting scene
  109487. * @param updatable defines if the mesh must be flagged as updatable
  109488. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109489. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109490. * @returns a new Mesh
  109491. */
  109492. 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;
  109493. /**
  109494. * Creates a tube mesh.
  109495. * The tube is a parametric shape.
  109496. * It has no predefined shape. Its final shape will depend on the input parameters.
  109497. * Please consider using the same method from the MeshBuilder class instead
  109498. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109499. * @param name defines the name of the mesh to create
  109500. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109501. * @param radius sets the tube radius size
  109502. * @param tessellation is the number of sides on the tubular surface
  109503. * @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
  109504. * @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
  109505. * @param scene defines the hosting scene
  109506. * @param updatable defines if the mesh must be flagged as updatable
  109507. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109508. * @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)
  109509. * @returns a new Mesh
  109510. */
  109511. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109512. (i: number, distance: number): number;
  109513. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109514. /**
  109515. * Creates a polyhedron mesh.
  109516. * Please consider using the same method from the MeshBuilder class instead.
  109517. * * 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
  109518. * * The parameter `size` (positive float, default 1) sets the polygon size
  109519. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109520. * * 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`
  109521. * * 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
  109522. * * 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)`)
  109523. * * 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
  109524. * * 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
  109525. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109526. * * 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
  109527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109528. * @param name defines the name of the mesh to create
  109529. * @param options defines the options used to create the mesh
  109530. * @param scene defines the hosting scene
  109531. * @returns a new Mesh
  109532. */
  109533. static CreatePolyhedron(name: string, options: {
  109534. type?: number;
  109535. size?: number;
  109536. sizeX?: number;
  109537. sizeY?: number;
  109538. sizeZ?: number;
  109539. custom?: any;
  109540. faceUV?: Vector4[];
  109541. faceColors?: Color4[];
  109542. updatable?: boolean;
  109543. sideOrientation?: number;
  109544. }, scene: Scene): Mesh;
  109545. /**
  109546. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109547. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109548. * * 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`)
  109549. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109550. * * 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
  109551. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109552. * * 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
  109553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109554. * @param name defines the name of the mesh
  109555. * @param options defines the options used to create the mesh
  109556. * @param scene defines the hosting scene
  109557. * @returns a new Mesh
  109558. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109559. */
  109560. static CreateIcoSphere(name: string, options: {
  109561. radius?: number;
  109562. flat?: boolean;
  109563. subdivisions?: number;
  109564. sideOrientation?: number;
  109565. updatable?: boolean;
  109566. }, scene: Scene): Mesh;
  109567. /**
  109568. * Creates a decal mesh.
  109569. * Please consider using the same method from the MeshBuilder class instead.
  109570. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109571. * @param name defines the name of the mesh
  109572. * @param sourceMesh defines the mesh receiving the decal
  109573. * @param position sets the position of the decal in world coordinates
  109574. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109575. * @param size sets the decal scaling
  109576. * @param angle sets the angle to rotate the decal
  109577. * @returns a new Mesh
  109578. */
  109579. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109580. /** Creates a Capsule Mesh
  109581. * @param name defines the name of the mesh.
  109582. * @param options the constructors options used to shape the mesh.
  109583. * @param scene defines the scene the mesh is scoped to.
  109584. * @returns the capsule mesh
  109585. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109586. */
  109587. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109588. /**
  109589. * Prepare internal position array for software CPU skinning
  109590. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109591. */
  109592. setPositionsForCPUSkinning(): Float32Array;
  109593. /**
  109594. * Prepare internal normal array for software CPU skinning
  109595. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109596. */
  109597. setNormalsForCPUSkinning(): Float32Array;
  109598. /**
  109599. * Updates the vertex buffer by applying transformation from the bones
  109600. * @param skeleton defines the skeleton to apply to current mesh
  109601. * @returns the current mesh
  109602. */
  109603. applySkeleton(skeleton: Skeleton): Mesh;
  109604. /**
  109605. * 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
  109606. * @param meshes defines the list of meshes to scan
  109607. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109608. */
  109609. static MinMax(meshes: AbstractMesh[]): {
  109610. min: Vector3;
  109611. max: Vector3;
  109612. };
  109613. /**
  109614. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109615. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109616. * @returns a vector3
  109617. */
  109618. static Center(meshesOrMinMaxVector: {
  109619. min: Vector3;
  109620. max: Vector3;
  109621. } | AbstractMesh[]): Vector3;
  109622. /**
  109623. * Merge the array of meshes into a single mesh for performance reasons.
  109624. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109625. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109626. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109627. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109628. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109629. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109630. * @returns a new mesh
  109631. */
  109632. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109633. /** @hidden */
  109634. addInstance(instance: InstancedMesh): void;
  109635. /** @hidden */
  109636. removeInstance(instance: InstancedMesh): void;
  109637. }
  109638. }
  109639. declare module BABYLON {
  109640. /**
  109641. * This is the base class of all the camera used in the application.
  109642. * @see https://doc.babylonjs.com/features/cameras
  109643. */
  109644. export class Camera extends Node {
  109645. /** @hidden */
  109646. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109647. /**
  109648. * This is the default projection mode used by the cameras.
  109649. * It helps recreating a feeling of perspective and better appreciate depth.
  109650. * This is the best way to simulate real life cameras.
  109651. */
  109652. static readonly PERSPECTIVE_CAMERA: number;
  109653. /**
  109654. * This helps creating camera with an orthographic mode.
  109655. * 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.
  109656. */
  109657. static readonly ORTHOGRAPHIC_CAMERA: number;
  109658. /**
  109659. * This is the default FOV mode for perspective cameras.
  109660. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109661. */
  109662. static readonly FOVMODE_VERTICAL_FIXED: number;
  109663. /**
  109664. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109665. */
  109666. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109667. /**
  109668. * This specifies ther is no need for a camera rig.
  109669. * Basically only one eye is rendered corresponding to the camera.
  109670. */
  109671. static readonly RIG_MODE_NONE: number;
  109672. /**
  109673. * Simulates a camera Rig with one blue eye and one red eye.
  109674. * This can be use with 3d blue and red glasses.
  109675. */
  109676. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109677. /**
  109678. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109679. */
  109680. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109681. /**
  109682. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109683. */
  109684. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109685. /**
  109686. * Defines that both eyes of the camera will be rendered over under each other.
  109687. */
  109688. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109689. /**
  109690. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  109691. */
  109692. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  109693. /**
  109694. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  109695. */
  109696. static readonly RIG_MODE_VR: number;
  109697. /**
  109698. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  109699. */
  109700. static readonly RIG_MODE_WEBVR: number;
  109701. /**
  109702. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  109703. */
  109704. static readonly RIG_MODE_CUSTOM: number;
  109705. /**
  109706. * Defines if by default attaching controls should prevent the default javascript event to continue.
  109707. */
  109708. static ForceAttachControlToAlwaysPreventDefault: boolean;
  109709. /**
  109710. * Define the input manager associated with the camera.
  109711. */
  109712. inputs: CameraInputsManager<Camera>;
  109713. /** @hidden */
  109714. _position: Vector3;
  109715. /**
  109716. * Define the current local position of the camera in the scene
  109717. */
  109718. get position(): Vector3;
  109719. set position(newPosition: Vector3);
  109720. protected _upVector: Vector3;
  109721. /**
  109722. * The vector the camera should consider as up.
  109723. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  109724. */
  109725. set upVector(vec: Vector3);
  109726. get upVector(): Vector3;
  109727. /**
  109728. * Define the current limit on the left side for an orthographic camera
  109729. * In scene unit
  109730. */
  109731. orthoLeft: Nullable<number>;
  109732. /**
  109733. * Define the current limit on the right side for an orthographic camera
  109734. * In scene unit
  109735. */
  109736. orthoRight: Nullable<number>;
  109737. /**
  109738. * Define the current limit on the bottom side for an orthographic camera
  109739. * In scene unit
  109740. */
  109741. orthoBottom: Nullable<number>;
  109742. /**
  109743. * Define the current limit on the top side for an orthographic camera
  109744. * In scene unit
  109745. */
  109746. orthoTop: Nullable<number>;
  109747. /**
  109748. * Field Of View is set in Radians. (default is 0.8)
  109749. */
  109750. fov: number;
  109751. /**
  109752. * Define the minimum distance the camera can see from.
  109753. * This is important to note that the depth buffer are not infinite and the closer it starts
  109754. * the more your scene might encounter depth fighting issue.
  109755. */
  109756. minZ: number;
  109757. /**
  109758. * Define the maximum distance the camera can see to.
  109759. * This is important to note that the depth buffer are not infinite and the further it end
  109760. * the more your scene might encounter depth fighting issue.
  109761. */
  109762. maxZ: number;
  109763. /**
  109764. * Define the default inertia of the camera.
  109765. * This helps giving a smooth feeling to the camera movement.
  109766. */
  109767. inertia: number;
  109768. /**
  109769. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  109770. */
  109771. mode: number;
  109772. /**
  109773. * Define whether the camera is intermediate.
  109774. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  109775. */
  109776. isIntermediate: boolean;
  109777. /**
  109778. * Define the viewport of the camera.
  109779. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  109780. */
  109781. viewport: Viewport;
  109782. /**
  109783. * Restricts the camera to viewing objects with the same layerMask.
  109784. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  109785. */
  109786. layerMask: number;
  109787. /**
  109788. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  109789. */
  109790. fovMode: number;
  109791. /**
  109792. * Rig mode of the camera.
  109793. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  109794. * This is normally controlled byt the camera themselves as internal use.
  109795. */
  109796. cameraRigMode: number;
  109797. /**
  109798. * Defines the distance between both "eyes" in case of a RIG
  109799. */
  109800. interaxialDistance: number;
  109801. /**
  109802. * Defines if stereoscopic rendering is done side by side or over under.
  109803. */
  109804. isStereoscopicSideBySide: boolean;
  109805. /**
  109806. * 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
  109807. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  109808. * else in the scene. (Eg. security camera)
  109809. *
  109810. * 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)
  109811. */
  109812. customRenderTargets: RenderTargetTexture[];
  109813. /**
  109814. * When set, the camera will render to this render target instead of the default canvas
  109815. *
  109816. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  109817. */
  109818. outputRenderTarget: Nullable<RenderTargetTexture>;
  109819. /**
  109820. * Observable triggered when the camera view matrix has changed.
  109821. */
  109822. onViewMatrixChangedObservable: Observable<Camera>;
  109823. /**
  109824. * Observable triggered when the camera Projection matrix has changed.
  109825. */
  109826. onProjectionMatrixChangedObservable: Observable<Camera>;
  109827. /**
  109828. * Observable triggered when the inputs have been processed.
  109829. */
  109830. onAfterCheckInputsObservable: Observable<Camera>;
  109831. /**
  109832. * Observable triggered when reset has been called and applied to the camera.
  109833. */
  109834. onRestoreStateObservable: Observable<Camera>;
  109835. /**
  109836. * Is this camera a part of a rig system?
  109837. */
  109838. isRigCamera: boolean;
  109839. /**
  109840. * If isRigCamera set to true this will be set with the parent camera.
  109841. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  109842. */
  109843. rigParent?: Camera;
  109844. /** @hidden */
  109845. _cameraRigParams: any;
  109846. /** @hidden */
  109847. _rigCameras: Camera[];
  109848. /** @hidden */
  109849. _rigPostProcess: Nullable<PostProcess>;
  109850. protected _webvrViewMatrix: Matrix;
  109851. /** @hidden */
  109852. _skipRendering: boolean;
  109853. /** @hidden */
  109854. _projectionMatrix: Matrix;
  109855. /** @hidden */
  109856. _postProcesses: Nullable<PostProcess>[];
  109857. /** @hidden */
  109858. _activeMeshes: SmartArray<AbstractMesh>;
  109859. protected _globalPosition: Vector3;
  109860. /** @hidden */
  109861. _computedViewMatrix: Matrix;
  109862. private _doNotComputeProjectionMatrix;
  109863. private _transformMatrix;
  109864. private _frustumPlanes;
  109865. private _refreshFrustumPlanes;
  109866. private _storedFov;
  109867. private _stateStored;
  109868. /**
  109869. * Instantiates a new camera object.
  109870. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  109871. * @see https://doc.babylonjs.com/features/cameras
  109872. * @param name Defines the name of the camera in the scene
  109873. * @param position Defines the position of the camera
  109874. * @param scene Defines the scene the camera belongs too
  109875. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  109876. */
  109877. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  109878. /**
  109879. * Store current camera state (fov, position, etc..)
  109880. * @returns the camera
  109881. */
  109882. storeState(): Camera;
  109883. /**
  109884. * Restores the camera state values if it has been stored. You must call storeState() first
  109885. */
  109886. protected _restoreStateValues(): boolean;
  109887. /**
  109888. * Restored camera state. You must call storeState() first.
  109889. * @returns true if restored and false otherwise
  109890. */
  109891. restoreState(): boolean;
  109892. /**
  109893. * Gets the class name of the camera.
  109894. * @returns the class name
  109895. */
  109896. getClassName(): string;
  109897. /** @hidden */
  109898. readonly _isCamera: boolean;
  109899. /**
  109900. * Gets a string representation of the camera useful for debug purpose.
  109901. * @param fullDetails Defines that a more verboe level of logging is required
  109902. * @returns the string representation
  109903. */
  109904. toString(fullDetails?: boolean): string;
  109905. /**
  109906. * Gets the current world space position of the camera.
  109907. */
  109908. get globalPosition(): Vector3;
  109909. /**
  109910. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  109911. * @returns the active meshe list
  109912. */
  109913. getActiveMeshes(): SmartArray<AbstractMesh>;
  109914. /**
  109915. * Check whether a mesh is part of the current active mesh list of the camera
  109916. * @param mesh Defines the mesh to check
  109917. * @returns true if active, false otherwise
  109918. */
  109919. isActiveMesh(mesh: Mesh): boolean;
  109920. /**
  109921. * Is this camera ready to be used/rendered
  109922. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  109923. * @return true if the camera is ready
  109924. */
  109925. isReady(completeCheck?: boolean): boolean;
  109926. /** @hidden */
  109927. _initCache(): void;
  109928. /** @hidden */
  109929. _updateCache(ignoreParentClass?: boolean): void;
  109930. /** @hidden */
  109931. _isSynchronized(): boolean;
  109932. /** @hidden */
  109933. _isSynchronizedViewMatrix(): boolean;
  109934. /** @hidden */
  109935. _isSynchronizedProjectionMatrix(): boolean;
  109936. /**
  109937. * Attach the input controls to a specific dom element to get the input from.
  109938. * @param element Defines the element the controls should be listened from
  109939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  109940. */
  109941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  109942. /**
  109943. * Detach the current controls from the specified dom element.
  109944. * @param element Defines the element to stop listening the inputs from
  109945. */
  109946. detachControl(element: HTMLElement): void;
  109947. /**
  109948. * Update the camera state according to the different inputs gathered during the frame.
  109949. */
  109950. update(): void;
  109951. /** @hidden */
  109952. _checkInputs(): void;
  109953. /** @hidden */
  109954. get rigCameras(): Camera[];
  109955. /**
  109956. * Gets the post process used by the rig cameras
  109957. */
  109958. get rigPostProcess(): Nullable<PostProcess>;
  109959. /**
  109960. * Internal, gets the first post proces.
  109961. * @returns the first post process to be run on this camera.
  109962. */
  109963. _getFirstPostProcess(): Nullable<PostProcess>;
  109964. private _cascadePostProcessesToRigCams;
  109965. /**
  109966. * Attach a post process to the camera.
  109967. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109968. * @param postProcess The post process to attach to the camera
  109969. * @param insertAt The position of the post process in case several of them are in use in the scene
  109970. * @returns the position the post process has been inserted at
  109971. */
  109972. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  109973. /**
  109974. * Detach a post process to the camera.
  109975. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  109976. * @param postProcess The post process to detach from the camera
  109977. */
  109978. detachPostProcess(postProcess: PostProcess): void;
  109979. /**
  109980. * Gets the current world matrix of the camera
  109981. */
  109982. getWorldMatrix(): Matrix;
  109983. /** @hidden */
  109984. _getViewMatrix(): Matrix;
  109985. /**
  109986. * Gets the current view matrix of the camera.
  109987. * @param force forces the camera to recompute the matrix without looking at the cached state
  109988. * @returns the view matrix
  109989. */
  109990. getViewMatrix(force?: boolean): Matrix;
  109991. /**
  109992. * Freeze the projection matrix.
  109993. * It will prevent the cache check of the camera projection compute and can speed up perf
  109994. * if no parameter of the camera are meant to change
  109995. * @param projection Defines manually a projection if necessary
  109996. */
  109997. freezeProjectionMatrix(projection?: Matrix): void;
  109998. /**
  109999. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110000. */
  110001. unfreezeProjectionMatrix(): void;
  110002. /**
  110003. * Gets the current projection matrix of the camera.
  110004. * @param force forces the camera to recompute the matrix without looking at the cached state
  110005. * @returns the projection matrix
  110006. */
  110007. getProjectionMatrix(force?: boolean): Matrix;
  110008. /**
  110009. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110010. * @returns a Matrix
  110011. */
  110012. getTransformationMatrix(): Matrix;
  110013. private _updateFrustumPlanes;
  110014. /**
  110015. * Checks if a cullable object (mesh...) is in the camera frustum
  110016. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110017. * @param target The object to check
  110018. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110019. * @returns true if the object is in frustum otherwise false
  110020. */
  110021. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110022. /**
  110023. * Checks if a cullable object (mesh...) is in the camera frustum
  110024. * Unlike isInFrustum this cheks the full bounding box
  110025. * @param target The object to check
  110026. * @returns true if the object is in frustum otherwise false
  110027. */
  110028. isCompletelyInFrustum(target: ICullable): boolean;
  110029. /**
  110030. * Gets a ray in the forward direction from the camera.
  110031. * @param length Defines the length of the ray to create
  110032. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110033. * @param origin Defines the start point of the ray which defaults to the camera position
  110034. * @returns the forward ray
  110035. */
  110036. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110037. /**
  110038. * Gets a ray in the forward direction from the camera.
  110039. * @param refRay the ray to (re)use when setting the values
  110040. * @param length Defines the length of the ray to create
  110041. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110042. * @param origin Defines the start point of the ray which defaults to the camera position
  110043. * @returns the forward ray
  110044. */
  110045. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110046. /**
  110047. * Releases resources associated with this node.
  110048. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110049. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110050. */
  110051. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110052. /** @hidden */
  110053. _isLeftCamera: boolean;
  110054. /**
  110055. * Gets the left camera of a rig setup in case of Rigged Camera
  110056. */
  110057. get isLeftCamera(): boolean;
  110058. /** @hidden */
  110059. _isRightCamera: boolean;
  110060. /**
  110061. * Gets the right camera of a rig setup in case of Rigged Camera
  110062. */
  110063. get isRightCamera(): boolean;
  110064. /**
  110065. * Gets the left camera of a rig setup in case of Rigged Camera
  110066. */
  110067. get leftCamera(): Nullable<FreeCamera>;
  110068. /**
  110069. * Gets the right camera of a rig setup in case of Rigged Camera
  110070. */
  110071. get rightCamera(): Nullable<FreeCamera>;
  110072. /**
  110073. * Gets the left camera target of a rig setup in case of Rigged Camera
  110074. * @returns the target position
  110075. */
  110076. getLeftTarget(): Nullable<Vector3>;
  110077. /**
  110078. * Gets the right camera target of a rig setup in case of Rigged Camera
  110079. * @returns the target position
  110080. */
  110081. getRightTarget(): Nullable<Vector3>;
  110082. /**
  110083. * @hidden
  110084. */
  110085. setCameraRigMode(mode: number, rigParams: any): void;
  110086. /** @hidden */
  110087. static _setStereoscopicRigMode(camera: Camera): void;
  110088. /** @hidden */
  110089. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110090. /** @hidden */
  110091. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110092. /** @hidden */
  110093. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110094. /** @hidden */
  110095. _getVRProjectionMatrix(): Matrix;
  110096. protected _updateCameraRotationMatrix(): void;
  110097. protected _updateWebVRCameraRotationMatrix(): void;
  110098. /**
  110099. * This function MUST be overwritten by the different WebVR cameras available.
  110100. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110101. * @hidden
  110102. */
  110103. _getWebVRProjectionMatrix(): Matrix;
  110104. /**
  110105. * This function MUST be overwritten by the different WebVR cameras available.
  110106. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110107. * @hidden
  110108. */
  110109. _getWebVRViewMatrix(): Matrix;
  110110. /** @hidden */
  110111. setCameraRigParameter(name: string, value: any): void;
  110112. /**
  110113. * needs to be overridden by children so sub has required properties to be copied
  110114. * @hidden
  110115. */
  110116. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110117. /**
  110118. * May need to be overridden by children
  110119. * @hidden
  110120. */
  110121. _updateRigCameras(): void;
  110122. /** @hidden */
  110123. _setupInputs(): void;
  110124. /**
  110125. * Serialiaze the camera setup to a json represention
  110126. * @returns the JSON representation
  110127. */
  110128. serialize(): any;
  110129. /**
  110130. * Clones the current camera.
  110131. * @param name The cloned camera name
  110132. * @returns the cloned camera
  110133. */
  110134. clone(name: string): Camera;
  110135. /**
  110136. * Gets the direction of the camera relative to a given local axis.
  110137. * @param localAxis Defines the reference axis to provide a relative direction.
  110138. * @return the direction
  110139. */
  110140. getDirection(localAxis: Vector3): Vector3;
  110141. /**
  110142. * Returns the current camera absolute rotation
  110143. */
  110144. get absoluteRotation(): Quaternion;
  110145. /**
  110146. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110147. * @param localAxis Defines the reference axis to provide a relative direction.
  110148. * @param result Defines the vector to store the result in
  110149. */
  110150. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110151. /**
  110152. * Gets a camera constructor for a given camera type
  110153. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110154. * @param name The name of the camera the result will be able to instantiate
  110155. * @param scene The scene the result will construct the camera in
  110156. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110157. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110158. * @returns a factory method to construc the camera
  110159. */
  110160. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110161. /**
  110162. * Compute the world matrix of the camera.
  110163. * @returns the camera world matrix
  110164. */
  110165. computeWorldMatrix(): Matrix;
  110166. /**
  110167. * Parse a JSON and creates the camera from the parsed information
  110168. * @param parsedCamera The JSON to parse
  110169. * @param scene The scene to instantiate the camera in
  110170. * @returns the newly constructed camera
  110171. */
  110172. static Parse(parsedCamera: any, scene: Scene): Camera;
  110173. }
  110174. }
  110175. declare module BABYLON {
  110176. /**
  110177. * Class containing static functions to help procedurally build meshes
  110178. */
  110179. export class DiscBuilder {
  110180. /**
  110181. * Creates a plane polygonal mesh. By default, this is a disc
  110182. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110183. * * 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
  110184. * * 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
  110185. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110186. * * 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
  110187. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110188. * @param name defines the name of the mesh
  110189. * @param options defines the options used to create the mesh
  110190. * @param scene defines the hosting scene
  110191. * @returns the plane polygonal mesh
  110192. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110193. */
  110194. static CreateDisc(name: string, options: {
  110195. radius?: number;
  110196. tessellation?: number;
  110197. arc?: number;
  110198. updatable?: boolean;
  110199. sideOrientation?: number;
  110200. frontUVs?: Vector4;
  110201. backUVs?: Vector4;
  110202. }, scene?: Nullable<Scene>): Mesh;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * Options to be used when creating a FresnelParameters.
  110208. */
  110209. export type IFresnelParametersCreationOptions = {
  110210. /**
  110211. * Define the color used on edges (grazing angle)
  110212. */
  110213. leftColor?: Color3;
  110214. /**
  110215. * Define the color used on center
  110216. */
  110217. rightColor?: Color3;
  110218. /**
  110219. * Define bias applied to computed fresnel term
  110220. */
  110221. bias?: number;
  110222. /**
  110223. * Defined the power exponent applied to fresnel term
  110224. */
  110225. power?: number;
  110226. /**
  110227. * Define if the fresnel effect is enable or not.
  110228. */
  110229. isEnabled?: boolean;
  110230. };
  110231. /**
  110232. * Serialized format for FresnelParameters.
  110233. */
  110234. export type IFresnelParametersSerialized = {
  110235. /**
  110236. * Define the color used on edges (grazing angle) [as an array]
  110237. */
  110238. leftColor: number[];
  110239. /**
  110240. * Define the color used on center [as an array]
  110241. */
  110242. rightColor: number[];
  110243. /**
  110244. * Define bias applied to computed fresnel term
  110245. */
  110246. bias: number;
  110247. /**
  110248. * Defined the power exponent applied to fresnel term
  110249. */
  110250. power?: number;
  110251. /**
  110252. * Define if the fresnel effect is enable or not.
  110253. */
  110254. isEnabled: boolean;
  110255. };
  110256. /**
  110257. * This represents all the required information to add a fresnel effect on a material:
  110258. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110259. */
  110260. export class FresnelParameters {
  110261. private _isEnabled;
  110262. /**
  110263. * Define if the fresnel effect is enable or not.
  110264. */
  110265. get isEnabled(): boolean;
  110266. set isEnabled(value: boolean);
  110267. /**
  110268. * Define the color used on edges (grazing angle)
  110269. */
  110270. leftColor: Color3;
  110271. /**
  110272. * Define the color used on center
  110273. */
  110274. rightColor: Color3;
  110275. /**
  110276. * Define bias applied to computed fresnel term
  110277. */
  110278. bias: number;
  110279. /**
  110280. * Defined the power exponent applied to fresnel term
  110281. */
  110282. power: number;
  110283. /**
  110284. * Creates a new FresnelParameters object.
  110285. *
  110286. * @param options provide your own settings to optionally to override defaults
  110287. */
  110288. constructor(options?: IFresnelParametersCreationOptions);
  110289. /**
  110290. * Clones the current fresnel and its valuues
  110291. * @returns a clone fresnel configuration
  110292. */
  110293. clone(): FresnelParameters;
  110294. /**
  110295. * Determines equality between FresnelParameters objects
  110296. * @param otherFresnelParameters defines the second operand
  110297. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110298. */
  110299. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110300. /**
  110301. * Serializes the current fresnel parameters to a JSON representation.
  110302. * @return the JSON serialization
  110303. */
  110304. serialize(): IFresnelParametersSerialized;
  110305. /**
  110306. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110307. * @param parsedFresnelParameters Define the JSON representation
  110308. * @returns the parsed parameters
  110309. */
  110310. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110311. }
  110312. }
  110313. declare module BABYLON {
  110314. /**
  110315. * This groups all the flags used to control the materials channel.
  110316. */
  110317. export class MaterialFlags {
  110318. private static _DiffuseTextureEnabled;
  110319. /**
  110320. * Are diffuse textures enabled in the application.
  110321. */
  110322. static get DiffuseTextureEnabled(): boolean;
  110323. static set DiffuseTextureEnabled(value: boolean);
  110324. private static _DetailTextureEnabled;
  110325. /**
  110326. * Are detail textures enabled in the application.
  110327. */
  110328. static get DetailTextureEnabled(): boolean;
  110329. static set DetailTextureEnabled(value: boolean);
  110330. private static _AmbientTextureEnabled;
  110331. /**
  110332. * Are ambient textures enabled in the application.
  110333. */
  110334. static get AmbientTextureEnabled(): boolean;
  110335. static set AmbientTextureEnabled(value: boolean);
  110336. private static _OpacityTextureEnabled;
  110337. /**
  110338. * Are opacity textures enabled in the application.
  110339. */
  110340. static get OpacityTextureEnabled(): boolean;
  110341. static set OpacityTextureEnabled(value: boolean);
  110342. private static _ReflectionTextureEnabled;
  110343. /**
  110344. * Are reflection textures enabled in the application.
  110345. */
  110346. static get ReflectionTextureEnabled(): boolean;
  110347. static set ReflectionTextureEnabled(value: boolean);
  110348. private static _EmissiveTextureEnabled;
  110349. /**
  110350. * Are emissive textures enabled in the application.
  110351. */
  110352. static get EmissiveTextureEnabled(): boolean;
  110353. static set EmissiveTextureEnabled(value: boolean);
  110354. private static _SpecularTextureEnabled;
  110355. /**
  110356. * Are specular textures enabled in the application.
  110357. */
  110358. static get SpecularTextureEnabled(): boolean;
  110359. static set SpecularTextureEnabled(value: boolean);
  110360. private static _BumpTextureEnabled;
  110361. /**
  110362. * Are bump textures enabled in the application.
  110363. */
  110364. static get BumpTextureEnabled(): boolean;
  110365. static set BumpTextureEnabled(value: boolean);
  110366. private static _LightmapTextureEnabled;
  110367. /**
  110368. * Are lightmap textures enabled in the application.
  110369. */
  110370. static get LightmapTextureEnabled(): boolean;
  110371. static set LightmapTextureEnabled(value: boolean);
  110372. private static _RefractionTextureEnabled;
  110373. /**
  110374. * Are refraction textures enabled in the application.
  110375. */
  110376. static get RefractionTextureEnabled(): boolean;
  110377. static set RefractionTextureEnabled(value: boolean);
  110378. private static _ColorGradingTextureEnabled;
  110379. /**
  110380. * Are color grading textures enabled in the application.
  110381. */
  110382. static get ColorGradingTextureEnabled(): boolean;
  110383. static set ColorGradingTextureEnabled(value: boolean);
  110384. private static _FresnelEnabled;
  110385. /**
  110386. * Are fresnels enabled in the application.
  110387. */
  110388. static get FresnelEnabled(): boolean;
  110389. static set FresnelEnabled(value: boolean);
  110390. private static _ClearCoatTextureEnabled;
  110391. /**
  110392. * Are clear coat textures enabled in the application.
  110393. */
  110394. static get ClearCoatTextureEnabled(): boolean;
  110395. static set ClearCoatTextureEnabled(value: boolean);
  110396. private static _ClearCoatBumpTextureEnabled;
  110397. /**
  110398. * Are clear coat bump textures enabled in the application.
  110399. */
  110400. static get ClearCoatBumpTextureEnabled(): boolean;
  110401. static set ClearCoatBumpTextureEnabled(value: boolean);
  110402. private static _ClearCoatTintTextureEnabled;
  110403. /**
  110404. * Are clear coat tint textures enabled in the application.
  110405. */
  110406. static get ClearCoatTintTextureEnabled(): boolean;
  110407. static set ClearCoatTintTextureEnabled(value: boolean);
  110408. private static _SheenTextureEnabled;
  110409. /**
  110410. * Are sheen textures enabled in the application.
  110411. */
  110412. static get SheenTextureEnabled(): boolean;
  110413. static set SheenTextureEnabled(value: boolean);
  110414. private static _AnisotropicTextureEnabled;
  110415. /**
  110416. * Are anisotropic textures enabled in the application.
  110417. */
  110418. static get AnisotropicTextureEnabled(): boolean;
  110419. static set AnisotropicTextureEnabled(value: boolean);
  110420. private static _ThicknessTextureEnabled;
  110421. /**
  110422. * Are thickness textures enabled in the application.
  110423. */
  110424. static get ThicknessTextureEnabled(): boolean;
  110425. static set ThicknessTextureEnabled(value: boolean);
  110426. }
  110427. }
  110428. declare module BABYLON {
  110429. /** @hidden */
  110430. export var defaultFragmentDeclaration: {
  110431. name: string;
  110432. shader: string;
  110433. };
  110434. }
  110435. declare module BABYLON {
  110436. /** @hidden */
  110437. export var defaultUboDeclaration: {
  110438. name: string;
  110439. shader: string;
  110440. };
  110441. }
  110442. declare module BABYLON {
  110443. /** @hidden */
  110444. export var prePassDeclaration: {
  110445. name: string;
  110446. shader: string;
  110447. };
  110448. }
  110449. declare module BABYLON {
  110450. /** @hidden */
  110451. export var lightFragmentDeclaration: {
  110452. name: string;
  110453. shader: string;
  110454. };
  110455. }
  110456. declare module BABYLON {
  110457. /** @hidden */
  110458. export var lightUboDeclaration: {
  110459. name: string;
  110460. shader: string;
  110461. };
  110462. }
  110463. declare module BABYLON {
  110464. /** @hidden */
  110465. export var lightsFragmentFunctions: {
  110466. name: string;
  110467. shader: string;
  110468. };
  110469. }
  110470. declare module BABYLON {
  110471. /** @hidden */
  110472. export var shadowsFragmentFunctions: {
  110473. name: string;
  110474. shader: string;
  110475. };
  110476. }
  110477. declare module BABYLON {
  110478. /** @hidden */
  110479. export var fresnelFunction: {
  110480. name: string;
  110481. shader: string;
  110482. };
  110483. }
  110484. declare module BABYLON {
  110485. /** @hidden */
  110486. export var bumpFragmentMainFunctions: {
  110487. name: string;
  110488. shader: string;
  110489. };
  110490. }
  110491. declare module BABYLON {
  110492. /** @hidden */
  110493. export var bumpFragmentFunctions: {
  110494. name: string;
  110495. shader: string;
  110496. };
  110497. }
  110498. declare module BABYLON {
  110499. /** @hidden */
  110500. export var logDepthDeclaration: {
  110501. name: string;
  110502. shader: string;
  110503. };
  110504. }
  110505. declare module BABYLON {
  110506. /** @hidden */
  110507. export var bumpFragment: {
  110508. name: string;
  110509. shader: string;
  110510. };
  110511. }
  110512. declare module BABYLON {
  110513. /** @hidden */
  110514. export var depthPrePass: {
  110515. name: string;
  110516. shader: string;
  110517. };
  110518. }
  110519. declare module BABYLON {
  110520. /** @hidden */
  110521. export var lightFragment: {
  110522. name: string;
  110523. shader: string;
  110524. };
  110525. }
  110526. declare module BABYLON {
  110527. /** @hidden */
  110528. export var logDepthFragment: {
  110529. name: string;
  110530. shader: string;
  110531. };
  110532. }
  110533. declare module BABYLON {
  110534. /** @hidden */
  110535. export var defaultPixelShader: {
  110536. name: string;
  110537. shader: string;
  110538. };
  110539. }
  110540. declare module BABYLON {
  110541. /** @hidden */
  110542. export var defaultVertexDeclaration: {
  110543. name: string;
  110544. shader: string;
  110545. };
  110546. }
  110547. declare module BABYLON {
  110548. /** @hidden */
  110549. export var bumpVertexDeclaration: {
  110550. name: string;
  110551. shader: string;
  110552. };
  110553. }
  110554. declare module BABYLON {
  110555. /** @hidden */
  110556. export var bumpVertex: {
  110557. name: string;
  110558. shader: string;
  110559. };
  110560. }
  110561. declare module BABYLON {
  110562. /** @hidden */
  110563. export var fogVertex: {
  110564. name: string;
  110565. shader: string;
  110566. };
  110567. }
  110568. declare module BABYLON {
  110569. /** @hidden */
  110570. export var shadowsVertex: {
  110571. name: string;
  110572. shader: string;
  110573. };
  110574. }
  110575. declare module BABYLON {
  110576. /** @hidden */
  110577. export var pointCloudVertex: {
  110578. name: string;
  110579. shader: string;
  110580. };
  110581. }
  110582. declare module BABYLON {
  110583. /** @hidden */
  110584. export var logDepthVertex: {
  110585. name: string;
  110586. shader: string;
  110587. };
  110588. }
  110589. declare module BABYLON {
  110590. /** @hidden */
  110591. export var defaultVertexShader: {
  110592. name: string;
  110593. shader: string;
  110594. };
  110595. }
  110596. declare module BABYLON {
  110597. /**
  110598. * @hidden
  110599. */
  110600. export interface IMaterialDetailMapDefines {
  110601. DETAIL: boolean;
  110602. DETAILDIRECTUV: number;
  110603. DETAIL_NORMALBLENDMETHOD: number;
  110604. /** @hidden */
  110605. _areTexturesDirty: boolean;
  110606. }
  110607. /**
  110608. * Define the code related to the detail map parameters of a material
  110609. *
  110610. * Inspired from:
  110611. * 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
  110612. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110613. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110614. */
  110615. export class DetailMapConfiguration {
  110616. private _texture;
  110617. /**
  110618. * The detail texture of the material.
  110619. */
  110620. texture: Nullable<BaseTexture>;
  110621. /**
  110622. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110623. * Bigger values mean stronger blending
  110624. */
  110625. diffuseBlendLevel: number;
  110626. /**
  110627. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110628. * Bigger values mean stronger blending. Only used with PBR materials
  110629. */
  110630. roughnessBlendLevel: number;
  110631. /**
  110632. * Defines how strong the bump effect from the detail map is
  110633. * Bigger values mean stronger effect
  110634. */
  110635. bumpLevel: number;
  110636. private _normalBlendMethod;
  110637. /**
  110638. * The method used to blend the bump and detail normals together
  110639. */
  110640. normalBlendMethod: number;
  110641. private _isEnabled;
  110642. /**
  110643. * Enable or disable the detail map on this material
  110644. */
  110645. isEnabled: boolean;
  110646. /** @hidden */
  110647. private _internalMarkAllSubMeshesAsTexturesDirty;
  110648. /** @hidden */
  110649. _markAllSubMeshesAsTexturesDirty(): void;
  110650. /**
  110651. * Instantiate a new detail map
  110652. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110653. */
  110654. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110655. /**
  110656. * Gets whether the submesh is ready to be used or not.
  110657. * @param defines the list of "defines" to update.
  110658. * @param scene defines the scene the material belongs to.
  110659. * @returns - boolean indicating that the submesh is ready or not.
  110660. */
  110661. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110662. /**
  110663. * Update the defines for detail map usage
  110664. * @param defines the list of "defines" to update.
  110665. * @param scene defines the scene the material belongs to.
  110666. */
  110667. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110668. /**
  110669. * Binds the material data.
  110670. * @param uniformBuffer defines the Uniform buffer to fill in.
  110671. * @param scene defines the scene the material belongs to.
  110672. * @param isFrozen defines whether the material is frozen or not.
  110673. */
  110674. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110675. /**
  110676. * Checks to see if a texture is used in the material.
  110677. * @param texture - Base texture to use.
  110678. * @returns - Boolean specifying if a texture is used in the material.
  110679. */
  110680. hasTexture(texture: BaseTexture): boolean;
  110681. /**
  110682. * Returns an array of the actively used textures.
  110683. * @param activeTextures Array of BaseTextures
  110684. */
  110685. getActiveTextures(activeTextures: BaseTexture[]): void;
  110686. /**
  110687. * Returns the animatable textures.
  110688. * @param animatables Array of animatable textures.
  110689. */
  110690. getAnimatables(animatables: IAnimatable[]): void;
  110691. /**
  110692. * Disposes the resources of the material.
  110693. * @param forceDisposeTextures - Forces the disposal of all textures.
  110694. */
  110695. dispose(forceDisposeTextures?: boolean): void;
  110696. /**
  110697. * Get the current class name useful for serialization or dynamic coding.
  110698. * @returns "DetailMap"
  110699. */
  110700. getClassName(): string;
  110701. /**
  110702. * Add the required uniforms to the current list.
  110703. * @param uniforms defines the current uniform list.
  110704. */
  110705. static AddUniforms(uniforms: string[]): void;
  110706. /**
  110707. * Add the required samplers to the current list.
  110708. * @param samplers defines the current sampler list.
  110709. */
  110710. static AddSamplers(samplers: string[]): void;
  110711. /**
  110712. * Add the required uniforms to the current buffer.
  110713. * @param uniformBuffer defines the current uniform buffer.
  110714. */
  110715. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  110716. /**
  110717. * Makes a duplicate of the current instance into another one.
  110718. * @param detailMap define the instance where to copy the info
  110719. */
  110720. copyTo(detailMap: DetailMapConfiguration): void;
  110721. /**
  110722. * Serializes this detail map instance
  110723. * @returns - An object with the serialized instance.
  110724. */
  110725. serialize(): any;
  110726. /**
  110727. * Parses a detail map setting from a serialized object.
  110728. * @param source - Serialized object.
  110729. * @param scene Defines the scene we are parsing for
  110730. * @param rootUrl Defines the rootUrl to load from
  110731. */
  110732. parse(source: any, scene: Scene, rootUrl: string): void;
  110733. }
  110734. }
  110735. declare module BABYLON {
  110736. /** @hidden */
  110737. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  110738. MAINUV1: boolean;
  110739. MAINUV2: boolean;
  110740. DIFFUSE: boolean;
  110741. DIFFUSEDIRECTUV: number;
  110742. DETAIL: boolean;
  110743. DETAILDIRECTUV: number;
  110744. DETAIL_NORMALBLENDMETHOD: number;
  110745. AMBIENT: boolean;
  110746. AMBIENTDIRECTUV: number;
  110747. OPACITY: boolean;
  110748. OPACITYDIRECTUV: number;
  110749. OPACITYRGB: boolean;
  110750. REFLECTION: boolean;
  110751. EMISSIVE: boolean;
  110752. EMISSIVEDIRECTUV: number;
  110753. SPECULAR: boolean;
  110754. SPECULARDIRECTUV: number;
  110755. BUMP: boolean;
  110756. BUMPDIRECTUV: number;
  110757. PARALLAX: boolean;
  110758. PARALLAXOCCLUSION: boolean;
  110759. SPECULAROVERALPHA: boolean;
  110760. CLIPPLANE: boolean;
  110761. CLIPPLANE2: boolean;
  110762. CLIPPLANE3: boolean;
  110763. CLIPPLANE4: boolean;
  110764. CLIPPLANE5: boolean;
  110765. CLIPPLANE6: boolean;
  110766. ALPHATEST: boolean;
  110767. DEPTHPREPASS: boolean;
  110768. ALPHAFROMDIFFUSE: boolean;
  110769. POINTSIZE: boolean;
  110770. FOG: boolean;
  110771. SPECULARTERM: boolean;
  110772. DIFFUSEFRESNEL: boolean;
  110773. OPACITYFRESNEL: boolean;
  110774. REFLECTIONFRESNEL: boolean;
  110775. REFRACTIONFRESNEL: boolean;
  110776. EMISSIVEFRESNEL: boolean;
  110777. FRESNEL: boolean;
  110778. NORMAL: boolean;
  110779. UV1: boolean;
  110780. UV2: boolean;
  110781. VERTEXCOLOR: boolean;
  110782. VERTEXALPHA: boolean;
  110783. NUM_BONE_INFLUENCERS: number;
  110784. BonesPerMesh: number;
  110785. BONETEXTURE: boolean;
  110786. INSTANCES: boolean;
  110787. THIN_INSTANCES: boolean;
  110788. GLOSSINESS: boolean;
  110789. ROUGHNESS: boolean;
  110790. EMISSIVEASILLUMINATION: boolean;
  110791. LINKEMISSIVEWITHDIFFUSE: boolean;
  110792. REFLECTIONFRESNELFROMSPECULAR: boolean;
  110793. LIGHTMAP: boolean;
  110794. LIGHTMAPDIRECTUV: number;
  110795. OBJECTSPACE_NORMALMAP: boolean;
  110796. USELIGHTMAPASSHADOWMAP: boolean;
  110797. REFLECTIONMAP_3D: boolean;
  110798. REFLECTIONMAP_SPHERICAL: boolean;
  110799. REFLECTIONMAP_PLANAR: boolean;
  110800. REFLECTIONMAP_CUBIC: boolean;
  110801. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  110802. REFLECTIONMAP_PROJECTION: boolean;
  110803. REFLECTIONMAP_SKYBOX: boolean;
  110804. REFLECTIONMAP_EXPLICIT: boolean;
  110805. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  110806. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  110807. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  110808. INVERTCUBICMAP: boolean;
  110809. LOGARITHMICDEPTH: boolean;
  110810. REFRACTION: boolean;
  110811. REFRACTIONMAP_3D: boolean;
  110812. REFLECTIONOVERALPHA: boolean;
  110813. TWOSIDEDLIGHTING: boolean;
  110814. SHADOWFLOAT: boolean;
  110815. MORPHTARGETS: boolean;
  110816. MORPHTARGETS_NORMAL: boolean;
  110817. MORPHTARGETS_TANGENT: boolean;
  110818. MORPHTARGETS_UV: boolean;
  110819. NUM_MORPH_INFLUENCERS: number;
  110820. NONUNIFORMSCALING: boolean;
  110821. PREMULTIPLYALPHA: boolean;
  110822. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  110823. ALPHABLEND: boolean;
  110824. PREPASS: boolean;
  110825. PREPASS_IRRADIANCE: boolean;
  110826. PREPASS_IRRADIANCE_INDEX: number;
  110827. PREPASS_ALBEDO: boolean;
  110828. PREPASS_ALBEDO_INDEX: number;
  110829. PREPASS_DEPTHNORMAL: boolean;
  110830. PREPASS_DEPTHNORMAL_INDEX: number;
  110831. SCENE_MRT_COUNT: number;
  110832. RGBDLIGHTMAP: boolean;
  110833. RGBDREFLECTION: boolean;
  110834. RGBDREFRACTION: boolean;
  110835. IMAGEPROCESSING: boolean;
  110836. VIGNETTE: boolean;
  110837. VIGNETTEBLENDMODEMULTIPLY: boolean;
  110838. VIGNETTEBLENDMODEOPAQUE: boolean;
  110839. TONEMAPPING: boolean;
  110840. TONEMAPPING_ACES: boolean;
  110841. CONTRAST: boolean;
  110842. COLORCURVES: boolean;
  110843. COLORGRADING: boolean;
  110844. COLORGRADING3D: boolean;
  110845. SAMPLER3DGREENDEPTH: boolean;
  110846. SAMPLER3DBGRMAP: boolean;
  110847. IMAGEPROCESSINGPOSTPROCESS: boolean;
  110848. MULTIVIEW: boolean;
  110849. /**
  110850. * If the reflection texture on this material is in linear color space
  110851. * @hidden
  110852. */
  110853. IS_REFLECTION_LINEAR: boolean;
  110854. /**
  110855. * If the refraction texture on this material is in linear color space
  110856. * @hidden
  110857. */
  110858. IS_REFRACTION_LINEAR: boolean;
  110859. EXPOSURE: boolean;
  110860. constructor();
  110861. setReflectionMode(modeToEnable: string): void;
  110862. }
  110863. /**
  110864. * This is the default material used in Babylon. It is the best trade off between quality
  110865. * and performances.
  110866. * @see https://doc.babylonjs.com/babylon101/materials
  110867. */
  110868. export class StandardMaterial extends PushMaterial {
  110869. private _diffuseTexture;
  110870. /**
  110871. * The basic texture of the material as viewed under a light.
  110872. */
  110873. diffuseTexture: Nullable<BaseTexture>;
  110874. private _ambientTexture;
  110875. /**
  110876. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  110877. */
  110878. ambientTexture: Nullable<BaseTexture>;
  110879. private _opacityTexture;
  110880. /**
  110881. * Define the transparency of the material from a texture.
  110882. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  110883. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  110884. */
  110885. opacityTexture: Nullable<BaseTexture>;
  110886. private _reflectionTexture;
  110887. /**
  110888. * Define the texture used to display the reflection.
  110889. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110890. */
  110891. reflectionTexture: Nullable<BaseTexture>;
  110892. private _emissiveTexture;
  110893. /**
  110894. * Define texture of the material as if self lit.
  110895. * This will be mixed in the final result even in the absence of light.
  110896. */
  110897. emissiveTexture: Nullable<BaseTexture>;
  110898. private _specularTexture;
  110899. /**
  110900. * Define how the color and intensity of the highlight given by the light in the material.
  110901. */
  110902. specularTexture: Nullable<BaseTexture>;
  110903. private _bumpTexture;
  110904. /**
  110905. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  110906. * 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.
  110907. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  110908. */
  110909. bumpTexture: Nullable<BaseTexture>;
  110910. private _lightmapTexture;
  110911. /**
  110912. * Complex lighting can be computationally expensive to compute at runtime.
  110913. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  110914. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  110915. */
  110916. lightmapTexture: Nullable<BaseTexture>;
  110917. private _refractionTexture;
  110918. /**
  110919. * Define the texture used to display the refraction.
  110920. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  110921. */
  110922. refractionTexture: Nullable<BaseTexture>;
  110923. /**
  110924. * The color of the material lit by the environmental background lighting.
  110925. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  110926. */
  110927. ambientColor: Color3;
  110928. /**
  110929. * The basic color of the material as viewed under a light.
  110930. */
  110931. diffuseColor: Color3;
  110932. /**
  110933. * Define how the color and intensity of the highlight given by the light in the material.
  110934. */
  110935. specularColor: Color3;
  110936. /**
  110937. * Define the color of the material as if self lit.
  110938. * This will be mixed in the final result even in the absence of light.
  110939. */
  110940. emissiveColor: Color3;
  110941. /**
  110942. * Defines how sharp are the highlights in the material.
  110943. * The bigger the value the sharper giving a more glossy feeling to the result.
  110944. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  110945. */
  110946. specularPower: number;
  110947. private _useAlphaFromDiffuseTexture;
  110948. /**
  110949. * Does the transparency come from the diffuse texture alpha channel.
  110950. */
  110951. useAlphaFromDiffuseTexture: boolean;
  110952. private _useEmissiveAsIllumination;
  110953. /**
  110954. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  110955. */
  110956. useEmissiveAsIllumination: boolean;
  110957. private _linkEmissiveWithDiffuse;
  110958. /**
  110959. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  110960. * the emissive level when the final color is close to one.
  110961. */
  110962. linkEmissiveWithDiffuse: boolean;
  110963. private _useSpecularOverAlpha;
  110964. /**
  110965. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  110966. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  110967. */
  110968. useSpecularOverAlpha: boolean;
  110969. private _useReflectionOverAlpha;
  110970. /**
  110971. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  110972. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  110973. */
  110974. useReflectionOverAlpha: boolean;
  110975. private _disableLighting;
  110976. /**
  110977. * Does lights from the scene impacts this material.
  110978. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  110979. */
  110980. disableLighting: boolean;
  110981. private _useObjectSpaceNormalMap;
  110982. /**
  110983. * Allows using an object space normal map (instead of tangent space).
  110984. */
  110985. useObjectSpaceNormalMap: boolean;
  110986. private _useParallax;
  110987. /**
  110988. * Is parallax enabled or not.
  110989. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110990. */
  110991. useParallax: boolean;
  110992. private _useParallaxOcclusion;
  110993. /**
  110994. * Is parallax occlusion enabled or not.
  110995. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  110996. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  110997. */
  110998. useParallaxOcclusion: boolean;
  110999. /**
  111000. * 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.
  111001. */
  111002. parallaxScaleBias: number;
  111003. private _roughness;
  111004. /**
  111005. * Helps to define how blurry the reflections should appears in the material.
  111006. */
  111007. roughness: number;
  111008. /**
  111009. * In case of refraction, define the value of the index of refraction.
  111010. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111011. */
  111012. indexOfRefraction: number;
  111013. /**
  111014. * Invert the refraction texture alongside the y axis.
  111015. * It can be useful with procedural textures or probe for instance.
  111016. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111017. */
  111018. invertRefractionY: boolean;
  111019. /**
  111020. * Defines the alpha limits in alpha test mode.
  111021. */
  111022. alphaCutOff: number;
  111023. private _useLightmapAsShadowmap;
  111024. /**
  111025. * In case of light mapping, define whether the map contains light or shadow informations.
  111026. */
  111027. useLightmapAsShadowmap: boolean;
  111028. private _diffuseFresnelParameters;
  111029. /**
  111030. * Define the diffuse fresnel parameters of the material.
  111031. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111032. */
  111033. diffuseFresnelParameters: FresnelParameters;
  111034. private _opacityFresnelParameters;
  111035. /**
  111036. * Define the opacity fresnel parameters of the material.
  111037. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111038. */
  111039. opacityFresnelParameters: FresnelParameters;
  111040. private _reflectionFresnelParameters;
  111041. /**
  111042. * Define the reflection fresnel parameters of the material.
  111043. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111044. */
  111045. reflectionFresnelParameters: FresnelParameters;
  111046. private _refractionFresnelParameters;
  111047. /**
  111048. * Define the refraction fresnel parameters of the material.
  111049. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111050. */
  111051. refractionFresnelParameters: FresnelParameters;
  111052. private _emissiveFresnelParameters;
  111053. /**
  111054. * Define the emissive fresnel parameters of the material.
  111055. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111056. */
  111057. emissiveFresnelParameters: FresnelParameters;
  111058. private _useReflectionFresnelFromSpecular;
  111059. /**
  111060. * If true automatically deducts the fresnels values from the material specularity.
  111061. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111062. */
  111063. useReflectionFresnelFromSpecular: boolean;
  111064. private _useGlossinessFromSpecularMapAlpha;
  111065. /**
  111066. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111067. */
  111068. useGlossinessFromSpecularMapAlpha: boolean;
  111069. private _maxSimultaneousLights;
  111070. /**
  111071. * Defines the maximum number of lights that can be used in the material
  111072. */
  111073. maxSimultaneousLights: number;
  111074. private _invertNormalMapX;
  111075. /**
  111076. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111077. */
  111078. invertNormalMapX: boolean;
  111079. private _invertNormalMapY;
  111080. /**
  111081. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111082. */
  111083. invertNormalMapY: boolean;
  111084. private _twoSidedLighting;
  111085. /**
  111086. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111087. */
  111088. twoSidedLighting: boolean;
  111089. /**
  111090. * Default configuration related to image processing available in the standard Material.
  111091. */
  111092. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111093. /**
  111094. * Gets the image processing configuration used either in this material.
  111095. */
  111096. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111097. /**
  111098. * Sets the Default image processing configuration used either in the this material.
  111099. *
  111100. * If sets to null, the scene one is in use.
  111101. */
  111102. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111103. /**
  111104. * Keep track of the image processing observer to allow dispose and replace.
  111105. */
  111106. private _imageProcessingObserver;
  111107. /**
  111108. * Attaches a new image processing configuration to the Standard Material.
  111109. * @param configuration
  111110. */
  111111. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111112. /**
  111113. * Gets wether the color curves effect is enabled.
  111114. */
  111115. get cameraColorCurvesEnabled(): boolean;
  111116. /**
  111117. * Sets wether the color curves effect is enabled.
  111118. */
  111119. set cameraColorCurvesEnabled(value: boolean);
  111120. /**
  111121. * Gets wether the color grading effect is enabled.
  111122. */
  111123. get cameraColorGradingEnabled(): boolean;
  111124. /**
  111125. * Gets wether the color grading effect is enabled.
  111126. */
  111127. set cameraColorGradingEnabled(value: boolean);
  111128. /**
  111129. * Gets wether tonemapping is enabled or not.
  111130. */
  111131. get cameraToneMappingEnabled(): boolean;
  111132. /**
  111133. * Sets wether tonemapping is enabled or not
  111134. */
  111135. set cameraToneMappingEnabled(value: boolean);
  111136. /**
  111137. * The camera exposure used on this material.
  111138. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111139. * This corresponds to a photographic exposure.
  111140. */
  111141. get cameraExposure(): number;
  111142. /**
  111143. * The camera exposure used on this material.
  111144. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111145. * This corresponds to a photographic exposure.
  111146. */
  111147. set cameraExposure(value: number);
  111148. /**
  111149. * Gets The camera contrast used on this material.
  111150. */
  111151. get cameraContrast(): number;
  111152. /**
  111153. * Sets The camera contrast used on this material.
  111154. */
  111155. set cameraContrast(value: number);
  111156. /**
  111157. * Gets the Color Grading 2D Lookup Texture.
  111158. */
  111159. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111160. /**
  111161. * Sets the Color Grading 2D Lookup Texture.
  111162. */
  111163. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111164. /**
  111165. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111166. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111167. * 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;
  111168. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111169. */
  111170. get cameraColorCurves(): Nullable<ColorCurves>;
  111171. /**
  111172. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111173. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111174. * 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;
  111175. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111176. */
  111177. set cameraColorCurves(value: Nullable<ColorCurves>);
  111178. /**
  111179. * Can this material render to several textures at once
  111180. */
  111181. get canRenderToMRT(): boolean;
  111182. /**
  111183. * Defines the detail map parameters for the material.
  111184. */
  111185. readonly detailMap: DetailMapConfiguration;
  111186. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111187. protected _worldViewProjectionMatrix: Matrix;
  111188. protected _globalAmbientColor: Color3;
  111189. protected _useLogarithmicDepth: boolean;
  111190. protected _rebuildInParallel: boolean;
  111191. /**
  111192. * Instantiates a new standard material.
  111193. * This is the default material used in Babylon. It is the best trade off between quality
  111194. * and performances.
  111195. * @see https://doc.babylonjs.com/babylon101/materials
  111196. * @param name Define the name of the material in the scene
  111197. * @param scene Define the scene the material belong to
  111198. */
  111199. constructor(name: string, scene: Scene);
  111200. /**
  111201. * Gets a boolean indicating that current material needs to register RTT
  111202. */
  111203. get hasRenderTargetTextures(): boolean;
  111204. /**
  111205. * Gets the current class name of the material e.g. "StandardMaterial"
  111206. * Mainly use in serialization.
  111207. * @returns the class name
  111208. */
  111209. getClassName(): string;
  111210. /**
  111211. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111212. * You can try switching to logarithmic depth.
  111213. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111214. */
  111215. get useLogarithmicDepth(): boolean;
  111216. set useLogarithmicDepth(value: boolean);
  111217. /**
  111218. * Specifies if the material will require alpha blending
  111219. * @returns a boolean specifying if alpha blending is needed
  111220. */
  111221. needAlphaBlending(): boolean;
  111222. /**
  111223. * Specifies if this material should be rendered in alpha test mode
  111224. * @returns a boolean specifying if an alpha test is needed.
  111225. */
  111226. needAlphaTesting(): boolean;
  111227. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111228. /**
  111229. * Get the texture used for alpha test purpose.
  111230. * @returns the diffuse texture in case of the standard material.
  111231. */
  111232. getAlphaTestTexture(): Nullable<BaseTexture>;
  111233. /**
  111234. * Get if the submesh is ready to be used and all its information available.
  111235. * Child classes can use it to update shaders
  111236. * @param mesh defines the mesh to check
  111237. * @param subMesh defines which submesh to check
  111238. * @param useInstances specifies that instances should be used
  111239. * @returns a boolean indicating that the submesh is ready or not
  111240. */
  111241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111242. /**
  111243. * Builds the material UBO layouts.
  111244. * Used internally during the effect preparation.
  111245. */
  111246. buildUniformLayout(): void;
  111247. /**
  111248. * Unbinds the material from the mesh
  111249. */
  111250. unbind(): void;
  111251. /**
  111252. * Binds the submesh to this material by preparing the effect and shader to draw
  111253. * @param world defines the world transformation matrix
  111254. * @param mesh defines the mesh containing the submesh
  111255. * @param subMesh defines the submesh to bind the material to
  111256. */
  111257. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111258. /**
  111259. * Get the list of animatables in the material.
  111260. * @returns the list of animatables object used in the material
  111261. */
  111262. getAnimatables(): IAnimatable[];
  111263. /**
  111264. * Gets the active textures from the material
  111265. * @returns an array of textures
  111266. */
  111267. getActiveTextures(): BaseTexture[];
  111268. /**
  111269. * Specifies if the material uses a texture
  111270. * @param texture defines the texture to check against the material
  111271. * @returns a boolean specifying if the material uses the texture
  111272. */
  111273. hasTexture(texture: BaseTexture): boolean;
  111274. /**
  111275. * Disposes the material
  111276. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111277. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111278. */
  111279. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111280. /**
  111281. * Makes a duplicate of the material, and gives it a new name
  111282. * @param name defines the new name for the duplicated material
  111283. * @returns the cloned material
  111284. */
  111285. clone(name: string): StandardMaterial;
  111286. /**
  111287. * Serializes this material in a JSON representation
  111288. * @returns the serialized material object
  111289. */
  111290. serialize(): any;
  111291. /**
  111292. * Creates a standard material from parsed material data
  111293. * @param source defines the JSON representation of the material
  111294. * @param scene defines the hosting scene
  111295. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111296. * @returns a new standard material
  111297. */
  111298. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111299. /**
  111300. * Are diffuse textures enabled in the application.
  111301. */
  111302. static get DiffuseTextureEnabled(): boolean;
  111303. static set DiffuseTextureEnabled(value: boolean);
  111304. /**
  111305. * Are detail textures enabled in the application.
  111306. */
  111307. static get DetailTextureEnabled(): boolean;
  111308. static set DetailTextureEnabled(value: boolean);
  111309. /**
  111310. * Are ambient textures enabled in the application.
  111311. */
  111312. static get AmbientTextureEnabled(): boolean;
  111313. static set AmbientTextureEnabled(value: boolean);
  111314. /**
  111315. * Are opacity textures enabled in the application.
  111316. */
  111317. static get OpacityTextureEnabled(): boolean;
  111318. static set OpacityTextureEnabled(value: boolean);
  111319. /**
  111320. * Are reflection textures enabled in the application.
  111321. */
  111322. static get ReflectionTextureEnabled(): boolean;
  111323. static set ReflectionTextureEnabled(value: boolean);
  111324. /**
  111325. * Are emissive textures enabled in the application.
  111326. */
  111327. static get EmissiveTextureEnabled(): boolean;
  111328. static set EmissiveTextureEnabled(value: boolean);
  111329. /**
  111330. * Are specular textures enabled in the application.
  111331. */
  111332. static get SpecularTextureEnabled(): boolean;
  111333. static set SpecularTextureEnabled(value: boolean);
  111334. /**
  111335. * Are bump textures enabled in the application.
  111336. */
  111337. static get BumpTextureEnabled(): boolean;
  111338. static set BumpTextureEnabled(value: boolean);
  111339. /**
  111340. * Are lightmap textures enabled in the application.
  111341. */
  111342. static get LightmapTextureEnabled(): boolean;
  111343. static set LightmapTextureEnabled(value: boolean);
  111344. /**
  111345. * Are refraction textures enabled in the application.
  111346. */
  111347. static get RefractionTextureEnabled(): boolean;
  111348. static set RefractionTextureEnabled(value: boolean);
  111349. /**
  111350. * Are color grading textures enabled in the application.
  111351. */
  111352. static get ColorGradingTextureEnabled(): boolean;
  111353. static set ColorGradingTextureEnabled(value: boolean);
  111354. /**
  111355. * Are fresnels enabled in the application.
  111356. */
  111357. static get FresnelEnabled(): boolean;
  111358. static set FresnelEnabled(value: boolean);
  111359. }
  111360. }
  111361. declare module BABYLON {
  111362. /**
  111363. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111364. *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.
  111365. * The SPS is also a particle system. It provides some methods to manage the particles.
  111366. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111367. *
  111368. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111369. */
  111370. export class SolidParticleSystem implements IDisposable {
  111371. /**
  111372. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111373. * Example : var p = SPS.particles[i];
  111374. */
  111375. particles: SolidParticle[];
  111376. /**
  111377. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111378. */
  111379. nbParticles: number;
  111380. /**
  111381. * If the particles must ever face the camera (default false). Useful for planar particles.
  111382. */
  111383. billboard: boolean;
  111384. /**
  111385. * Recompute normals when adding a shape
  111386. */
  111387. recomputeNormals: boolean;
  111388. /**
  111389. * This a counter ofr your own usage. It's not set by any SPS functions.
  111390. */
  111391. counter: number;
  111392. /**
  111393. * The SPS name. This name is also given to the underlying mesh.
  111394. */
  111395. name: string;
  111396. /**
  111397. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111398. */
  111399. mesh: Mesh;
  111400. /**
  111401. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111402. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111403. */
  111404. vars: any;
  111405. /**
  111406. * This array is populated when the SPS is set as 'pickable'.
  111407. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111408. * Each element of this array is an object `{idx: int, faceId: int}`.
  111409. * `idx` is the picked particle index in the `SPS.particles` array
  111410. * `faceId` is the picked face index counted within this particle.
  111411. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111412. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111413. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111414. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111415. */
  111416. pickedParticles: {
  111417. idx: number;
  111418. faceId: number;
  111419. }[];
  111420. /**
  111421. * This array is populated when the SPS is set as 'pickable'
  111422. * Each key of this array is a submesh index.
  111423. * Each element of this array is a second array defined like this :
  111424. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111425. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111426. * `idx` is the picked particle index in the `SPS.particles` array
  111427. * `faceId` is the picked face index counted within this particle.
  111428. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111429. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111430. */
  111431. pickedBySubMesh: {
  111432. idx: number;
  111433. faceId: number;
  111434. }[][];
  111435. /**
  111436. * This array is populated when `enableDepthSort` is set to true.
  111437. * Each element of this array is an instance of the class DepthSortedParticle.
  111438. */
  111439. depthSortedParticles: DepthSortedParticle[];
  111440. /**
  111441. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111442. * @hidden
  111443. */
  111444. _bSphereOnly: boolean;
  111445. /**
  111446. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111447. * @hidden
  111448. */
  111449. _bSphereRadiusFactor: number;
  111450. private _scene;
  111451. private _positions;
  111452. private _indices;
  111453. private _normals;
  111454. private _colors;
  111455. private _uvs;
  111456. private _indices32;
  111457. private _positions32;
  111458. private _normals32;
  111459. private _fixedNormal32;
  111460. private _colors32;
  111461. private _uvs32;
  111462. private _index;
  111463. private _updatable;
  111464. private _pickable;
  111465. private _isVisibilityBoxLocked;
  111466. private _alwaysVisible;
  111467. private _depthSort;
  111468. private _expandable;
  111469. private _shapeCounter;
  111470. private _copy;
  111471. private _color;
  111472. private _computeParticleColor;
  111473. private _computeParticleTexture;
  111474. private _computeParticleRotation;
  111475. private _computeParticleVertex;
  111476. private _computeBoundingBox;
  111477. private _depthSortParticles;
  111478. private _camera;
  111479. private _mustUnrotateFixedNormals;
  111480. private _particlesIntersect;
  111481. private _needs32Bits;
  111482. private _isNotBuilt;
  111483. private _lastParticleId;
  111484. private _idxOfId;
  111485. private _multimaterialEnabled;
  111486. private _useModelMaterial;
  111487. private _indicesByMaterial;
  111488. private _materialIndexes;
  111489. private _depthSortFunction;
  111490. private _materialSortFunction;
  111491. private _materials;
  111492. private _multimaterial;
  111493. private _materialIndexesById;
  111494. private _defaultMaterial;
  111495. private _autoUpdateSubMeshes;
  111496. private _tmpVertex;
  111497. /**
  111498. * Creates a SPS (Solid Particle System) object.
  111499. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111500. * @param scene (Scene) is the scene in which the SPS is added.
  111501. * @param options defines the options of the sps e.g.
  111502. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111503. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111504. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111505. * * 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.
  111506. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111507. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111508. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111509. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111510. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111511. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111512. */
  111513. constructor(name: string, scene: Scene, options?: {
  111514. updatable?: boolean;
  111515. isPickable?: boolean;
  111516. enableDepthSort?: boolean;
  111517. particleIntersection?: boolean;
  111518. boundingSphereOnly?: boolean;
  111519. bSphereRadiusFactor?: number;
  111520. expandable?: boolean;
  111521. useModelMaterial?: boolean;
  111522. enableMultiMaterial?: boolean;
  111523. });
  111524. /**
  111525. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111526. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111527. * @returns the created mesh
  111528. */
  111529. buildMesh(): Mesh;
  111530. /**
  111531. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111532. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111533. * Thus the particles generated from `digest()` have their property `position` set yet.
  111534. * @param mesh ( Mesh ) is the mesh to be digested
  111535. * @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
  111536. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111537. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111538. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111539. * @returns the current SPS
  111540. */
  111541. digest(mesh: Mesh, options?: {
  111542. facetNb?: number;
  111543. number?: number;
  111544. delta?: number;
  111545. storage?: [];
  111546. }): SolidParticleSystem;
  111547. /**
  111548. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111549. * @hidden
  111550. */
  111551. private _unrotateFixedNormals;
  111552. /**
  111553. * Resets the temporary working copy particle
  111554. * @hidden
  111555. */
  111556. private _resetCopy;
  111557. /**
  111558. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111559. * @param p the current index in the positions array to be updated
  111560. * @param ind the current index in the indices array
  111561. * @param shape a Vector3 array, the shape geometry
  111562. * @param positions the positions array to be updated
  111563. * @param meshInd the shape indices array
  111564. * @param indices the indices array to be updated
  111565. * @param meshUV the shape uv array
  111566. * @param uvs the uv array to be updated
  111567. * @param meshCol the shape color array
  111568. * @param colors the color array to be updated
  111569. * @param meshNor the shape normals array
  111570. * @param normals the normals array to be updated
  111571. * @param idx the particle index
  111572. * @param idxInShape the particle index in its shape
  111573. * @param options the addShape() method passed options
  111574. * @model the particle model
  111575. * @hidden
  111576. */
  111577. private _meshBuilder;
  111578. /**
  111579. * Returns a shape Vector3 array from positions float array
  111580. * @param positions float array
  111581. * @returns a vector3 array
  111582. * @hidden
  111583. */
  111584. private _posToShape;
  111585. /**
  111586. * Returns a shapeUV array from a float uvs (array deep copy)
  111587. * @param uvs as a float array
  111588. * @returns a shapeUV array
  111589. * @hidden
  111590. */
  111591. private _uvsToShapeUV;
  111592. /**
  111593. * Adds a new particle object in the particles array
  111594. * @param idx particle index in particles array
  111595. * @param id particle id
  111596. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111597. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111598. * @param model particle ModelShape object
  111599. * @param shapeId model shape identifier
  111600. * @param idxInShape index of the particle in the current model
  111601. * @param bInfo model bounding info object
  111602. * @param storage target storage array, if any
  111603. * @hidden
  111604. */
  111605. private _addParticle;
  111606. /**
  111607. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111608. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111609. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111610. * @param nb (positive integer) the number of particles to be created from this model
  111611. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111612. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111613. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111614. * @returns the number of shapes in the system
  111615. */
  111616. addShape(mesh: Mesh, nb: number, options?: {
  111617. positionFunction?: any;
  111618. vertexFunction?: any;
  111619. storage?: [];
  111620. }): number;
  111621. /**
  111622. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111623. * @hidden
  111624. */
  111625. private _rebuildParticle;
  111626. /**
  111627. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111628. * @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.
  111629. * @returns the SPS.
  111630. */
  111631. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111632. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111633. * Returns an array with the removed particles.
  111634. * 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.
  111635. * The SPS can't be empty so at least one particle needs to remain in place.
  111636. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111637. * @param start index of the first particle to remove
  111638. * @param end index of the last particle to remove (included)
  111639. * @returns an array populated with the removed particles
  111640. */
  111641. removeParticles(start: number, end: number): SolidParticle[];
  111642. /**
  111643. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111644. * @param solidParticleArray an array populated with Solid Particles objects
  111645. * @returns the SPS
  111646. */
  111647. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111648. /**
  111649. * Creates a new particle and modifies the SPS mesh geometry :
  111650. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111651. * - calls _addParticle() to populate the particle array
  111652. * factorized code from addShape() and insertParticlesFromArray()
  111653. * @param idx particle index in the particles array
  111654. * @param i particle index in its shape
  111655. * @param modelShape particle ModelShape object
  111656. * @param shape shape vertex array
  111657. * @param meshInd shape indices array
  111658. * @param meshUV shape uv array
  111659. * @param meshCol shape color array
  111660. * @param meshNor shape normals array
  111661. * @param bbInfo shape bounding info
  111662. * @param storage target particle storage
  111663. * @options addShape() passed options
  111664. * @hidden
  111665. */
  111666. private _insertNewParticle;
  111667. /**
  111668. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  111669. * This method calls `updateParticle()` for each particle of the SPS.
  111670. * For an animated SPS, it is usually called within the render loop.
  111671. * 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.
  111672. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  111673. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  111674. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  111675. * @returns the SPS.
  111676. */
  111677. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  111678. /**
  111679. * Disposes the SPS.
  111680. */
  111681. dispose(): void;
  111682. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  111683. * idx is the particle index in the SPS
  111684. * faceId is the picked face index counted within this particle.
  111685. * Returns null if the pickInfo can't identify a picked particle.
  111686. * @param pickingInfo (PickingInfo object)
  111687. * @returns {idx: number, faceId: number} or null
  111688. */
  111689. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  111690. idx: number;
  111691. faceId: number;
  111692. }>;
  111693. /**
  111694. * Returns a SolidParticle object from its identifier : particle.id
  111695. * @param id (integer) the particle Id
  111696. * @returns the searched particle or null if not found in the SPS.
  111697. */
  111698. getParticleById(id: number): Nullable<SolidParticle>;
  111699. /**
  111700. * Returns a new array populated with the particles having the passed shapeId.
  111701. * @param shapeId (integer) the shape identifier
  111702. * @returns a new solid particle array
  111703. */
  111704. getParticlesByShapeId(shapeId: number): SolidParticle[];
  111705. /**
  111706. * Populates the passed array "ref" with the particles having the passed shapeId.
  111707. * @param shapeId the shape identifier
  111708. * @returns the SPS
  111709. * @param ref
  111710. */
  111711. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  111712. /**
  111713. * Computes the required SubMeshes according the materials assigned to the particles.
  111714. * @returns the solid particle system.
  111715. * Does nothing if called before the SPS mesh is built.
  111716. */
  111717. computeSubMeshes(): SolidParticleSystem;
  111718. /**
  111719. * Sorts the solid particles by material when MultiMaterial is enabled.
  111720. * Updates the indices32 array.
  111721. * Updates the indicesByMaterial array.
  111722. * Updates the mesh indices array.
  111723. * @returns the SPS
  111724. * @hidden
  111725. */
  111726. private _sortParticlesByMaterial;
  111727. /**
  111728. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  111729. * @hidden
  111730. */
  111731. private _setMaterialIndexesById;
  111732. /**
  111733. * Returns an array with unique values of Materials from the passed array
  111734. * @param array the material array to be checked and filtered
  111735. * @hidden
  111736. */
  111737. private _filterUniqueMaterialId;
  111738. /**
  111739. * Sets a new Standard Material as _defaultMaterial if not already set.
  111740. * @hidden
  111741. */
  111742. private _setDefaultMaterial;
  111743. /**
  111744. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  111745. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111746. * @returns the SPS.
  111747. */
  111748. refreshVisibleSize(): SolidParticleSystem;
  111749. /**
  111750. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  111751. * @param size the size (float) of the visibility box
  111752. * note : this doesn't lock the SPS mesh bounding box.
  111753. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111754. */
  111755. setVisibilityBox(size: number): void;
  111756. /**
  111757. * Gets whether the SPS as always visible or not
  111758. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111759. */
  111760. get isAlwaysVisible(): boolean;
  111761. /**
  111762. * Sets the SPS as always visible or not
  111763. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111764. */
  111765. set isAlwaysVisible(val: boolean);
  111766. /**
  111767. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111768. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111769. */
  111770. set isVisibilityBoxLocked(val: boolean);
  111771. /**
  111772. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  111773. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  111774. */
  111775. get isVisibilityBoxLocked(): boolean;
  111776. /**
  111777. * Tells to `setParticles()` to compute the particle rotations or not.
  111778. * Default value : true. The SPS is faster when it's set to false.
  111779. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111780. */
  111781. set computeParticleRotation(val: boolean);
  111782. /**
  111783. * Tells to `setParticles()` to compute the particle colors or not.
  111784. * Default value : true. The SPS is faster when it's set to false.
  111785. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111786. */
  111787. set computeParticleColor(val: boolean);
  111788. set computeParticleTexture(val: boolean);
  111789. /**
  111790. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  111791. * Default value : false. The SPS is faster when it's set to false.
  111792. * Note : the particle custom vertex positions aren't stored values.
  111793. */
  111794. set computeParticleVertex(val: boolean);
  111795. /**
  111796. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  111797. */
  111798. set computeBoundingBox(val: boolean);
  111799. /**
  111800. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  111801. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111802. * Default : `true`
  111803. */
  111804. set depthSortParticles(val: boolean);
  111805. /**
  111806. * Gets if `setParticles()` computes the particle rotations or not.
  111807. * Default value : true. The SPS is faster when it's set to false.
  111808. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  111809. */
  111810. get computeParticleRotation(): boolean;
  111811. /**
  111812. * Gets if `setParticles()` computes the particle colors or not.
  111813. * Default value : true. The SPS is faster when it's set to false.
  111814. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  111815. */
  111816. get computeParticleColor(): boolean;
  111817. /**
  111818. * Gets if `setParticles()` computes the particle textures or not.
  111819. * Default value : true. The SPS is faster when it's set to false.
  111820. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  111821. */
  111822. get computeParticleTexture(): boolean;
  111823. /**
  111824. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  111825. * Default value : false. The SPS is faster when it's set to false.
  111826. * Note : the particle custom vertex positions aren't stored values.
  111827. */
  111828. get computeParticleVertex(): boolean;
  111829. /**
  111830. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  111831. */
  111832. get computeBoundingBox(): boolean;
  111833. /**
  111834. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  111835. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  111836. * Default : `true`
  111837. */
  111838. get depthSortParticles(): boolean;
  111839. /**
  111840. * Gets if the SPS is created as expandable at construction time.
  111841. * Default : `false`
  111842. */
  111843. get expandable(): boolean;
  111844. /**
  111845. * Gets if the SPS supports the Multi Materials
  111846. */
  111847. get multimaterialEnabled(): boolean;
  111848. /**
  111849. * Gets if the SPS uses the model materials for its own multimaterial.
  111850. */
  111851. get useModelMaterial(): boolean;
  111852. /**
  111853. * The SPS used material array.
  111854. */
  111855. get materials(): Material[];
  111856. /**
  111857. * Sets the SPS MultiMaterial from the passed materials.
  111858. * Note : the passed array is internally copied and not used then by reference.
  111859. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  111860. */
  111861. setMultiMaterial(materials: Material[]): void;
  111862. /**
  111863. * The SPS computed multimaterial object
  111864. */
  111865. get multimaterial(): MultiMaterial;
  111866. set multimaterial(mm: MultiMaterial);
  111867. /**
  111868. * If the subMeshes must be updated on the next call to setParticles()
  111869. */
  111870. get autoUpdateSubMeshes(): boolean;
  111871. set autoUpdateSubMeshes(val: boolean);
  111872. /**
  111873. * This function does nothing. It may be overwritten to set all the particle first values.
  111874. * The SPS doesn't call this function, you may have to call it by your own.
  111875. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111876. */
  111877. initParticles(): void;
  111878. /**
  111879. * This function does nothing. It may be overwritten to recycle a particle.
  111880. * The SPS doesn't call this function, you may have to call it by your own.
  111881. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111882. * @param particle The particle to recycle
  111883. * @returns the recycled particle
  111884. */
  111885. recycleParticle(particle: SolidParticle): SolidParticle;
  111886. /**
  111887. * Updates a particle : this function should be overwritten by the user.
  111888. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  111889. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  111890. * @example : just set a particle position or velocity and recycle conditions
  111891. * @param particle The particle to update
  111892. * @returns the updated particle
  111893. */
  111894. updateParticle(particle: SolidParticle): SolidParticle;
  111895. /**
  111896. * Updates a vertex of a particle : it can be overwritten by the user.
  111897. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  111898. * @param particle the current particle
  111899. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  111900. * @param pt the index of the current vertex in the particle shape
  111901. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  111902. * @example : just set a vertex particle position or color
  111903. * @returns the sps
  111904. */
  111905. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  111906. /**
  111907. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  111908. * This does nothing and may be overwritten by the user.
  111909. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111910. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111911. * @param update the boolean update value actually passed to setParticles()
  111912. */
  111913. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111914. /**
  111915. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  111916. * This will be passed three parameters.
  111917. * This does nothing and may be overwritten by the user.
  111918. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111919. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  111920. * @param update the boolean update value actually passed to setParticles()
  111921. */
  111922. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  111923. }
  111924. }
  111925. declare module BABYLON {
  111926. /**
  111927. * Represents one particle of a solid particle system.
  111928. */
  111929. export class SolidParticle {
  111930. /**
  111931. * particle global index
  111932. */
  111933. idx: number;
  111934. /**
  111935. * particle identifier
  111936. */
  111937. id: number;
  111938. /**
  111939. * The color of the particle
  111940. */
  111941. color: Nullable<Color4>;
  111942. /**
  111943. * The world space position of the particle.
  111944. */
  111945. position: Vector3;
  111946. /**
  111947. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  111948. */
  111949. rotation: Vector3;
  111950. /**
  111951. * The world space rotation quaternion of the particle.
  111952. */
  111953. rotationQuaternion: Nullable<Quaternion>;
  111954. /**
  111955. * The scaling of the particle.
  111956. */
  111957. scaling: Vector3;
  111958. /**
  111959. * The uvs of the particle.
  111960. */
  111961. uvs: Vector4;
  111962. /**
  111963. * The current speed of the particle.
  111964. */
  111965. velocity: Vector3;
  111966. /**
  111967. * The pivot point in the particle local space.
  111968. */
  111969. pivot: Vector3;
  111970. /**
  111971. * Must the particle be translated from its pivot point in its local space ?
  111972. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  111973. * Default : false
  111974. */
  111975. translateFromPivot: boolean;
  111976. /**
  111977. * Is the particle active or not ?
  111978. */
  111979. alive: boolean;
  111980. /**
  111981. * Is the particle visible or not ?
  111982. */
  111983. isVisible: boolean;
  111984. /**
  111985. * Index of this particle in the global "positions" array (Internal use)
  111986. * @hidden
  111987. */
  111988. _pos: number;
  111989. /**
  111990. * @hidden Index of this particle in the global "indices" array (Internal use)
  111991. */
  111992. _ind: number;
  111993. /**
  111994. * @hidden ModelShape of this particle (Internal use)
  111995. */
  111996. _model: ModelShape;
  111997. /**
  111998. * ModelShape id of this particle
  111999. */
  112000. shapeId: number;
  112001. /**
  112002. * Index of the particle in its shape id
  112003. */
  112004. idxInShape: number;
  112005. /**
  112006. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112007. */
  112008. _modelBoundingInfo: BoundingInfo;
  112009. /**
  112010. * @hidden Particle BoundingInfo object (Internal use)
  112011. */
  112012. _boundingInfo: BoundingInfo;
  112013. /**
  112014. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112015. */
  112016. _sps: SolidParticleSystem;
  112017. /**
  112018. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112019. */
  112020. _stillInvisible: boolean;
  112021. /**
  112022. * @hidden Last computed particle rotation matrix
  112023. */
  112024. _rotationMatrix: number[];
  112025. /**
  112026. * Parent particle Id, if any.
  112027. * Default null.
  112028. */
  112029. parentId: Nullable<number>;
  112030. /**
  112031. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112032. */
  112033. materialIndex: Nullable<number>;
  112034. /**
  112035. * Custom object or properties.
  112036. */
  112037. props: Nullable<any>;
  112038. /**
  112039. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112040. * The possible values are :
  112041. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112042. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112043. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112044. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112045. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112046. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112047. * */
  112048. cullingStrategy: number;
  112049. /**
  112050. * @hidden Internal global position in the SPS.
  112051. */
  112052. _globalPosition: Vector3;
  112053. /**
  112054. * Creates a Solid Particle object.
  112055. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112056. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112057. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112058. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112059. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112060. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112061. * @param shapeId (integer) is the model shape identifier in the SPS.
  112062. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112063. * @param sps defines the sps it is associated to
  112064. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112065. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112066. */
  112067. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112068. /**
  112069. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112070. * @param target the particle target
  112071. * @returns the current particle
  112072. */
  112073. copyToRef(target: SolidParticle): SolidParticle;
  112074. /**
  112075. * Legacy support, changed scale to scaling
  112076. */
  112077. get scale(): Vector3;
  112078. /**
  112079. * Legacy support, changed scale to scaling
  112080. */
  112081. set scale(scale: Vector3);
  112082. /**
  112083. * Legacy support, changed quaternion to rotationQuaternion
  112084. */
  112085. get quaternion(): Nullable<Quaternion>;
  112086. /**
  112087. * Legacy support, changed quaternion to rotationQuaternion
  112088. */
  112089. set quaternion(q: Nullable<Quaternion>);
  112090. /**
  112091. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112092. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112093. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112094. * @returns true if it intersects
  112095. */
  112096. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112097. /**
  112098. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112099. * A particle is in the frustum if its bounding box intersects the frustum
  112100. * @param frustumPlanes defines the frustum to test
  112101. * @returns true if the particle is in the frustum planes
  112102. */
  112103. isInFrustum(frustumPlanes: Plane[]): boolean;
  112104. /**
  112105. * get the rotation matrix of the particle
  112106. * @hidden
  112107. */
  112108. getRotationMatrix(m: Matrix): void;
  112109. }
  112110. /**
  112111. * Represents the shape of the model used by one particle of a solid particle system.
  112112. * SPS internal tool, don't use it manually.
  112113. */
  112114. export class ModelShape {
  112115. /**
  112116. * The shape id
  112117. * @hidden
  112118. */
  112119. shapeID: number;
  112120. /**
  112121. * flat array of model positions (internal use)
  112122. * @hidden
  112123. */
  112124. _shape: Vector3[];
  112125. /**
  112126. * flat array of model UVs (internal use)
  112127. * @hidden
  112128. */
  112129. _shapeUV: number[];
  112130. /**
  112131. * color array of the model
  112132. * @hidden
  112133. */
  112134. _shapeColors: number[];
  112135. /**
  112136. * indices array of the model
  112137. * @hidden
  112138. */
  112139. _indices: number[];
  112140. /**
  112141. * normals array of the model
  112142. * @hidden
  112143. */
  112144. _normals: number[];
  112145. /**
  112146. * length of the shape in the model indices array (internal use)
  112147. * @hidden
  112148. */
  112149. _indicesLength: number;
  112150. /**
  112151. * Custom position function (internal use)
  112152. * @hidden
  112153. */
  112154. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112155. /**
  112156. * Custom vertex function (internal use)
  112157. * @hidden
  112158. */
  112159. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112160. /**
  112161. * Model material (internal use)
  112162. * @hidden
  112163. */
  112164. _material: Nullable<Material>;
  112165. /**
  112166. * 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.
  112167. * SPS internal tool, don't use it manually.
  112168. * @hidden
  112169. */
  112170. 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>);
  112171. }
  112172. /**
  112173. * Represents a Depth Sorted Particle in the solid particle system.
  112174. * @hidden
  112175. */
  112176. export class DepthSortedParticle {
  112177. /**
  112178. * Particle index
  112179. */
  112180. idx: number;
  112181. /**
  112182. * Index of the particle in the "indices" array
  112183. */
  112184. ind: number;
  112185. /**
  112186. * Length of the particle shape in the "indices" array
  112187. */
  112188. indicesLength: number;
  112189. /**
  112190. * Squared distance from the particle to the camera
  112191. */
  112192. sqDistance: number;
  112193. /**
  112194. * Material index when used with MultiMaterials
  112195. */
  112196. materialIndex: number;
  112197. /**
  112198. * Creates a new sorted particle
  112199. * @param materialIndex
  112200. */
  112201. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112202. }
  112203. /**
  112204. * Represents a solid particle vertex
  112205. */
  112206. export class SolidParticleVertex {
  112207. /**
  112208. * Vertex position
  112209. */
  112210. position: Vector3;
  112211. /**
  112212. * Vertex color
  112213. */
  112214. color: Color4;
  112215. /**
  112216. * Vertex UV
  112217. */
  112218. uv: Vector2;
  112219. /**
  112220. * Creates a new solid particle vertex
  112221. */
  112222. constructor();
  112223. /** Vertex x coordinate */
  112224. get x(): number;
  112225. set x(val: number);
  112226. /** Vertex y coordinate */
  112227. get y(): number;
  112228. set y(val: number);
  112229. /** Vertex z coordinate */
  112230. get z(): number;
  112231. set z(val: number);
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /**
  112236. * @hidden
  112237. */
  112238. export class _MeshCollisionData {
  112239. _checkCollisions: boolean;
  112240. _collisionMask: number;
  112241. _collisionGroup: number;
  112242. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112243. _collider: Nullable<Collider>;
  112244. _oldPositionForCollisions: Vector3;
  112245. _diffPositionForCollisions: Vector3;
  112246. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112247. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112248. _collisionResponse: boolean;
  112249. }
  112250. }
  112251. declare module BABYLON {
  112252. /** @hidden */
  112253. class _FacetDataStorage {
  112254. facetPositions: Vector3[];
  112255. facetNormals: Vector3[];
  112256. facetPartitioning: number[][];
  112257. facetNb: number;
  112258. partitioningSubdivisions: number;
  112259. partitioningBBoxRatio: number;
  112260. facetDataEnabled: boolean;
  112261. facetParameters: any;
  112262. bbSize: Vector3;
  112263. subDiv: {
  112264. max: number;
  112265. X: number;
  112266. Y: number;
  112267. Z: number;
  112268. };
  112269. facetDepthSort: boolean;
  112270. facetDepthSortEnabled: boolean;
  112271. depthSortedIndices: IndicesArray;
  112272. depthSortedFacets: {
  112273. ind: number;
  112274. sqDistance: number;
  112275. }[];
  112276. facetDepthSortFunction: (f1: {
  112277. ind: number;
  112278. sqDistance: number;
  112279. }, f2: {
  112280. ind: number;
  112281. sqDistance: number;
  112282. }) => number;
  112283. facetDepthSortFrom: Vector3;
  112284. facetDepthSortOrigin: Vector3;
  112285. invertedMatrix: Matrix;
  112286. }
  112287. /**
  112288. * @hidden
  112289. **/
  112290. class _InternalAbstractMeshDataInfo {
  112291. _hasVertexAlpha: boolean;
  112292. _useVertexColors: boolean;
  112293. _numBoneInfluencers: number;
  112294. _applyFog: boolean;
  112295. _receiveShadows: boolean;
  112296. _facetData: _FacetDataStorage;
  112297. _visibility: number;
  112298. _skeleton: Nullable<Skeleton>;
  112299. _layerMask: number;
  112300. _computeBonesUsingShaders: boolean;
  112301. _isActive: boolean;
  112302. _onlyForInstances: boolean;
  112303. _isActiveIntermediate: boolean;
  112304. _onlyForInstancesIntermediate: boolean;
  112305. _actAsRegularMesh: boolean;
  112306. }
  112307. /**
  112308. * Class used to store all common mesh properties
  112309. */
  112310. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112311. /** No occlusion */
  112312. static OCCLUSION_TYPE_NONE: number;
  112313. /** Occlusion set to optimisitic */
  112314. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112315. /** Occlusion set to strict */
  112316. static OCCLUSION_TYPE_STRICT: number;
  112317. /** Use an accurante occlusion algorithm */
  112318. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112319. /** Use a conservative occlusion algorithm */
  112320. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112321. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112322. * Test order :
  112323. * Is the bounding sphere outside the frustum ?
  112324. * If not, are the bounding box vertices outside the frustum ?
  112325. * It not, then the cullable object is in the frustum.
  112326. */
  112327. static readonly CULLINGSTRATEGY_STANDARD: number;
  112328. /** Culling strategy : Bounding Sphere Only.
  112329. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112330. * It's also less accurate than the standard because some not visible objects can still be selected.
  112331. * Test : is the bounding sphere outside the frustum ?
  112332. * If not, then the cullable object is in the frustum.
  112333. */
  112334. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112335. /** Culling strategy : Optimistic Inclusion.
  112336. * This in an inclusion test first, then the standard exclusion test.
  112337. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112338. * 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.
  112339. * Anyway, it's as accurate as the standard strategy.
  112340. * Test :
  112341. * Is the cullable object bounding sphere center in the frustum ?
  112342. * If not, apply the default culling strategy.
  112343. */
  112344. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112345. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112346. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112347. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112348. * 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.
  112349. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112350. * Test :
  112351. * Is the cullable object bounding sphere center in the frustum ?
  112352. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112353. */
  112354. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112355. /**
  112356. * No billboard
  112357. */
  112358. static get BILLBOARDMODE_NONE(): number;
  112359. /** Billboard on X axis */
  112360. static get BILLBOARDMODE_X(): number;
  112361. /** Billboard on Y axis */
  112362. static get BILLBOARDMODE_Y(): number;
  112363. /** Billboard on Z axis */
  112364. static get BILLBOARDMODE_Z(): number;
  112365. /** Billboard on all axes */
  112366. static get BILLBOARDMODE_ALL(): number;
  112367. /** Billboard on using position instead of orientation */
  112368. static get BILLBOARDMODE_USE_POSITION(): number;
  112369. /** @hidden */
  112370. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112371. /**
  112372. * The culling strategy to use to check whether the mesh must be rendered or not.
  112373. * This value can be changed at any time and will be used on the next render mesh selection.
  112374. * The possible values are :
  112375. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112376. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112377. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112379. * Please read each static variable documentation to get details about the culling process.
  112380. * */
  112381. cullingStrategy: number;
  112382. /**
  112383. * Gets the number of facets in the mesh
  112384. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112385. */
  112386. get facetNb(): number;
  112387. /**
  112388. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112389. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112390. */
  112391. get partitioningSubdivisions(): number;
  112392. set partitioningSubdivisions(nb: number);
  112393. /**
  112394. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112395. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112396. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112397. */
  112398. get partitioningBBoxRatio(): number;
  112399. set partitioningBBoxRatio(ratio: number);
  112400. /**
  112401. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112402. * Works only for updatable meshes.
  112403. * Doesn't work with multi-materials
  112404. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112405. */
  112406. get mustDepthSortFacets(): boolean;
  112407. set mustDepthSortFacets(sort: boolean);
  112408. /**
  112409. * The location (Vector3) where the facet depth sort must be computed from.
  112410. * By default, the active camera position.
  112411. * Used only when facet depth sort is enabled
  112412. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112413. */
  112414. get facetDepthSortFrom(): Vector3;
  112415. set facetDepthSortFrom(location: Vector3);
  112416. /**
  112417. * gets a boolean indicating if facetData is enabled
  112418. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112419. */
  112420. get isFacetDataEnabled(): boolean;
  112421. /** @hidden */
  112422. _updateNonUniformScalingState(value: boolean): boolean;
  112423. /**
  112424. * An event triggered when this mesh collides with another one
  112425. */
  112426. onCollideObservable: Observable<AbstractMesh>;
  112427. /** Set a function to call when this mesh collides with another one */
  112428. set onCollide(callback: () => void);
  112429. /**
  112430. * An event triggered when the collision's position changes
  112431. */
  112432. onCollisionPositionChangeObservable: Observable<Vector3>;
  112433. /** Set a function to call when the collision's position changes */
  112434. set onCollisionPositionChange(callback: () => void);
  112435. /**
  112436. * An event triggered when material is changed
  112437. */
  112438. onMaterialChangedObservable: Observable<AbstractMesh>;
  112439. /**
  112440. * Gets or sets the orientation for POV movement & rotation
  112441. */
  112442. definedFacingForward: boolean;
  112443. /** @hidden */
  112444. _occlusionQuery: Nullable<WebGLQuery>;
  112445. /** @hidden */
  112446. _renderingGroup: Nullable<RenderingGroup>;
  112447. /**
  112448. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112449. */
  112450. get visibility(): number;
  112451. /**
  112452. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112453. */
  112454. set visibility(value: number);
  112455. /** Gets or sets the alpha index used to sort transparent meshes
  112456. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112457. */
  112458. alphaIndex: number;
  112459. /**
  112460. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112461. */
  112462. isVisible: boolean;
  112463. /**
  112464. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112465. */
  112466. isPickable: boolean;
  112467. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112468. showSubMeshesBoundingBox: boolean;
  112469. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112470. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112471. */
  112472. isBlocker: boolean;
  112473. /**
  112474. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112475. */
  112476. enablePointerMoveEvents: boolean;
  112477. private _renderingGroupId;
  112478. /**
  112479. * Specifies the rendering group id for this mesh (0 by default)
  112480. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112481. */
  112482. get renderingGroupId(): number;
  112483. set renderingGroupId(value: number);
  112484. private _material;
  112485. /** Gets or sets current material */
  112486. get material(): Nullable<Material>;
  112487. set material(value: Nullable<Material>);
  112488. /**
  112489. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112490. * @see https://doc.babylonjs.com/babylon101/shadows
  112491. */
  112492. get receiveShadows(): boolean;
  112493. set receiveShadows(value: boolean);
  112494. /** Defines color to use when rendering outline */
  112495. outlineColor: Color3;
  112496. /** Define width to use when rendering outline */
  112497. outlineWidth: number;
  112498. /** Defines color to use when rendering overlay */
  112499. overlayColor: Color3;
  112500. /** Defines alpha to use when rendering overlay */
  112501. overlayAlpha: number;
  112502. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112503. get hasVertexAlpha(): boolean;
  112504. set hasVertexAlpha(value: boolean);
  112505. /** 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) */
  112506. get useVertexColors(): boolean;
  112507. set useVertexColors(value: boolean);
  112508. /**
  112509. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112510. */
  112511. get computeBonesUsingShaders(): boolean;
  112512. set computeBonesUsingShaders(value: boolean);
  112513. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112514. get numBoneInfluencers(): number;
  112515. set numBoneInfluencers(value: number);
  112516. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112517. get applyFog(): boolean;
  112518. set applyFog(value: boolean);
  112519. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112520. useOctreeForRenderingSelection: boolean;
  112521. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112522. useOctreeForPicking: boolean;
  112523. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112524. useOctreeForCollisions: boolean;
  112525. /**
  112526. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112527. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112528. */
  112529. get layerMask(): number;
  112530. set layerMask(value: number);
  112531. /**
  112532. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112533. */
  112534. alwaysSelectAsActiveMesh: boolean;
  112535. /**
  112536. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112537. */
  112538. doNotSyncBoundingInfo: boolean;
  112539. /**
  112540. * Gets or sets the current action manager
  112541. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112542. */
  112543. actionManager: Nullable<AbstractActionManager>;
  112544. private _meshCollisionData;
  112545. /**
  112546. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112547. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112548. */
  112549. ellipsoid: Vector3;
  112550. /**
  112551. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112552. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112553. */
  112554. ellipsoidOffset: Vector3;
  112555. /**
  112556. * Gets or sets a collision mask used to mask collisions (default is -1).
  112557. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112558. */
  112559. get collisionMask(): number;
  112560. set collisionMask(mask: number);
  112561. /**
  112562. * Gets or sets a collision response flag (default is true).
  112563. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112564. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112565. * to respond to the collision.
  112566. */
  112567. get collisionResponse(): boolean;
  112568. set collisionResponse(response: boolean);
  112569. /**
  112570. * Gets or sets the current collision group mask (-1 by default).
  112571. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112572. */
  112573. get collisionGroup(): number;
  112574. set collisionGroup(mask: number);
  112575. /**
  112576. * Gets or sets current surrounding meshes (null by default).
  112577. *
  112578. * By default collision detection is tested against every mesh in the scene.
  112579. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112580. * meshes will be tested for the collision.
  112581. *
  112582. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112583. */
  112584. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112585. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112586. /**
  112587. * Defines edge width used when edgesRenderer is enabled
  112588. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112589. */
  112590. edgesWidth: number;
  112591. /**
  112592. * Defines edge color used when edgesRenderer is enabled
  112593. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112594. */
  112595. edgesColor: Color4;
  112596. /** @hidden */
  112597. _edgesRenderer: Nullable<IEdgesRenderer>;
  112598. /** @hidden */
  112599. _masterMesh: Nullable<AbstractMesh>;
  112600. /** @hidden */
  112601. _boundingInfo: Nullable<BoundingInfo>;
  112602. /** @hidden */
  112603. _renderId: number;
  112604. /**
  112605. * Gets or sets the list of subMeshes
  112606. * @see https://doc.babylonjs.com/how_to/multi_materials
  112607. */
  112608. subMeshes: SubMesh[];
  112609. /** @hidden */
  112610. _intersectionsInProgress: AbstractMesh[];
  112611. /** @hidden */
  112612. _unIndexed: boolean;
  112613. /** @hidden */
  112614. _lightSources: Light[];
  112615. /** Gets the list of lights affecting that mesh */
  112616. get lightSources(): Light[];
  112617. /** @hidden */
  112618. get _positions(): Nullable<Vector3[]>;
  112619. /** @hidden */
  112620. _waitingData: {
  112621. lods: Nullable<any>;
  112622. actions: Nullable<any>;
  112623. freezeWorldMatrix: Nullable<boolean>;
  112624. };
  112625. /** @hidden */
  112626. _bonesTransformMatrices: Nullable<Float32Array>;
  112627. /** @hidden */
  112628. _transformMatrixTexture: Nullable<RawTexture>;
  112629. /**
  112630. * Gets or sets a skeleton to apply skining transformations
  112631. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112632. */
  112633. set skeleton(value: Nullable<Skeleton>);
  112634. get skeleton(): Nullable<Skeleton>;
  112635. /**
  112636. * An event triggered when the mesh is rebuilt.
  112637. */
  112638. onRebuildObservable: Observable<AbstractMesh>;
  112639. /**
  112640. * Creates a new AbstractMesh
  112641. * @param name defines the name of the mesh
  112642. * @param scene defines the hosting scene
  112643. */
  112644. constructor(name: string, scene?: Nullable<Scene>);
  112645. /**
  112646. * Returns the string "AbstractMesh"
  112647. * @returns "AbstractMesh"
  112648. */
  112649. getClassName(): string;
  112650. /**
  112651. * Gets a string representation of the current mesh
  112652. * @param fullDetails defines a boolean indicating if full details must be included
  112653. * @returns a string representation of the current mesh
  112654. */
  112655. toString(fullDetails?: boolean): string;
  112656. /**
  112657. * @hidden
  112658. */
  112659. protected _getEffectiveParent(): Nullable<Node>;
  112660. /** @hidden */
  112661. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112662. /** @hidden */
  112663. _rebuild(): void;
  112664. /** @hidden */
  112665. _resyncLightSources(): void;
  112666. /** @hidden */
  112667. _resyncLightSource(light: Light): void;
  112668. /** @hidden */
  112669. _unBindEffect(): void;
  112670. /** @hidden */
  112671. _removeLightSource(light: Light, dispose: boolean): void;
  112672. private _markSubMeshesAsDirty;
  112673. /** @hidden */
  112674. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  112675. /** @hidden */
  112676. _markSubMeshesAsAttributesDirty(): void;
  112677. /** @hidden */
  112678. _markSubMeshesAsMiscDirty(): void;
  112679. /**
  112680. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  112681. */
  112682. get scaling(): Vector3;
  112683. set scaling(newScaling: Vector3);
  112684. /**
  112685. * Returns true if the mesh is blocked. Implemented by child classes
  112686. */
  112687. get isBlocked(): boolean;
  112688. /**
  112689. * Returns the mesh itself by default. Implemented by child classes
  112690. * @param camera defines the camera to use to pick the right LOD level
  112691. * @returns the currentAbstractMesh
  112692. */
  112693. getLOD(camera: Camera): Nullable<AbstractMesh>;
  112694. /**
  112695. * Returns 0 by default. Implemented by child classes
  112696. * @returns an integer
  112697. */
  112698. getTotalVertices(): number;
  112699. /**
  112700. * Returns a positive integer : the total number of indices in this mesh geometry.
  112701. * @returns the numner of indices or zero if the mesh has no geometry.
  112702. */
  112703. getTotalIndices(): number;
  112704. /**
  112705. * Returns null by default. Implemented by child classes
  112706. * @returns null
  112707. */
  112708. getIndices(): Nullable<IndicesArray>;
  112709. /**
  112710. * Returns the array of the requested vertex data kind. Implemented by child classes
  112711. * @param kind defines the vertex data kind to use
  112712. * @returns null
  112713. */
  112714. getVerticesData(kind: string): Nullable<FloatArray>;
  112715. /**
  112716. * Sets the vertex data of the mesh geometry for the requested `kind`.
  112717. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  112718. * Note that a new underlying VertexBuffer object is created each call.
  112719. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  112720. * @param kind defines vertex data kind:
  112721. * * VertexBuffer.PositionKind
  112722. * * VertexBuffer.UVKind
  112723. * * VertexBuffer.UV2Kind
  112724. * * VertexBuffer.UV3Kind
  112725. * * VertexBuffer.UV4Kind
  112726. * * VertexBuffer.UV5Kind
  112727. * * VertexBuffer.UV6Kind
  112728. * * VertexBuffer.ColorKind
  112729. * * VertexBuffer.MatricesIndicesKind
  112730. * * VertexBuffer.MatricesIndicesExtraKind
  112731. * * VertexBuffer.MatricesWeightsKind
  112732. * * VertexBuffer.MatricesWeightsExtraKind
  112733. * @param data defines the data source
  112734. * @param updatable defines if the data must be flagged as updatable (or static)
  112735. * @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
  112736. * @returns the current mesh
  112737. */
  112738. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  112739. /**
  112740. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  112741. * If the mesh has no geometry, it is simply returned as it is.
  112742. * @param kind defines vertex data kind:
  112743. * * VertexBuffer.PositionKind
  112744. * * VertexBuffer.UVKind
  112745. * * VertexBuffer.UV2Kind
  112746. * * VertexBuffer.UV3Kind
  112747. * * VertexBuffer.UV4Kind
  112748. * * VertexBuffer.UV5Kind
  112749. * * VertexBuffer.UV6Kind
  112750. * * VertexBuffer.ColorKind
  112751. * * VertexBuffer.MatricesIndicesKind
  112752. * * VertexBuffer.MatricesIndicesExtraKind
  112753. * * VertexBuffer.MatricesWeightsKind
  112754. * * VertexBuffer.MatricesWeightsExtraKind
  112755. * @param data defines the data source
  112756. * @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
  112757. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  112758. * @returns the current mesh
  112759. */
  112760. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  112761. /**
  112762. * Sets the mesh indices,
  112763. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  112764. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  112765. * @param totalVertices Defines the total number of vertices
  112766. * @returns the current mesh
  112767. */
  112768. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  112769. /**
  112770. * Gets a boolean indicating if specific vertex data is present
  112771. * @param kind defines the vertex data kind to use
  112772. * @returns true is data kind is present
  112773. */
  112774. isVerticesDataPresent(kind: string): boolean;
  112775. /**
  112776. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  112777. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  112778. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  112779. * @returns a BoundingInfo
  112780. */
  112781. getBoundingInfo(): BoundingInfo;
  112782. /**
  112783. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  112784. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  112785. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  112786. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  112787. * @returns the current mesh
  112788. */
  112789. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  112790. /**
  112791. * Overwrite the current bounding info
  112792. * @param boundingInfo defines the new bounding info
  112793. * @returns the current mesh
  112794. */
  112795. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  112796. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  112797. get useBones(): boolean;
  112798. /** @hidden */
  112799. _preActivate(): void;
  112800. /** @hidden */
  112801. _preActivateForIntermediateRendering(renderId: number): void;
  112802. /** @hidden */
  112803. _activate(renderId: number, intermediateRendering: boolean): boolean;
  112804. /** @hidden */
  112805. _postActivate(): void;
  112806. /** @hidden */
  112807. _freeze(): void;
  112808. /** @hidden */
  112809. _unFreeze(): void;
  112810. /**
  112811. * Gets the current world matrix
  112812. * @returns a Matrix
  112813. */
  112814. getWorldMatrix(): Matrix;
  112815. /** @hidden */
  112816. _getWorldMatrixDeterminant(): number;
  112817. /**
  112818. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  112819. */
  112820. get isAnInstance(): boolean;
  112821. /**
  112822. * Gets a boolean indicating if this mesh has instances
  112823. */
  112824. get hasInstances(): boolean;
  112825. /**
  112826. * Gets a boolean indicating if this mesh has thin instances
  112827. */
  112828. get hasThinInstances(): boolean;
  112829. /**
  112830. * Perform relative position change from the point of view of behind the front of the mesh.
  112831. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112832. * Supports definition of mesh facing forward or backward
  112833. * @param amountRight defines the distance on the right axis
  112834. * @param amountUp defines the distance on the up axis
  112835. * @param amountForward defines the distance on the forward axis
  112836. * @returns the current mesh
  112837. */
  112838. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  112839. /**
  112840. * Calculate relative position change from the point of view of behind the front of the mesh.
  112841. * This is performed taking into account the meshes current rotation, so you do not have to care.
  112842. * Supports definition of mesh facing forward or backward
  112843. * @param amountRight defines the distance on the right axis
  112844. * @param amountUp defines the distance on the up axis
  112845. * @param amountForward defines the distance on the forward axis
  112846. * @returns the new displacement vector
  112847. */
  112848. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  112849. /**
  112850. * Perform relative rotation change from the point of view of behind the front of the mesh.
  112851. * Supports definition of mesh facing forward or backward
  112852. * @param flipBack defines the flip
  112853. * @param twirlClockwise defines the twirl
  112854. * @param tiltRight defines the tilt
  112855. * @returns the current mesh
  112856. */
  112857. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  112858. /**
  112859. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  112860. * Supports definition of mesh facing forward or backward.
  112861. * @param flipBack defines the flip
  112862. * @param twirlClockwise defines the twirl
  112863. * @param tiltRight defines the tilt
  112864. * @returns the new rotation vector
  112865. */
  112866. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  112867. /**
  112868. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  112869. * This means the mesh underlying bounding box and sphere are recomputed.
  112870. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  112871. * @returns the current mesh
  112872. */
  112873. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  112874. /** @hidden */
  112875. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  112876. /** @hidden */
  112877. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  112878. /** @hidden */
  112879. _updateBoundingInfo(): AbstractMesh;
  112880. /** @hidden */
  112881. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  112882. /** @hidden */
  112883. protected _afterComputeWorldMatrix(): void;
  112884. /** @hidden */
  112885. get _effectiveMesh(): AbstractMesh;
  112886. /**
  112887. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  112888. * A mesh is in the frustum if its bounding box intersects the frustum
  112889. * @param frustumPlanes defines the frustum to test
  112890. * @returns true if the mesh is in the frustum planes
  112891. */
  112892. isInFrustum(frustumPlanes: Plane[]): boolean;
  112893. /**
  112894. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  112895. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  112896. * @param frustumPlanes defines the frustum to test
  112897. * @returns true if the mesh is completely in the frustum planes
  112898. */
  112899. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  112900. /**
  112901. * True if the mesh intersects another mesh or a SolidParticle object
  112902. * @param mesh defines a target mesh or SolidParticle to test
  112903. * @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)
  112904. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  112905. * @returns true if there is an intersection
  112906. */
  112907. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  112908. /**
  112909. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  112910. * @param point defines the point to test
  112911. * @returns true if there is an intersection
  112912. */
  112913. intersectsPoint(point: Vector3): boolean;
  112914. /**
  112915. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  112916. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112917. */
  112918. get checkCollisions(): boolean;
  112919. set checkCollisions(collisionEnabled: boolean);
  112920. /**
  112921. * Gets Collider object used to compute collisions (not physics)
  112922. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112923. */
  112924. get collider(): Nullable<Collider>;
  112925. /**
  112926. * Move the mesh using collision engine
  112927. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112928. * @param displacement defines the requested displacement vector
  112929. * @returns the current mesh
  112930. */
  112931. moveWithCollisions(displacement: Vector3): AbstractMesh;
  112932. private _onCollisionPositionChange;
  112933. /** @hidden */
  112934. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  112935. /** @hidden */
  112936. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  112937. /** @hidden */
  112938. _checkCollision(collider: Collider): AbstractMesh;
  112939. /** @hidden */
  112940. _generatePointsArray(): boolean;
  112941. /**
  112942. * Checks if the passed Ray intersects with the mesh
  112943. * @param ray defines the ray to use
  112944. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  112945. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  112946. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  112947. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  112948. * @returns the picking info
  112949. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  112950. */
  112951. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  112952. /**
  112953. * Clones the current mesh
  112954. * @param name defines the mesh name
  112955. * @param newParent defines the new mesh parent
  112956. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  112957. * @returns the new mesh
  112958. */
  112959. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  112960. /**
  112961. * Disposes all the submeshes of the current meshnp
  112962. * @returns the current mesh
  112963. */
  112964. releaseSubMeshes(): AbstractMesh;
  112965. /**
  112966. * Releases resources associated with this abstract mesh.
  112967. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  112968. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  112969. */
  112970. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  112971. /**
  112972. * Adds the passed mesh as a child to the current mesh
  112973. * @param mesh defines the child mesh
  112974. * @returns the current mesh
  112975. */
  112976. addChild(mesh: AbstractMesh): AbstractMesh;
  112977. /**
  112978. * Removes the passed mesh from the current mesh children list
  112979. * @param mesh defines the child mesh
  112980. * @returns the current mesh
  112981. */
  112982. removeChild(mesh: AbstractMesh): AbstractMesh;
  112983. /** @hidden */
  112984. private _initFacetData;
  112985. /**
  112986. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  112987. * This method can be called within the render loop.
  112988. * 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
  112989. * @returns the current mesh
  112990. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112991. */
  112992. updateFacetData(): AbstractMesh;
  112993. /**
  112994. * Returns the facetLocalNormals array.
  112995. * The normals are expressed in the mesh local spac
  112996. * @returns an array of Vector3
  112997. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  112998. */
  112999. getFacetLocalNormals(): Vector3[];
  113000. /**
  113001. * Returns the facetLocalPositions array.
  113002. * The facet positions are expressed in the mesh local space
  113003. * @returns an array of Vector3
  113004. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113005. */
  113006. getFacetLocalPositions(): Vector3[];
  113007. /**
  113008. * Returns the facetLocalPartioning array
  113009. * @returns an array of array of numbers
  113010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113011. */
  113012. getFacetLocalPartitioning(): number[][];
  113013. /**
  113014. * Returns the i-th facet position in the world system.
  113015. * This method allocates a new Vector3 per call
  113016. * @param i defines the facet index
  113017. * @returns a new Vector3
  113018. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113019. */
  113020. getFacetPosition(i: number): Vector3;
  113021. /**
  113022. * Sets the reference Vector3 with the i-th facet position in the world system
  113023. * @param i defines the facet index
  113024. * @param ref defines the target vector
  113025. * @returns the current mesh
  113026. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113027. */
  113028. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113029. /**
  113030. * Returns the i-th facet normal in the world system.
  113031. * This method allocates a new Vector3 per call
  113032. * @param i defines the facet index
  113033. * @returns a new Vector3
  113034. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113035. */
  113036. getFacetNormal(i: number): Vector3;
  113037. /**
  113038. * Sets the reference Vector3 with the i-th facet normal in the world system
  113039. * @param i defines the facet index
  113040. * @param ref defines the target vector
  113041. * @returns the current mesh
  113042. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113043. */
  113044. getFacetNormalToRef(i: number, ref: Vector3): this;
  113045. /**
  113046. * 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)
  113047. * @param x defines x coordinate
  113048. * @param y defines y coordinate
  113049. * @param z defines z coordinate
  113050. * @returns the array of facet indexes
  113051. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113052. */
  113053. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113054. /**
  113055. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113056. * @param projected sets as the (x,y,z) world projection on the facet
  113057. * @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
  113058. * @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
  113059. * @param x defines x coordinate
  113060. * @param y defines y coordinate
  113061. * @param z defines z coordinate
  113062. * @returns the face index if found (or null instead)
  113063. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113064. */
  113065. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113066. /**
  113067. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113068. * @param projected sets as the (x,y,z) local projection on the facet
  113069. * @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
  113070. * @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
  113071. * @param x defines x coordinate
  113072. * @param y defines y coordinate
  113073. * @param z defines z coordinate
  113074. * @returns the face index if found (or null instead)
  113075. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113076. */
  113077. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113078. /**
  113079. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113080. * @returns the parameters
  113081. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113082. */
  113083. getFacetDataParameters(): any;
  113084. /**
  113085. * Disables the feature FacetData and frees the related memory
  113086. * @returns the current mesh
  113087. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113088. */
  113089. disableFacetData(): AbstractMesh;
  113090. /**
  113091. * Updates the AbstractMesh indices array
  113092. * @param indices defines the data source
  113093. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113094. * @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)
  113095. * @returns the current mesh
  113096. */
  113097. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113098. /**
  113099. * Creates new normals data for the mesh
  113100. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113101. * @returns the current mesh
  113102. */
  113103. createNormals(updatable: boolean): AbstractMesh;
  113104. /**
  113105. * Align the mesh with a normal
  113106. * @param normal defines the normal to use
  113107. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113108. * @returns the current mesh
  113109. */
  113110. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113111. /** @hidden */
  113112. _checkOcclusionQuery(): boolean;
  113113. /**
  113114. * Disables the mesh edge rendering mode
  113115. * @returns the currentAbstractMesh
  113116. */
  113117. disableEdgesRendering(): AbstractMesh;
  113118. /**
  113119. * Enables the edge rendering mode on the mesh.
  113120. * This mode makes the mesh edges visible
  113121. * @param epsilon defines the maximal distance between two angles to detect a face
  113122. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113123. * @returns the currentAbstractMesh
  113124. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113125. */
  113126. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113127. /**
  113128. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113129. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113130. */
  113131. getConnectedParticleSystems(): IParticleSystem[];
  113132. }
  113133. }
  113134. declare module BABYLON {
  113135. /**
  113136. * Interface used to define ActionEvent
  113137. */
  113138. export interface IActionEvent {
  113139. /** The mesh or sprite that triggered the action */
  113140. source: any;
  113141. /** The X mouse cursor position at the time of the event */
  113142. pointerX: number;
  113143. /** The Y mouse cursor position at the time of the event */
  113144. pointerY: number;
  113145. /** The mesh that is currently pointed at (can be null) */
  113146. meshUnderPointer: Nullable<AbstractMesh>;
  113147. /** the original (browser) event that triggered the ActionEvent */
  113148. sourceEvent?: any;
  113149. /** additional data for the event */
  113150. additionalData?: any;
  113151. }
  113152. /**
  113153. * ActionEvent is the event being sent when an action is triggered.
  113154. */
  113155. export class ActionEvent implements IActionEvent {
  113156. /** The mesh or sprite that triggered the action */
  113157. source: any;
  113158. /** The X mouse cursor position at the time of the event */
  113159. pointerX: number;
  113160. /** The Y mouse cursor position at the time of the event */
  113161. pointerY: number;
  113162. /** The mesh that is currently pointed at (can be null) */
  113163. meshUnderPointer: Nullable<AbstractMesh>;
  113164. /** the original (browser) event that triggered the ActionEvent */
  113165. sourceEvent?: any;
  113166. /** additional data for the event */
  113167. additionalData?: any;
  113168. /**
  113169. * Creates a new ActionEvent
  113170. * @param source The mesh or sprite that triggered the action
  113171. * @param pointerX The X mouse cursor position at the time of the event
  113172. * @param pointerY The Y mouse cursor position at the time of the event
  113173. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113174. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113175. * @param additionalData additional data for the event
  113176. */
  113177. constructor(
  113178. /** The mesh or sprite that triggered the action */
  113179. source: any,
  113180. /** The X mouse cursor position at the time of the event */
  113181. pointerX: number,
  113182. /** The Y mouse cursor position at the time of the event */
  113183. pointerY: number,
  113184. /** The mesh that is currently pointed at (can be null) */
  113185. meshUnderPointer: Nullable<AbstractMesh>,
  113186. /** the original (browser) event that triggered the ActionEvent */
  113187. sourceEvent?: any,
  113188. /** additional data for the event */
  113189. additionalData?: any);
  113190. /**
  113191. * Helper function to auto-create an ActionEvent from a source mesh.
  113192. * @param source The source mesh that triggered the event
  113193. * @param evt The original (browser) event
  113194. * @param additionalData additional data for the event
  113195. * @returns the new ActionEvent
  113196. */
  113197. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113198. /**
  113199. * Helper function to auto-create an ActionEvent from a source sprite
  113200. * @param source The source sprite that triggered the event
  113201. * @param scene Scene associated with the sprite
  113202. * @param evt The original (browser) event
  113203. * @param additionalData additional data for the event
  113204. * @returns the new ActionEvent
  113205. */
  113206. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113207. /**
  113208. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113209. * @param scene the scene where the event occurred
  113210. * @param evt The original (browser) event
  113211. * @returns the new ActionEvent
  113212. */
  113213. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113214. /**
  113215. * Helper function to auto-create an ActionEvent from a primitive
  113216. * @param prim defines the target primitive
  113217. * @param pointerPos defines the pointer position
  113218. * @param evt The original (browser) event
  113219. * @param additionalData additional data for the event
  113220. * @returns the new ActionEvent
  113221. */
  113222. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113223. }
  113224. }
  113225. declare module BABYLON {
  113226. /**
  113227. * Abstract class used to decouple action Manager from scene and meshes.
  113228. * Do not instantiate.
  113229. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113230. */
  113231. export abstract class AbstractActionManager implements IDisposable {
  113232. /** Gets the list of active triggers */
  113233. static Triggers: {
  113234. [key: string]: number;
  113235. };
  113236. /** Gets the cursor to use when hovering items */
  113237. hoverCursor: string;
  113238. /** Gets the list of actions */
  113239. actions: IAction[];
  113240. /**
  113241. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113242. */
  113243. isRecursive: boolean;
  113244. /**
  113245. * Releases all associated resources
  113246. */
  113247. abstract dispose(): void;
  113248. /**
  113249. * Does this action manager has pointer triggers
  113250. */
  113251. abstract get hasPointerTriggers(): boolean;
  113252. /**
  113253. * Does this action manager has pick triggers
  113254. */
  113255. abstract get hasPickTriggers(): boolean;
  113256. /**
  113257. * Process a specific trigger
  113258. * @param trigger defines the trigger to process
  113259. * @param evt defines the event details to be processed
  113260. */
  113261. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113262. /**
  113263. * Does this action manager handles actions of any of the given triggers
  113264. * @param triggers defines the triggers to be tested
  113265. * @return a boolean indicating whether one (or more) of the triggers is handled
  113266. */
  113267. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113268. /**
  113269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113270. * speed.
  113271. * @param triggerA defines the trigger to be tested
  113272. * @param triggerB defines the trigger to be tested
  113273. * @return a boolean indicating whether one (or more) of the triggers is handled
  113274. */
  113275. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113276. /**
  113277. * Does this action manager handles actions of a given trigger
  113278. * @param trigger defines the trigger to be tested
  113279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113280. * @return whether the trigger is handled
  113281. */
  113282. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113283. /**
  113284. * Serialize this manager to a JSON object
  113285. * @param name defines the property name to store this manager
  113286. * @returns a JSON representation of this manager
  113287. */
  113288. abstract serialize(name: string): any;
  113289. /**
  113290. * Registers an action to this action manager
  113291. * @param action defines the action to be registered
  113292. * @return the action amended (prepared) after registration
  113293. */
  113294. abstract registerAction(action: IAction): Nullable<IAction>;
  113295. /**
  113296. * Unregisters an action to this action manager
  113297. * @param action defines the action to be unregistered
  113298. * @return a boolean indicating whether the action has been unregistered
  113299. */
  113300. abstract unregisterAction(action: IAction): Boolean;
  113301. /**
  113302. * Does exist one action manager with at least one trigger
  113303. **/
  113304. static get HasTriggers(): boolean;
  113305. /**
  113306. * Does exist one action manager with at least one pick trigger
  113307. **/
  113308. static get HasPickTriggers(): boolean;
  113309. /**
  113310. * Does exist one action manager that handles actions of a given trigger
  113311. * @param trigger defines the trigger to be tested
  113312. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113313. **/
  113314. static HasSpecificTrigger(trigger: number): boolean;
  113315. }
  113316. }
  113317. declare module BABYLON {
  113318. /**
  113319. * Defines how a node can be built from a string name.
  113320. */
  113321. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113322. /**
  113323. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113324. */
  113325. export class Node implements IBehaviorAware<Node> {
  113326. /** @hidden */
  113327. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113328. private static _NodeConstructors;
  113329. /**
  113330. * Add a new node constructor
  113331. * @param type defines the type name of the node to construct
  113332. * @param constructorFunc defines the constructor function
  113333. */
  113334. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113335. /**
  113336. * Returns a node constructor based on type name
  113337. * @param type defines the type name
  113338. * @param name defines the new node name
  113339. * @param scene defines the hosting scene
  113340. * @param options defines optional options to transmit to constructors
  113341. * @returns the new constructor or null
  113342. */
  113343. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113344. /**
  113345. * Gets or sets the name of the node
  113346. */
  113347. name: string;
  113348. /**
  113349. * Gets or sets the id of the node
  113350. */
  113351. id: string;
  113352. /**
  113353. * Gets or sets the unique id of the node
  113354. */
  113355. uniqueId: number;
  113356. /**
  113357. * Gets or sets a string used to store user defined state for the node
  113358. */
  113359. state: string;
  113360. /**
  113361. * Gets or sets an object used to store user defined information for the node
  113362. */
  113363. metadata: any;
  113364. /**
  113365. * For internal use only. Please do not use.
  113366. */
  113367. reservedDataStore: any;
  113368. /**
  113369. * List of inspectable custom properties (used by the Inspector)
  113370. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113371. */
  113372. inspectableCustomProperties: IInspectable[];
  113373. private _doNotSerialize;
  113374. /**
  113375. * Gets or sets a boolean used to define if the node must be serialized
  113376. */
  113377. get doNotSerialize(): boolean;
  113378. set doNotSerialize(value: boolean);
  113379. /** @hidden */
  113380. _isDisposed: boolean;
  113381. /**
  113382. * Gets a list of Animations associated with the node
  113383. */
  113384. animations: Animation[];
  113385. protected _ranges: {
  113386. [name: string]: Nullable<AnimationRange>;
  113387. };
  113388. /**
  113389. * Callback raised when the node is ready to be used
  113390. */
  113391. onReady: Nullable<(node: Node) => void>;
  113392. private _isEnabled;
  113393. private _isParentEnabled;
  113394. private _isReady;
  113395. /** @hidden */
  113396. _currentRenderId: number;
  113397. private _parentUpdateId;
  113398. /** @hidden */
  113399. _childUpdateId: number;
  113400. /** @hidden */
  113401. _waitingParentId: Nullable<string>;
  113402. /** @hidden */
  113403. _scene: Scene;
  113404. /** @hidden */
  113405. _cache: any;
  113406. private _parentNode;
  113407. private _children;
  113408. /** @hidden */
  113409. _worldMatrix: Matrix;
  113410. /** @hidden */
  113411. _worldMatrixDeterminant: number;
  113412. /** @hidden */
  113413. _worldMatrixDeterminantIsDirty: boolean;
  113414. /** @hidden */
  113415. private _sceneRootNodesIndex;
  113416. /**
  113417. * Gets a boolean indicating if the node has been disposed
  113418. * @returns true if the node was disposed
  113419. */
  113420. isDisposed(): boolean;
  113421. /**
  113422. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113423. * @see https://doc.babylonjs.com/how_to/parenting
  113424. */
  113425. set parent(parent: Nullable<Node>);
  113426. get parent(): Nullable<Node>;
  113427. /** @hidden */
  113428. _addToSceneRootNodes(): void;
  113429. /** @hidden */
  113430. _removeFromSceneRootNodes(): void;
  113431. private _animationPropertiesOverride;
  113432. /**
  113433. * Gets or sets the animation properties override
  113434. */
  113435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113436. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113437. /**
  113438. * Gets a string identifying the name of the class
  113439. * @returns "Node" string
  113440. */
  113441. getClassName(): string;
  113442. /** @hidden */
  113443. readonly _isNode: boolean;
  113444. /**
  113445. * An event triggered when the mesh is disposed
  113446. */
  113447. onDisposeObservable: Observable<Node>;
  113448. private _onDisposeObserver;
  113449. /**
  113450. * Sets a callback that will be raised when the node will be disposed
  113451. */
  113452. set onDispose(callback: () => void);
  113453. /**
  113454. * Creates a new Node
  113455. * @param name the name and id to be given to this node
  113456. * @param scene the scene this node will be added to
  113457. */
  113458. constructor(name: string, scene?: Nullable<Scene>);
  113459. /**
  113460. * Gets the scene of the node
  113461. * @returns a scene
  113462. */
  113463. getScene(): Scene;
  113464. /**
  113465. * Gets the engine of the node
  113466. * @returns a Engine
  113467. */
  113468. getEngine(): Engine;
  113469. private _behaviors;
  113470. /**
  113471. * Attach a behavior to the node
  113472. * @see https://doc.babylonjs.com/features/behaviour
  113473. * @param behavior defines the behavior to attach
  113474. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113475. * @returns the current Node
  113476. */
  113477. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113478. /**
  113479. * Remove an attached behavior
  113480. * @see https://doc.babylonjs.com/features/behaviour
  113481. * @param behavior defines the behavior to attach
  113482. * @returns the current Node
  113483. */
  113484. removeBehavior(behavior: Behavior<Node>): Node;
  113485. /**
  113486. * Gets the list of attached behaviors
  113487. * @see https://doc.babylonjs.com/features/behaviour
  113488. */
  113489. get behaviors(): Behavior<Node>[];
  113490. /**
  113491. * Gets an attached behavior by name
  113492. * @param name defines the name of the behavior to look for
  113493. * @see https://doc.babylonjs.com/features/behaviour
  113494. * @returns null if behavior was not found else the requested behavior
  113495. */
  113496. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113497. /**
  113498. * Returns the latest update of the World matrix
  113499. * @returns a Matrix
  113500. */
  113501. getWorldMatrix(): Matrix;
  113502. /** @hidden */
  113503. _getWorldMatrixDeterminant(): number;
  113504. /**
  113505. * Returns directly the latest state of the mesh World matrix.
  113506. * A Matrix is returned.
  113507. */
  113508. get worldMatrixFromCache(): Matrix;
  113509. /** @hidden */
  113510. _initCache(): void;
  113511. /** @hidden */
  113512. updateCache(force?: boolean): void;
  113513. /** @hidden */
  113514. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113515. /** @hidden */
  113516. _updateCache(ignoreParentClass?: boolean): void;
  113517. /** @hidden */
  113518. _isSynchronized(): boolean;
  113519. /** @hidden */
  113520. _markSyncedWithParent(): void;
  113521. /** @hidden */
  113522. isSynchronizedWithParent(): boolean;
  113523. /** @hidden */
  113524. isSynchronized(): boolean;
  113525. /**
  113526. * Is this node ready to be used/rendered
  113527. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113528. * @return true if the node is ready
  113529. */
  113530. isReady(completeCheck?: boolean): boolean;
  113531. /**
  113532. * Is this node enabled?
  113533. * 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
  113534. * @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
  113535. * @return whether this node (and its parent) is enabled
  113536. */
  113537. isEnabled(checkAncestors?: boolean): boolean;
  113538. /** @hidden */
  113539. protected _syncParentEnabledState(): void;
  113540. /**
  113541. * Set the enabled state of this node
  113542. * @param value defines the new enabled state
  113543. */
  113544. setEnabled(value: boolean): void;
  113545. /**
  113546. * Is this node a descendant of the given node?
  113547. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113548. * @param ancestor defines the parent node to inspect
  113549. * @returns a boolean indicating if this node is a descendant of the given node
  113550. */
  113551. isDescendantOf(ancestor: Node): boolean;
  113552. /** @hidden */
  113553. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113554. /**
  113555. * Will return all nodes that have this node as ascendant
  113556. * @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
  113557. * @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
  113558. * @return all children nodes of all types
  113559. */
  113560. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113561. /**
  113562. * Get all child-meshes of this node
  113563. * @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)
  113564. * @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
  113565. * @returns an array of AbstractMesh
  113566. */
  113567. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113568. /**
  113569. * Get all direct children of this node
  113570. * @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
  113571. * @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)
  113572. * @returns an array of Node
  113573. */
  113574. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113575. /** @hidden */
  113576. _setReady(state: boolean): void;
  113577. /**
  113578. * Get an animation by name
  113579. * @param name defines the name of the animation to look for
  113580. * @returns null if not found else the requested animation
  113581. */
  113582. getAnimationByName(name: string): Nullable<Animation>;
  113583. /**
  113584. * Creates an animation range for this node
  113585. * @param name defines the name of the range
  113586. * @param from defines the starting key
  113587. * @param to defines the end key
  113588. */
  113589. createAnimationRange(name: string, from: number, to: number): void;
  113590. /**
  113591. * Delete a specific animation range
  113592. * @param name defines the name of the range to delete
  113593. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113594. */
  113595. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113596. /**
  113597. * Get an animation range by name
  113598. * @param name defines the name of the animation range to look for
  113599. * @returns null if not found else the requested animation range
  113600. */
  113601. getAnimationRange(name: string): Nullable<AnimationRange>;
  113602. /**
  113603. * Gets the list of all animation ranges defined on this node
  113604. * @returns an array
  113605. */
  113606. getAnimationRanges(): Nullable<AnimationRange>[];
  113607. /**
  113608. * Will start the animation sequence
  113609. * @param name defines the range frames for animation sequence
  113610. * @param loop defines if the animation should loop (false by default)
  113611. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113612. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113613. * @returns the object created for this animation. If range does not exist, it will return null
  113614. */
  113615. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113616. /**
  113617. * Serialize animation ranges into a JSON compatible object
  113618. * @returns serialization object
  113619. */
  113620. serializeAnimationRanges(): any;
  113621. /**
  113622. * Computes the world matrix of the node
  113623. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113624. * @returns the world matrix
  113625. */
  113626. computeWorldMatrix(force?: boolean): Matrix;
  113627. /**
  113628. * Releases resources associated with this node.
  113629. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113630. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113631. */
  113632. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113633. /**
  113634. * Parse animation range data from a serialization object and store them into a given node
  113635. * @param node defines where to store the animation ranges
  113636. * @param parsedNode defines the serialization object to read data from
  113637. * @param scene defines the hosting scene
  113638. */
  113639. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113640. /**
  113641. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113642. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113643. * @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
  113644. * @returns the new bounding vectors
  113645. */
  113646. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113647. min: Vector3;
  113648. max: Vector3;
  113649. };
  113650. }
  113651. }
  113652. declare module BABYLON {
  113653. /**
  113654. * @hidden
  113655. */
  113656. export class _IAnimationState {
  113657. key: number;
  113658. repeatCount: number;
  113659. workValue?: any;
  113660. loopMode?: number;
  113661. offsetValue?: any;
  113662. highLimitValue?: any;
  113663. }
  113664. /**
  113665. * Class used to store any kind of animation
  113666. */
  113667. export class Animation {
  113668. /**Name of the animation */
  113669. name: string;
  113670. /**Property to animate */
  113671. targetProperty: string;
  113672. /**The frames per second of the animation */
  113673. framePerSecond: number;
  113674. /**The data type of the animation */
  113675. dataType: number;
  113676. /**The loop mode of the animation */
  113677. loopMode?: number | undefined;
  113678. /**Specifies if blending should be enabled */
  113679. enableBlending?: boolean | undefined;
  113680. /**
  113681. * Use matrix interpolation instead of using direct key value when animating matrices
  113682. */
  113683. static AllowMatricesInterpolation: boolean;
  113684. /**
  113685. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  113686. */
  113687. static AllowMatrixDecomposeForInterpolation: boolean;
  113688. /** Define the Url to load snippets */
  113689. static SnippetUrl: string;
  113690. /** Snippet ID if the animation was created from the snippet server */
  113691. snippetId: string;
  113692. /**
  113693. * Stores the key frames of the animation
  113694. */
  113695. private _keys;
  113696. /**
  113697. * Stores the easing function of the animation
  113698. */
  113699. private _easingFunction;
  113700. /**
  113701. * @hidden Internal use only
  113702. */
  113703. _runtimeAnimations: RuntimeAnimation[];
  113704. /**
  113705. * The set of event that will be linked to this animation
  113706. */
  113707. private _events;
  113708. /**
  113709. * Stores an array of target property paths
  113710. */
  113711. targetPropertyPath: string[];
  113712. /**
  113713. * Stores the blending speed of the animation
  113714. */
  113715. blendingSpeed: number;
  113716. /**
  113717. * Stores the animation ranges for the animation
  113718. */
  113719. private _ranges;
  113720. /**
  113721. * @hidden Internal use
  113722. */
  113723. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  113724. /**
  113725. * Sets up an animation
  113726. * @param property The property to animate
  113727. * @param animationType The animation type to apply
  113728. * @param framePerSecond The frames per second of the animation
  113729. * @param easingFunction The easing function used in the animation
  113730. * @returns The created animation
  113731. */
  113732. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  113733. /**
  113734. * Create and start an animation on a node
  113735. * @param name defines the name of the global animation that will be run on all nodes
  113736. * @param node defines the root node where the animation will take place
  113737. * @param targetProperty defines property to animate
  113738. * @param framePerSecond defines the number of frame per second yo use
  113739. * @param totalFrame defines the number of frames in total
  113740. * @param from defines the initial value
  113741. * @param to defines the final value
  113742. * @param loopMode defines which loop mode you want to use (off by default)
  113743. * @param easingFunction defines the easing function to use (linear by default)
  113744. * @param onAnimationEnd defines the callback to call when animation end
  113745. * @returns the animatable created for this animation
  113746. */
  113747. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113748. /**
  113749. * Create and start an animation on a node and its descendants
  113750. * @param name defines the name of the global animation that will be run on all nodes
  113751. * @param node defines the root node where the animation will take place
  113752. * @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
  113753. * @param targetProperty defines property to animate
  113754. * @param framePerSecond defines the number of frame per second to use
  113755. * @param totalFrame defines the number of frames in total
  113756. * @param from defines the initial value
  113757. * @param to defines the final value
  113758. * @param loopMode defines which loop mode you want to use (off by default)
  113759. * @param easingFunction defines the easing function to use (linear by default)
  113760. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  113761. * @returns the list of animatables created for all nodes
  113762. * @example https://www.babylonjs-playground.com/#MH0VLI
  113763. */
  113764. 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[]>;
  113765. /**
  113766. * Creates a new animation, merges it with the existing animations and starts it
  113767. * @param name Name of the animation
  113768. * @param node Node which contains the scene that begins the animations
  113769. * @param targetProperty Specifies which property to animate
  113770. * @param framePerSecond The frames per second of the animation
  113771. * @param totalFrame The total number of frames
  113772. * @param from The frame at the beginning of the animation
  113773. * @param to The frame at the end of the animation
  113774. * @param loopMode Specifies the loop mode of the animation
  113775. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  113776. * @param onAnimationEnd Callback to run once the animation is complete
  113777. * @returns Nullable animation
  113778. */
  113779. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  113780. /**
  113781. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  113782. * @param sourceAnimation defines the Animation containing keyframes to convert
  113783. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  113784. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  113785. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  113786. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  113787. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  113788. */
  113789. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  113790. /**
  113791. * Transition property of an host to the target Value
  113792. * @param property The property to transition
  113793. * @param targetValue The target Value of the property
  113794. * @param host The object where the property to animate belongs
  113795. * @param scene Scene used to run the animation
  113796. * @param frameRate Framerate (in frame/s) to use
  113797. * @param transition The transition type we want to use
  113798. * @param duration The duration of the animation, in milliseconds
  113799. * @param onAnimationEnd Callback trigger at the end of the animation
  113800. * @returns Nullable animation
  113801. */
  113802. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  113803. /**
  113804. * Return the array of runtime animations currently using this animation
  113805. */
  113806. get runtimeAnimations(): RuntimeAnimation[];
  113807. /**
  113808. * Specifies if any of the runtime animations are currently running
  113809. */
  113810. get hasRunningRuntimeAnimations(): boolean;
  113811. /**
  113812. * Initializes the animation
  113813. * @param name Name of the animation
  113814. * @param targetProperty Property to animate
  113815. * @param framePerSecond The frames per second of the animation
  113816. * @param dataType The data type of the animation
  113817. * @param loopMode The loop mode of the animation
  113818. * @param enableBlending Specifies if blending should be enabled
  113819. */
  113820. constructor(
  113821. /**Name of the animation */
  113822. name: string,
  113823. /**Property to animate */
  113824. targetProperty: string,
  113825. /**The frames per second of the animation */
  113826. framePerSecond: number,
  113827. /**The data type of the animation */
  113828. dataType: number,
  113829. /**The loop mode of the animation */
  113830. loopMode?: number | undefined,
  113831. /**Specifies if blending should be enabled */
  113832. enableBlending?: boolean | undefined);
  113833. /**
  113834. * Converts the animation to a string
  113835. * @param fullDetails support for multiple levels of logging within scene loading
  113836. * @returns String form of the animation
  113837. */
  113838. toString(fullDetails?: boolean): string;
  113839. /**
  113840. * Add an event to this animation
  113841. * @param event Event to add
  113842. */
  113843. addEvent(event: AnimationEvent): void;
  113844. /**
  113845. * Remove all events found at the given frame
  113846. * @param frame The frame to remove events from
  113847. */
  113848. removeEvents(frame: number): void;
  113849. /**
  113850. * Retrieves all the events from the animation
  113851. * @returns Events from the animation
  113852. */
  113853. getEvents(): AnimationEvent[];
  113854. /**
  113855. * Creates an animation range
  113856. * @param name Name of the animation range
  113857. * @param from Starting frame of the animation range
  113858. * @param to Ending frame of the animation
  113859. */
  113860. createRange(name: string, from: number, to: number): void;
  113861. /**
  113862. * Deletes an animation range by name
  113863. * @param name Name of the animation range to delete
  113864. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  113865. */
  113866. deleteRange(name: string, deleteFrames?: boolean): void;
  113867. /**
  113868. * Gets the animation range by name, or null if not defined
  113869. * @param name Name of the animation range
  113870. * @returns Nullable animation range
  113871. */
  113872. getRange(name: string): Nullable<AnimationRange>;
  113873. /**
  113874. * Gets the key frames from the animation
  113875. * @returns The key frames of the animation
  113876. */
  113877. getKeys(): Array<IAnimationKey>;
  113878. /**
  113879. * Gets the highest frame rate of the animation
  113880. * @returns Highest frame rate of the animation
  113881. */
  113882. getHighestFrame(): number;
  113883. /**
  113884. * Gets the easing function of the animation
  113885. * @returns Easing function of the animation
  113886. */
  113887. getEasingFunction(): IEasingFunction;
  113888. /**
  113889. * Sets the easing function of the animation
  113890. * @param easingFunction A custom mathematical formula for animation
  113891. */
  113892. setEasingFunction(easingFunction: EasingFunction): void;
  113893. /**
  113894. * Interpolates a scalar linearly
  113895. * @param startValue Start value of the animation curve
  113896. * @param endValue End value of the animation curve
  113897. * @param gradient Scalar amount to interpolate
  113898. * @returns Interpolated scalar value
  113899. */
  113900. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  113901. /**
  113902. * Interpolates a scalar cubically
  113903. * @param startValue Start value of the animation curve
  113904. * @param outTangent End tangent of the animation
  113905. * @param endValue End value of the animation curve
  113906. * @param inTangent Start tangent of the animation curve
  113907. * @param gradient Scalar amount to interpolate
  113908. * @returns Interpolated scalar value
  113909. */
  113910. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  113911. /**
  113912. * Interpolates a quaternion using a spherical linear interpolation
  113913. * @param startValue Start value of the animation curve
  113914. * @param endValue End value of the animation curve
  113915. * @param gradient Scalar amount to interpolate
  113916. * @returns Interpolated quaternion value
  113917. */
  113918. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  113919. /**
  113920. * Interpolates a quaternion cubically
  113921. * @param startValue Start value of the animation curve
  113922. * @param outTangent End tangent of the animation curve
  113923. * @param endValue End value of the animation curve
  113924. * @param inTangent Start tangent of the animation curve
  113925. * @param gradient Scalar amount to interpolate
  113926. * @returns Interpolated quaternion value
  113927. */
  113928. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  113929. /**
  113930. * Interpolates a Vector3 linearl
  113931. * @param startValue Start value of the animation curve
  113932. * @param endValue End value of the animation curve
  113933. * @param gradient Scalar amount to interpolate
  113934. * @returns Interpolated scalar value
  113935. */
  113936. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  113937. /**
  113938. * Interpolates a Vector3 cubically
  113939. * @param startValue Start value of the animation curve
  113940. * @param outTangent End tangent of the animation
  113941. * @param endValue End value of the animation curve
  113942. * @param inTangent Start tangent of the animation curve
  113943. * @param gradient Scalar amount to interpolate
  113944. * @returns InterpolatedVector3 value
  113945. */
  113946. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  113947. /**
  113948. * Interpolates a Vector2 linearly
  113949. * @param startValue Start value of the animation curve
  113950. * @param endValue End value of the animation curve
  113951. * @param gradient Scalar amount to interpolate
  113952. * @returns Interpolated Vector2 value
  113953. */
  113954. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  113955. /**
  113956. * Interpolates a Vector2 cubically
  113957. * @param startValue Start value of the animation curve
  113958. * @param outTangent End tangent of the animation
  113959. * @param endValue End value of the animation curve
  113960. * @param inTangent Start tangent of the animation curve
  113961. * @param gradient Scalar amount to interpolate
  113962. * @returns Interpolated Vector2 value
  113963. */
  113964. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  113965. /**
  113966. * Interpolates a size linearly
  113967. * @param startValue Start value of the animation curve
  113968. * @param endValue End value of the animation curve
  113969. * @param gradient Scalar amount to interpolate
  113970. * @returns Interpolated Size value
  113971. */
  113972. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  113973. /**
  113974. * Interpolates a Color3 linearly
  113975. * @param startValue Start value of the animation curve
  113976. * @param endValue End value of the animation curve
  113977. * @param gradient Scalar amount to interpolate
  113978. * @returns Interpolated Color3 value
  113979. */
  113980. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  113981. /**
  113982. * Interpolates a Color4 linearly
  113983. * @param startValue Start value of the animation curve
  113984. * @param endValue End value of the animation curve
  113985. * @param gradient Scalar amount to interpolate
  113986. * @returns Interpolated Color3 value
  113987. */
  113988. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  113989. /**
  113990. * @hidden Internal use only
  113991. */
  113992. _getKeyValue(value: any): any;
  113993. /**
  113994. * @hidden Internal use only
  113995. */
  113996. _interpolate(currentFrame: number, state: _IAnimationState): any;
  113997. /**
  113998. * Defines the function to use to interpolate matrices
  113999. * @param startValue defines the start matrix
  114000. * @param endValue defines the end matrix
  114001. * @param gradient defines the gradient between both matrices
  114002. * @param result defines an optional target matrix where to store the interpolation
  114003. * @returns the interpolated matrix
  114004. */
  114005. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114006. /**
  114007. * Makes a copy of the animation
  114008. * @returns Cloned animation
  114009. */
  114010. clone(): Animation;
  114011. /**
  114012. * Sets the key frames of the animation
  114013. * @param values The animation key frames to set
  114014. */
  114015. setKeys(values: Array<IAnimationKey>): void;
  114016. /**
  114017. * Serializes the animation to an object
  114018. * @returns Serialized object
  114019. */
  114020. serialize(): any;
  114021. /**
  114022. * Float animation type
  114023. */
  114024. static readonly ANIMATIONTYPE_FLOAT: number;
  114025. /**
  114026. * Vector3 animation type
  114027. */
  114028. static readonly ANIMATIONTYPE_VECTOR3: number;
  114029. /**
  114030. * Quaternion animation type
  114031. */
  114032. static readonly ANIMATIONTYPE_QUATERNION: number;
  114033. /**
  114034. * Matrix animation type
  114035. */
  114036. static readonly ANIMATIONTYPE_MATRIX: number;
  114037. /**
  114038. * Color3 animation type
  114039. */
  114040. static readonly ANIMATIONTYPE_COLOR3: number;
  114041. /**
  114042. * Color3 animation type
  114043. */
  114044. static readonly ANIMATIONTYPE_COLOR4: number;
  114045. /**
  114046. * Vector2 animation type
  114047. */
  114048. static readonly ANIMATIONTYPE_VECTOR2: number;
  114049. /**
  114050. * Size animation type
  114051. */
  114052. static readonly ANIMATIONTYPE_SIZE: number;
  114053. /**
  114054. * Relative Loop Mode
  114055. */
  114056. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114057. /**
  114058. * Cycle Loop Mode
  114059. */
  114060. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114061. /**
  114062. * Constant Loop Mode
  114063. */
  114064. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114065. /** @hidden */
  114066. static _UniversalLerp(left: any, right: any, amount: number): any;
  114067. /**
  114068. * Parses an animation object and creates an animation
  114069. * @param parsedAnimation Parsed animation object
  114070. * @returns Animation object
  114071. */
  114072. static Parse(parsedAnimation: any): Animation;
  114073. /**
  114074. * Appends the serialized animations from the source animations
  114075. * @param source Source containing the animations
  114076. * @param destination Target to store the animations
  114077. */
  114078. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114079. /**
  114080. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114081. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114082. * @param url defines the url to load from
  114083. * @returns a promise that will resolve to the new animation or an array of animations
  114084. */
  114085. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114086. /**
  114087. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114088. * @param snippetId defines the snippet to load
  114089. * @returns a promise that will resolve to the new animation or a new array of animations
  114090. */
  114091. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114092. }
  114093. }
  114094. declare module BABYLON {
  114095. /**
  114096. * Interface containing an array of animations
  114097. */
  114098. export interface IAnimatable {
  114099. /**
  114100. * Array of animations
  114101. */
  114102. animations: Nullable<Array<Animation>>;
  114103. }
  114104. }
  114105. declare module BABYLON {
  114106. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114107. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114108. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114109. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114110. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114111. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114112. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114113. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114114. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114115. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114116. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114117. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114118. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114119. /**
  114120. * Decorator used to define property that can be serialized as reference to a camera
  114121. * @param sourceName defines the name of the property to decorate
  114122. */
  114123. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114124. /**
  114125. * Class used to help serialization objects
  114126. */
  114127. export class SerializationHelper {
  114128. /** @hidden */
  114129. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114130. /** @hidden */
  114131. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114132. /** @hidden */
  114133. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114134. /** @hidden */
  114135. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114136. /**
  114137. * Appends the serialized animations from the source animations
  114138. * @param source Source containing the animations
  114139. * @param destination Target to store the animations
  114140. */
  114141. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114142. /**
  114143. * Static function used to serialized a specific entity
  114144. * @param entity defines the entity to serialize
  114145. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114146. * @returns a JSON compatible object representing the serialization of the entity
  114147. */
  114148. static Serialize<T>(entity: T, serializationObject?: any): any;
  114149. /**
  114150. * Creates a new entity from a serialization data object
  114151. * @param creationFunction defines a function used to instanciated the new entity
  114152. * @param source defines the source serialization data
  114153. * @param scene defines the hosting scene
  114154. * @param rootUrl defines the root url for resources
  114155. * @returns a new entity
  114156. */
  114157. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114158. /**
  114159. * Clones an object
  114160. * @param creationFunction defines the function used to instanciate the new object
  114161. * @param source defines the source object
  114162. * @returns the cloned object
  114163. */
  114164. static Clone<T>(creationFunction: () => T, source: T): T;
  114165. /**
  114166. * Instanciates a new object based on a source one (some data will be shared between both object)
  114167. * @param creationFunction defines the function used to instanciate the new object
  114168. * @param source defines the source object
  114169. * @returns the new object
  114170. */
  114171. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114172. }
  114173. }
  114174. declare module BABYLON {
  114175. /**
  114176. * Base class of all the textures in babylon.
  114177. * It groups all the common properties the materials, post process, lights... might need
  114178. * in order to make a correct use of the texture.
  114179. */
  114180. export class BaseTexture implements IAnimatable {
  114181. /**
  114182. * Default anisotropic filtering level for the application.
  114183. * It is set to 4 as a good tradeoff between perf and quality.
  114184. */
  114185. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114186. /**
  114187. * Gets or sets the unique id of the texture
  114188. */
  114189. uniqueId: number;
  114190. /**
  114191. * Define the name of the texture.
  114192. */
  114193. name: string;
  114194. /**
  114195. * Gets or sets an object used to store user defined information.
  114196. */
  114197. metadata: any;
  114198. /**
  114199. * For internal use only. Please do not use.
  114200. */
  114201. reservedDataStore: any;
  114202. private _hasAlpha;
  114203. /**
  114204. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114205. */
  114206. set hasAlpha(value: boolean);
  114207. get hasAlpha(): boolean;
  114208. /**
  114209. * Defines if the alpha value should be determined via the rgb values.
  114210. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114211. */
  114212. getAlphaFromRGB: boolean;
  114213. /**
  114214. * Intensity or strength of the texture.
  114215. * It is commonly used by materials to fine tune the intensity of the texture
  114216. */
  114217. level: number;
  114218. /**
  114219. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114220. * This is part of the texture as textures usually maps to one uv set.
  114221. */
  114222. coordinatesIndex: number;
  114223. protected _coordinatesMode: number;
  114224. /**
  114225. * How a texture is mapped.
  114226. *
  114227. * | Value | Type | Description |
  114228. * | ----- | ----------------------------------- | ----------- |
  114229. * | 0 | EXPLICIT_MODE | |
  114230. * | 1 | SPHERICAL_MODE | |
  114231. * | 2 | PLANAR_MODE | |
  114232. * | 3 | CUBIC_MODE | |
  114233. * | 4 | PROJECTION_MODE | |
  114234. * | 5 | SKYBOX_MODE | |
  114235. * | 6 | INVCUBIC_MODE | |
  114236. * | 7 | EQUIRECTANGULAR_MODE | |
  114237. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114238. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114239. */
  114240. set coordinatesMode(value: number);
  114241. get coordinatesMode(): number;
  114242. private _wrapU;
  114243. /**
  114244. * | Value | Type | Description |
  114245. * | ----- | ------------------ | ----------- |
  114246. * | 0 | CLAMP_ADDRESSMODE | |
  114247. * | 1 | WRAP_ADDRESSMODE | |
  114248. * | 2 | MIRROR_ADDRESSMODE | |
  114249. */
  114250. get wrapU(): number;
  114251. set wrapU(value: number);
  114252. private _wrapV;
  114253. /**
  114254. * | Value | Type | Description |
  114255. * | ----- | ------------------ | ----------- |
  114256. * | 0 | CLAMP_ADDRESSMODE | |
  114257. * | 1 | WRAP_ADDRESSMODE | |
  114258. * | 2 | MIRROR_ADDRESSMODE | |
  114259. */
  114260. get wrapV(): number;
  114261. set wrapV(value: number);
  114262. /**
  114263. * | Value | Type | Description |
  114264. * | ----- | ------------------ | ----------- |
  114265. * | 0 | CLAMP_ADDRESSMODE | |
  114266. * | 1 | WRAP_ADDRESSMODE | |
  114267. * | 2 | MIRROR_ADDRESSMODE | |
  114268. */
  114269. wrapR: number;
  114270. /**
  114271. * With compliant hardware and browser (supporting anisotropic filtering)
  114272. * this defines the level of anisotropic filtering in the texture.
  114273. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114274. */
  114275. anisotropicFilteringLevel: number;
  114276. /**
  114277. * Define if the texture is a cube texture or if false a 2d texture.
  114278. */
  114279. get isCube(): boolean;
  114280. set isCube(value: boolean);
  114281. /**
  114282. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114283. */
  114284. get is3D(): boolean;
  114285. set is3D(value: boolean);
  114286. /**
  114287. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114288. */
  114289. get is2DArray(): boolean;
  114290. set is2DArray(value: boolean);
  114291. private _gammaSpace;
  114292. /**
  114293. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114294. * HDR texture are usually stored in linear space.
  114295. * This only impacts the PBR and Background materials
  114296. */
  114297. get gammaSpace(): boolean;
  114298. set gammaSpace(gamma: boolean);
  114299. /**
  114300. * Gets or sets whether or not the texture contains RGBD data.
  114301. */
  114302. get isRGBD(): boolean;
  114303. set isRGBD(value: boolean);
  114304. /**
  114305. * Is Z inverted in the texture (useful in a cube texture).
  114306. */
  114307. invertZ: boolean;
  114308. /**
  114309. * Are mip maps generated for this texture or not.
  114310. */
  114311. get noMipmap(): boolean;
  114312. /**
  114313. * @hidden
  114314. */
  114315. lodLevelInAlpha: boolean;
  114316. /**
  114317. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114318. */
  114319. get lodGenerationOffset(): number;
  114320. set lodGenerationOffset(value: number);
  114321. /**
  114322. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114323. */
  114324. get lodGenerationScale(): number;
  114325. set lodGenerationScale(value: number);
  114326. /**
  114327. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114328. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114329. * average roughness values.
  114330. */
  114331. get linearSpecularLOD(): boolean;
  114332. set linearSpecularLOD(value: boolean);
  114333. /**
  114334. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114335. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114336. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114337. */
  114338. get irradianceTexture(): Nullable<BaseTexture>;
  114339. set irradianceTexture(value: Nullable<BaseTexture>);
  114340. /**
  114341. * Define if the texture is a render target.
  114342. */
  114343. isRenderTarget: boolean;
  114344. /**
  114345. * Define the unique id of the texture in the scene.
  114346. */
  114347. get uid(): string;
  114348. /** @hidden */
  114349. _prefiltered: boolean;
  114350. /**
  114351. * Return a string representation of the texture.
  114352. * @returns the texture as a string
  114353. */
  114354. toString(): string;
  114355. /**
  114356. * Get the class name of the texture.
  114357. * @returns "BaseTexture"
  114358. */
  114359. getClassName(): string;
  114360. /**
  114361. * Define the list of animation attached to the texture.
  114362. */
  114363. animations: Animation[];
  114364. /**
  114365. * An event triggered when the texture is disposed.
  114366. */
  114367. onDisposeObservable: Observable<BaseTexture>;
  114368. private _onDisposeObserver;
  114369. /**
  114370. * Callback triggered when the texture has been disposed.
  114371. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114372. */
  114373. set onDispose(callback: () => void);
  114374. /**
  114375. * Define the current state of the loading sequence when in delayed load mode.
  114376. */
  114377. delayLoadState: number;
  114378. protected _scene: Nullable<Scene>;
  114379. protected _engine: Nullable<ThinEngine>;
  114380. /** @hidden */
  114381. _texture: Nullable<InternalTexture>;
  114382. private _uid;
  114383. /**
  114384. * Define if the texture is preventinga material to render or not.
  114385. * If not and the texture is not ready, the engine will use a default black texture instead.
  114386. */
  114387. get isBlocking(): boolean;
  114388. /**
  114389. * Instantiates a new BaseTexture.
  114390. * Base class of all the textures in babylon.
  114391. * It groups all the common properties the materials, post process, lights... might need
  114392. * in order to make a correct use of the texture.
  114393. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114394. */
  114395. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114396. /**
  114397. * Get the scene the texture belongs to.
  114398. * @returns the scene or null if undefined
  114399. */
  114400. getScene(): Nullable<Scene>;
  114401. /** @hidden */
  114402. protected _getEngine(): Nullable<ThinEngine>;
  114403. /**
  114404. * Get the texture transform matrix used to offset tile the texture for istance.
  114405. * @returns the transformation matrix
  114406. */
  114407. getTextureMatrix(): Matrix;
  114408. /**
  114409. * Get the texture reflection matrix used to rotate/transform the reflection.
  114410. * @returns the reflection matrix
  114411. */
  114412. getReflectionTextureMatrix(): Matrix;
  114413. /**
  114414. * Get the underlying lower level texture from Babylon.
  114415. * @returns the insternal texture
  114416. */
  114417. getInternalTexture(): Nullable<InternalTexture>;
  114418. /**
  114419. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114420. * @returns true if ready or not blocking
  114421. */
  114422. isReadyOrNotBlocking(): boolean;
  114423. /**
  114424. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114425. * @returns true if fully ready
  114426. */
  114427. isReady(): boolean;
  114428. private _cachedSize;
  114429. /**
  114430. * Get the size of the texture.
  114431. * @returns the texture size.
  114432. */
  114433. getSize(): ISize;
  114434. /**
  114435. * Get the base size of the texture.
  114436. * It can be different from the size if the texture has been resized for POT for instance
  114437. * @returns the base size
  114438. */
  114439. getBaseSize(): ISize;
  114440. /**
  114441. * Update the sampling mode of the texture.
  114442. * Default is Trilinear mode.
  114443. *
  114444. * | Value | Type | Description |
  114445. * | ----- | ------------------ | ----------- |
  114446. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114447. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114448. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114449. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114450. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114451. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114452. * | 7 | NEAREST_LINEAR | |
  114453. * | 8 | NEAREST_NEAREST | |
  114454. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114455. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114456. * | 11 | LINEAR_LINEAR | |
  114457. * | 12 | LINEAR_NEAREST | |
  114458. *
  114459. * > _mag_: magnification filter (close to the viewer)
  114460. * > _min_: minification filter (far from the viewer)
  114461. * > _mip_: filter used between mip map levels
  114462. *@param samplingMode Define the new sampling mode of the texture
  114463. */
  114464. updateSamplingMode(samplingMode: number): void;
  114465. /**
  114466. * Scales the texture if is `canRescale()`
  114467. * @param ratio the resize factor we want to use to rescale
  114468. */
  114469. scale(ratio: number): void;
  114470. /**
  114471. * Get if the texture can rescale.
  114472. */
  114473. get canRescale(): boolean;
  114474. /** @hidden */
  114475. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114476. /** @hidden */
  114477. _rebuild(): void;
  114478. /**
  114479. * Triggers the load sequence in delayed load mode.
  114480. */
  114481. delayLoad(): void;
  114482. /**
  114483. * Clones the texture.
  114484. * @returns the cloned texture
  114485. */
  114486. clone(): Nullable<BaseTexture>;
  114487. /**
  114488. * Get the texture underlying type (INT, FLOAT...)
  114489. */
  114490. get textureType(): number;
  114491. /**
  114492. * Get the texture underlying format (RGB, RGBA...)
  114493. */
  114494. get textureFormat(): number;
  114495. /**
  114496. * Indicates that textures need to be re-calculated for all materials
  114497. */
  114498. protected _markAllSubMeshesAsTexturesDirty(): void;
  114499. /**
  114500. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114501. * This will returns an RGBA array buffer containing either in values (0-255) or
  114502. * float values (0-1) depending of the underlying buffer type.
  114503. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114504. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114505. * @param buffer defines a user defined buffer to fill with data (can be null)
  114506. * @returns The Array buffer containing the pixels data.
  114507. */
  114508. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114509. /**
  114510. * Release and destroy the underlying lower level texture aka internalTexture.
  114511. */
  114512. releaseInternalTexture(): void;
  114513. /** @hidden */
  114514. get _lodTextureHigh(): Nullable<BaseTexture>;
  114515. /** @hidden */
  114516. get _lodTextureMid(): Nullable<BaseTexture>;
  114517. /** @hidden */
  114518. get _lodTextureLow(): Nullable<BaseTexture>;
  114519. /**
  114520. * Dispose the texture and release its associated resources.
  114521. */
  114522. dispose(): void;
  114523. /**
  114524. * Serialize the texture into a JSON representation that can be parsed later on.
  114525. * @returns the JSON representation of the texture
  114526. */
  114527. serialize(): any;
  114528. /**
  114529. * Helper function to be called back once a list of texture contains only ready textures.
  114530. * @param textures Define the list of textures to wait for
  114531. * @param callback Define the callback triggered once the entire list will be ready
  114532. */
  114533. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114534. private static _isScene;
  114535. }
  114536. }
  114537. declare module BABYLON {
  114538. /**
  114539. * Options to be used when creating an effect.
  114540. */
  114541. export interface IEffectCreationOptions {
  114542. /**
  114543. * Atrributes that will be used in the shader.
  114544. */
  114545. attributes: string[];
  114546. /**
  114547. * Uniform varible names that will be set in the shader.
  114548. */
  114549. uniformsNames: string[];
  114550. /**
  114551. * Uniform buffer variable names that will be set in the shader.
  114552. */
  114553. uniformBuffersNames: string[];
  114554. /**
  114555. * Sampler texture variable names that will be set in the shader.
  114556. */
  114557. samplers: string[];
  114558. /**
  114559. * Define statements that will be set in the shader.
  114560. */
  114561. defines: any;
  114562. /**
  114563. * Possible fallbacks for this effect to improve performance when needed.
  114564. */
  114565. fallbacks: Nullable<IEffectFallbacks>;
  114566. /**
  114567. * Callback that will be called when the shader is compiled.
  114568. */
  114569. onCompiled: Nullable<(effect: Effect) => void>;
  114570. /**
  114571. * Callback that will be called if an error occurs during shader compilation.
  114572. */
  114573. onError: Nullable<(effect: Effect, errors: string) => void>;
  114574. /**
  114575. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114576. */
  114577. indexParameters?: any;
  114578. /**
  114579. * Max number of lights that can be used in the shader.
  114580. */
  114581. maxSimultaneousLights?: number;
  114582. /**
  114583. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114584. */
  114585. transformFeedbackVaryings?: Nullable<string[]>;
  114586. /**
  114587. * 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
  114588. */
  114589. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114590. /**
  114591. * Is this effect rendering to several color attachments ?
  114592. */
  114593. multiTarget?: boolean;
  114594. }
  114595. /**
  114596. * Effect containing vertex and fragment shader that can be executed on an object.
  114597. */
  114598. export class Effect implements IDisposable {
  114599. /**
  114600. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114601. */
  114602. static ShadersRepository: string;
  114603. /**
  114604. * Enable logging of the shader code when a compilation error occurs
  114605. */
  114606. static LogShaderCodeOnCompilationError: boolean;
  114607. /**
  114608. * Name of the effect.
  114609. */
  114610. name: any;
  114611. /**
  114612. * String container all the define statements that should be set on the shader.
  114613. */
  114614. defines: string;
  114615. /**
  114616. * Callback that will be called when the shader is compiled.
  114617. */
  114618. onCompiled: Nullable<(effect: Effect) => void>;
  114619. /**
  114620. * Callback that will be called if an error occurs during shader compilation.
  114621. */
  114622. onError: Nullable<(effect: Effect, errors: string) => void>;
  114623. /**
  114624. * Callback that will be called when effect is bound.
  114625. */
  114626. onBind: Nullable<(effect: Effect) => void>;
  114627. /**
  114628. * Unique ID of the effect.
  114629. */
  114630. uniqueId: number;
  114631. /**
  114632. * Observable that will be called when the shader is compiled.
  114633. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114634. */
  114635. onCompileObservable: Observable<Effect>;
  114636. /**
  114637. * Observable that will be called if an error occurs during shader compilation.
  114638. */
  114639. onErrorObservable: Observable<Effect>;
  114640. /** @hidden */
  114641. _onBindObservable: Nullable<Observable<Effect>>;
  114642. /**
  114643. * @hidden
  114644. * Specifies if the effect was previously ready
  114645. */
  114646. _wasPreviouslyReady: boolean;
  114647. /**
  114648. * Observable that will be called when effect is bound.
  114649. */
  114650. get onBindObservable(): Observable<Effect>;
  114651. /** @hidden */
  114652. _bonesComputationForcedToCPU: boolean;
  114653. /** @hidden */
  114654. _multiTarget: boolean;
  114655. private static _uniqueIdSeed;
  114656. private _engine;
  114657. private _uniformBuffersNames;
  114658. private _uniformBuffersNamesList;
  114659. private _uniformsNames;
  114660. private _samplerList;
  114661. private _samplers;
  114662. private _isReady;
  114663. private _compilationError;
  114664. private _allFallbacksProcessed;
  114665. private _attributesNames;
  114666. private _attributes;
  114667. private _attributeLocationByName;
  114668. private _uniforms;
  114669. /**
  114670. * Key for the effect.
  114671. * @hidden
  114672. */
  114673. _key: string;
  114674. private _indexParameters;
  114675. private _fallbacks;
  114676. private _vertexSourceCode;
  114677. private _fragmentSourceCode;
  114678. private _vertexSourceCodeOverride;
  114679. private _fragmentSourceCodeOverride;
  114680. private _transformFeedbackVaryings;
  114681. /**
  114682. * Compiled shader to webGL program.
  114683. * @hidden
  114684. */
  114685. _pipelineContext: Nullable<IPipelineContext>;
  114686. private _valueCache;
  114687. private static _baseCache;
  114688. /**
  114689. * Instantiates an effect.
  114690. * An effect can be used to create/manage/execute vertex and fragment shaders.
  114691. * @param baseName Name of the effect.
  114692. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  114693. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  114694. * @param samplers List of sampler variables that will be passed to the shader.
  114695. * @param engine Engine to be used to render the effect
  114696. * @param defines Define statements to be added to the shader.
  114697. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  114698. * @param onCompiled Callback that will be called when the shader is compiled.
  114699. * @param onError Callback that will be called if an error occurs during shader compilation.
  114700. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114701. */
  114702. 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);
  114703. private _useFinalCode;
  114704. /**
  114705. * Unique key for this effect
  114706. */
  114707. get key(): string;
  114708. /**
  114709. * If the effect has been compiled and prepared.
  114710. * @returns if the effect is compiled and prepared.
  114711. */
  114712. isReady(): boolean;
  114713. private _isReadyInternal;
  114714. /**
  114715. * The engine the effect was initialized with.
  114716. * @returns the engine.
  114717. */
  114718. getEngine(): Engine;
  114719. /**
  114720. * The pipeline context for this effect
  114721. * @returns the associated pipeline context
  114722. */
  114723. getPipelineContext(): Nullable<IPipelineContext>;
  114724. /**
  114725. * The set of names of attribute variables for the shader.
  114726. * @returns An array of attribute names.
  114727. */
  114728. getAttributesNames(): string[];
  114729. /**
  114730. * Returns the attribute at the given index.
  114731. * @param index The index of the attribute.
  114732. * @returns The location of the attribute.
  114733. */
  114734. getAttributeLocation(index: number): number;
  114735. /**
  114736. * Returns the attribute based on the name of the variable.
  114737. * @param name of the attribute to look up.
  114738. * @returns the attribute location.
  114739. */
  114740. getAttributeLocationByName(name: string): number;
  114741. /**
  114742. * The number of attributes.
  114743. * @returns the numnber of attributes.
  114744. */
  114745. getAttributesCount(): number;
  114746. /**
  114747. * Gets the index of a uniform variable.
  114748. * @param uniformName of the uniform to look up.
  114749. * @returns the index.
  114750. */
  114751. getUniformIndex(uniformName: string): number;
  114752. /**
  114753. * Returns the attribute based on the name of the variable.
  114754. * @param uniformName of the uniform to look up.
  114755. * @returns the location of the uniform.
  114756. */
  114757. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  114758. /**
  114759. * Returns an array of sampler variable names
  114760. * @returns The array of sampler variable names.
  114761. */
  114762. getSamplers(): string[];
  114763. /**
  114764. * Returns an array of uniform variable names
  114765. * @returns The array of uniform variable names.
  114766. */
  114767. getUniformNames(): string[];
  114768. /**
  114769. * Returns an array of uniform buffer variable names
  114770. * @returns The array of uniform buffer variable names.
  114771. */
  114772. getUniformBuffersNames(): string[];
  114773. /**
  114774. * Returns the index parameters used to create the effect
  114775. * @returns The index parameters object
  114776. */
  114777. getIndexParameters(): any;
  114778. /**
  114779. * The error from the last compilation.
  114780. * @returns the error string.
  114781. */
  114782. getCompilationError(): string;
  114783. /**
  114784. * Gets a boolean indicating that all fallbacks were used during compilation
  114785. * @returns true if all fallbacks were used
  114786. */
  114787. allFallbacksProcessed(): boolean;
  114788. /**
  114789. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  114790. * @param func The callback to be used.
  114791. */
  114792. executeWhenCompiled(func: (effect: Effect) => void): void;
  114793. private _checkIsReady;
  114794. private _loadShader;
  114795. /**
  114796. * Gets the vertex shader source code of this effect
  114797. */
  114798. get vertexSourceCode(): string;
  114799. /**
  114800. * Gets the fragment shader source code of this effect
  114801. */
  114802. get fragmentSourceCode(): string;
  114803. /**
  114804. * Recompiles the webGL program
  114805. * @param vertexSourceCode The source code for the vertex shader.
  114806. * @param fragmentSourceCode The source code for the fragment shader.
  114807. * @param onCompiled Callback called when completed.
  114808. * @param onError Callback called on error.
  114809. * @hidden
  114810. */
  114811. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  114812. /**
  114813. * Prepares the effect
  114814. * @hidden
  114815. */
  114816. _prepareEffect(): void;
  114817. private _getShaderCodeAndErrorLine;
  114818. private _processCompilationErrors;
  114819. /**
  114820. * Checks if the effect is supported. (Must be called after compilation)
  114821. */
  114822. get isSupported(): boolean;
  114823. /**
  114824. * Binds a texture to the engine to be used as output of the shader.
  114825. * @param channel Name of the output variable.
  114826. * @param texture Texture to bind.
  114827. * @hidden
  114828. */
  114829. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  114830. /**
  114831. * Sets a texture on the engine to be used in the shader.
  114832. * @param channel Name of the sampler variable.
  114833. * @param texture Texture to set.
  114834. */
  114835. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  114836. /**
  114837. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  114838. * @param channel Name of the sampler variable.
  114839. * @param texture Texture to set.
  114840. */
  114841. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  114842. /**
  114843. * Sets an array of textures on the engine to be used in the shader.
  114844. * @param channel Name of the variable.
  114845. * @param textures Textures to set.
  114846. */
  114847. setTextureArray(channel: string, textures: BaseTexture[]): void;
  114848. /**
  114849. * 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)
  114850. * @param channel Name of the sampler variable.
  114851. * @param postProcess Post process to get the input texture from.
  114852. */
  114853. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  114854. /**
  114855. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  114856. * 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)
  114857. * @param channel Name of the sampler variable.
  114858. * @param postProcess Post process to get the output texture from.
  114859. */
  114860. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  114861. /** @hidden */
  114862. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  114863. /** @hidden */
  114864. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  114865. /** @hidden */
  114866. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  114867. /** @hidden */
  114868. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  114869. /**
  114870. * Binds a buffer to a uniform.
  114871. * @param buffer Buffer to bind.
  114872. * @param name Name of the uniform variable to bind to.
  114873. */
  114874. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  114875. /**
  114876. * Binds block to a uniform.
  114877. * @param blockName Name of the block to bind.
  114878. * @param index Index to bind.
  114879. */
  114880. bindUniformBlock(blockName: string, index: number): void;
  114881. /**
  114882. * Sets an interger value on a uniform variable.
  114883. * @param uniformName Name of the variable.
  114884. * @param value Value to be set.
  114885. * @returns this effect.
  114886. */
  114887. setInt(uniformName: string, value: number): Effect;
  114888. /**
  114889. * Sets an int array on a uniform variable.
  114890. * @param uniformName Name of the variable.
  114891. * @param array array to be set.
  114892. * @returns this effect.
  114893. */
  114894. setIntArray(uniformName: string, array: Int32Array): Effect;
  114895. /**
  114896. * 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)
  114897. * @param uniformName Name of the variable.
  114898. * @param array array to be set.
  114899. * @returns this effect.
  114900. */
  114901. setIntArray2(uniformName: string, array: Int32Array): Effect;
  114902. /**
  114903. * 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)
  114904. * @param uniformName Name of the variable.
  114905. * @param array array to be set.
  114906. * @returns this effect.
  114907. */
  114908. setIntArray3(uniformName: string, array: Int32Array): Effect;
  114909. /**
  114910. * 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)
  114911. * @param uniformName Name of the variable.
  114912. * @param array array to be set.
  114913. * @returns this effect.
  114914. */
  114915. setIntArray4(uniformName: string, array: Int32Array): Effect;
  114916. /**
  114917. * Sets an float array on a uniform variable.
  114918. * @param uniformName Name of the variable.
  114919. * @param array array to be set.
  114920. * @returns this effect.
  114921. */
  114922. setFloatArray(uniformName: string, array: Float32Array): Effect;
  114923. /**
  114924. * 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)
  114925. * @param uniformName Name of the variable.
  114926. * @param array array to be set.
  114927. * @returns this effect.
  114928. */
  114929. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  114930. /**
  114931. * 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)
  114932. * @param uniformName Name of the variable.
  114933. * @param array array to be set.
  114934. * @returns this effect.
  114935. */
  114936. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  114937. /**
  114938. * 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)
  114939. * @param uniformName Name of the variable.
  114940. * @param array array to be set.
  114941. * @returns this effect.
  114942. */
  114943. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  114944. /**
  114945. * Sets an array on a uniform variable.
  114946. * @param uniformName Name of the variable.
  114947. * @param array array to be set.
  114948. * @returns this effect.
  114949. */
  114950. setArray(uniformName: string, array: number[]): Effect;
  114951. /**
  114952. * 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)
  114953. * @param uniformName Name of the variable.
  114954. * @param array array to be set.
  114955. * @returns this effect.
  114956. */
  114957. setArray2(uniformName: string, array: number[]): Effect;
  114958. /**
  114959. * 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)
  114960. * @param uniformName Name of the variable.
  114961. * @param array array to be set.
  114962. * @returns this effect.
  114963. */
  114964. setArray3(uniformName: string, array: number[]): Effect;
  114965. /**
  114966. * 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)
  114967. * @param uniformName Name of the variable.
  114968. * @param array array to be set.
  114969. * @returns this effect.
  114970. */
  114971. setArray4(uniformName: string, array: number[]): Effect;
  114972. /**
  114973. * Sets matrices on a uniform variable.
  114974. * @param uniformName Name of the variable.
  114975. * @param matrices matrices to be set.
  114976. * @returns this effect.
  114977. */
  114978. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  114979. /**
  114980. * Sets matrix on a uniform variable.
  114981. * @param uniformName Name of the variable.
  114982. * @param matrix matrix to be set.
  114983. * @returns this effect.
  114984. */
  114985. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  114986. /**
  114987. * 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)
  114988. * @param uniformName Name of the variable.
  114989. * @param matrix matrix to be set.
  114990. * @returns this effect.
  114991. */
  114992. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  114993. /**
  114994. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  114995. * @param uniformName Name of the variable.
  114996. * @param matrix matrix to be set.
  114997. * @returns this effect.
  114998. */
  114999. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115000. /**
  115001. * Sets a float on a uniform variable.
  115002. * @param uniformName Name of the variable.
  115003. * @param value value to be set.
  115004. * @returns this effect.
  115005. */
  115006. setFloat(uniformName: string, value: number): Effect;
  115007. /**
  115008. * Sets a boolean on a uniform variable.
  115009. * @param uniformName Name of the variable.
  115010. * @param bool value to be set.
  115011. * @returns this effect.
  115012. */
  115013. setBool(uniformName: string, bool: boolean): Effect;
  115014. /**
  115015. * Sets a Vector2 on a uniform variable.
  115016. * @param uniformName Name of the variable.
  115017. * @param vector2 vector2 to be set.
  115018. * @returns this effect.
  115019. */
  115020. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115021. /**
  115022. * Sets a float2 on a uniform variable.
  115023. * @param uniformName Name of the variable.
  115024. * @param x First float in float2.
  115025. * @param y Second float in float2.
  115026. * @returns this effect.
  115027. */
  115028. setFloat2(uniformName: string, x: number, y: number): Effect;
  115029. /**
  115030. * Sets a Vector3 on a uniform variable.
  115031. * @param uniformName Name of the variable.
  115032. * @param vector3 Value to be set.
  115033. * @returns this effect.
  115034. */
  115035. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115036. /**
  115037. * Sets a float3 on a uniform variable.
  115038. * @param uniformName Name of the variable.
  115039. * @param x First float in float3.
  115040. * @param y Second float in float3.
  115041. * @param z Third float in float3.
  115042. * @returns this effect.
  115043. */
  115044. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115045. /**
  115046. * Sets a Vector4 on a uniform variable.
  115047. * @param uniformName Name of the variable.
  115048. * @param vector4 Value to be set.
  115049. * @returns this effect.
  115050. */
  115051. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115052. /**
  115053. * Sets a float4 on a uniform variable.
  115054. * @param uniformName Name of the variable.
  115055. * @param x First float in float4.
  115056. * @param y Second float in float4.
  115057. * @param z Third float in float4.
  115058. * @param w Fourth float in float4.
  115059. * @returns this effect.
  115060. */
  115061. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115062. /**
  115063. * Sets a Color3 on a uniform variable.
  115064. * @param uniformName Name of the variable.
  115065. * @param color3 Value to be set.
  115066. * @returns this effect.
  115067. */
  115068. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115069. /**
  115070. * Sets a Color4 on a uniform variable.
  115071. * @param uniformName Name of the variable.
  115072. * @param color3 Value to be set.
  115073. * @param alpha Alpha value to be set.
  115074. * @returns this effect.
  115075. */
  115076. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115077. /**
  115078. * Sets a Color4 on a uniform variable
  115079. * @param uniformName defines the name of the variable
  115080. * @param color4 defines the value to be set
  115081. * @returns this effect.
  115082. */
  115083. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115084. /** Release all associated resources */
  115085. dispose(): void;
  115086. /**
  115087. * This function will add a new shader to the shader store
  115088. * @param name the name of the shader
  115089. * @param pixelShader optional pixel shader content
  115090. * @param vertexShader optional vertex shader content
  115091. */
  115092. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115093. /**
  115094. * Store of each shader (The can be looked up using effect.key)
  115095. */
  115096. static ShadersStore: {
  115097. [key: string]: string;
  115098. };
  115099. /**
  115100. * Store of each included file for a shader (The can be looked up using effect.key)
  115101. */
  115102. static IncludesShadersStore: {
  115103. [key: string]: string;
  115104. };
  115105. /**
  115106. * Resets the cache of effects.
  115107. */
  115108. static ResetCache(): void;
  115109. }
  115110. }
  115111. declare module BABYLON {
  115112. /**
  115113. * Interface used to describe the capabilities of the engine relatively to the current browser
  115114. */
  115115. export interface EngineCapabilities {
  115116. /** Maximum textures units per fragment shader */
  115117. maxTexturesImageUnits: number;
  115118. /** Maximum texture units per vertex shader */
  115119. maxVertexTextureImageUnits: number;
  115120. /** Maximum textures units in the entire pipeline */
  115121. maxCombinedTexturesImageUnits: number;
  115122. /** Maximum texture size */
  115123. maxTextureSize: number;
  115124. /** Maximum texture samples */
  115125. maxSamples?: number;
  115126. /** Maximum cube texture size */
  115127. maxCubemapTextureSize: number;
  115128. /** Maximum render texture size */
  115129. maxRenderTextureSize: number;
  115130. /** Maximum number of vertex attributes */
  115131. maxVertexAttribs: number;
  115132. /** Maximum number of varyings */
  115133. maxVaryingVectors: number;
  115134. /** Maximum number of uniforms per vertex shader */
  115135. maxVertexUniformVectors: number;
  115136. /** Maximum number of uniforms per fragment shader */
  115137. maxFragmentUniformVectors: number;
  115138. /** Defines if standard derivates (dx/dy) are supported */
  115139. standardDerivatives: boolean;
  115140. /** Defines if s3tc texture compression is supported */
  115141. s3tc?: WEBGL_compressed_texture_s3tc;
  115142. /** Defines if pvrtc texture compression is supported */
  115143. pvrtc: any;
  115144. /** Defines if etc1 texture compression is supported */
  115145. etc1: any;
  115146. /** Defines if etc2 texture compression is supported */
  115147. etc2: any;
  115148. /** Defines if astc texture compression is supported */
  115149. astc: any;
  115150. /** Defines if bptc texture compression is supported */
  115151. bptc: any;
  115152. /** Defines if float textures are supported */
  115153. textureFloat: boolean;
  115154. /** Defines if vertex array objects are supported */
  115155. vertexArrayObject: boolean;
  115156. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115157. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115158. /** Gets the maximum level of anisotropy supported */
  115159. maxAnisotropy: number;
  115160. /** Defines if instancing is supported */
  115161. instancedArrays: boolean;
  115162. /** Defines if 32 bits indices are supported */
  115163. uintIndices: boolean;
  115164. /** Defines if high precision shaders are supported */
  115165. highPrecisionShaderSupported: boolean;
  115166. /** Defines if depth reading in the fragment shader is supported */
  115167. fragmentDepthSupported: boolean;
  115168. /** Defines if float texture linear filtering is supported*/
  115169. textureFloatLinearFiltering: boolean;
  115170. /** Defines if rendering to float textures is supported */
  115171. textureFloatRender: boolean;
  115172. /** Defines if half float textures are supported*/
  115173. textureHalfFloat: boolean;
  115174. /** Defines if half float texture linear filtering is supported*/
  115175. textureHalfFloatLinearFiltering: boolean;
  115176. /** Defines if rendering to half float textures is supported */
  115177. textureHalfFloatRender: boolean;
  115178. /** Defines if textureLOD shader command is supported */
  115179. textureLOD: boolean;
  115180. /** Defines if draw buffers extension is supported */
  115181. drawBuffersExtension: boolean;
  115182. /** Defines if depth textures are supported */
  115183. depthTextureExtension: boolean;
  115184. /** Defines if float color buffer are supported */
  115185. colorBufferFloat: boolean;
  115186. /** Gets disjoint timer query extension (null if not supported) */
  115187. timerQuery?: EXT_disjoint_timer_query;
  115188. /** Defines if timestamp can be used with timer query */
  115189. canUseTimestampForTimerQuery: boolean;
  115190. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115191. multiview?: any;
  115192. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115193. oculusMultiview?: any;
  115194. /** Function used to let the system compiles shaders in background */
  115195. parallelShaderCompile?: {
  115196. COMPLETION_STATUS_KHR: number;
  115197. };
  115198. /** Max number of texture samples for MSAA */
  115199. maxMSAASamples: number;
  115200. /** Defines if the blend min max extension is supported */
  115201. blendMinMax: boolean;
  115202. }
  115203. }
  115204. declare module BABYLON {
  115205. /**
  115206. * @hidden
  115207. **/
  115208. export class DepthCullingState {
  115209. private _isDepthTestDirty;
  115210. private _isDepthMaskDirty;
  115211. private _isDepthFuncDirty;
  115212. private _isCullFaceDirty;
  115213. private _isCullDirty;
  115214. private _isZOffsetDirty;
  115215. private _isFrontFaceDirty;
  115216. private _depthTest;
  115217. private _depthMask;
  115218. private _depthFunc;
  115219. private _cull;
  115220. private _cullFace;
  115221. private _zOffset;
  115222. private _frontFace;
  115223. /**
  115224. * Initializes the state.
  115225. */
  115226. constructor();
  115227. get isDirty(): boolean;
  115228. get zOffset(): number;
  115229. set zOffset(value: number);
  115230. get cullFace(): Nullable<number>;
  115231. set cullFace(value: Nullable<number>);
  115232. get cull(): Nullable<boolean>;
  115233. set cull(value: Nullable<boolean>);
  115234. get depthFunc(): Nullable<number>;
  115235. set depthFunc(value: Nullable<number>);
  115236. get depthMask(): boolean;
  115237. set depthMask(value: boolean);
  115238. get depthTest(): boolean;
  115239. set depthTest(value: boolean);
  115240. get frontFace(): Nullable<number>;
  115241. set frontFace(value: Nullable<number>);
  115242. reset(): void;
  115243. apply(gl: WebGLRenderingContext): void;
  115244. }
  115245. }
  115246. declare module BABYLON {
  115247. /**
  115248. * @hidden
  115249. **/
  115250. export class StencilState {
  115251. /** 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 */
  115252. static readonly ALWAYS: number;
  115253. /** Passed to stencilOperation to specify that stencil value must be kept */
  115254. static readonly KEEP: number;
  115255. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115256. static readonly REPLACE: number;
  115257. private _isStencilTestDirty;
  115258. private _isStencilMaskDirty;
  115259. private _isStencilFuncDirty;
  115260. private _isStencilOpDirty;
  115261. private _stencilTest;
  115262. private _stencilMask;
  115263. private _stencilFunc;
  115264. private _stencilFuncRef;
  115265. private _stencilFuncMask;
  115266. private _stencilOpStencilFail;
  115267. private _stencilOpDepthFail;
  115268. private _stencilOpStencilDepthPass;
  115269. get isDirty(): boolean;
  115270. get stencilFunc(): number;
  115271. set stencilFunc(value: number);
  115272. get stencilFuncRef(): number;
  115273. set stencilFuncRef(value: number);
  115274. get stencilFuncMask(): number;
  115275. set stencilFuncMask(value: number);
  115276. get stencilOpStencilFail(): number;
  115277. set stencilOpStencilFail(value: number);
  115278. get stencilOpDepthFail(): number;
  115279. set stencilOpDepthFail(value: number);
  115280. get stencilOpStencilDepthPass(): number;
  115281. set stencilOpStencilDepthPass(value: number);
  115282. get stencilMask(): number;
  115283. set stencilMask(value: number);
  115284. get stencilTest(): boolean;
  115285. set stencilTest(value: boolean);
  115286. constructor();
  115287. reset(): void;
  115288. apply(gl: WebGLRenderingContext): void;
  115289. }
  115290. }
  115291. declare module BABYLON {
  115292. /**
  115293. * @hidden
  115294. **/
  115295. export class AlphaState {
  115296. private _isAlphaBlendDirty;
  115297. private _isBlendFunctionParametersDirty;
  115298. private _isBlendEquationParametersDirty;
  115299. private _isBlendConstantsDirty;
  115300. private _alphaBlend;
  115301. private _blendFunctionParameters;
  115302. private _blendEquationParameters;
  115303. private _blendConstants;
  115304. /**
  115305. * Initializes the state.
  115306. */
  115307. constructor();
  115308. get isDirty(): boolean;
  115309. get alphaBlend(): boolean;
  115310. set alphaBlend(value: boolean);
  115311. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115312. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115313. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115314. reset(): void;
  115315. apply(gl: WebGLRenderingContext): void;
  115316. }
  115317. }
  115318. declare module BABYLON {
  115319. /** @hidden */
  115320. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115321. attributeProcessor(attribute: string): string;
  115322. varyingProcessor(varying: string, isFragment: boolean): string;
  115323. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115324. }
  115325. }
  115326. declare module BABYLON {
  115327. /**
  115328. * Interface for attribute information associated with buffer instanciation
  115329. */
  115330. export interface InstancingAttributeInfo {
  115331. /**
  115332. * Name of the GLSL attribute
  115333. * if attribute index is not specified, this is used to retrieve the index from the effect
  115334. */
  115335. attributeName: string;
  115336. /**
  115337. * Index/offset of the attribute in the vertex shader
  115338. * if not specified, this will be computes from the name.
  115339. */
  115340. index?: number;
  115341. /**
  115342. * size of the attribute, 1, 2, 3 or 4
  115343. */
  115344. attributeSize: number;
  115345. /**
  115346. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115347. */
  115348. offset: number;
  115349. /**
  115350. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115351. * default to 1
  115352. */
  115353. divisor?: number;
  115354. /**
  115355. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115356. * default is FLOAT
  115357. */
  115358. attributeType?: number;
  115359. /**
  115360. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115361. */
  115362. normalized?: boolean;
  115363. }
  115364. }
  115365. declare module BABYLON {
  115366. interface ThinEngine {
  115367. /**
  115368. * Update a video texture
  115369. * @param texture defines the texture to update
  115370. * @param video defines the video element to use
  115371. * @param invertY defines if data must be stored with Y axis inverted
  115372. */
  115373. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115374. }
  115375. }
  115376. declare module BABYLON {
  115377. interface ThinEngine {
  115378. /**
  115379. * Creates a dynamic texture
  115380. * @param width defines the width of the texture
  115381. * @param height defines the height of the texture
  115382. * @param generateMipMaps defines if the engine should generate the mip levels
  115383. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115384. * @returns the dynamic texture inside an InternalTexture
  115385. */
  115386. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115387. /**
  115388. * Update the content of a dynamic texture
  115389. * @param texture defines the texture to update
  115390. * @param canvas defines the canvas containing the source
  115391. * @param invertY defines if data must be stored with Y axis inverted
  115392. * @param premulAlpha defines if alpha is stored as premultiplied
  115393. * @param format defines the format of the data
  115394. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115395. */
  115396. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115397. }
  115398. }
  115399. declare module BABYLON {
  115400. /**
  115401. * Settings for finer control over video usage
  115402. */
  115403. export interface VideoTextureSettings {
  115404. /**
  115405. * Applies `autoplay` to video, if specified
  115406. */
  115407. autoPlay?: boolean;
  115408. /**
  115409. * Applies `loop` to video, if specified
  115410. */
  115411. loop?: boolean;
  115412. /**
  115413. * Automatically updates internal texture from video at every frame in the render loop
  115414. */
  115415. autoUpdateTexture: boolean;
  115416. /**
  115417. * Image src displayed during the video loading or until the user interacts with the video.
  115418. */
  115419. poster?: string;
  115420. }
  115421. /**
  115422. * If you want to display a video in your scene, this is the special texture for that.
  115423. * This special texture works similar to other textures, with the exception of a few parameters.
  115424. * @see https://doc.babylonjs.com/how_to/video_texture
  115425. */
  115426. export class VideoTexture extends Texture {
  115427. /**
  115428. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115429. */
  115430. readonly autoUpdateTexture: boolean;
  115431. /**
  115432. * The video instance used by the texture internally
  115433. */
  115434. readonly video: HTMLVideoElement;
  115435. private _onUserActionRequestedObservable;
  115436. /**
  115437. * Event triggerd when a dom action is required by the user to play the video.
  115438. * This happens due to recent changes in browser policies preventing video to auto start.
  115439. */
  115440. get onUserActionRequestedObservable(): Observable<Texture>;
  115441. private _generateMipMaps;
  115442. private _stillImageCaptured;
  115443. private _displayingPosterTexture;
  115444. private _settings;
  115445. private _createInternalTextureOnEvent;
  115446. private _frameId;
  115447. private _currentSrc;
  115448. /**
  115449. * Creates a video texture.
  115450. * If you want to display a video in your scene, this is the special texture for that.
  115451. * This special texture works similar to other textures, with the exception of a few parameters.
  115452. * @see https://doc.babylonjs.com/how_to/video_texture
  115453. * @param name optional name, will detect from video source, if not defined
  115454. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115455. * @param scene is obviously the current scene.
  115456. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115457. * @param invertY is false by default but can be used to invert video on Y axis
  115458. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115459. * @param settings allows finer control over video usage
  115460. */
  115461. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115462. private _getName;
  115463. private _getVideo;
  115464. private _createInternalTexture;
  115465. private reset;
  115466. /**
  115467. * @hidden Internal method to initiate `update`.
  115468. */
  115469. _rebuild(): void;
  115470. /**
  115471. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115472. */
  115473. update(): void;
  115474. /**
  115475. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115476. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115477. */
  115478. updateTexture(isVisible: boolean): void;
  115479. protected _updateInternalTexture: () => void;
  115480. /**
  115481. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115482. * @param url New url.
  115483. */
  115484. updateURL(url: string): void;
  115485. /**
  115486. * Clones the texture.
  115487. * @returns the cloned texture
  115488. */
  115489. clone(): VideoTexture;
  115490. /**
  115491. * Dispose the texture and release its associated resources.
  115492. */
  115493. dispose(): void;
  115494. /**
  115495. * Creates a video texture straight from a stream.
  115496. * @param scene Define the scene the texture should be created in
  115497. * @param stream Define the stream the texture should be created from
  115498. * @returns The created video texture as a promise
  115499. */
  115500. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115501. /**
  115502. * Creates a video texture straight from your WebCam video feed.
  115503. * @param scene Define the scene the texture should be created in
  115504. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115505. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115506. * @returns The created video texture as a promise
  115507. */
  115508. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115509. minWidth: number;
  115510. maxWidth: number;
  115511. minHeight: number;
  115512. maxHeight: number;
  115513. deviceId: string;
  115514. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115515. /**
  115516. * Creates a video texture straight from your WebCam video feed.
  115517. * @param scene Define the scene the texture should be created in
  115518. * @param onReady Define a callback to triggered once the texture will be ready
  115519. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115520. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115521. */
  115522. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115523. minWidth: number;
  115524. maxWidth: number;
  115525. minHeight: number;
  115526. maxHeight: number;
  115527. deviceId: string;
  115528. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115529. }
  115530. }
  115531. declare module BABYLON {
  115532. /**
  115533. * Defines the interface used by objects working like Scene
  115534. * @hidden
  115535. */
  115536. export interface ISceneLike {
  115537. _addPendingData(data: any): void;
  115538. _removePendingData(data: any): void;
  115539. offlineProvider: IOfflineProvider;
  115540. }
  115541. /**
  115542. * Information about the current host
  115543. */
  115544. export interface HostInformation {
  115545. /**
  115546. * Defines if the current host is a mobile
  115547. */
  115548. isMobile: boolean;
  115549. }
  115550. /** Interface defining initialization parameters for Engine class */
  115551. export interface EngineOptions extends WebGLContextAttributes {
  115552. /**
  115553. * Defines if the engine should no exceed a specified device ratio
  115554. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115555. */
  115556. limitDeviceRatio?: number;
  115557. /**
  115558. * Defines if webvr should be enabled automatically
  115559. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115560. */
  115561. autoEnableWebVR?: boolean;
  115562. /**
  115563. * Defines if webgl2 should be turned off even if supported
  115564. * @see https://doc.babylonjs.com/features/webgl2
  115565. */
  115566. disableWebGL2Support?: boolean;
  115567. /**
  115568. * Defines if webaudio should be initialized as well
  115569. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115570. */
  115571. audioEngine?: boolean;
  115572. /**
  115573. * Defines if animations should run using a deterministic lock step
  115574. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115575. */
  115576. deterministicLockstep?: boolean;
  115577. /** Defines the maximum steps to use with deterministic lock step mode */
  115578. lockstepMaxSteps?: number;
  115579. /** Defines the seconds between each deterministic lock step */
  115580. timeStep?: number;
  115581. /**
  115582. * Defines that engine should ignore context lost events
  115583. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115584. */
  115585. doNotHandleContextLost?: boolean;
  115586. /**
  115587. * Defines that engine should ignore modifying touch action attribute and style
  115588. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115589. */
  115590. doNotHandleTouchAction?: boolean;
  115591. /**
  115592. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115593. */
  115594. useHighPrecisionFloats?: boolean;
  115595. /**
  115596. * Make the canvas XR Compatible for XR sessions
  115597. */
  115598. xrCompatible?: boolean;
  115599. /**
  115600. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115601. */
  115602. useHighPrecisionMatrix?: boolean;
  115603. }
  115604. /**
  115605. * The base engine class (root of all engines)
  115606. */
  115607. export class ThinEngine {
  115608. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115609. static ExceptionList: ({
  115610. key: string;
  115611. capture: string;
  115612. captureConstraint: number;
  115613. targets: string[];
  115614. } | {
  115615. key: string;
  115616. capture: null;
  115617. captureConstraint: null;
  115618. targets: string[];
  115619. })[];
  115620. /** @hidden */
  115621. static _TextureLoaders: IInternalTextureLoader[];
  115622. /**
  115623. * Returns the current npm package of the sdk
  115624. */
  115625. static get NpmPackage(): string;
  115626. /**
  115627. * Returns the current version of the framework
  115628. */
  115629. static get Version(): string;
  115630. /**
  115631. * Returns a string describing the current engine
  115632. */
  115633. get description(): string;
  115634. /**
  115635. * Gets or sets the epsilon value used by collision engine
  115636. */
  115637. static CollisionsEpsilon: number;
  115638. /**
  115639. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115640. */
  115641. static get ShadersRepository(): string;
  115642. static set ShadersRepository(value: string);
  115643. /** @hidden */
  115644. _shaderProcessor: IShaderProcessor;
  115645. /**
  115646. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115647. */
  115648. forcePOTTextures: boolean;
  115649. /**
  115650. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115651. */
  115652. isFullscreen: boolean;
  115653. /**
  115654. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115655. */
  115656. cullBackFaces: boolean;
  115657. /**
  115658. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115659. */
  115660. renderEvenInBackground: boolean;
  115661. /**
  115662. * Gets or sets a boolean indicating that cache can be kept between frames
  115663. */
  115664. preventCacheWipeBetweenFrames: boolean;
  115665. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  115666. validateShaderPrograms: boolean;
  115667. /**
  115668. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  115669. * This can provide greater z depth for distant objects.
  115670. */
  115671. useReverseDepthBuffer: boolean;
  115672. /**
  115673. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  115674. */
  115675. disableUniformBuffers: boolean;
  115676. /** @hidden */
  115677. _uniformBuffers: UniformBuffer[];
  115678. /**
  115679. * Gets a boolean indicating that the engine supports uniform buffers
  115680. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  115681. */
  115682. get supportsUniformBuffers(): boolean;
  115683. /** @hidden */
  115684. _gl: WebGLRenderingContext;
  115685. /** @hidden */
  115686. _webGLVersion: number;
  115687. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  115688. protected _windowIsBackground: boolean;
  115689. protected _creationOptions: EngineOptions;
  115690. protected _highPrecisionShadersAllowed: boolean;
  115691. /** @hidden */
  115692. get _shouldUseHighPrecisionShader(): boolean;
  115693. /**
  115694. * Gets a boolean indicating that only power of 2 textures are supported
  115695. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  115696. */
  115697. get needPOTTextures(): boolean;
  115698. /** @hidden */
  115699. _badOS: boolean;
  115700. /** @hidden */
  115701. _badDesktopOS: boolean;
  115702. private _hardwareScalingLevel;
  115703. /** @hidden */
  115704. _caps: EngineCapabilities;
  115705. private _isStencilEnable;
  115706. private _glVersion;
  115707. private _glRenderer;
  115708. private _glVendor;
  115709. /** @hidden */
  115710. _videoTextureSupported: boolean;
  115711. protected _renderingQueueLaunched: boolean;
  115712. protected _activeRenderLoops: (() => void)[];
  115713. /**
  115714. * Observable signaled when a context lost event is raised
  115715. */
  115716. onContextLostObservable: Observable<ThinEngine>;
  115717. /**
  115718. * Observable signaled when a context restored event is raised
  115719. */
  115720. onContextRestoredObservable: Observable<ThinEngine>;
  115721. private _onContextLost;
  115722. private _onContextRestored;
  115723. protected _contextWasLost: boolean;
  115724. /** @hidden */
  115725. _doNotHandleContextLost: boolean;
  115726. /**
  115727. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  115728. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  115729. */
  115730. get doNotHandleContextLost(): boolean;
  115731. set doNotHandleContextLost(value: boolean);
  115732. /**
  115733. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  115734. */
  115735. disableVertexArrayObjects: boolean;
  115736. /** @hidden */
  115737. protected _colorWrite: boolean;
  115738. /** @hidden */
  115739. protected _colorWriteChanged: boolean;
  115740. /** @hidden */
  115741. protected _depthCullingState: DepthCullingState;
  115742. /** @hidden */
  115743. protected _stencilState: StencilState;
  115744. /** @hidden */
  115745. _alphaState: AlphaState;
  115746. /** @hidden */
  115747. _alphaMode: number;
  115748. /** @hidden */
  115749. _alphaEquation: number;
  115750. /** @hidden */
  115751. _internalTexturesCache: InternalTexture[];
  115752. /** @hidden */
  115753. protected _activeChannel: number;
  115754. private _currentTextureChannel;
  115755. /** @hidden */
  115756. protected _boundTexturesCache: {
  115757. [key: string]: Nullable<InternalTexture>;
  115758. };
  115759. /** @hidden */
  115760. protected _currentEffect: Nullable<Effect>;
  115761. /** @hidden */
  115762. protected _currentProgram: Nullable<WebGLProgram>;
  115763. private _compiledEffects;
  115764. private _vertexAttribArraysEnabled;
  115765. /** @hidden */
  115766. protected _cachedViewport: Nullable<IViewportLike>;
  115767. private _cachedVertexArrayObject;
  115768. /** @hidden */
  115769. protected _cachedVertexBuffers: any;
  115770. /** @hidden */
  115771. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  115772. /** @hidden */
  115773. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  115774. /** @hidden */
  115775. _currentRenderTarget: Nullable<InternalTexture>;
  115776. private _uintIndicesCurrentlySet;
  115777. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  115778. /** @hidden */
  115779. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  115780. /** @hidden */
  115781. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  115782. private _currentBufferPointers;
  115783. private _currentInstanceLocations;
  115784. private _currentInstanceBuffers;
  115785. private _textureUnits;
  115786. /** @hidden */
  115787. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  115788. /** @hidden */
  115789. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  115790. /** @hidden */
  115791. _boundRenderFunction: any;
  115792. private _vaoRecordInProgress;
  115793. private _mustWipeVertexAttributes;
  115794. private _emptyTexture;
  115795. private _emptyCubeTexture;
  115796. private _emptyTexture3D;
  115797. private _emptyTexture2DArray;
  115798. /** @hidden */
  115799. _frameHandler: number;
  115800. private _nextFreeTextureSlots;
  115801. private _maxSimultaneousTextures;
  115802. private _activeRequests;
  115803. /** @hidden */
  115804. _transformTextureUrl: Nullable<(url: string) => string>;
  115805. /**
  115806. * Gets information about the current host
  115807. */
  115808. hostInformation: HostInformation;
  115809. protected get _supportsHardwareTextureRescaling(): boolean;
  115810. private _framebufferDimensionsObject;
  115811. /**
  115812. * sets the object from which width and height will be taken from when getting render width and height
  115813. * Will fallback to the gl object
  115814. * @param dimensions the framebuffer width and height that will be used.
  115815. */
  115816. set framebufferDimensionsObject(dimensions: Nullable<{
  115817. framebufferWidth: number;
  115818. framebufferHeight: number;
  115819. }>);
  115820. /**
  115821. * Gets the current viewport
  115822. */
  115823. get currentViewport(): Nullable<IViewportLike>;
  115824. /**
  115825. * Gets the default empty texture
  115826. */
  115827. get emptyTexture(): InternalTexture;
  115828. /**
  115829. * Gets the default empty 3D texture
  115830. */
  115831. get emptyTexture3D(): InternalTexture;
  115832. /**
  115833. * Gets the default empty 2D array texture
  115834. */
  115835. get emptyTexture2DArray(): InternalTexture;
  115836. /**
  115837. * Gets the default empty cube texture
  115838. */
  115839. get emptyCubeTexture(): InternalTexture;
  115840. /**
  115841. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  115842. */
  115843. readonly premultipliedAlpha: boolean;
  115844. /**
  115845. * Observable event triggered before each texture is initialized
  115846. */
  115847. onBeforeTextureInitObservable: Observable<Texture>;
  115848. /**
  115849. * Creates a new engine
  115850. * @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
  115851. * @param antialias defines enable antialiasing (default: false)
  115852. * @param options defines further options to be sent to the getContext() function
  115853. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  115854. */
  115855. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  115856. private _rebuildInternalTextures;
  115857. private _rebuildEffects;
  115858. /**
  115859. * Gets a boolean indicating if all created effects are ready
  115860. * @returns true if all effects are ready
  115861. */
  115862. areAllEffectsReady(): boolean;
  115863. protected _rebuildBuffers(): void;
  115864. protected _initGLContext(): void;
  115865. /**
  115866. * Gets version of the current webGL context
  115867. */
  115868. get webGLVersion(): number;
  115869. /**
  115870. * Gets a string identifying the name of the class
  115871. * @returns "Engine" string
  115872. */
  115873. getClassName(): string;
  115874. /**
  115875. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  115876. */
  115877. get isStencilEnable(): boolean;
  115878. /** @hidden */
  115879. _prepareWorkingCanvas(): void;
  115880. /**
  115881. * Reset the texture cache to empty state
  115882. */
  115883. resetTextureCache(): void;
  115884. /**
  115885. * Gets an object containing information about the current webGL context
  115886. * @returns an object containing the vender, the renderer and the version of the current webGL context
  115887. */
  115888. getGlInfo(): {
  115889. vendor: string;
  115890. renderer: string;
  115891. version: string;
  115892. };
  115893. /**
  115894. * Defines the hardware scaling level.
  115895. * By default the hardware scaling level is computed from the window device ratio.
  115896. * 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.
  115897. * @param level defines the level to use
  115898. */
  115899. setHardwareScalingLevel(level: number): void;
  115900. /**
  115901. * Gets the current hardware scaling level.
  115902. * By default the hardware scaling level is computed from the window device ratio.
  115903. * 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.
  115904. * @returns a number indicating the current hardware scaling level
  115905. */
  115906. getHardwareScalingLevel(): number;
  115907. /**
  115908. * Gets the list of loaded textures
  115909. * @returns an array containing all loaded textures
  115910. */
  115911. getLoadedTexturesCache(): InternalTexture[];
  115912. /**
  115913. * Gets the object containing all engine capabilities
  115914. * @returns the EngineCapabilities object
  115915. */
  115916. getCaps(): EngineCapabilities;
  115917. /**
  115918. * stop executing a render loop function and remove it from the execution array
  115919. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  115920. */
  115921. stopRenderLoop(renderFunction?: () => void): void;
  115922. /** @hidden */
  115923. _renderLoop(): void;
  115924. /**
  115925. * Gets the HTML canvas attached with the current webGL context
  115926. * @returns a HTML canvas
  115927. */
  115928. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  115929. /**
  115930. * Gets host window
  115931. * @returns the host window object
  115932. */
  115933. getHostWindow(): Nullable<Window>;
  115934. /**
  115935. * Gets the current render width
  115936. * @param useScreen defines if screen size must be used (or the current render target if any)
  115937. * @returns a number defining the current render width
  115938. */
  115939. getRenderWidth(useScreen?: boolean): number;
  115940. /**
  115941. * Gets the current render height
  115942. * @param useScreen defines if screen size must be used (or the current render target if any)
  115943. * @returns a number defining the current render height
  115944. */
  115945. getRenderHeight(useScreen?: boolean): number;
  115946. /**
  115947. * Can be used to override the current requestAnimationFrame requester.
  115948. * @hidden
  115949. */
  115950. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  115951. /**
  115952. * Register and execute a render loop. The engine can have more than one render function
  115953. * @param renderFunction defines the function to continuously execute
  115954. */
  115955. runRenderLoop(renderFunction: () => void): void;
  115956. /**
  115957. * Clear the current render buffer or the current render target (if any is set up)
  115958. * @param color defines the color to use
  115959. * @param backBuffer defines if the back buffer must be cleared
  115960. * @param depth defines if the depth buffer must be cleared
  115961. * @param stencil defines if the stencil buffer must be cleared
  115962. */
  115963. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  115964. private _viewportCached;
  115965. /** @hidden */
  115966. _viewport(x: number, y: number, width: number, height: number): void;
  115967. /**
  115968. * Set the WebGL's viewport
  115969. * @param viewport defines the viewport element to be used
  115970. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  115971. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  115972. */
  115973. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  115974. /**
  115975. * Begin a new frame
  115976. */
  115977. beginFrame(): void;
  115978. /**
  115979. * Enf the current frame
  115980. */
  115981. endFrame(): void;
  115982. /**
  115983. * Resize the view according to the canvas' size
  115984. */
  115985. resize(): void;
  115986. /**
  115987. * Force a specific size of the canvas
  115988. * @param width defines the new canvas' width
  115989. * @param height defines the new canvas' height
  115990. * @returns true if the size was changed
  115991. */
  115992. setSize(width: number, height: number): boolean;
  115993. /**
  115994. * Binds the frame buffer to the specified texture.
  115995. * @param texture The texture to render to or null for the default canvas
  115996. * @param faceIndex The face of the texture to render to in case of cube texture
  115997. * @param requiredWidth The width of the target to render to
  115998. * @param requiredHeight The height of the target to render to
  115999. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116000. * @param lodLevel defines the lod level to bind to the frame buffer
  116001. * @param layer defines the 2d array index to bind to frame buffer to
  116002. */
  116003. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116004. /** @hidden */
  116005. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116006. /**
  116007. * Unbind the current render target texture from the webGL context
  116008. * @param texture defines the render target texture to unbind
  116009. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116010. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116011. */
  116012. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116013. /**
  116014. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116015. */
  116016. flushFramebuffer(): void;
  116017. /**
  116018. * Unbind the current render target and bind the default framebuffer
  116019. */
  116020. restoreDefaultFramebuffer(): void;
  116021. /** @hidden */
  116022. protected _resetVertexBufferBinding(): void;
  116023. /**
  116024. * Creates a vertex buffer
  116025. * @param data the data for the vertex buffer
  116026. * @returns the new WebGL static buffer
  116027. */
  116028. createVertexBuffer(data: DataArray): DataBuffer;
  116029. private _createVertexBuffer;
  116030. /**
  116031. * Creates a dynamic vertex buffer
  116032. * @param data the data for the dynamic vertex buffer
  116033. * @returns the new WebGL dynamic buffer
  116034. */
  116035. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116036. protected _resetIndexBufferBinding(): void;
  116037. /**
  116038. * Creates a new index buffer
  116039. * @param indices defines the content of the index buffer
  116040. * @param updatable defines if the index buffer must be updatable
  116041. * @returns a new webGL buffer
  116042. */
  116043. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116044. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116045. /**
  116046. * Bind a webGL buffer to the webGL context
  116047. * @param buffer defines the buffer to bind
  116048. */
  116049. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116050. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116051. private bindBuffer;
  116052. /**
  116053. * update the bound buffer with the given data
  116054. * @param data defines the data to update
  116055. */
  116056. updateArrayBuffer(data: Float32Array): void;
  116057. private _vertexAttribPointer;
  116058. /** @hidden */
  116059. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116060. private _bindVertexBuffersAttributes;
  116061. /**
  116062. * Records a vertex array object
  116063. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116064. * @param vertexBuffers defines the list of vertex buffers to store
  116065. * @param indexBuffer defines the index buffer to store
  116066. * @param effect defines the effect to store
  116067. * @returns the new vertex array object
  116068. */
  116069. recordVertexArrayObject(vertexBuffers: {
  116070. [key: string]: VertexBuffer;
  116071. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116072. /**
  116073. * Bind a specific vertex array object
  116074. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116075. * @param vertexArrayObject defines the vertex array object to bind
  116076. * @param indexBuffer defines the index buffer to bind
  116077. */
  116078. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116079. /**
  116080. * Bind webGl buffers directly to the webGL context
  116081. * @param vertexBuffer defines the vertex buffer to bind
  116082. * @param indexBuffer defines the index buffer to bind
  116083. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116084. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116085. * @param effect defines the effect associated with the vertex buffer
  116086. */
  116087. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116088. private _unbindVertexArrayObject;
  116089. /**
  116090. * Bind a list of vertex buffers to the webGL context
  116091. * @param vertexBuffers defines the list of vertex buffers to bind
  116092. * @param indexBuffer defines the index buffer to bind
  116093. * @param effect defines the effect associated with the vertex buffers
  116094. */
  116095. bindBuffers(vertexBuffers: {
  116096. [key: string]: Nullable<VertexBuffer>;
  116097. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116098. /**
  116099. * Unbind all instance attributes
  116100. */
  116101. unbindInstanceAttributes(): void;
  116102. /**
  116103. * Release and free the memory of a vertex array object
  116104. * @param vao defines the vertex array object to delete
  116105. */
  116106. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116107. /** @hidden */
  116108. _releaseBuffer(buffer: DataBuffer): boolean;
  116109. protected _deleteBuffer(buffer: DataBuffer): void;
  116110. /**
  116111. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116112. * @param instancesBuffer defines the webGL buffer to update and bind
  116113. * @param data defines the data to store in the buffer
  116114. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116115. */
  116116. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116117. /**
  116118. * Bind the content of a webGL buffer used with instantiation
  116119. * @param instancesBuffer defines the webGL buffer to bind
  116120. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116121. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116122. */
  116123. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116124. /**
  116125. * Disable the instance attribute corresponding to the name in parameter
  116126. * @param name defines the name of the attribute to disable
  116127. */
  116128. disableInstanceAttributeByName(name: string): void;
  116129. /**
  116130. * Disable the instance attribute corresponding to the location in parameter
  116131. * @param attributeLocation defines the attribute location of the attribute to disable
  116132. */
  116133. disableInstanceAttribute(attributeLocation: number): void;
  116134. /**
  116135. * Disable the attribute corresponding to the location in parameter
  116136. * @param attributeLocation defines the attribute location of the attribute to disable
  116137. */
  116138. disableAttributeByIndex(attributeLocation: number): void;
  116139. /**
  116140. * Send a draw order
  116141. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116142. * @param indexStart defines the starting index
  116143. * @param indexCount defines the number of index to draw
  116144. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116145. */
  116146. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116147. /**
  116148. * Draw a list of points
  116149. * @param verticesStart defines the index of first vertex to draw
  116150. * @param verticesCount defines the count of vertices to draw
  116151. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116152. */
  116153. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116154. /**
  116155. * Draw a list of unindexed primitives
  116156. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116157. * @param verticesStart defines the index of first vertex to draw
  116158. * @param verticesCount defines the count of vertices to draw
  116159. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116160. */
  116161. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116162. /**
  116163. * Draw a list of indexed primitives
  116164. * @param fillMode defines the primitive to use
  116165. * @param indexStart defines the starting index
  116166. * @param indexCount defines the number of index to draw
  116167. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116168. */
  116169. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116170. /**
  116171. * Draw a list of unindexed primitives
  116172. * @param fillMode defines the primitive to use
  116173. * @param verticesStart defines the index of first vertex to draw
  116174. * @param verticesCount defines the count of vertices to draw
  116175. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116176. */
  116177. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116178. private _drawMode;
  116179. /** @hidden */
  116180. protected _reportDrawCall(): void;
  116181. /** @hidden */
  116182. _releaseEffect(effect: Effect): void;
  116183. /** @hidden */
  116184. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116185. /**
  116186. * Create a new effect (used to store vertex/fragment shaders)
  116187. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116188. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116189. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116190. * @param samplers defines an array of string used to represent textures
  116191. * @param defines defines the string containing the defines to use to compile the shaders
  116192. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116193. * @param onCompiled defines a function to call when the effect creation is successful
  116194. * @param onError defines a function to call when the effect creation has failed
  116195. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116196. * @returns the new Effect
  116197. */
  116198. 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;
  116199. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116200. private _compileShader;
  116201. private _compileRawShader;
  116202. /** @hidden */
  116203. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116204. /**
  116205. * Directly creates a webGL program
  116206. * @param pipelineContext defines the pipeline context to attach to
  116207. * @param vertexCode defines the vertex shader code to use
  116208. * @param fragmentCode defines the fragment shader code to use
  116209. * @param context defines the webGL context to use (if not set, the current one will be used)
  116210. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116211. * @returns the new webGL program
  116212. */
  116213. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116214. /**
  116215. * Creates a webGL program
  116216. * @param pipelineContext defines the pipeline context to attach to
  116217. * @param vertexCode defines the vertex shader code to use
  116218. * @param fragmentCode defines the fragment shader code to use
  116219. * @param defines defines the string containing the defines to use to compile the shaders
  116220. * @param context defines the webGL context to use (if not set, the current one will be used)
  116221. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116222. * @returns the new webGL program
  116223. */
  116224. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116225. /**
  116226. * Creates a new pipeline context
  116227. * @returns the new pipeline
  116228. */
  116229. createPipelineContext(): IPipelineContext;
  116230. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116231. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116232. /** @hidden */
  116233. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116234. /** @hidden */
  116235. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116236. /** @hidden */
  116237. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116238. /**
  116239. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116240. * @param pipelineContext defines the pipeline context to use
  116241. * @param uniformsNames defines the list of uniform names
  116242. * @returns an array of webGL uniform locations
  116243. */
  116244. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116245. /**
  116246. * Gets the lsit of active attributes for a given webGL program
  116247. * @param pipelineContext defines the pipeline context to use
  116248. * @param attributesNames defines the list of attribute names to get
  116249. * @returns an array of indices indicating the offset of each attribute
  116250. */
  116251. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116252. /**
  116253. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116254. * @param effect defines the effect to activate
  116255. */
  116256. enableEffect(effect: Nullable<Effect>): void;
  116257. /**
  116258. * Set the value of an uniform to a number (int)
  116259. * @param uniform defines the webGL uniform location where to store the value
  116260. * @param value defines the int number to store
  116261. * @returns true if the value was set
  116262. */
  116263. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116264. /**
  116265. * Set the value of an uniform to an array of int32
  116266. * @param uniform defines the webGL uniform location where to store the value
  116267. * @param array defines the array of int32 to store
  116268. * @returns true if the value was set
  116269. */
  116270. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116271. /**
  116272. * Set the value of an uniform to an array of int32 (stored as vec2)
  116273. * @param uniform defines the webGL uniform location where to store the value
  116274. * @param array defines the array of int32 to store
  116275. * @returns true if the value was set
  116276. */
  116277. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116278. /**
  116279. * Set the value of an uniform to an array of int32 (stored as vec3)
  116280. * @param uniform defines the webGL uniform location where to store the value
  116281. * @param array defines the array of int32 to store
  116282. * @returns true if the value was set
  116283. */
  116284. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116285. /**
  116286. * Set the value of an uniform to an array of int32 (stored as vec4)
  116287. * @param uniform defines the webGL uniform location where to store the value
  116288. * @param array defines the array of int32 to store
  116289. * @returns true if the value was set
  116290. */
  116291. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116292. /**
  116293. * Set the value of an uniform to an array of number
  116294. * @param uniform defines the webGL uniform location where to store the value
  116295. * @param array defines the array of number to store
  116296. * @returns true if the value was set
  116297. */
  116298. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116299. /**
  116300. * Set the value of an uniform to an array of number (stored as vec2)
  116301. * @param uniform defines the webGL uniform location where to store the value
  116302. * @param array defines the array of number to store
  116303. * @returns true if the value was set
  116304. */
  116305. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116306. /**
  116307. * Set the value of an uniform to an array of number (stored as vec3)
  116308. * @param uniform defines the webGL uniform location where to store the value
  116309. * @param array defines the array of number to store
  116310. * @returns true if the value was set
  116311. */
  116312. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116313. /**
  116314. * Set the value of an uniform to an array of number (stored as vec4)
  116315. * @param uniform defines the webGL uniform location where to store the value
  116316. * @param array defines the array of number to store
  116317. * @returns true if the value was set
  116318. */
  116319. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116320. /**
  116321. * Set the value of an uniform to an array of float32 (stored as matrices)
  116322. * @param uniform defines the webGL uniform location where to store the value
  116323. * @param matrices defines the array of float32 to store
  116324. * @returns true if the value was set
  116325. */
  116326. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116327. /**
  116328. * Set the value of an uniform to a matrix (3x3)
  116329. * @param uniform defines the webGL uniform location where to store the value
  116330. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116331. * @returns true if the value was set
  116332. */
  116333. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116334. /**
  116335. * Set the value of an uniform to a matrix (2x2)
  116336. * @param uniform defines the webGL uniform location where to store the value
  116337. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116338. * @returns true if the value was set
  116339. */
  116340. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116341. /**
  116342. * Set the value of an uniform to a number (float)
  116343. * @param uniform defines the webGL uniform location where to store the value
  116344. * @param value defines the float number to store
  116345. * @returns true if the value was transfered
  116346. */
  116347. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116348. /**
  116349. * Set the value of an uniform to a vec2
  116350. * @param uniform defines the webGL uniform location where to store the value
  116351. * @param x defines the 1st component of the value
  116352. * @param y defines the 2nd component of the value
  116353. * @returns true if the value was set
  116354. */
  116355. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116356. /**
  116357. * Set the value of an uniform to a vec3
  116358. * @param uniform defines the webGL uniform location where to store the value
  116359. * @param x defines the 1st component of the value
  116360. * @param y defines the 2nd component of the value
  116361. * @param z defines the 3rd component of the value
  116362. * @returns true if the value was set
  116363. */
  116364. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116365. /**
  116366. * Set the value of an uniform to a vec4
  116367. * @param uniform defines the webGL uniform location where to store the value
  116368. * @param x defines the 1st component of the value
  116369. * @param y defines the 2nd component of the value
  116370. * @param z defines the 3rd component of the value
  116371. * @param w defines the 4th component of the value
  116372. * @returns true if the value was set
  116373. */
  116374. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116375. /**
  116376. * Apply all cached states (depth, culling, stencil and alpha)
  116377. */
  116378. applyStates(): void;
  116379. /**
  116380. * Enable or disable color writing
  116381. * @param enable defines the state to set
  116382. */
  116383. setColorWrite(enable: boolean): void;
  116384. /**
  116385. * Gets a boolean indicating if color writing is enabled
  116386. * @returns the current color writing state
  116387. */
  116388. getColorWrite(): boolean;
  116389. /**
  116390. * Gets the depth culling state manager
  116391. */
  116392. get depthCullingState(): DepthCullingState;
  116393. /**
  116394. * Gets the alpha state manager
  116395. */
  116396. get alphaState(): AlphaState;
  116397. /**
  116398. * Gets the stencil state manager
  116399. */
  116400. get stencilState(): StencilState;
  116401. /**
  116402. * Clears the list of texture accessible through engine.
  116403. * This can help preventing texture load conflict due to name collision.
  116404. */
  116405. clearInternalTexturesCache(): void;
  116406. /**
  116407. * Force the entire cache to be cleared
  116408. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116409. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116410. */
  116411. wipeCaches(bruteForce?: boolean): void;
  116412. /** @hidden */
  116413. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116414. min: number;
  116415. mag: number;
  116416. };
  116417. /** @hidden */
  116418. _createTexture(): WebGLTexture;
  116419. /**
  116420. * Usually called from Texture.ts.
  116421. * Passed information to create a WebGLTexture
  116422. * @param url defines a value which contains one of the following:
  116423. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116424. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116425. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116426. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116427. * @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)
  116428. * @param scene needed for loading to the correct scene
  116429. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116430. * @param onLoad optional callback to be called upon successful completion
  116431. * @param onError optional callback to be called upon failure
  116432. * @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
  116433. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116434. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116435. * @param forcedExtension defines the extension to use to pick the right loader
  116436. * @param mimeType defines an optional mime type
  116437. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116438. */
  116439. 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;
  116440. /**
  116441. * Loads an image as an HTMLImageElement.
  116442. * @param input url string, ArrayBuffer, or Blob to load
  116443. * @param onLoad callback called when the image successfully loads
  116444. * @param onError callback called when the image fails to load
  116445. * @param offlineProvider offline provider for caching
  116446. * @param mimeType optional mime type
  116447. * @returns the HTMLImageElement of the loaded image
  116448. * @hidden
  116449. */
  116450. 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>;
  116451. /**
  116452. * @hidden
  116453. */
  116454. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116455. private _unpackFlipYCached;
  116456. /**
  116457. * In case you are sharing the context with other applications, it might
  116458. * be interested to not cache the unpack flip y state to ensure a consistent
  116459. * value would be set.
  116460. */
  116461. enableUnpackFlipYCached: boolean;
  116462. /** @hidden */
  116463. _unpackFlipY(value: boolean): void;
  116464. /** @hidden */
  116465. _getUnpackAlignement(): number;
  116466. private _getTextureTarget;
  116467. /**
  116468. * Update the sampling mode of a given texture
  116469. * @param samplingMode defines the required sampling mode
  116470. * @param texture defines the texture to update
  116471. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116472. */
  116473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116474. /**
  116475. * Update the sampling mode of a given texture
  116476. * @param texture defines the texture to update
  116477. * @param wrapU defines the texture wrap mode of the u coordinates
  116478. * @param wrapV defines the texture wrap mode of the v coordinates
  116479. * @param wrapR defines the texture wrap mode of the r coordinates
  116480. */
  116481. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116482. /** @hidden */
  116483. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116484. width: number;
  116485. height: number;
  116486. layers?: number;
  116487. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116488. /** @hidden */
  116489. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116490. /** @hidden */
  116491. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116492. /**
  116493. * Update a portion of an internal texture
  116494. * @param texture defines the texture to update
  116495. * @param imageData defines the data to store into the texture
  116496. * @param xOffset defines the x coordinates of the update rectangle
  116497. * @param yOffset defines the y coordinates of the update rectangle
  116498. * @param width defines the width of the update rectangle
  116499. * @param height defines the height of the update rectangle
  116500. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116501. * @param lod defines the lod level to update (0 by default)
  116502. */
  116503. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116504. /** @hidden */
  116505. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116506. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116507. private _prepareWebGLTexture;
  116508. /** @hidden */
  116509. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116510. private _getDepthStencilBuffer;
  116511. /** @hidden */
  116512. _releaseFramebufferObjects(texture: InternalTexture): void;
  116513. /** @hidden */
  116514. _releaseTexture(texture: InternalTexture): void;
  116515. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116516. protected _setProgram(program: WebGLProgram): void;
  116517. protected _boundUniforms: {
  116518. [key: number]: WebGLUniformLocation;
  116519. };
  116520. /**
  116521. * Binds an effect to the webGL context
  116522. * @param effect defines the effect to bind
  116523. */
  116524. bindSamplers(effect: Effect): void;
  116525. private _activateCurrentTexture;
  116526. /** @hidden */
  116527. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116528. /** @hidden */
  116529. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116530. /**
  116531. * Unbind all textures from the webGL context
  116532. */
  116533. unbindAllTextures(): void;
  116534. /**
  116535. * Sets a texture to the according uniform.
  116536. * @param channel The texture channel
  116537. * @param uniform The uniform to set
  116538. * @param texture The texture to apply
  116539. */
  116540. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116541. private _bindSamplerUniformToChannel;
  116542. private _getTextureWrapMode;
  116543. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116544. /**
  116545. * Sets an array of texture to the webGL context
  116546. * @param channel defines the channel where the texture array must be set
  116547. * @param uniform defines the associated uniform location
  116548. * @param textures defines the array of textures to bind
  116549. */
  116550. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116551. /** @hidden */
  116552. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116553. private _setTextureParameterFloat;
  116554. private _setTextureParameterInteger;
  116555. /**
  116556. * Unbind all vertex attributes from the webGL context
  116557. */
  116558. unbindAllAttributes(): void;
  116559. /**
  116560. * 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
  116561. */
  116562. releaseEffects(): void;
  116563. /**
  116564. * Dispose and release all associated resources
  116565. */
  116566. dispose(): void;
  116567. /**
  116568. * Attach a new callback raised when context lost event is fired
  116569. * @param callback defines the callback to call
  116570. */
  116571. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116572. /**
  116573. * Attach a new callback raised when context restored event is fired
  116574. * @param callback defines the callback to call
  116575. */
  116576. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116577. /**
  116578. * Get the current error code of the webGL context
  116579. * @returns the error code
  116580. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116581. */
  116582. getError(): number;
  116583. private _canRenderToFloatFramebuffer;
  116584. private _canRenderToHalfFloatFramebuffer;
  116585. private _canRenderToFramebuffer;
  116586. /** @hidden */
  116587. _getWebGLTextureType(type: number): number;
  116588. /** @hidden */
  116589. _getInternalFormat(format: number): number;
  116590. /** @hidden */
  116591. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116592. /** @hidden */
  116593. _getRGBAMultiSampleBufferFormat(type: number): number;
  116594. /** @hidden */
  116595. _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;
  116596. /**
  116597. * Loads a file from a url
  116598. * @param url url to load
  116599. * @param onSuccess callback called when the file successfully loads
  116600. * @param onProgress callback called while file is loading (if the server supports this mode)
  116601. * @param offlineProvider defines the offline provider for caching
  116602. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116603. * @param onError callback called when the file fails to load
  116604. * @returns a file request object
  116605. * @hidden
  116606. */
  116607. 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;
  116608. /**
  116609. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116610. * @param x defines the x coordinate of the rectangle where pixels must be read
  116611. * @param y defines the y coordinate of the rectangle where pixels must be read
  116612. * @param width defines the width of the rectangle where pixels must be read
  116613. * @param height defines the height of the rectangle where pixels must be read
  116614. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116615. * @returns a Uint8Array containing RGBA colors
  116616. */
  116617. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116618. private static _isSupported;
  116619. /**
  116620. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116621. * @returns true if the engine can be created
  116622. * @ignorenaming
  116623. */
  116624. static isSupported(): boolean;
  116625. /**
  116626. * Find the next highest power of two.
  116627. * @param x Number to start search from.
  116628. * @return Next highest power of two.
  116629. */
  116630. static CeilingPOT(x: number): number;
  116631. /**
  116632. * Find the next lowest power of two.
  116633. * @param x Number to start search from.
  116634. * @return Next lowest power of two.
  116635. */
  116636. static FloorPOT(x: number): number;
  116637. /**
  116638. * Find the nearest power of two.
  116639. * @param x Number to start search from.
  116640. * @return Next nearest power of two.
  116641. */
  116642. static NearestPOT(x: number): number;
  116643. /**
  116644. * Get the closest exponent of two
  116645. * @param value defines the value to approximate
  116646. * @param max defines the maximum value to return
  116647. * @param mode defines how to define the closest value
  116648. * @returns closest exponent of two of the given value
  116649. */
  116650. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116651. /**
  116652. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  116653. * @param func - the function to be called
  116654. * @param requester - the object that will request the next frame. Falls back to window.
  116655. * @returns frame number
  116656. */
  116657. static QueueNewFrame(func: () => void, requester?: any): number;
  116658. /**
  116659. * Gets host document
  116660. * @returns the host document object
  116661. */
  116662. getHostDocument(): Nullable<Document>;
  116663. }
  116664. }
  116665. declare module BABYLON {
  116666. /**
  116667. * Class representing spherical harmonics coefficients to the 3rd degree
  116668. */
  116669. export class SphericalHarmonics {
  116670. /**
  116671. * Defines whether or not the harmonics have been prescaled for rendering.
  116672. */
  116673. preScaled: boolean;
  116674. /**
  116675. * The l0,0 coefficients of the spherical harmonics
  116676. */
  116677. l00: Vector3;
  116678. /**
  116679. * The l1,-1 coefficients of the spherical harmonics
  116680. */
  116681. l1_1: Vector3;
  116682. /**
  116683. * The l1,0 coefficients of the spherical harmonics
  116684. */
  116685. l10: Vector3;
  116686. /**
  116687. * The l1,1 coefficients of the spherical harmonics
  116688. */
  116689. l11: Vector3;
  116690. /**
  116691. * The l2,-2 coefficients of the spherical harmonics
  116692. */
  116693. l2_2: Vector3;
  116694. /**
  116695. * The l2,-1 coefficients of the spherical harmonics
  116696. */
  116697. l2_1: Vector3;
  116698. /**
  116699. * The l2,0 coefficients of the spherical harmonics
  116700. */
  116701. l20: Vector3;
  116702. /**
  116703. * The l2,1 coefficients of the spherical harmonics
  116704. */
  116705. l21: Vector3;
  116706. /**
  116707. * The l2,2 coefficients of the spherical harmonics
  116708. */
  116709. l22: Vector3;
  116710. /**
  116711. * Adds a light to the spherical harmonics
  116712. * @param direction the direction of the light
  116713. * @param color the color of the light
  116714. * @param deltaSolidAngle the delta solid angle of the light
  116715. */
  116716. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  116717. /**
  116718. * Scales the spherical harmonics by the given amount
  116719. * @param scale the amount to scale
  116720. */
  116721. scaleInPlace(scale: number): void;
  116722. /**
  116723. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  116724. *
  116725. * ```
  116726. * E_lm = A_l * L_lm
  116727. * ```
  116728. *
  116729. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  116730. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  116731. * the scaling factors are given in equation 9.
  116732. */
  116733. convertIncidentRadianceToIrradiance(): void;
  116734. /**
  116735. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  116736. *
  116737. * ```
  116738. * L = (1/pi) * E * rho
  116739. * ```
  116740. *
  116741. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  116742. */
  116743. convertIrradianceToLambertianRadiance(): void;
  116744. /**
  116745. * Integrates the reconstruction coefficients directly in to the SH preventing further
  116746. * required operations at run time.
  116747. *
  116748. * This is simply done by scaling back the SH with Ylm constants parameter.
  116749. * The trigonometric part being applied by the shader at run time.
  116750. */
  116751. preScaleForRendering(): void;
  116752. /**
  116753. * Constructs a spherical harmonics from an array.
  116754. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  116755. * @returns the spherical harmonics
  116756. */
  116757. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  116758. /**
  116759. * Gets the spherical harmonics from polynomial
  116760. * @param polynomial the spherical polynomial
  116761. * @returns the spherical harmonics
  116762. */
  116763. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  116764. }
  116765. /**
  116766. * Class representing spherical polynomial coefficients to the 3rd degree
  116767. */
  116768. export class SphericalPolynomial {
  116769. private _harmonics;
  116770. /**
  116771. * The spherical harmonics used to create the polynomials.
  116772. */
  116773. get preScaledHarmonics(): SphericalHarmonics;
  116774. /**
  116775. * The x coefficients of the spherical polynomial
  116776. */
  116777. x: Vector3;
  116778. /**
  116779. * The y coefficients of the spherical polynomial
  116780. */
  116781. y: Vector3;
  116782. /**
  116783. * The z coefficients of the spherical polynomial
  116784. */
  116785. z: Vector3;
  116786. /**
  116787. * The xx coefficients of the spherical polynomial
  116788. */
  116789. xx: Vector3;
  116790. /**
  116791. * The yy coefficients of the spherical polynomial
  116792. */
  116793. yy: Vector3;
  116794. /**
  116795. * The zz coefficients of the spherical polynomial
  116796. */
  116797. zz: Vector3;
  116798. /**
  116799. * The xy coefficients of the spherical polynomial
  116800. */
  116801. xy: Vector3;
  116802. /**
  116803. * The yz coefficients of the spherical polynomial
  116804. */
  116805. yz: Vector3;
  116806. /**
  116807. * The zx coefficients of the spherical polynomial
  116808. */
  116809. zx: Vector3;
  116810. /**
  116811. * Adds an ambient color to the spherical polynomial
  116812. * @param color the color to add
  116813. */
  116814. addAmbient(color: Color3): void;
  116815. /**
  116816. * Scales the spherical polynomial by the given amount
  116817. * @param scale the amount to scale
  116818. */
  116819. scaleInPlace(scale: number): void;
  116820. /**
  116821. * Gets the spherical polynomial from harmonics
  116822. * @param harmonics the spherical harmonics
  116823. * @returns the spherical polynomial
  116824. */
  116825. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  116826. /**
  116827. * Constructs a spherical polynomial from an array.
  116828. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  116829. * @returns the spherical polynomial
  116830. */
  116831. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  116832. }
  116833. }
  116834. declare module BABYLON {
  116835. /**
  116836. * Defines the source of the internal texture
  116837. */
  116838. export enum InternalTextureSource {
  116839. /**
  116840. * The source of the texture data is unknown
  116841. */
  116842. Unknown = 0,
  116843. /**
  116844. * Texture data comes from an URL
  116845. */
  116846. Url = 1,
  116847. /**
  116848. * Texture data is only used for temporary storage
  116849. */
  116850. Temp = 2,
  116851. /**
  116852. * Texture data comes from raw data (ArrayBuffer)
  116853. */
  116854. Raw = 3,
  116855. /**
  116856. * Texture content is dynamic (video or dynamic texture)
  116857. */
  116858. Dynamic = 4,
  116859. /**
  116860. * Texture content is generated by rendering to it
  116861. */
  116862. RenderTarget = 5,
  116863. /**
  116864. * Texture content is part of a multi render target process
  116865. */
  116866. MultiRenderTarget = 6,
  116867. /**
  116868. * Texture data comes from a cube data file
  116869. */
  116870. Cube = 7,
  116871. /**
  116872. * Texture data comes from a raw cube data
  116873. */
  116874. CubeRaw = 8,
  116875. /**
  116876. * Texture data come from a prefiltered cube data file
  116877. */
  116878. CubePrefiltered = 9,
  116879. /**
  116880. * Texture content is raw 3D data
  116881. */
  116882. Raw3D = 10,
  116883. /**
  116884. * Texture content is raw 2D array data
  116885. */
  116886. Raw2DArray = 11,
  116887. /**
  116888. * Texture content is a depth texture
  116889. */
  116890. Depth = 12,
  116891. /**
  116892. * Texture data comes from a raw cube data encoded with RGBD
  116893. */
  116894. CubeRawRGBD = 13
  116895. }
  116896. /**
  116897. * Class used to store data associated with WebGL texture data for the engine
  116898. * This class should not be used directly
  116899. */
  116900. export class InternalTexture {
  116901. /** @hidden */
  116902. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  116903. /**
  116904. * Defines if the texture is ready
  116905. */
  116906. isReady: boolean;
  116907. /**
  116908. * Defines if the texture is a cube texture
  116909. */
  116910. isCube: boolean;
  116911. /**
  116912. * Defines if the texture contains 3D data
  116913. */
  116914. is3D: boolean;
  116915. /**
  116916. * Defines if the texture contains 2D array data
  116917. */
  116918. is2DArray: boolean;
  116919. /**
  116920. * Defines if the texture contains multiview data
  116921. */
  116922. isMultiview: boolean;
  116923. /**
  116924. * Gets the URL used to load this texture
  116925. */
  116926. url: string;
  116927. /**
  116928. * Gets the sampling mode of the texture
  116929. */
  116930. samplingMode: number;
  116931. /**
  116932. * Gets a boolean indicating if the texture needs mipmaps generation
  116933. */
  116934. generateMipMaps: boolean;
  116935. /**
  116936. * Gets the number of samples used by the texture (WebGL2+ only)
  116937. */
  116938. samples: number;
  116939. /**
  116940. * Gets the type of the texture (int, float...)
  116941. */
  116942. type: number;
  116943. /**
  116944. * Gets the format of the texture (RGB, RGBA...)
  116945. */
  116946. format: number;
  116947. /**
  116948. * Observable called when the texture is loaded
  116949. */
  116950. onLoadedObservable: Observable<InternalTexture>;
  116951. /**
  116952. * Gets the width of the texture
  116953. */
  116954. width: number;
  116955. /**
  116956. * Gets the height of the texture
  116957. */
  116958. height: number;
  116959. /**
  116960. * Gets the depth of the texture
  116961. */
  116962. depth: number;
  116963. /**
  116964. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  116965. */
  116966. baseWidth: number;
  116967. /**
  116968. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  116969. */
  116970. baseHeight: number;
  116971. /**
  116972. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  116973. */
  116974. baseDepth: number;
  116975. /**
  116976. * Gets a boolean indicating if the texture is inverted on Y axis
  116977. */
  116978. invertY: boolean;
  116979. /** @hidden */
  116980. _invertVScale: boolean;
  116981. /** @hidden */
  116982. _associatedChannel: number;
  116983. /** @hidden */
  116984. _source: InternalTextureSource;
  116985. /** @hidden */
  116986. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  116987. /** @hidden */
  116988. _bufferView: Nullable<ArrayBufferView>;
  116989. /** @hidden */
  116990. _bufferViewArray: Nullable<ArrayBufferView[]>;
  116991. /** @hidden */
  116992. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  116993. /** @hidden */
  116994. _size: number;
  116995. /** @hidden */
  116996. _extension: string;
  116997. /** @hidden */
  116998. _files: Nullable<string[]>;
  116999. /** @hidden */
  117000. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117001. /** @hidden */
  117002. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117003. /** @hidden */
  117004. _framebuffer: Nullable<WebGLFramebuffer>;
  117005. /** @hidden */
  117006. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117007. /** @hidden */
  117008. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117009. /** @hidden */
  117010. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117011. /** @hidden */
  117012. _attachments: Nullable<number[]>;
  117013. /** @hidden */
  117014. _textureArray: Nullable<InternalTexture[]>;
  117015. /** @hidden */
  117016. _cachedCoordinatesMode: Nullable<number>;
  117017. /** @hidden */
  117018. _cachedWrapU: Nullable<number>;
  117019. /** @hidden */
  117020. _cachedWrapV: Nullable<number>;
  117021. /** @hidden */
  117022. _cachedWrapR: Nullable<number>;
  117023. /** @hidden */
  117024. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117025. /** @hidden */
  117026. _isDisabled: boolean;
  117027. /** @hidden */
  117028. _compression: Nullable<string>;
  117029. /** @hidden */
  117030. _generateStencilBuffer: boolean;
  117031. /** @hidden */
  117032. _generateDepthBuffer: boolean;
  117033. /** @hidden */
  117034. _comparisonFunction: number;
  117035. /** @hidden */
  117036. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117037. /** @hidden */
  117038. _lodGenerationScale: number;
  117039. /** @hidden */
  117040. _lodGenerationOffset: number;
  117041. /** @hidden */
  117042. _depthStencilTexture: Nullable<InternalTexture>;
  117043. /** @hidden */
  117044. _colorTextureArray: Nullable<WebGLTexture>;
  117045. /** @hidden */
  117046. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117047. /** @hidden */
  117048. _lodTextureHigh: Nullable<BaseTexture>;
  117049. /** @hidden */
  117050. _lodTextureMid: Nullable<BaseTexture>;
  117051. /** @hidden */
  117052. _lodTextureLow: Nullable<BaseTexture>;
  117053. /** @hidden */
  117054. _isRGBD: boolean;
  117055. /** @hidden */
  117056. _linearSpecularLOD: boolean;
  117057. /** @hidden */
  117058. _irradianceTexture: Nullable<BaseTexture>;
  117059. /** @hidden */
  117060. _webGLTexture: Nullable<WebGLTexture>;
  117061. /** @hidden */
  117062. _references: number;
  117063. /** @hidden */
  117064. _gammaSpace: Nullable<boolean>;
  117065. private _engine;
  117066. /**
  117067. * Gets the Engine the texture belongs to.
  117068. * @returns The babylon engine
  117069. */
  117070. getEngine(): ThinEngine;
  117071. /**
  117072. * Gets the data source type of the texture
  117073. */
  117074. get source(): InternalTextureSource;
  117075. /**
  117076. * Creates a new InternalTexture
  117077. * @param engine defines the engine to use
  117078. * @param source defines the type of data that will be used
  117079. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117080. */
  117081. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117082. /**
  117083. * Increments the number of references (ie. the number of Texture that point to it)
  117084. */
  117085. incrementReferences(): void;
  117086. /**
  117087. * Change the size of the texture (not the size of the content)
  117088. * @param width defines the new width
  117089. * @param height defines the new height
  117090. * @param depth defines the new depth (1 by default)
  117091. */
  117092. updateSize(width: int, height: int, depth?: int): void;
  117093. /** @hidden */
  117094. _rebuild(): void;
  117095. /** @hidden */
  117096. _swapAndDie(target: InternalTexture): void;
  117097. /**
  117098. * Dispose the current allocated resources
  117099. */
  117100. dispose(): void;
  117101. }
  117102. }
  117103. declare module BABYLON {
  117104. /**
  117105. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117106. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117107. */
  117108. export class Analyser {
  117109. /**
  117110. * Gets or sets the smoothing
  117111. * @ignorenaming
  117112. */
  117113. SMOOTHING: number;
  117114. /**
  117115. * Gets or sets the FFT table size
  117116. * @ignorenaming
  117117. */
  117118. FFT_SIZE: number;
  117119. /**
  117120. * Gets or sets the bar graph amplitude
  117121. * @ignorenaming
  117122. */
  117123. BARGRAPHAMPLITUDE: number;
  117124. /**
  117125. * Gets or sets the position of the debug canvas
  117126. * @ignorenaming
  117127. */
  117128. DEBUGCANVASPOS: {
  117129. x: number;
  117130. y: number;
  117131. };
  117132. /**
  117133. * Gets or sets the debug canvas size
  117134. * @ignorenaming
  117135. */
  117136. DEBUGCANVASSIZE: {
  117137. width: number;
  117138. height: number;
  117139. };
  117140. private _byteFreqs;
  117141. private _byteTime;
  117142. private _floatFreqs;
  117143. private _webAudioAnalyser;
  117144. private _debugCanvas;
  117145. private _debugCanvasContext;
  117146. private _scene;
  117147. private _registerFunc;
  117148. private _audioEngine;
  117149. /**
  117150. * Creates a new analyser
  117151. * @param scene defines hosting scene
  117152. */
  117153. constructor(scene: Scene);
  117154. /**
  117155. * Get the number of data values you will have to play with for the visualization
  117156. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117157. * @returns a number
  117158. */
  117159. getFrequencyBinCount(): number;
  117160. /**
  117161. * Gets the current frequency data as a byte array
  117162. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117163. * @returns a Uint8Array
  117164. */
  117165. getByteFrequencyData(): Uint8Array;
  117166. /**
  117167. * Gets the current waveform as a byte array
  117168. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117169. * @returns a Uint8Array
  117170. */
  117171. getByteTimeDomainData(): Uint8Array;
  117172. /**
  117173. * Gets the current frequency data as a float array
  117174. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117175. * @returns a Float32Array
  117176. */
  117177. getFloatFrequencyData(): Float32Array;
  117178. /**
  117179. * Renders the debug canvas
  117180. */
  117181. drawDebugCanvas(): void;
  117182. /**
  117183. * Stops rendering the debug canvas and removes it
  117184. */
  117185. stopDebugCanvas(): void;
  117186. /**
  117187. * Connects two audio nodes
  117188. * @param inputAudioNode defines first node to connect
  117189. * @param outputAudioNode defines second node to connect
  117190. */
  117191. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117192. /**
  117193. * Releases all associated resources
  117194. */
  117195. dispose(): void;
  117196. }
  117197. }
  117198. declare module BABYLON {
  117199. /**
  117200. * This represents an audio engine and it is responsible
  117201. * to play, synchronize and analyse sounds throughout the application.
  117202. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117203. */
  117204. export interface IAudioEngine extends IDisposable {
  117205. /**
  117206. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117207. */
  117208. readonly canUseWebAudio: boolean;
  117209. /**
  117210. * Gets the current AudioContext if available.
  117211. */
  117212. readonly audioContext: Nullable<AudioContext>;
  117213. /**
  117214. * The master gain node defines the global audio volume of your audio engine.
  117215. */
  117216. readonly masterGain: GainNode;
  117217. /**
  117218. * Gets whether or not mp3 are supported by your browser.
  117219. */
  117220. readonly isMP3supported: boolean;
  117221. /**
  117222. * Gets whether or not ogg are supported by your browser.
  117223. */
  117224. readonly isOGGsupported: boolean;
  117225. /**
  117226. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117227. * @ignoreNaming
  117228. */
  117229. WarnedWebAudioUnsupported: boolean;
  117230. /**
  117231. * Defines if the audio engine relies on a custom unlocked button.
  117232. * In this case, the embedded button will not be displayed.
  117233. */
  117234. useCustomUnlockedButton: boolean;
  117235. /**
  117236. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117237. */
  117238. readonly unlocked: boolean;
  117239. /**
  117240. * Event raised when audio has been unlocked on the browser.
  117241. */
  117242. onAudioUnlockedObservable: Observable<AudioEngine>;
  117243. /**
  117244. * Event raised when audio has been locked on the browser.
  117245. */
  117246. onAudioLockedObservable: Observable<AudioEngine>;
  117247. /**
  117248. * Flags the audio engine in Locked state.
  117249. * This happens due to new browser policies preventing audio to autoplay.
  117250. */
  117251. lock(): void;
  117252. /**
  117253. * Unlocks the audio engine once a user action has been done on the dom.
  117254. * This is helpful to resume play once browser policies have been satisfied.
  117255. */
  117256. unlock(): void;
  117257. /**
  117258. * Gets the global volume sets on the master gain.
  117259. * @returns the global volume if set or -1 otherwise
  117260. */
  117261. getGlobalVolume(): number;
  117262. /**
  117263. * Sets the global volume of your experience (sets on the master gain).
  117264. * @param newVolume Defines the new global volume of the application
  117265. */
  117266. setGlobalVolume(newVolume: number): void;
  117267. /**
  117268. * Connect the audio engine to an audio analyser allowing some amazing
  117269. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117271. * @param analyser The analyser to connect to the engine
  117272. */
  117273. connectToAnalyser(analyser: Analyser): void;
  117274. }
  117275. /**
  117276. * This represents the default audio engine used in babylon.
  117277. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117278. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117279. */
  117280. export class AudioEngine implements IAudioEngine {
  117281. private _audioContext;
  117282. private _audioContextInitialized;
  117283. private _muteButton;
  117284. private _hostElement;
  117285. /**
  117286. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117287. */
  117288. canUseWebAudio: boolean;
  117289. /**
  117290. * The master gain node defines the global audio volume of your audio engine.
  117291. */
  117292. masterGain: GainNode;
  117293. /**
  117294. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117295. * @ignoreNaming
  117296. */
  117297. WarnedWebAudioUnsupported: boolean;
  117298. /**
  117299. * Gets whether or not mp3 are supported by your browser.
  117300. */
  117301. isMP3supported: boolean;
  117302. /**
  117303. * Gets whether or not ogg are supported by your browser.
  117304. */
  117305. isOGGsupported: boolean;
  117306. /**
  117307. * Gets whether audio has been unlocked on the device.
  117308. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117309. * a user interaction has happened.
  117310. */
  117311. unlocked: boolean;
  117312. /**
  117313. * Defines if the audio engine relies on a custom unlocked button.
  117314. * In this case, the embedded button will not be displayed.
  117315. */
  117316. useCustomUnlockedButton: boolean;
  117317. /**
  117318. * Event raised when audio has been unlocked on the browser.
  117319. */
  117320. onAudioUnlockedObservable: Observable<AudioEngine>;
  117321. /**
  117322. * Event raised when audio has been locked on the browser.
  117323. */
  117324. onAudioLockedObservable: Observable<AudioEngine>;
  117325. /**
  117326. * Gets the current AudioContext if available.
  117327. */
  117328. get audioContext(): Nullable<AudioContext>;
  117329. private _connectedAnalyser;
  117330. /**
  117331. * Instantiates a new audio engine.
  117332. *
  117333. * There should be only one per page as some browsers restrict the number
  117334. * of audio contexts you can create.
  117335. * @param hostElement defines the host element where to display the mute icon if necessary
  117336. */
  117337. constructor(hostElement?: Nullable<HTMLElement>);
  117338. /**
  117339. * Flags the audio engine in Locked state.
  117340. * This happens due to new browser policies preventing audio to autoplay.
  117341. */
  117342. lock(): void;
  117343. /**
  117344. * Unlocks the audio engine once a user action has been done on the dom.
  117345. * This is helpful to resume play once browser policies have been satisfied.
  117346. */
  117347. unlock(): void;
  117348. private _resumeAudioContext;
  117349. private _initializeAudioContext;
  117350. private _tryToRun;
  117351. private _triggerRunningState;
  117352. private _triggerSuspendedState;
  117353. private _displayMuteButton;
  117354. private _moveButtonToTopLeft;
  117355. private _onResize;
  117356. private _hideMuteButton;
  117357. /**
  117358. * Destroy and release the resources associated with the audio ccontext.
  117359. */
  117360. dispose(): void;
  117361. /**
  117362. * Gets the global volume sets on the master gain.
  117363. * @returns the global volume if set or -1 otherwise
  117364. */
  117365. getGlobalVolume(): number;
  117366. /**
  117367. * Sets the global volume of your experience (sets on the master gain).
  117368. * @param newVolume Defines the new global volume of the application
  117369. */
  117370. setGlobalVolume(newVolume: number): void;
  117371. /**
  117372. * Connect the audio engine to an audio analyser allowing some amazing
  117373. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117375. * @param analyser The analyser to connect to the engine
  117376. */
  117377. connectToAnalyser(analyser: Analyser): void;
  117378. }
  117379. }
  117380. declare module BABYLON {
  117381. /**
  117382. * Interface used to present a loading screen while loading a scene
  117383. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117384. */
  117385. export interface ILoadingScreen {
  117386. /**
  117387. * Function called to display the loading screen
  117388. */
  117389. displayLoadingUI: () => void;
  117390. /**
  117391. * Function called to hide the loading screen
  117392. */
  117393. hideLoadingUI: () => void;
  117394. /**
  117395. * Gets or sets the color to use for the background
  117396. */
  117397. loadingUIBackgroundColor: string;
  117398. /**
  117399. * Gets or sets the text to display while loading
  117400. */
  117401. loadingUIText: string;
  117402. }
  117403. /**
  117404. * Class used for the default loading screen
  117405. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117406. */
  117407. export class DefaultLoadingScreen implements ILoadingScreen {
  117408. private _renderingCanvas;
  117409. private _loadingText;
  117410. private _loadingDivBackgroundColor;
  117411. private _loadingDiv;
  117412. private _loadingTextDiv;
  117413. /** Gets or sets the logo url to use for the default loading screen */
  117414. static DefaultLogoUrl: string;
  117415. /** Gets or sets the spinner url to use for the default loading screen */
  117416. static DefaultSpinnerUrl: string;
  117417. /**
  117418. * Creates a new default loading screen
  117419. * @param _renderingCanvas defines the canvas used to render the scene
  117420. * @param _loadingText defines the default text to display
  117421. * @param _loadingDivBackgroundColor defines the default background color
  117422. */
  117423. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117424. /**
  117425. * Function called to display the loading screen
  117426. */
  117427. displayLoadingUI(): void;
  117428. /**
  117429. * Function called to hide the loading screen
  117430. */
  117431. hideLoadingUI(): void;
  117432. /**
  117433. * Gets or sets the text to display while loading
  117434. */
  117435. set loadingUIText(text: string);
  117436. get loadingUIText(): string;
  117437. /**
  117438. * Gets or sets the color to use for the background
  117439. */
  117440. get loadingUIBackgroundColor(): string;
  117441. set loadingUIBackgroundColor(color: string);
  117442. private _resizeLoadingUI;
  117443. }
  117444. }
  117445. declare module BABYLON {
  117446. /**
  117447. * Interface for any object that can request an animation frame
  117448. */
  117449. export interface ICustomAnimationFrameRequester {
  117450. /**
  117451. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117452. */
  117453. renderFunction?: Function;
  117454. /**
  117455. * Called to request the next frame to render to
  117456. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117457. */
  117458. requestAnimationFrame: Function;
  117459. /**
  117460. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117461. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117462. */
  117463. requestID?: number;
  117464. }
  117465. }
  117466. declare module BABYLON {
  117467. /**
  117468. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117469. */
  117470. export class PerformanceMonitor {
  117471. private _enabled;
  117472. private _rollingFrameTime;
  117473. private _lastFrameTimeMs;
  117474. /**
  117475. * constructor
  117476. * @param frameSampleSize The number of samples required to saturate the sliding window
  117477. */
  117478. constructor(frameSampleSize?: number);
  117479. /**
  117480. * Samples current frame
  117481. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117482. */
  117483. sampleFrame(timeMs?: number): void;
  117484. /**
  117485. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117486. */
  117487. get averageFrameTime(): number;
  117488. /**
  117489. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117490. */
  117491. get averageFrameTimeVariance(): number;
  117492. /**
  117493. * Returns the frame time of the most recent frame
  117494. */
  117495. get instantaneousFrameTime(): number;
  117496. /**
  117497. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117498. */
  117499. get averageFPS(): number;
  117500. /**
  117501. * Returns the average framerate in frames per second using the most recent frame time
  117502. */
  117503. get instantaneousFPS(): number;
  117504. /**
  117505. * Returns true if enough samples have been taken to completely fill the sliding window
  117506. */
  117507. get isSaturated(): boolean;
  117508. /**
  117509. * Enables contributions to the sliding window sample set
  117510. */
  117511. enable(): void;
  117512. /**
  117513. * Disables contributions to the sliding window sample set
  117514. * Samples will not be interpolated over the disabled period
  117515. */
  117516. disable(): void;
  117517. /**
  117518. * Returns true if sampling is enabled
  117519. */
  117520. get isEnabled(): boolean;
  117521. /**
  117522. * Resets performance monitor
  117523. */
  117524. reset(): void;
  117525. }
  117526. /**
  117527. * RollingAverage
  117528. *
  117529. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117530. */
  117531. export class RollingAverage {
  117532. /**
  117533. * Current average
  117534. */
  117535. average: number;
  117536. /**
  117537. * Current variance
  117538. */
  117539. variance: number;
  117540. protected _samples: Array<number>;
  117541. protected _sampleCount: number;
  117542. protected _pos: number;
  117543. protected _m2: number;
  117544. /**
  117545. * constructor
  117546. * @param length The number of samples required to saturate the sliding window
  117547. */
  117548. constructor(length: number);
  117549. /**
  117550. * Adds a sample to the sample set
  117551. * @param v The sample value
  117552. */
  117553. add(v: number): void;
  117554. /**
  117555. * Returns previously added values or null if outside of history or outside the sliding window domain
  117556. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117557. * @return Value previously recorded with add() or null if outside of range
  117558. */
  117559. history(i: number): number;
  117560. /**
  117561. * Returns true if enough samples have been taken to completely fill the sliding window
  117562. * @return true if sample-set saturated
  117563. */
  117564. isSaturated(): boolean;
  117565. /**
  117566. * Resets the rolling average (equivalent to 0 samples taken so far)
  117567. */
  117568. reset(): void;
  117569. /**
  117570. * Wraps a value around the sample range boundaries
  117571. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117572. * @return Wrapped position in sample range
  117573. */
  117574. protected _wrapPosition(i: number): number;
  117575. }
  117576. }
  117577. declare module BABYLON {
  117578. /**
  117579. * This class is used to track a performance counter which is number based.
  117580. * The user has access to many properties which give statistics of different nature.
  117581. *
  117582. * The implementer can track two kinds of Performance Counter: time and count.
  117583. * 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.
  117584. * 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.
  117585. */
  117586. export class PerfCounter {
  117587. /**
  117588. * Gets or sets a global boolean to turn on and off all the counters
  117589. */
  117590. static Enabled: boolean;
  117591. /**
  117592. * Returns the smallest value ever
  117593. */
  117594. get min(): number;
  117595. /**
  117596. * Returns the biggest value ever
  117597. */
  117598. get max(): number;
  117599. /**
  117600. * Returns the average value since the performance counter is running
  117601. */
  117602. get average(): number;
  117603. /**
  117604. * Returns the average value of the last second the counter was monitored
  117605. */
  117606. get lastSecAverage(): number;
  117607. /**
  117608. * Returns the current value
  117609. */
  117610. get current(): number;
  117611. /**
  117612. * Gets the accumulated total
  117613. */
  117614. get total(): number;
  117615. /**
  117616. * Gets the total value count
  117617. */
  117618. get count(): number;
  117619. /**
  117620. * Creates a new counter
  117621. */
  117622. constructor();
  117623. /**
  117624. * Call this method to start monitoring a new frame.
  117625. * 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.
  117626. */
  117627. fetchNewFrame(): void;
  117628. /**
  117629. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117630. * @param newCount the count value to add to the monitored count
  117631. * @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.
  117632. */
  117633. addCount(newCount: number, fetchResult: boolean): void;
  117634. /**
  117635. * Start monitoring this performance counter
  117636. */
  117637. beginMonitoring(): void;
  117638. /**
  117639. * Compute the time lapsed since the previous beginMonitoring() call.
  117640. * @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
  117641. */
  117642. endMonitoring(newFrame?: boolean): void;
  117643. private _fetchResult;
  117644. private _startMonitoringTime;
  117645. private _min;
  117646. private _max;
  117647. private _average;
  117648. private _current;
  117649. private _totalValueCount;
  117650. private _totalAccumulated;
  117651. private _lastSecAverage;
  117652. private _lastSecAccumulated;
  117653. private _lastSecTime;
  117654. private _lastSecValueCount;
  117655. }
  117656. }
  117657. declare module BABYLON {
  117658. interface ThinEngine {
  117659. /** @hidden */
  117660. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  117661. }
  117662. }
  117663. declare module BABYLON {
  117664. /**
  117665. * Defines the interface used by display changed events
  117666. */
  117667. export interface IDisplayChangedEventArgs {
  117668. /** Gets the vrDisplay object (if any) */
  117669. vrDisplay: Nullable<any>;
  117670. /** Gets a boolean indicating if webVR is supported */
  117671. vrSupported: boolean;
  117672. }
  117673. /**
  117674. * Defines the interface used by objects containing a viewport (like a camera)
  117675. */
  117676. interface IViewportOwnerLike {
  117677. /**
  117678. * Gets or sets the viewport
  117679. */
  117680. viewport: IViewportLike;
  117681. }
  117682. /**
  117683. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  117684. */
  117685. export class Engine extends ThinEngine {
  117686. /** Defines that alpha blending is disabled */
  117687. static readonly ALPHA_DISABLE: number;
  117688. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  117689. static readonly ALPHA_ADD: number;
  117690. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  117691. static readonly ALPHA_COMBINE: number;
  117692. /** Defines that alpha blending to DEST - SRC * DEST */
  117693. static readonly ALPHA_SUBTRACT: number;
  117694. /** Defines that alpha blending to SRC * DEST */
  117695. static readonly ALPHA_MULTIPLY: number;
  117696. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  117697. static readonly ALPHA_MAXIMIZED: number;
  117698. /** Defines that alpha blending to SRC + DEST */
  117699. static readonly ALPHA_ONEONE: number;
  117700. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  117701. static readonly ALPHA_PREMULTIPLIED: number;
  117702. /**
  117703. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  117704. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  117705. */
  117706. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  117707. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  117708. static readonly ALPHA_INTERPOLATE: number;
  117709. /**
  117710. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  117711. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  117712. */
  117713. static readonly ALPHA_SCREENMODE: number;
  117714. /** Defines that the ressource is not delayed*/
  117715. static readonly DELAYLOADSTATE_NONE: number;
  117716. /** Defines that the ressource was successfully delay loaded */
  117717. static readonly DELAYLOADSTATE_LOADED: number;
  117718. /** Defines that the ressource is currently delay loading */
  117719. static readonly DELAYLOADSTATE_LOADING: number;
  117720. /** Defines that the ressource is delayed and has not started loading */
  117721. static readonly DELAYLOADSTATE_NOTLOADED: number;
  117722. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  117723. static readonly NEVER: number;
  117724. /** 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 */
  117725. static readonly ALWAYS: number;
  117726. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  117727. static readonly LESS: number;
  117728. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  117729. static readonly EQUAL: number;
  117730. /** 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 */
  117731. static readonly LEQUAL: number;
  117732. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  117733. static readonly GREATER: number;
  117734. /** 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 */
  117735. static readonly GEQUAL: number;
  117736. /** 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 */
  117737. static readonly NOTEQUAL: number;
  117738. /** Passed to stencilOperation to specify that stencil value must be kept */
  117739. static readonly KEEP: number;
  117740. /** Passed to stencilOperation to specify that stencil value must be replaced */
  117741. static readonly REPLACE: number;
  117742. /** Passed to stencilOperation to specify that stencil value must be incremented */
  117743. static readonly INCR: number;
  117744. /** Passed to stencilOperation to specify that stencil value must be decremented */
  117745. static readonly DECR: number;
  117746. /** Passed to stencilOperation to specify that stencil value must be inverted */
  117747. static readonly INVERT: number;
  117748. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  117749. static readonly INCR_WRAP: number;
  117750. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  117751. static readonly DECR_WRAP: number;
  117752. /** Texture is not repeating outside of 0..1 UVs */
  117753. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  117754. /** Texture is repeating outside of 0..1 UVs */
  117755. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  117756. /** Texture is repeating and mirrored */
  117757. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  117758. /** ALPHA */
  117759. static readonly TEXTUREFORMAT_ALPHA: number;
  117760. /** LUMINANCE */
  117761. static readonly TEXTUREFORMAT_LUMINANCE: number;
  117762. /** LUMINANCE_ALPHA */
  117763. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  117764. /** RGB */
  117765. static readonly TEXTUREFORMAT_RGB: number;
  117766. /** RGBA */
  117767. static readonly TEXTUREFORMAT_RGBA: number;
  117768. /** RED */
  117769. static readonly TEXTUREFORMAT_RED: number;
  117770. /** RED (2nd reference) */
  117771. static readonly TEXTUREFORMAT_R: number;
  117772. /** RG */
  117773. static readonly TEXTUREFORMAT_RG: number;
  117774. /** RED_INTEGER */
  117775. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  117776. /** RED_INTEGER (2nd reference) */
  117777. static readonly TEXTUREFORMAT_R_INTEGER: number;
  117778. /** RG_INTEGER */
  117779. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  117780. /** RGB_INTEGER */
  117781. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  117782. /** RGBA_INTEGER */
  117783. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  117784. /** UNSIGNED_BYTE */
  117785. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  117786. /** UNSIGNED_BYTE (2nd reference) */
  117787. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  117788. /** FLOAT */
  117789. static readonly TEXTURETYPE_FLOAT: number;
  117790. /** HALF_FLOAT */
  117791. static readonly TEXTURETYPE_HALF_FLOAT: number;
  117792. /** BYTE */
  117793. static readonly TEXTURETYPE_BYTE: number;
  117794. /** SHORT */
  117795. static readonly TEXTURETYPE_SHORT: number;
  117796. /** UNSIGNED_SHORT */
  117797. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  117798. /** INT */
  117799. static readonly TEXTURETYPE_INT: number;
  117800. /** UNSIGNED_INT */
  117801. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  117802. /** UNSIGNED_SHORT_4_4_4_4 */
  117803. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  117804. /** UNSIGNED_SHORT_5_5_5_1 */
  117805. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  117806. /** UNSIGNED_SHORT_5_6_5 */
  117807. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  117808. /** UNSIGNED_INT_2_10_10_10_REV */
  117809. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  117810. /** UNSIGNED_INT_24_8 */
  117811. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  117812. /** UNSIGNED_INT_10F_11F_11F_REV */
  117813. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  117814. /** UNSIGNED_INT_5_9_9_9_REV */
  117815. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  117816. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  117817. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  117818. /** nearest is mag = nearest and min = nearest and mip = linear */
  117819. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  117820. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117821. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  117822. /** Trilinear is mag = linear and min = linear and mip = linear */
  117823. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  117824. /** nearest is mag = nearest and min = nearest and mip = linear */
  117825. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  117826. /** Bilinear is mag = linear and min = linear and mip = nearest */
  117827. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  117828. /** Trilinear is mag = linear and min = linear and mip = linear */
  117829. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  117830. /** mag = nearest and min = nearest and mip = nearest */
  117831. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  117832. /** mag = nearest and min = linear and mip = nearest */
  117833. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  117834. /** mag = nearest and min = linear and mip = linear */
  117835. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  117836. /** mag = nearest and min = linear and mip = none */
  117837. static readonly TEXTURE_NEAREST_LINEAR: number;
  117838. /** mag = nearest and min = nearest and mip = none */
  117839. static readonly TEXTURE_NEAREST_NEAREST: number;
  117840. /** mag = linear and min = nearest and mip = nearest */
  117841. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  117842. /** mag = linear and min = nearest and mip = linear */
  117843. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  117844. /** mag = linear and min = linear and mip = none */
  117845. static readonly TEXTURE_LINEAR_LINEAR: number;
  117846. /** mag = linear and min = nearest and mip = none */
  117847. static readonly TEXTURE_LINEAR_NEAREST: number;
  117848. /** Explicit coordinates mode */
  117849. static readonly TEXTURE_EXPLICIT_MODE: number;
  117850. /** Spherical coordinates mode */
  117851. static readonly TEXTURE_SPHERICAL_MODE: number;
  117852. /** Planar coordinates mode */
  117853. static readonly TEXTURE_PLANAR_MODE: number;
  117854. /** Cubic coordinates mode */
  117855. static readonly TEXTURE_CUBIC_MODE: number;
  117856. /** Projection coordinates mode */
  117857. static readonly TEXTURE_PROJECTION_MODE: number;
  117858. /** Skybox coordinates mode */
  117859. static readonly TEXTURE_SKYBOX_MODE: number;
  117860. /** Inverse Cubic coordinates mode */
  117861. static readonly TEXTURE_INVCUBIC_MODE: number;
  117862. /** Equirectangular coordinates mode */
  117863. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  117864. /** Equirectangular Fixed coordinates mode */
  117865. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  117866. /** Equirectangular Fixed Mirrored coordinates mode */
  117867. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  117868. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  117869. static readonly SCALEMODE_FLOOR: number;
  117870. /** Defines that texture rescaling will look for the nearest power of 2 size */
  117871. static readonly SCALEMODE_NEAREST: number;
  117872. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  117873. static readonly SCALEMODE_CEILING: number;
  117874. /**
  117875. * Returns the current npm package of the sdk
  117876. */
  117877. static get NpmPackage(): string;
  117878. /**
  117879. * Returns the current version of the framework
  117880. */
  117881. static get Version(): string;
  117882. /** Gets the list of created engines */
  117883. static get Instances(): Engine[];
  117884. /**
  117885. * Gets the latest created engine
  117886. */
  117887. static get LastCreatedEngine(): Nullable<Engine>;
  117888. /**
  117889. * Gets the latest created scene
  117890. */
  117891. static get LastCreatedScene(): Nullable<Scene>;
  117892. /**
  117893. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  117894. * @param flag defines which part of the materials must be marked as dirty
  117895. * @param predicate defines a predicate used to filter which materials should be affected
  117896. */
  117897. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  117898. /**
  117899. * Method called to create the default loading screen.
  117900. * This can be overriden in your own app.
  117901. * @param canvas The rendering canvas element
  117902. * @returns The loading screen
  117903. */
  117904. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  117905. /**
  117906. * Method called to create the default rescale post process on each engine.
  117907. */
  117908. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  117909. /**
  117910. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  117911. **/
  117912. enableOfflineSupport: boolean;
  117913. /**
  117914. * 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)
  117915. **/
  117916. disableManifestCheck: boolean;
  117917. /**
  117918. * Gets the list of created scenes
  117919. */
  117920. scenes: Scene[];
  117921. /**
  117922. * Event raised when a new scene is created
  117923. */
  117924. onNewSceneAddedObservable: Observable<Scene>;
  117925. /**
  117926. * Gets the list of created postprocesses
  117927. */
  117928. postProcesses: PostProcess[];
  117929. /**
  117930. * Gets a boolean indicating if the pointer is currently locked
  117931. */
  117932. isPointerLock: boolean;
  117933. /**
  117934. * Observable event triggered each time the rendering canvas is resized
  117935. */
  117936. onResizeObservable: Observable<Engine>;
  117937. /**
  117938. * Observable event triggered each time the canvas loses focus
  117939. */
  117940. onCanvasBlurObservable: Observable<Engine>;
  117941. /**
  117942. * Observable event triggered each time the canvas gains focus
  117943. */
  117944. onCanvasFocusObservable: Observable<Engine>;
  117945. /**
  117946. * Observable event triggered each time the canvas receives pointerout event
  117947. */
  117948. onCanvasPointerOutObservable: Observable<PointerEvent>;
  117949. /**
  117950. * Observable raised when the engine begins a new frame
  117951. */
  117952. onBeginFrameObservable: Observable<Engine>;
  117953. /**
  117954. * If set, will be used to request the next animation frame for the render loop
  117955. */
  117956. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  117957. /**
  117958. * Observable raised when the engine ends the current frame
  117959. */
  117960. onEndFrameObservable: Observable<Engine>;
  117961. /**
  117962. * Observable raised when the engine is about to compile a shader
  117963. */
  117964. onBeforeShaderCompilationObservable: Observable<Engine>;
  117965. /**
  117966. * Observable raised when the engine has jsut compiled a shader
  117967. */
  117968. onAfterShaderCompilationObservable: Observable<Engine>;
  117969. /**
  117970. * Gets the audio engine
  117971. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117972. * @ignorenaming
  117973. */
  117974. static audioEngine: IAudioEngine;
  117975. /**
  117976. * Default AudioEngine factory responsible of creating the Audio Engine.
  117977. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  117978. */
  117979. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  117980. /**
  117981. * Default offline support factory responsible of creating a tool used to store data locally.
  117982. * By default, this will create a Database object if the workload has been embedded.
  117983. */
  117984. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  117985. private _loadingScreen;
  117986. private _pointerLockRequested;
  117987. private _rescalePostProcess;
  117988. private _deterministicLockstep;
  117989. private _lockstepMaxSteps;
  117990. private _timeStep;
  117991. protected get _supportsHardwareTextureRescaling(): boolean;
  117992. private _fps;
  117993. private _deltaTime;
  117994. /** @hidden */
  117995. _drawCalls: PerfCounter;
  117996. /** 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 */
  117997. canvasTabIndex: number;
  117998. /**
  117999. * Turn this value on if you want to pause FPS computation when in background
  118000. */
  118001. disablePerformanceMonitorInBackground: boolean;
  118002. private _performanceMonitor;
  118003. /**
  118004. * Gets the performance monitor attached to this engine
  118005. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118006. */
  118007. get performanceMonitor(): PerformanceMonitor;
  118008. private _onFocus;
  118009. private _onBlur;
  118010. private _onCanvasPointerOut;
  118011. private _onCanvasBlur;
  118012. private _onCanvasFocus;
  118013. private _onFullscreenChange;
  118014. private _onPointerLockChange;
  118015. /**
  118016. * Gets the HTML element used to attach event listeners
  118017. * @returns a HTML element
  118018. */
  118019. getInputElement(): Nullable<HTMLElement>;
  118020. /**
  118021. * Creates a new engine
  118022. * @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
  118023. * @param antialias defines enable antialiasing (default: false)
  118024. * @param options defines further options to be sent to the getContext() function
  118025. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118026. */
  118027. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118028. /**
  118029. * Gets current aspect ratio
  118030. * @param viewportOwner defines the camera to use to get the aspect ratio
  118031. * @param useScreen defines if screen size must be used (or the current render target if any)
  118032. * @returns a number defining the aspect ratio
  118033. */
  118034. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118035. /**
  118036. * Gets current screen aspect ratio
  118037. * @returns a number defining the aspect ratio
  118038. */
  118039. getScreenAspectRatio(): number;
  118040. /**
  118041. * Gets the client rect of the HTML canvas attached with the current webGL context
  118042. * @returns a client rectanglee
  118043. */
  118044. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118045. /**
  118046. * Gets the client rect of the HTML element used for events
  118047. * @returns a client rectanglee
  118048. */
  118049. getInputElementClientRect(): Nullable<ClientRect>;
  118050. /**
  118051. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118052. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118053. * @returns true if engine is in deterministic lock step mode
  118054. */
  118055. isDeterministicLockStep(): boolean;
  118056. /**
  118057. * Gets the max steps when engine is running in deterministic lock step
  118058. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118059. * @returns the max steps
  118060. */
  118061. getLockstepMaxSteps(): number;
  118062. /**
  118063. * Returns the time in ms between steps when using deterministic lock step.
  118064. * @returns time step in (ms)
  118065. */
  118066. getTimeStep(): number;
  118067. /**
  118068. * Force the mipmap generation for the given render target texture
  118069. * @param texture defines the render target texture to use
  118070. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118071. */
  118072. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118073. /** States */
  118074. /**
  118075. * Set various states to the webGL context
  118076. * @param culling defines backface culling state
  118077. * @param zOffset defines the value to apply to zOffset (0 by default)
  118078. * @param force defines if states must be applied even if cache is up to date
  118079. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118080. */
  118081. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118082. /**
  118083. * Set the z offset to apply to current rendering
  118084. * @param value defines the offset to apply
  118085. */
  118086. setZOffset(value: number): void;
  118087. /**
  118088. * Gets the current value of the zOffset
  118089. * @returns the current zOffset state
  118090. */
  118091. getZOffset(): number;
  118092. /**
  118093. * Enable or disable depth buffering
  118094. * @param enable defines the state to set
  118095. */
  118096. setDepthBuffer(enable: boolean): void;
  118097. /**
  118098. * Gets a boolean indicating if depth writing is enabled
  118099. * @returns the current depth writing state
  118100. */
  118101. getDepthWrite(): boolean;
  118102. /**
  118103. * Enable or disable depth writing
  118104. * @param enable defines the state to set
  118105. */
  118106. setDepthWrite(enable: boolean): void;
  118107. /**
  118108. * Gets a boolean indicating if stencil buffer is enabled
  118109. * @returns the current stencil buffer state
  118110. */
  118111. getStencilBuffer(): boolean;
  118112. /**
  118113. * Enable or disable the stencil buffer
  118114. * @param enable defines if the stencil buffer must be enabled or disabled
  118115. */
  118116. setStencilBuffer(enable: boolean): void;
  118117. /**
  118118. * Gets the current stencil mask
  118119. * @returns a number defining the new stencil mask to use
  118120. */
  118121. getStencilMask(): number;
  118122. /**
  118123. * Sets the current stencil mask
  118124. * @param mask defines the new stencil mask to use
  118125. */
  118126. setStencilMask(mask: number): void;
  118127. /**
  118128. * Gets the current stencil function
  118129. * @returns a number defining the stencil function to use
  118130. */
  118131. getStencilFunction(): number;
  118132. /**
  118133. * Gets the current stencil reference value
  118134. * @returns a number defining the stencil reference value to use
  118135. */
  118136. getStencilFunctionReference(): number;
  118137. /**
  118138. * Gets the current stencil mask
  118139. * @returns a number defining the stencil mask to use
  118140. */
  118141. getStencilFunctionMask(): number;
  118142. /**
  118143. * Sets the current stencil function
  118144. * @param stencilFunc defines the new stencil function to use
  118145. */
  118146. setStencilFunction(stencilFunc: number): void;
  118147. /**
  118148. * Sets the current stencil reference
  118149. * @param reference defines the new stencil reference to use
  118150. */
  118151. setStencilFunctionReference(reference: number): void;
  118152. /**
  118153. * Sets the current stencil mask
  118154. * @param mask defines the new stencil mask to use
  118155. */
  118156. setStencilFunctionMask(mask: number): void;
  118157. /**
  118158. * Gets the current stencil operation when stencil fails
  118159. * @returns a number defining stencil operation to use when stencil fails
  118160. */
  118161. getStencilOperationFail(): number;
  118162. /**
  118163. * Gets the current stencil operation when depth fails
  118164. * @returns a number defining stencil operation to use when depth fails
  118165. */
  118166. getStencilOperationDepthFail(): number;
  118167. /**
  118168. * Gets the current stencil operation when stencil passes
  118169. * @returns a number defining stencil operation to use when stencil passes
  118170. */
  118171. getStencilOperationPass(): number;
  118172. /**
  118173. * Sets the stencil operation to use when stencil fails
  118174. * @param operation defines the stencil operation to use when stencil fails
  118175. */
  118176. setStencilOperationFail(operation: number): void;
  118177. /**
  118178. * Sets the stencil operation to use when depth fails
  118179. * @param operation defines the stencil operation to use when depth fails
  118180. */
  118181. setStencilOperationDepthFail(operation: number): void;
  118182. /**
  118183. * Sets the stencil operation to use when stencil passes
  118184. * @param operation defines the stencil operation to use when stencil passes
  118185. */
  118186. setStencilOperationPass(operation: number): void;
  118187. /**
  118188. * Sets a boolean indicating if the dithering state is enabled or disabled
  118189. * @param value defines the dithering state
  118190. */
  118191. setDitheringState(value: boolean): void;
  118192. /**
  118193. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118194. * @param value defines the rasterizer state
  118195. */
  118196. setRasterizerState(value: boolean): void;
  118197. /**
  118198. * Gets the current depth function
  118199. * @returns a number defining the depth function
  118200. */
  118201. getDepthFunction(): Nullable<number>;
  118202. /**
  118203. * Sets the current depth function
  118204. * @param depthFunc defines the function to use
  118205. */
  118206. setDepthFunction(depthFunc: number): void;
  118207. /**
  118208. * Sets the current depth function to GREATER
  118209. */
  118210. setDepthFunctionToGreater(): void;
  118211. /**
  118212. * Sets the current depth function to GEQUAL
  118213. */
  118214. setDepthFunctionToGreaterOrEqual(): void;
  118215. /**
  118216. * Sets the current depth function to LESS
  118217. */
  118218. setDepthFunctionToLess(): void;
  118219. /**
  118220. * Sets the current depth function to LEQUAL
  118221. */
  118222. setDepthFunctionToLessOrEqual(): void;
  118223. private _cachedStencilBuffer;
  118224. private _cachedStencilFunction;
  118225. private _cachedStencilMask;
  118226. private _cachedStencilOperationPass;
  118227. private _cachedStencilOperationFail;
  118228. private _cachedStencilOperationDepthFail;
  118229. private _cachedStencilReference;
  118230. /**
  118231. * Caches the the state of the stencil buffer
  118232. */
  118233. cacheStencilState(): void;
  118234. /**
  118235. * Restores the state of the stencil buffer
  118236. */
  118237. restoreStencilState(): void;
  118238. /**
  118239. * Directly set the WebGL Viewport
  118240. * @param x defines the x coordinate of the viewport (in screen space)
  118241. * @param y defines the y coordinate of the viewport (in screen space)
  118242. * @param width defines the width of the viewport (in screen space)
  118243. * @param height defines the height of the viewport (in screen space)
  118244. * @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
  118245. */
  118246. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118247. /**
  118248. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118249. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118250. * @param y defines the y-coordinate of the corner of the clear rectangle
  118251. * @param width defines the width of the clear rectangle
  118252. * @param height defines the height of the clear rectangle
  118253. * @param clearColor defines the clear color
  118254. */
  118255. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118256. /**
  118257. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118258. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118259. * @param y defines the y-coordinate of the corner of the clear rectangle
  118260. * @param width defines the width of the clear rectangle
  118261. * @param height defines the height of the clear rectangle
  118262. */
  118263. enableScissor(x: number, y: number, width: number, height: number): void;
  118264. /**
  118265. * Disable previously set scissor test rectangle
  118266. */
  118267. disableScissor(): void;
  118268. protected _reportDrawCall(): void;
  118269. /**
  118270. * Initializes a webVR display and starts listening to display change events
  118271. * The onVRDisplayChangedObservable will be notified upon these changes
  118272. * @returns The onVRDisplayChangedObservable
  118273. */
  118274. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118275. /** @hidden */
  118276. _prepareVRComponent(): void;
  118277. /** @hidden */
  118278. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118279. /** @hidden */
  118280. _submitVRFrame(): void;
  118281. /**
  118282. * Call this function to leave webVR mode
  118283. * Will do nothing if webVR is not supported or if there is no webVR device
  118284. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118285. */
  118286. disableVR(): void;
  118287. /**
  118288. * Gets a boolean indicating that the system is in VR mode and is presenting
  118289. * @returns true if VR mode is engaged
  118290. */
  118291. isVRPresenting(): boolean;
  118292. /** @hidden */
  118293. _requestVRFrame(): void;
  118294. /** @hidden */
  118295. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118296. /**
  118297. * Gets the source code of the vertex shader associated with a specific webGL program
  118298. * @param program defines the program to use
  118299. * @returns a string containing the source code of the vertex shader associated with the program
  118300. */
  118301. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118302. /**
  118303. * Gets the source code of the fragment shader associated with a specific webGL program
  118304. * @param program defines the program to use
  118305. * @returns a string containing the source code of the fragment shader associated with the program
  118306. */
  118307. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118308. /**
  118309. * Sets a depth stencil texture from a render target to the according uniform.
  118310. * @param channel The texture channel
  118311. * @param uniform The uniform to set
  118312. * @param texture The render target texture containing the depth stencil texture to apply
  118313. */
  118314. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118315. /**
  118316. * Sets a texture to the webGL context from a postprocess
  118317. * @param channel defines the channel to use
  118318. * @param postProcess defines the source postprocess
  118319. */
  118320. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118321. /**
  118322. * Binds the output of the passed in post process to the texture channel specified
  118323. * @param channel The channel the texture should be bound to
  118324. * @param postProcess The post process which's output should be bound
  118325. */
  118326. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118327. protected _rebuildBuffers(): void;
  118328. /** @hidden */
  118329. _renderFrame(): void;
  118330. _renderLoop(): void;
  118331. /** @hidden */
  118332. _renderViews(): boolean;
  118333. /**
  118334. * Toggle full screen mode
  118335. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118336. */
  118337. switchFullscreen(requestPointerLock: boolean): void;
  118338. /**
  118339. * Enters full screen mode
  118340. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118341. */
  118342. enterFullscreen(requestPointerLock: boolean): void;
  118343. /**
  118344. * Exits full screen mode
  118345. */
  118346. exitFullscreen(): void;
  118347. /**
  118348. * Enters Pointerlock mode
  118349. */
  118350. enterPointerlock(): void;
  118351. /**
  118352. * Exits Pointerlock mode
  118353. */
  118354. exitPointerlock(): void;
  118355. /**
  118356. * Begin a new frame
  118357. */
  118358. beginFrame(): void;
  118359. /**
  118360. * Enf the current frame
  118361. */
  118362. endFrame(): void;
  118363. resize(): void;
  118364. /**
  118365. * Force a specific size of the canvas
  118366. * @param width defines the new canvas' width
  118367. * @param height defines the new canvas' height
  118368. * @returns true if the size was changed
  118369. */
  118370. setSize(width: number, height: number): boolean;
  118371. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118372. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118373. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118374. _releaseTexture(texture: InternalTexture): void;
  118375. /**
  118376. * @hidden
  118377. * Rescales a texture
  118378. * @param source input texutre
  118379. * @param destination destination texture
  118380. * @param scene scene to use to render the resize
  118381. * @param internalFormat format to use when resizing
  118382. * @param onComplete callback to be called when resize has completed
  118383. */
  118384. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118385. /**
  118386. * Gets the current framerate
  118387. * @returns a number representing the framerate
  118388. */
  118389. getFps(): number;
  118390. /**
  118391. * Gets the time spent between current and previous frame
  118392. * @returns a number representing the delta time in ms
  118393. */
  118394. getDeltaTime(): number;
  118395. private _measureFps;
  118396. /** @hidden */
  118397. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118398. /**
  118399. * Updates the sample count of a render target texture
  118400. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118401. * @param texture defines the texture to update
  118402. * @param samples defines the sample count to set
  118403. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118404. */
  118405. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118406. /**
  118407. * Updates a depth texture Comparison Mode and Function.
  118408. * If the comparison Function is equal to 0, the mode will be set to none.
  118409. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118410. * @param texture The texture to set the comparison function for
  118411. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118412. */
  118413. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118414. /**
  118415. * Creates a webGL buffer to use with instanciation
  118416. * @param capacity defines the size of the buffer
  118417. * @returns the webGL buffer
  118418. */
  118419. createInstancesBuffer(capacity: number): DataBuffer;
  118420. /**
  118421. * Delete a webGL buffer used with instanciation
  118422. * @param buffer defines the webGL buffer to delete
  118423. */
  118424. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118425. private _clientWaitAsync;
  118426. /** @hidden */
  118427. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118428. dispose(): void;
  118429. private _disableTouchAction;
  118430. /**
  118431. * Display the loading screen
  118432. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118433. */
  118434. displayLoadingUI(): void;
  118435. /**
  118436. * Hide the loading screen
  118437. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118438. */
  118439. hideLoadingUI(): void;
  118440. /**
  118441. * Gets the current loading screen object
  118442. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118443. */
  118444. get loadingScreen(): ILoadingScreen;
  118445. /**
  118446. * Sets the current loading screen object
  118447. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118448. */
  118449. set loadingScreen(loadingScreen: ILoadingScreen);
  118450. /**
  118451. * Sets the current loading screen text
  118452. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118453. */
  118454. set loadingUIText(text: string);
  118455. /**
  118456. * Sets the current loading screen background color
  118457. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118458. */
  118459. set loadingUIBackgroundColor(color: string);
  118460. /** Pointerlock and fullscreen */
  118461. /**
  118462. * Ask the browser to promote the current element to pointerlock mode
  118463. * @param element defines the DOM element to promote
  118464. */
  118465. static _RequestPointerlock(element: HTMLElement): void;
  118466. /**
  118467. * Asks the browser to exit pointerlock mode
  118468. */
  118469. static _ExitPointerlock(): void;
  118470. /**
  118471. * Ask the browser to promote the current element to fullscreen rendering mode
  118472. * @param element defines the DOM element to promote
  118473. */
  118474. static _RequestFullscreen(element: HTMLElement): void;
  118475. /**
  118476. * Asks the browser to exit fullscreen mode
  118477. */
  118478. static _ExitFullscreen(): void;
  118479. }
  118480. }
  118481. declare module BABYLON {
  118482. /**
  118483. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118484. * during the life time of the application.
  118485. */
  118486. export class EngineStore {
  118487. /** Gets the list of created engines */
  118488. static Instances: Engine[];
  118489. /** @hidden */
  118490. static _LastCreatedScene: Nullable<Scene>;
  118491. /**
  118492. * Gets the latest created engine
  118493. */
  118494. static get LastCreatedEngine(): Nullable<Engine>;
  118495. /**
  118496. * Gets the latest created scene
  118497. */
  118498. static get LastCreatedScene(): Nullable<Scene>;
  118499. /**
  118500. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118501. * @ignorenaming
  118502. */
  118503. static UseFallbackTexture: boolean;
  118504. /**
  118505. * Texture content used if a texture cannot loaded
  118506. * @ignorenaming
  118507. */
  118508. static FallbackTexture: string;
  118509. }
  118510. }
  118511. declare module BABYLON {
  118512. /**
  118513. * Helper class that provides a small promise polyfill
  118514. */
  118515. export class PromisePolyfill {
  118516. /**
  118517. * Static function used to check if the polyfill is required
  118518. * If this is the case then the function will inject the polyfill to window.Promise
  118519. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118520. */
  118521. static Apply(force?: boolean): void;
  118522. }
  118523. }
  118524. declare module BABYLON {
  118525. /**
  118526. * Interface for screenshot methods with describe argument called `size` as object with options
  118527. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118528. */
  118529. export interface IScreenshotSize {
  118530. /**
  118531. * number in pixels for canvas height
  118532. */
  118533. height?: number;
  118534. /**
  118535. * multiplier allowing render at a higher or lower resolution
  118536. * If value is defined then height and width will be ignored and taken from camera
  118537. */
  118538. precision?: number;
  118539. /**
  118540. * number in pixels for canvas width
  118541. */
  118542. width?: number;
  118543. }
  118544. }
  118545. declare module BABYLON {
  118546. interface IColor4Like {
  118547. r: float;
  118548. g: float;
  118549. b: float;
  118550. a: float;
  118551. }
  118552. /**
  118553. * Class containing a set of static utilities functions
  118554. */
  118555. export class Tools {
  118556. /**
  118557. * Gets or sets the base URL to use to load assets
  118558. */
  118559. static get BaseUrl(): string;
  118560. static set BaseUrl(value: string);
  118561. /**
  118562. * Enable/Disable Custom HTTP Request Headers globally.
  118563. * default = false
  118564. * @see CustomRequestHeaders
  118565. */
  118566. static UseCustomRequestHeaders: boolean;
  118567. /**
  118568. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118569. * i.e. when loading files, where the server/service expects an Authorization header
  118570. */
  118571. static CustomRequestHeaders: {
  118572. [key: string]: string;
  118573. };
  118574. /**
  118575. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118576. */
  118577. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118578. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118579. /**
  118580. * Default behaviour for cors in the application.
  118581. * It can be a string if the expected behavior is identical in the entire app.
  118582. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118583. */
  118584. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118585. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118586. /**
  118587. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118588. * @ignorenaming
  118589. */
  118590. static get UseFallbackTexture(): boolean;
  118591. static set UseFallbackTexture(value: boolean);
  118592. /**
  118593. * Use this object to register external classes like custom textures or material
  118594. * to allow the laoders to instantiate them
  118595. */
  118596. static get RegisteredExternalClasses(): {
  118597. [key: string]: Object;
  118598. };
  118599. static set RegisteredExternalClasses(classes: {
  118600. [key: string]: Object;
  118601. });
  118602. /**
  118603. * Texture content used if a texture cannot loaded
  118604. * @ignorenaming
  118605. */
  118606. static get fallbackTexture(): string;
  118607. static set fallbackTexture(value: string);
  118608. /**
  118609. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118610. * @param u defines the coordinate on X axis
  118611. * @param v defines the coordinate on Y axis
  118612. * @param width defines the width of the source data
  118613. * @param height defines the height of the source data
  118614. * @param pixels defines the source byte array
  118615. * @param color defines the output color
  118616. */
  118617. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118618. /**
  118619. * Interpolates between a and b via alpha
  118620. * @param a The lower value (returned when alpha = 0)
  118621. * @param b The upper value (returned when alpha = 1)
  118622. * @param alpha The interpolation-factor
  118623. * @return The mixed value
  118624. */
  118625. static Mix(a: number, b: number, alpha: number): number;
  118626. /**
  118627. * Tries to instantiate a new object from a given class name
  118628. * @param className defines the class name to instantiate
  118629. * @returns the new object or null if the system was not able to do the instantiation
  118630. */
  118631. static Instantiate(className: string): any;
  118632. /**
  118633. * Provides a slice function that will work even on IE
  118634. * @param data defines the array to slice
  118635. * @param start defines the start of the data (optional)
  118636. * @param end defines the end of the data (optional)
  118637. * @returns the new sliced array
  118638. */
  118639. static Slice<T>(data: T, start?: number, end?: number): T;
  118640. /**
  118641. * Polyfill for setImmediate
  118642. * @param action defines the action to execute after the current execution block
  118643. */
  118644. static SetImmediate(action: () => void): void;
  118645. /**
  118646. * Function indicating if a number is an exponent of 2
  118647. * @param value defines the value to test
  118648. * @returns true if the value is an exponent of 2
  118649. */
  118650. static IsExponentOfTwo(value: number): boolean;
  118651. private static _tmpFloatArray;
  118652. /**
  118653. * Returns the nearest 32-bit single precision float representation of a Number
  118654. * @param value A Number. If the parameter is of a different type, it will get converted
  118655. * to a number or to NaN if it cannot be converted
  118656. * @returns number
  118657. */
  118658. static FloatRound(value: number): number;
  118659. /**
  118660. * Extracts the filename from a path
  118661. * @param path defines the path to use
  118662. * @returns the filename
  118663. */
  118664. static GetFilename(path: string): string;
  118665. /**
  118666. * Extracts the "folder" part of a path (everything before the filename).
  118667. * @param uri The URI to extract the info from
  118668. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  118669. * @returns The "folder" part of the path
  118670. */
  118671. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  118672. /**
  118673. * Extracts text content from a DOM element hierarchy
  118674. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  118675. */
  118676. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  118677. /**
  118678. * Convert an angle in radians to degrees
  118679. * @param angle defines the angle to convert
  118680. * @returns the angle in degrees
  118681. */
  118682. static ToDegrees(angle: number): number;
  118683. /**
  118684. * Convert an angle in degrees to radians
  118685. * @param angle defines the angle to convert
  118686. * @returns the angle in radians
  118687. */
  118688. static ToRadians(angle: number): number;
  118689. /**
  118690. * Returns an array if obj is not an array
  118691. * @param obj defines the object to evaluate as an array
  118692. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  118693. * @returns either obj directly if obj is an array or a new array containing obj
  118694. */
  118695. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  118696. /**
  118697. * Gets the pointer prefix to use
  118698. * @param engine defines the engine we are finding the prefix for
  118699. * @returns "pointer" if touch is enabled. Else returns "mouse"
  118700. */
  118701. static GetPointerPrefix(engine: Engine): string;
  118702. /**
  118703. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  118704. * @param url define the url we are trying
  118705. * @param element define the dom element where to configure the cors policy
  118706. */
  118707. static SetCorsBehavior(url: string | string[], element: {
  118708. crossOrigin: string | null;
  118709. }): void;
  118710. /**
  118711. * Removes unwanted characters from an url
  118712. * @param url defines the url to clean
  118713. * @returns the cleaned url
  118714. */
  118715. static CleanUrl(url: string): string;
  118716. /**
  118717. * Gets or sets a function used to pre-process url before using them to load assets
  118718. */
  118719. static get PreprocessUrl(): (url: string) => string;
  118720. static set PreprocessUrl(processor: (url: string) => string);
  118721. /**
  118722. * Loads an image as an HTMLImageElement.
  118723. * @param input url string, ArrayBuffer, or Blob to load
  118724. * @param onLoad callback called when the image successfully loads
  118725. * @param onError callback called when the image fails to load
  118726. * @param offlineProvider offline provider for caching
  118727. * @param mimeType optional mime type
  118728. * @returns the HTMLImageElement of the loaded image
  118729. */
  118730. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  118731. /**
  118732. * Loads a file from a url
  118733. * @param url url string, ArrayBuffer, or Blob to load
  118734. * @param onSuccess callback called when the file successfully loads
  118735. * @param onProgress callback called while file is loading (if the server supports this mode)
  118736. * @param offlineProvider defines the offline provider for caching
  118737. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118738. * @param onError callback called when the file fails to load
  118739. * @returns a file request object
  118740. */
  118741. 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;
  118742. /**
  118743. * Loads a file from a url
  118744. * @param url the file url to load
  118745. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  118746. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  118747. */
  118748. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  118749. /**
  118750. * Load a script (identified by an url). When the url returns, the
  118751. * content of this file is added into a new script element, attached to the DOM (body element)
  118752. * @param scriptUrl defines the url of the script to laod
  118753. * @param onSuccess defines the callback called when the script is loaded
  118754. * @param onError defines the callback to call if an error occurs
  118755. * @param scriptId defines the id of the script element
  118756. */
  118757. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  118758. /**
  118759. * Load an asynchronous script (identified by an url). When the url returns, the
  118760. * content of this file is added into a new script element, attached to the DOM (body element)
  118761. * @param scriptUrl defines the url of the script to laod
  118762. * @param scriptId defines the id of the script element
  118763. * @returns a promise request object
  118764. */
  118765. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  118766. /**
  118767. * Loads a file from a blob
  118768. * @param fileToLoad defines the blob to use
  118769. * @param callback defines the callback to call when data is loaded
  118770. * @param progressCallback defines the callback to call during loading process
  118771. * @returns a file request object
  118772. */
  118773. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  118774. /**
  118775. * Reads a file from a File object
  118776. * @param file defines the file to load
  118777. * @param onSuccess defines the callback to call when data is loaded
  118778. * @param onProgress defines the callback to call during loading process
  118779. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  118780. * @param onError defines the callback to call when an error occurs
  118781. * @returns a file request object
  118782. */
  118783. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  118784. /**
  118785. * Creates a data url from a given string content
  118786. * @param content defines the content to convert
  118787. * @returns the new data url link
  118788. */
  118789. static FileAsURL(content: string): string;
  118790. /**
  118791. * Format the given number to a specific decimal format
  118792. * @param value defines the number to format
  118793. * @param decimals defines the number of decimals to use
  118794. * @returns the formatted string
  118795. */
  118796. static Format(value: number, decimals?: number): string;
  118797. /**
  118798. * Tries to copy an object by duplicating every property
  118799. * @param source defines the source object
  118800. * @param destination defines the target object
  118801. * @param doNotCopyList defines a list of properties to avoid
  118802. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  118803. */
  118804. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  118805. /**
  118806. * Gets a boolean indicating if the given object has no own property
  118807. * @param obj defines the object to test
  118808. * @returns true if object has no own property
  118809. */
  118810. static IsEmpty(obj: any): boolean;
  118811. /**
  118812. * Function used to register events at window level
  118813. * @param windowElement defines the Window object to use
  118814. * @param events defines the events to register
  118815. */
  118816. static RegisterTopRootEvents(windowElement: Window, events: {
  118817. name: string;
  118818. handler: Nullable<(e: FocusEvent) => any>;
  118819. }[]): void;
  118820. /**
  118821. * Function used to unregister events from window level
  118822. * @param windowElement defines the Window object to use
  118823. * @param events defines the events to unregister
  118824. */
  118825. static UnregisterTopRootEvents(windowElement: Window, events: {
  118826. name: string;
  118827. handler: Nullable<(e: FocusEvent) => any>;
  118828. }[]): void;
  118829. /**
  118830. * @ignore
  118831. */
  118832. static _ScreenshotCanvas: HTMLCanvasElement;
  118833. /**
  118834. * Dumps the current bound framebuffer
  118835. * @param width defines the rendering width
  118836. * @param height defines the rendering height
  118837. * @param engine defines the hosting engine
  118838. * @param successCallback defines the callback triggered once the data are available
  118839. * @param mimeType defines the mime type of the result
  118840. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  118841. */
  118842. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118843. /**
  118844. * Converts the canvas data to blob.
  118845. * This acts as a polyfill for browsers not supporting the to blob function.
  118846. * @param canvas Defines the canvas to extract the data from
  118847. * @param successCallback Defines the callback triggered once the data are available
  118848. * @param mimeType Defines the mime type of the result
  118849. */
  118850. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  118851. /**
  118852. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  118853. * @param successCallback defines the callback triggered once the data are available
  118854. * @param mimeType defines the mime type of the result
  118855. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  118856. */
  118857. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  118858. /**
  118859. * Downloads a blob in the browser
  118860. * @param blob defines the blob to download
  118861. * @param fileName defines the name of the downloaded file
  118862. */
  118863. static Download(blob: Blob, fileName: string): void;
  118864. /**
  118865. * Captures a screenshot of the current rendering
  118866. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118867. * @param engine defines the rendering engine
  118868. * @param camera defines the source camera
  118869. * @param size This parameter can be set to a single number or to an object with the
  118870. * following (optional) properties: precision, width, height. If a single number is passed,
  118871. * it will be used for both width and height. If an object is passed, the screenshot size
  118872. * will be derived from the parameters. The precision property is a multiplier allowing
  118873. * rendering at a higher or lower resolution
  118874. * @param successCallback defines the callback receives a single parameter which contains the
  118875. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118876. * src parameter of an <img> to display it
  118877. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118878. * Check your browser for supported MIME types
  118879. */
  118880. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  118881. /**
  118882. * Captures a screenshot of the current rendering
  118883. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118884. * @param engine defines the rendering engine
  118885. * @param camera defines the source camera
  118886. * @param size This parameter can be set to a single number or to an object with the
  118887. * following (optional) properties: precision, width, height. If a single number is passed,
  118888. * it will be used for both width and height. If an object is passed, the screenshot size
  118889. * will be derived from the parameters. The precision property is a multiplier allowing
  118890. * rendering at a higher or lower resolution
  118891. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  118892. * Check your browser for supported MIME types
  118893. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118894. * to the src parameter of an <img> to display it
  118895. */
  118896. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  118897. /**
  118898. * Generates an image screenshot from the specified camera.
  118899. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118900. * @param engine The engine to use for rendering
  118901. * @param camera The camera to use for rendering
  118902. * @param size This parameter can be set to a single number or to an object with the
  118903. * following (optional) properties: precision, width, height. If a single number is passed,
  118904. * it will be used for both width and height. If an object is passed, the screenshot size
  118905. * will be derived from the parameters. The precision property is a multiplier allowing
  118906. * rendering at a higher or lower resolution
  118907. * @param successCallback The callback receives a single parameter which contains the
  118908. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  118909. * src parameter of an <img> to display it
  118910. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118911. * Check your browser for supported MIME types
  118912. * @param samples Texture samples (default: 1)
  118913. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118914. * @param fileName A name for for the downloaded file.
  118915. */
  118916. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  118917. /**
  118918. * Generates an image screenshot from the specified camera.
  118919. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  118920. * @param engine The engine to use for rendering
  118921. * @param camera The camera to use for rendering
  118922. * @param size This parameter can be set to a single number or to an object with the
  118923. * following (optional) properties: precision, width, height. If a single number is passed,
  118924. * it will be used for both width and height. If an object is passed, the screenshot size
  118925. * will be derived from the parameters. The precision property is a multiplier allowing
  118926. * rendering at a higher or lower resolution
  118927. * @param mimeType The MIME type of the screenshot image (default: image/png).
  118928. * Check your browser for supported MIME types
  118929. * @param samples Texture samples (default: 1)
  118930. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  118931. * @param fileName A name for for the downloaded file.
  118932. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  118933. * to the src parameter of an <img> to display it
  118934. */
  118935. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  118936. /**
  118937. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  118938. * Be aware Math.random() could cause collisions, but:
  118939. * "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"
  118940. * @returns a pseudo random id
  118941. */
  118942. static RandomId(): string;
  118943. /**
  118944. * Test if the given uri is a base64 string
  118945. * @param uri The uri to test
  118946. * @return True if the uri is a base64 string or false otherwise
  118947. */
  118948. static IsBase64(uri: string): boolean;
  118949. /**
  118950. * Decode the given base64 uri.
  118951. * @param uri The uri to decode
  118952. * @return The decoded base64 data.
  118953. */
  118954. static DecodeBase64(uri: string): ArrayBuffer;
  118955. /**
  118956. * Gets the absolute url.
  118957. * @param url the input url
  118958. * @return the absolute url
  118959. */
  118960. static GetAbsoluteUrl(url: string): string;
  118961. /**
  118962. * No log
  118963. */
  118964. static readonly NoneLogLevel: number;
  118965. /**
  118966. * Only message logs
  118967. */
  118968. static readonly MessageLogLevel: number;
  118969. /**
  118970. * Only warning logs
  118971. */
  118972. static readonly WarningLogLevel: number;
  118973. /**
  118974. * Only error logs
  118975. */
  118976. static readonly ErrorLogLevel: number;
  118977. /**
  118978. * All logs
  118979. */
  118980. static readonly AllLogLevel: number;
  118981. /**
  118982. * Gets a value indicating the number of loading errors
  118983. * @ignorenaming
  118984. */
  118985. static get errorsCount(): number;
  118986. /**
  118987. * Callback called when a new log is added
  118988. */
  118989. static OnNewCacheEntry: (entry: string) => void;
  118990. /**
  118991. * Log a message to the console
  118992. * @param message defines the message to log
  118993. */
  118994. static Log(message: string): void;
  118995. /**
  118996. * Write a warning message to the console
  118997. * @param message defines the message to log
  118998. */
  118999. static Warn(message: string): void;
  119000. /**
  119001. * Write an error message to the console
  119002. * @param message defines the message to log
  119003. */
  119004. static Error(message: string): void;
  119005. /**
  119006. * Gets current log cache (list of logs)
  119007. */
  119008. static get LogCache(): string;
  119009. /**
  119010. * Clears the log cache
  119011. */
  119012. static ClearLogCache(): void;
  119013. /**
  119014. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119015. */
  119016. static set LogLevels(level: number);
  119017. /**
  119018. * Checks if the window object exists
  119019. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119020. */
  119021. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119022. /**
  119023. * No performance log
  119024. */
  119025. static readonly PerformanceNoneLogLevel: number;
  119026. /**
  119027. * Use user marks to log performance
  119028. */
  119029. static readonly PerformanceUserMarkLogLevel: number;
  119030. /**
  119031. * Log performance to the console
  119032. */
  119033. static readonly PerformanceConsoleLogLevel: number;
  119034. private static _performance;
  119035. /**
  119036. * Sets the current performance log level
  119037. */
  119038. static set PerformanceLogLevel(level: number);
  119039. private static _StartPerformanceCounterDisabled;
  119040. private static _EndPerformanceCounterDisabled;
  119041. private static _StartUserMark;
  119042. private static _EndUserMark;
  119043. private static _StartPerformanceConsole;
  119044. private static _EndPerformanceConsole;
  119045. /**
  119046. * Starts a performance counter
  119047. */
  119048. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119049. /**
  119050. * Ends a specific performance coutner
  119051. */
  119052. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119053. /**
  119054. * Gets either window.performance.now() if supported or Date.now() else
  119055. */
  119056. static get Now(): number;
  119057. /**
  119058. * This method will return the name of the class used to create the instance of the given object.
  119059. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119060. * @param object the object to get the class name from
  119061. * @param isType defines if the object is actually a type
  119062. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119063. */
  119064. static GetClassName(object: any, isType?: boolean): string;
  119065. /**
  119066. * Gets the first element of an array satisfying a given predicate
  119067. * @param array defines the array to browse
  119068. * @param predicate defines the predicate to use
  119069. * @returns null if not found or the element
  119070. */
  119071. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119072. /**
  119073. * This method will return the name of the full name of the class, including its owning module (if any).
  119074. * 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).
  119075. * @param object the object to get the class name from
  119076. * @param isType defines if the object is actually a type
  119077. * @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.
  119078. * @ignorenaming
  119079. */
  119080. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119081. /**
  119082. * Returns a promise that resolves after the given amount of time.
  119083. * @param delay Number of milliseconds to delay
  119084. * @returns Promise that resolves after the given amount of time
  119085. */
  119086. static DelayAsync(delay: number): Promise<void>;
  119087. /**
  119088. * Utility function to detect if the current user agent is Safari
  119089. * @returns whether or not the current user agent is safari
  119090. */
  119091. static IsSafari(): boolean;
  119092. }
  119093. /**
  119094. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119095. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119096. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119097. * @param name The name of the class, case should be preserved
  119098. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119099. */
  119100. export function className(name: string, module?: string): (target: Object) => void;
  119101. /**
  119102. * An implementation of a loop for asynchronous functions.
  119103. */
  119104. export class AsyncLoop {
  119105. /**
  119106. * Defines the number of iterations for the loop
  119107. */
  119108. iterations: number;
  119109. /**
  119110. * Defines the current index of the loop.
  119111. */
  119112. index: number;
  119113. private _done;
  119114. private _fn;
  119115. private _successCallback;
  119116. /**
  119117. * Constructor.
  119118. * @param iterations the number of iterations.
  119119. * @param func the function to run each iteration
  119120. * @param successCallback the callback that will be called upon succesful execution
  119121. * @param offset starting offset.
  119122. */
  119123. constructor(
  119124. /**
  119125. * Defines the number of iterations for the loop
  119126. */
  119127. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119128. /**
  119129. * Execute the next iteration. Must be called after the last iteration was finished.
  119130. */
  119131. executeNext(): void;
  119132. /**
  119133. * Break the loop and run the success callback.
  119134. */
  119135. breakLoop(): void;
  119136. /**
  119137. * Create and run an async loop.
  119138. * @param iterations the number of iterations.
  119139. * @param fn the function to run each iteration
  119140. * @param successCallback the callback that will be called upon succesful execution
  119141. * @param offset starting offset.
  119142. * @returns the created async loop object
  119143. */
  119144. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119145. /**
  119146. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119147. * @param iterations total number of iterations
  119148. * @param syncedIterations number of synchronous iterations in each async iteration.
  119149. * @param fn the function to call each iteration.
  119150. * @param callback a success call back that will be called when iterating stops.
  119151. * @param breakFunction a break condition (optional)
  119152. * @param timeout timeout settings for the setTimeout function. default - 0.
  119153. * @returns the created async loop object
  119154. */
  119155. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119156. }
  119157. }
  119158. declare module BABYLON {
  119159. /**
  119160. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119161. * The underlying implementation relies on an associative array to ensure the best performances.
  119162. * The value can be anything including 'null' but except 'undefined'
  119163. */
  119164. export class StringDictionary<T> {
  119165. /**
  119166. * This will clear this dictionary and copy the content from the 'source' one.
  119167. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119168. * @param source the dictionary to take the content from and copy to this dictionary
  119169. */
  119170. copyFrom(source: StringDictionary<T>): void;
  119171. /**
  119172. * Get a value based from its key
  119173. * @param key the given key to get the matching value from
  119174. * @return the value if found, otherwise undefined is returned
  119175. */
  119176. get(key: string): T | undefined;
  119177. /**
  119178. * Get a value from its key or add it if it doesn't exist.
  119179. * This method will ensure you that a given key/data will be present in the dictionary.
  119180. * @param key the given key to get the matching value from
  119181. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119182. * The factory will only be invoked if there's no data for the given key.
  119183. * @return the value corresponding to the key.
  119184. */
  119185. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119186. /**
  119187. * Get a value from its key if present in the dictionary otherwise add it
  119188. * @param key the key to get the value from
  119189. * @param val if there's no such key/value pair in the dictionary add it with this value
  119190. * @return the value corresponding to the key
  119191. */
  119192. getOrAdd(key: string, val: T): T;
  119193. /**
  119194. * Check if there's a given key in the dictionary
  119195. * @param key the key to check for
  119196. * @return true if the key is present, false otherwise
  119197. */
  119198. contains(key: string): boolean;
  119199. /**
  119200. * Add a new key and its corresponding value
  119201. * @param key the key to add
  119202. * @param value the value corresponding to the key
  119203. * @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
  119204. */
  119205. add(key: string, value: T): boolean;
  119206. /**
  119207. * Update a specific value associated to a key
  119208. * @param key defines the key to use
  119209. * @param value defines the value to store
  119210. * @returns true if the value was updated (or false if the key was not found)
  119211. */
  119212. set(key: string, value: T): boolean;
  119213. /**
  119214. * Get the element of the given key and remove it from the dictionary
  119215. * @param key defines the key to search
  119216. * @returns the value associated with the key or null if not found
  119217. */
  119218. getAndRemove(key: string): Nullable<T>;
  119219. /**
  119220. * Remove a key/value from the dictionary.
  119221. * @param key the key to remove
  119222. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119223. */
  119224. remove(key: string): boolean;
  119225. /**
  119226. * Clear the whole content of the dictionary
  119227. */
  119228. clear(): void;
  119229. /**
  119230. * Gets the current count
  119231. */
  119232. get count(): number;
  119233. /**
  119234. * Execute a callback on each key/val of the dictionary.
  119235. * Note that you can remove any element in this dictionary in the callback implementation
  119236. * @param callback the callback to execute on a given key/value pair
  119237. */
  119238. forEach(callback: (key: string, val: T) => void): void;
  119239. /**
  119240. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119241. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119242. * Note that you can remove any element in this dictionary in the callback implementation
  119243. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119244. * @returns the first item
  119245. */
  119246. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119247. private _count;
  119248. private _data;
  119249. }
  119250. }
  119251. declare module BABYLON {
  119252. /** @hidden */
  119253. export interface ICollisionCoordinator {
  119254. createCollider(): Collider;
  119255. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119256. init(scene: Scene): void;
  119257. }
  119258. /** @hidden */
  119259. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119260. private _scene;
  119261. private _scaledPosition;
  119262. private _scaledVelocity;
  119263. private _finalPosition;
  119264. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119265. createCollider(): Collider;
  119266. init(scene: Scene): void;
  119267. private _collideWithWorld;
  119268. }
  119269. }
  119270. declare module BABYLON {
  119271. /**
  119272. * Class used to manage all inputs for the scene.
  119273. */
  119274. export class InputManager {
  119275. /** The distance in pixel that you have to move to prevent some events */
  119276. static DragMovementThreshold: number;
  119277. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119278. static LongPressDelay: number;
  119279. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119280. static DoubleClickDelay: number;
  119281. /** If you need to check double click without raising a single click at first click, enable this flag */
  119282. static ExclusiveDoubleClickMode: boolean;
  119283. /** This is a defensive check to not allow control attachment prior to an already active one. If already attached, previous control is unattached before attaching the new one. */
  119284. private _alreadyAttached;
  119285. private _wheelEventName;
  119286. private _onPointerMove;
  119287. private _onPointerDown;
  119288. private _onPointerUp;
  119289. private _initClickEvent;
  119290. private _initActionManager;
  119291. private _delayedSimpleClick;
  119292. private _delayedSimpleClickTimeout;
  119293. private _previousDelayedSimpleClickTimeout;
  119294. private _meshPickProceed;
  119295. private _previousButtonPressed;
  119296. private _currentPickResult;
  119297. private _previousPickResult;
  119298. private _totalPointersPressed;
  119299. private _doubleClickOccured;
  119300. private _pointerOverMesh;
  119301. private _pickedDownMesh;
  119302. private _pickedUpMesh;
  119303. private _pointerX;
  119304. private _pointerY;
  119305. private _unTranslatedPointerX;
  119306. private _unTranslatedPointerY;
  119307. private _startingPointerPosition;
  119308. private _previousStartingPointerPosition;
  119309. private _startingPointerTime;
  119310. private _previousStartingPointerTime;
  119311. private _pointerCaptures;
  119312. private _meshUnderPointerId;
  119313. private _onKeyDown;
  119314. private _onKeyUp;
  119315. private _onCanvasFocusObserver;
  119316. private _onCanvasBlurObserver;
  119317. private _scene;
  119318. /**
  119319. * Creates a new InputManager
  119320. * @param scene defines the hosting scene
  119321. */
  119322. constructor(scene: Scene);
  119323. /**
  119324. * Gets the mesh that is currently under the pointer
  119325. */
  119326. get meshUnderPointer(): Nullable<AbstractMesh>;
  119327. /**
  119328. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119329. * @param pointerId the pointer id to use
  119330. * @returns The mesh under this pointer id or null if not found
  119331. */
  119332. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119333. /**
  119334. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119335. */
  119336. get unTranslatedPointer(): Vector2;
  119337. /**
  119338. * Gets or sets the current on-screen X position of the pointer
  119339. */
  119340. get pointerX(): number;
  119341. set pointerX(value: number);
  119342. /**
  119343. * Gets or sets the current on-screen Y position of the pointer
  119344. */
  119345. get pointerY(): number;
  119346. set pointerY(value: number);
  119347. private _updatePointerPosition;
  119348. private _processPointerMove;
  119349. private _setRayOnPointerInfo;
  119350. private _checkPrePointerObservable;
  119351. /**
  119352. * Use this method to simulate a pointer move on a mesh
  119353. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119354. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119355. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119356. */
  119357. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119358. /**
  119359. * Use this method to simulate a pointer down on a mesh
  119360. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119361. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119362. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119363. */
  119364. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119365. private _processPointerDown;
  119366. /** @hidden */
  119367. _isPointerSwiping(): boolean;
  119368. /**
  119369. * Use this method to simulate a pointer up on a mesh
  119370. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119371. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119372. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119373. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119374. */
  119375. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119376. private _processPointerUp;
  119377. /**
  119378. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119379. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119380. * @returns true if the pointer was captured
  119381. */
  119382. isPointerCaptured(pointerId?: number): boolean;
  119383. /**
  119384. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119385. * @param attachUp defines if you want to attach events to pointerup
  119386. * @param attachDown defines if you want to attach events to pointerdown
  119387. * @param attachMove defines if you want to attach events to pointermove
  119388. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119389. */
  119390. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119391. /**
  119392. * Detaches all event handlers
  119393. */
  119394. detachControl(): void;
  119395. /**
  119396. * Force the value of meshUnderPointer
  119397. * @param mesh defines the mesh to use
  119398. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119399. */
  119400. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119401. /**
  119402. * Gets the mesh under the pointer
  119403. * @returns a Mesh or null if no mesh is under the pointer
  119404. */
  119405. getPointerOverMesh(): Nullable<AbstractMesh>;
  119406. }
  119407. }
  119408. declare module BABYLON {
  119409. /**
  119410. * This class defines the direct association between an animation and a target
  119411. */
  119412. export class TargetedAnimation {
  119413. /**
  119414. * Animation to perform
  119415. */
  119416. animation: Animation;
  119417. /**
  119418. * Target to animate
  119419. */
  119420. target: any;
  119421. /**
  119422. * Returns the string "TargetedAnimation"
  119423. * @returns "TargetedAnimation"
  119424. */
  119425. getClassName(): string;
  119426. /**
  119427. * Serialize the object
  119428. * @returns the JSON object representing the current entity
  119429. */
  119430. serialize(): any;
  119431. }
  119432. /**
  119433. * Use this class to create coordinated animations on multiple targets
  119434. */
  119435. export class AnimationGroup implements IDisposable {
  119436. /** The name of the animation group */
  119437. name: string;
  119438. private _scene;
  119439. private _targetedAnimations;
  119440. private _animatables;
  119441. private _from;
  119442. private _to;
  119443. private _isStarted;
  119444. private _isPaused;
  119445. private _speedRatio;
  119446. private _loopAnimation;
  119447. private _isAdditive;
  119448. /**
  119449. * Gets or sets the unique id of the node
  119450. */
  119451. uniqueId: number;
  119452. /**
  119453. * This observable will notify when one animation have ended
  119454. */
  119455. onAnimationEndObservable: Observable<TargetedAnimation>;
  119456. /**
  119457. * Observer raised when one animation loops
  119458. */
  119459. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119460. /**
  119461. * Observer raised when all animations have looped
  119462. */
  119463. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119464. /**
  119465. * This observable will notify when all animations have ended.
  119466. */
  119467. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119468. /**
  119469. * This observable will notify when all animations have paused.
  119470. */
  119471. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119472. /**
  119473. * This observable will notify when all animations are playing.
  119474. */
  119475. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119476. /**
  119477. * Gets the first frame
  119478. */
  119479. get from(): number;
  119480. /**
  119481. * Gets the last frame
  119482. */
  119483. get to(): number;
  119484. /**
  119485. * Define if the animations are started
  119486. */
  119487. get isStarted(): boolean;
  119488. /**
  119489. * Gets a value indicating that the current group is playing
  119490. */
  119491. get isPlaying(): boolean;
  119492. /**
  119493. * Gets or sets the speed ratio to use for all animations
  119494. */
  119495. get speedRatio(): number;
  119496. /**
  119497. * Gets or sets the speed ratio to use for all animations
  119498. */
  119499. set speedRatio(value: number);
  119500. /**
  119501. * Gets or sets if all animations should loop or not
  119502. */
  119503. get loopAnimation(): boolean;
  119504. set loopAnimation(value: boolean);
  119505. /**
  119506. * Gets or sets if all animations should be evaluated additively
  119507. */
  119508. get isAdditive(): boolean;
  119509. set isAdditive(value: boolean);
  119510. /**
  119511. * Gets the targeted animations for this animation group
  119512. */
  119513. get targetedAnimations(): Array<TargetedAnimation>;
  119514. /**
  119515. * returning the list of animatables controlled by this animation group.
  119516. */
  119517. get animatables(): Array<Animatable>;
  119518. /**
  119519. * Gets the list of target animations
  119520. */
  119521. get children(): TargetedAnimation[];
  119522. /**
  119523. * Instantiates a new Animation Group.
  119524. * This helps managing several animations at once.
  119525. * @see https://doc.babylonjs.com/how_to/group
  119526. * @param name Defines the name of the group
  119527. * @param scene Defines the scene the group belongs to
  119528. */
  119529. constructor(
  119530. /** The name of the animation group */
  119531. name: string, scene?: Nullable<Scene>);
  119532. /**
  119533. * Add an animation (with its target) in the group
  119534. * @param animation defines the animation we want to add
  119535. * @param target defines the target of the animation
  119536. * @returns the TargetedAnimation object
  119537. */
  119538. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119539. /**
  119540. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119541. * It can add constant keys at begin or end
  119542. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119543. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119544. * @returns the animation group
  119545. */
  119546. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119547. private _animationLoopCount;
  119548. private _animationLoopFlags;
  119549. private _processLoop;
  119550. /**
  119551. * Start all animations on given targets
  119552. * @param loop defines if animations must loop
  119553. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119554. * @param from defines the from key (optional)
  119555. * @param to defines the to key (optional)
  119556. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119557. * @returns the current animation group
  119558. */
  119559. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119560. /**
  119561. * Pause all animations
  119562. * @returns the animation group
  119563. */
  119564. pause(): AnimationGroup;
  119565. /**
  119566. * Play all animations to initial state
  119567. * This function will start() the animations if they were not started or will restart() them if they were paused
  119568. * @param loop defines if animations must loop
  119569. * @returns the animation group
  119570. */
  119571. play(loop?: boolean): AnimationGroup;
  119572. /**
  119573. * Reset all animations to initial state
  119574. * @returns the animation group
  119575. */
  119576. reset(): AnimationGroup;
  119577. /**
  119578. * Restart animations from key 0
  119579. * @returns the animation group
  119580. */
  119581. restart(): AnimationGroup;
  119582. /**
  119583. * Stop all animations
  119584. * @returns the animation group
  119585. */
  119586. stop(): AnimationGroup;
  119587. /**
  119588. * Set animation weight for all animatables
  119589. * @param weight defines the weight to use
  119590. * @return the animationGroup
  119591. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119592. */
  119593. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119594. /**
  119595. * Synchronize and normalize all animatables with a source animatable
  119596. * @param root defines the root animatable to synchronize with
  119597. * @return the animationGroup
  119598. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119599. */
  119600. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119601. /**
  119602. * Goes to a specific frame in this animation group
  119603. * @param frame the frame number to go to
  119604. * @return the animationGroup
  119605. */
  119606. goToFrame(frame: number): AnimationGroup;
  119607. /**
  119608. * Dispose all associated resources
  119609. */
  119610. dispose(): void;
  119611. private _checkAnimationGroupEnded;
  119612. /**
  119613. * Clone the current animation group and returns a copy
  119614. * @param newName defines the name of the new group
  119615. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119616. * @returns the new aniamtion group
  119617. */
  119618. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119619. /**
  119620. * Serializes the animationGroup to an object
  119621. * @returns Serialized object
  119622. */
  119623. serialize(): any;
  119624. /**
  119625. * Returns a new AnimationGroup object parsed from the source provided.
  119626. * @param parsedAnimationGroup defines the source
  119627. * @param scene defines the scene that will receive the animationGroup
  119628. * @returns a new AnimationGroup
  119629. */
  119630. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119631. /**
  119632. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119633. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119634. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119635. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119636. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119637. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119638. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119639. */
  119640. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119641. /**
  119642. * Returns the string "AnimationGroup"
  119643. * @returns "AnimationGroup"
  119644. */
  119645. getClassName(): string;
  119646. /**
  119647. * Creates a detailled string about the object
  119648. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119649. * @returns a string representing the object
  119650. */
  119651. toString(fullDetails?: boolean): string;
  119652. }
  119653. }
  119654. declare module BABYLON {
  119655. /**
  119656. * Define an interface for all classes that will hold resources
  119657. */
  119658. export interface IDisposable {
  119659. /**
  119660. * Releases all held resources
  119661. */
  119662. dispose(): void;
  119663. }
  119664. /** Interface defining initialization parameters for Scene class */
  119665. export interface SceneOptions {
  119666. /**
  119667. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  119668. * It will improve performance when the number of geometries becomes important.
  119669. */
  119670. useGeometryUniqueIdsMap?: boolean;
  119671. /**
  119672. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  119673. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119674. */
  119675. useMaterialMeshMap?: boolean;
  119676. /**
  119677. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  119678. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  119679. */
  119680. useClonedMeshMap?: boolean;
  119681. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  119682. virtual?: boolean;
  119683. }
  119684. /**
  119685. * Represents a scene to be rendered by the engine.
  119686. * @see https://doc.babylonjs.com/features/scene
  119687. */
  119688. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  119689. /** The fog is deactivated */
  119690. static readonly FOGMODE_NONE: number;
  119691. /** The fog density is following an exponential function */
  119692. static readonly FOGMODE_EXP: number;
  119693. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  119694. static readonly FOGMODE_EXP2: number;
  119695. /** The fog density is following a linear function. */
  119696. static readonly FOGMODE_LINEAR: number;
  119697. /**
  119698. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  119699. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119700. */
  119701. static MinDeltaTime: number;
  119702. /**
  119703. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  119704. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119705. */
  119706. static MaxDeltaTime: number;
  119707. /**
  119708. * Factory used to create the default material.
  119709. * @param name The name of the material to create
  119710. * @param scene The scene to create the material for
  119711. * @returns The default material
  119712. */
  119713. static DefaultMaterialFactory(scene: Scene): Material;
  119714. /**
  119715. * Factory used to create the a collision coordinator.
  119716. * @returns The collision coordinator
  119717. */
  119718. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  119719. /** @hidden */
  119720. _inputManager: InputManager;
  119721. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  119722. cameraToUseForPointers: Nullable<Camera>;
  119723. /** @hidden */
  119724. readonly _isScene: boolean;
  119725. /** @hidden */
  119726. _blockEntityCollection: boolean;
  119727. /**
  119728. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  119729. */
  119730. autoClear: boolean;
  119731. /**
  119732. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  119733. */
  119734. autoClearDepthAndStencil: boolean;
  119735. /**
  119736. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  119737. */
  119738. clearColor: Color4;
  119739. /**
  119740. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  119741. */
  119742. ambientColor: Color3;
  119743. /**
  119744. * This is use to store the default BRDF lookup for PBR materials in your scene.
  119745. * It should only be one of the following (if not the default embedded one):
  119746. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  119747. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  119748. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  119749. * The material properties need to be setup according to the type of texture in use.
  119750. */
  119751. environmentBRDFTexture: BaseTexture;
  119752. /**
  119753. * Texture used in all pbr material as the reflection texture.
  119754. * As in the majority of the scene they are the same (exception for multi room and so on),
  119755. * this is easier to reference from here than from all the materials.
  119756. */
  119757. get environmentTexture(): Nullable<BaseTexture>;
  119758. /**
  119759. * Texture used in all pbr material as the reflection texture.
  119760. * As in the majority of the scene they are the same (exception for multi room and so on),
  119761. * this is easier to set here than in all the materials.
  119762. */
  119763. set environmentTexture(value: Nullable<BaseTexture>);
  119764. /** @hidden */
  119765. protected _environmentIntensity: number;
  119766. /**
  119767. * Intensity of the environment in all pbr material.
  119768. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119769. * As in the majority of the scene they are the same (exception for multi room and so on),
  119770. * this is easier to reference from here than from all the materials.
  119771. */
  119772. get environmentIntensity(): number;
  119773. /**
  119774. * Intensity of the environment in all pbr material.
  119775. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  119776. * As in the majority of the scene they are the same (exception for multi room and so on),
  119777. * this is easier to set here than in all the materials.
  119778. */
  119779. set environmentIntensity(value: number);
  119780. /** @hidden */
  119781. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119782. /**
  119783. * Default image processing configuration used either in the rendering
  119784. * Forward main pass or through the imageProcessingPostProcess if present.
  119785. * As in the majority of the scene they are the same (exception for multi camera),
  119786. * this is easier to reference from here than from all the materials and post process.
  119787. *
  119788. * No setter as we it is a shared configuration, you can set the values instead.
  119789. */
  119790. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  119791. private _forceWireframe;
  119792. /**
  119793. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  119794. */
  119795. set forceWireframe(value: boolean);
  119796. get forceWireframe(): boolean;
  119797. private _skipFrustumClipping;
  119798. /**
  119799. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  119800. */
  119801. set skipFrustumClipping(value: boolean);
  119802. get skipFrustumClipping(): boolean;
  119803. private _forcePointsCloud;
  119804. /**
  119805. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  119806. */
  119807. set forcePointsCloud(value: boolean);
  119808. get forcePointsCloud(): boolean;
  119809. /**
  119810. * Gets or sets the active clipplane 1
  119811. */
  119812. clipPlane: Nullable<Plane>;
  119813. /**
  119814. * Gets or sets the active clipplane 2
  119815. */
  119816. clipPlane2: Nullable<Plane>;
  119817. /**
  119818. * Gets or sets the active clipplane 3
  119819. */
  119820. clipPlane3: Nullable<Plane>;
  119821. /**
  119822. * Gets or sets the active clipplane 4
  119823. */
  119824. clipPlane4: Nullable<Plane>;
  119825. /**
  119826. * Gets or sets the active clipplane 5
  119827. */
  119828. clipPlane5: Nullable<Plane>;
  119829. /**
  119830. * Gets or sets the active clipplane 6
  119831. */
  119832. clipPlane6: Nullable<Plane>;
  119833. /**
  119834. * Gets or sets a boolean indicating if animations are enabled
  119835. */
  119836. animationsEnabled: boolean;
  119837. private _animationPropertiesOverride;
  119838. /**
  119839. * Gets or sets the animation properties override
  119840. */
  119841. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  119842. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  119843. /**
  119844. * Gets or sets a boolean indicating if a constant deltatime has to be used
  119845. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  119846. */
  119847. useConstantAnimationDeltaTime: boolean;
  119848. /**
  119849. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  119850. * Please note that it requires to run a ray cast through the scene on every frame
  119851. */
  119852. constantlyUpdateMeshUnderPointer: boolean;
  119853. /**
  119854. * Defines the HTML cursor to use when hovering over interactive elements
  119855. */
  119856. hoverCursor: string;
  119857. /**
  119858. * Defines the HTML default cursor to use (empty by default)
  119859. */
  119860. defaultCursor: string;
  119861. /**
  119862. * Defines whether cursors are handled by the scene.
  119863. */
  119864. doNotHandleCursors: boolean;
  119865. /**
  119866. * This is used to call preventDefault() on pointer down
  119867. * in order to block unwanted artifacts like system double clicks
  119868. */
  119869. preventDefaultOnPointerDown: boolean;
  119870. /**
  119871. * This is used to call preventDefault() on pointer up
  119872. * in order to block unwanted artifacts like system double clicks
  119873. */
  119874. preventDefaultOnPointerUp: boolean;
  119875. /**
  119876. * Gets or sets user defined metadata
  119877. */
  119878. metadata: any;
  119879. /**
  119880. * For internal use only. Please do not use.
  119881. */
  119882. reservedDataStore: any;
  119883. /**
  119884. * Gets the name of the plugin used to load this scene (null by default)
  119885. */
  119886. loadingPluginName: string;
  119887. /**
  119888. * Use this array to add regular expressions used to disable offline support for specific urls
  119889. */
  119890. disableOfflineSupportExceptionRules: RegExp[];
  119891. /**
  119892. * An event triggered when the scene is disposed.
  119893. */
  119894. onDisposeObservable: Observable<Scene>;
  119895. private _onDisposeObserver;
  119896. /** Sets a function to be executed when this scene is disposed. */
  119897. set onDispose(callback: () => void);
  119898. /**
  119899. * An event triggered before rendering the scene (right after animations and physics)
  119900. */
  119901. onBeforeRenderObservable: Observable<Scene>;
  119902. private _onBeforeRenderObserver;
  119903. /** Sets a function to be executed before rendering this scene */
  119904. set beforeRender(callback: Nullable<() => void>);
  119905. /**
  119906. * An event triggered after rendering the scene
  119907. */
  119908. onAfterRenderObservable: Observable<Scene>;
  119909. /**
  119910. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  119911. */
  119912. onAfterRenderCameraObservable: Observable<Camera>;
  119913. private _onAfterRenderObserver;
  119914. /** Sets a function to be executed after rendering this scene */
  119915. set afterRender(callback: Nullable<() => void>);
  119916. /**
  119917. * An event triggered before animating the scene
  119918. */
  119919. onBeforeAnimationsObservable: Observable<Scene>;
  119920. /**
  119921. * An event triggered after animations processing
  119922. */
  119923. onAfterAnimationsObservable: Observable<Scene>;
  119924. /**
  119925. * An event triggered before draw calls are ready to be sent
  119926. */
  119927. onBeforeDrawPhaseObservable: Observable<Scene>;
  119928. /**
  119929. * An event triggered after draw calls have been sent
  119930. */
  119931. onAfterDrawPhaseObservable: Observable<Scene>;
  119932. /**
  119933. * An event triggered when the scene is ready
  119934. */
  119935. onReadyObservable: Observable<Scene>;
  119936. /**
  119937. * An event triggered before rendering a camera
  119938. */
  119939. onBeforeCameraRenderObservable: Observable<Camera>;
  119940. private _onBeforeCameraRenderObserver;
  119941. /** Sets a function to be executed before rendering a camera*/
  119942. set beforeCameraRender(callback: () => void);
  119943. /**
  119944. * An event triggered after rendering a camera
  119945. */
  119946. onAfterCameraRenderObservable: Observable<Camera>;
  119947. private _onAfterCameraRenderObserver;
  119948. /** Sets a function to be executed after rendering a camera*/
  119949. set afterCameraRender(callback: () => void);
  119950. /**
  119951. * An event triggered when active meshes evaluation is about to start
  119952. */
  119953. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  119954. /**
  119955. * An event triggered when active meshes evaluation is done
  119956. */
  119957. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  119958. /**
  119959. * An event triggered when particles rendering is about to start
  119960. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119961. */
  119962. onBeforeParticlesRenderingObservable: Observable<Scene>;
  119963. /**
  119964. * An event triggered when particles rendering is done
  119965. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  119966. */
  119967. onAfterParticlesRenderingObservable: Observable<Scene>;
  119968. /**
  119969. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  119970. */
  119971. onDataLoadedObservable: Observable<Scene>;
  119972. /**
  119973. * An event triggered when a camera is created
  119974. */
  119975. onNewCameraAddedObservable: Observable<Camera>;
  119976. /**
  119977. * An event triggered when a camera is removed
  119978. */
  119979. onCameraRemovedObservable: Observable<Camera>;
  119980. /**
  119981. * An event triggered when a light is created
  119982. */
  119983. onNewLightAddedObservable: Observable<Light>;
  119984. /**
  119985. * An event triggered when a light is removed
  119986. */
  119987. onLightRemovedObservable: Observable<Light>;
  119988. /**
  119989. * An event triggered when a geometry is created
  119990. */
  119991. onNewGeometryAddedObservable: Observable<Geometry>;
  119992. /**
  119993. * An event triggered when a geometry is removed
  119994. */
  119995. onGeometryRemovedObservable: Observable<Geometry>;
  119996. /**
  119997. * An event triggered when a transform node is created
  119998. */
  119999. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120000. /**
  120001. * An event triggered when a transform node is removed
  120002. */
  120003. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120004. /**
  120005. * An event triggered when a mesh is created
  120006. */
  120007. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120008. /**
  120009. * An event triggered when a mesh is removed
  120010. */
  120011. onMeshRemovedObservable: Observable<AbstractMesh>;
  120012. /**
  120013. * An event triggered when a skeleton is created
  120014. */
  120015. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120016. /**
  120017. * An event triggered when a skeleton is removed
  120018. */
  120019. onSkeletonRemovedObservable: Observable<Skeleton>;
  120020. /**
  120021. * An event triggered when a material is created
  120022. */
  120023. onNewMaterialAddedObservable: Observable<Material>;
  120024. /**
  120025. * An event triggered when a material is removed
  120026. */
  120027. onMaterialRemovedObservable: Observable<Material>;
  120028. /**
  120029. * An event triggered when a texture is created
  120030. */
  120031. onNewTextureAddedObservable: Observable<BaseTexture>;
  120032. /**
  120033. * An event triggered when a texture is removed
  120034. */
  120035. onTextureRemovedObservable: Observable<BaseTexture>;
  120036. /**
  120037. * An event triggered when render targets are about to be rendered
  120038. * Can happen multiple times per frame.
  120039. */
  120040. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120041. /**
  120042. * An event triggered when render targets were rendered.
  120043. * Can happen multiple times per frame.
  120044. */
  120045. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120046. /**
  120047. * An event triggered before calculating deterministic simulation step
  120048. */
  120049. onBeforeStepObservable: Observable<Scene>;
  120050. /**
  120051. * An event triggered after calculating deterministic simulation step
  120052. */
  120053. onAfterStepObservable: Observable<Scene>;
  120054. /**
  120055. * An event triggered when the activeCamera property is updated
  120056. */
  120057. onActiveCameraChanged: Observable<Scene>;
  120058. /**
  120059. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120060. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120061. * 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)
  120062. */
  120063. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120064. /**
  120065. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120066. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120067. * 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)
  120068. */
  120069. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120070. /**
  120071. * This Observable will when a mesh has been imported into the scene.
  120072. */
  120073. onMeshImportedObservable: Observable<AbstractMesh>;
  120074. /**
  120075. * This Observable will when an animation file has been imported into the scene.
  120076. */
  120077. onAnimationFileImportedObservable: Observable<Scene>;
  120078. /**
  120079. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120080. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120081. */
  120082. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120083. /** @hidden */
  120084. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120085. /**
  120086. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120087. */
  120088. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120089. /**
  120090. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120091. */
  120092. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120093. /**
  120094. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120095. */
  120096. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120097. /** Callback called when a pointer move is detected */
  120098. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120099. /** Callback called when a pointer down is detected */
  120100. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120101. /** Callback called when a pointer up is detected */
  120102. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120103. /** Callback called when a pointer pick is detected */
  120104. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120105. /**
  120106. * 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).
  120107. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120108. */
  120109. onPrePointerObservable: Observable<PointerInfoPre>;
  120110. /**
  120111. * Observable event triggered each time an input event is received from the rendering canvas
  120112. */
  120113. onPointerObservable: Observable<PointerInfo>;
  120114. /**
  120115. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120116. */
  120117. get unTranslatedPointer(): Vector2;
  120118. /**
  120119. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120120. */
  120121. static get DragMovementThreshold(): number;
  120122. static set DragMovementThreshold(value: number);
  120123. /**
  120124. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120125. */
  120126. static get LongPressDelay(): number;
  120127. static set LongPressDelay(value: number);
  120128. /**
  120129. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120130. */
  120131. static get DoubleClickDelay(): number;
  120132. static set DoubleClickDelay(value: number);
  120133. /** If you need to check double click without raising a single click at first click, enable this flag */
  120134. static get ExclusiveDoubleClickMode(): boolean;
  120135. static set ExclusiveDoubleClickMode(value: boolean);
  120136. /** @hidden */
  120137. _mirroredCameraPosition: Nullable<Vector3>;
  120138. /**
  120139. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120140. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120141. */
  120142. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120143. /**
  120144. * Observable event triggered each time an keyboard event is received from the hosting window
  120145. */
  120146. onKeyboardObservable: Observable<KeyboardInfo>;
  120147. private _useRightHandedSystem;
  120148. /**
  120149. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120150. */
  120151. set useRightHandedSystem(value: boolean);
  120152. get useRightHandedSystem(): boolean;
  120153. private _timeAccumulator;
  120154. private _currentStepId;
  120155. private _currentInternalStep;
  120156. /**
  120157. * Sets the step Id used by deterministic lock step
  120158. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120159. * @param newStepId defines the step Id
  120160. */
  120161. setStepId(newStepId: number): void;
  120162. /**
  120163. * Gets the step Id used by deterministic lock step
  120164. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120165. * @returns the step Id
  120166. */
  120167. getStepId(): number;
  120168. /**
  120169. * Gets the internal step used by deterministic lock step
  120170. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120171. * @returns the internal step
  120172. */
  120173. getInternalStep(): number;
  120174. private _fogEnabled;
  120175. /**
  120176. * Gets or sets a boolean indicating if fog is enabled on this scene
  120177. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120178. * (Default is true)
  120179. */
  120180. set fogEnabled(value: boolean);
  120181. get fogEnabled(): boolean;
  120182. private _fogMode;
  120183. /**
  120184. * Gets or sets the fog mode to use
  120185. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120186. * | mode | value |
  120187. * | --- | --- |
  120188. * | FOGMODE_NONE | 0 |
  120189. * | FOGMODE_EXP | 1 |
  120190. * | FOGMODE_EXP2 | 2 |
  120191. * | FOGMODE_LINEAR | 3 |
  120192. */
  120193. set fogMode(value: number);
  120194. get fogMode(): number;
  120195. /**
  120196. * Gets or sets the fog color to use
  120197. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120198. * (Default is Color3(0.2, 0.2, 0.3))
  120199. */
  120200. fogColor: Color3;
  120201. /**
  120202. * Gets or sets the fog density to use
  120203. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120204. * (Default is 0.1)
  120205. */
  120206. fogDensity: number;
  120207. /**
  120208. * Gets or sets the fog start distance to use
  120209. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120210. * (Default is 0)
  120211. */
  120212. fogStart: number;
  120213. /**
  120214. * Gets or sets the fog end distance to use
  120215. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120216. * (Default is 1000)
  120217. */
  120218. fogEnd: number;
  120219. /**
  120220. * Flag indicating that the frame buffer binding is handled by another component
  120221. */
  120222. prePass: boolean;
  120223. private _shadowsEnabled;
  120224. /**
  120225. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120226. */
  120227. set shadowsEnabled(value: boolean);
  120228. get shadowsEnabled(): boolean;
  120229. private _lightsEnabled;
  120230. /**
  120231. * Gets or sets a boolean indicating if lights are enabled on this scene
  120232. */
  120233. set lightsEnabled(value: boolean);
  120234. get lightsEnabled(): boolean;
  120235. /** All of the active cameras added to this scene. */
  120236. activeCameras: Camera[];
  120237. /** @hidden */
  120238. _activeCamera: Nullable<Camera>;
  120239. /** Gets or sets the current active camera */
  120240. get activeCamera(): Nullable<Camera>;
  120241. set activeCamera(value: Nullable<Camera>);
  120242. private _defaultMaterial;
  120243. /** The default material used on meshes when no material is affected */
  120244. get defaultMaterial(): Material;
  120245. /** The default material used on meshes when no material is affected */
  120246. set defaultMaterial(value: Material);
  120247. private _texturesEnabled;
  120248. /**
  120249. * Gets or sets a boolean indicating if textures are enabled on this scene
  120250. */
  120251. set texturesEnabled(value: boolean);
  120252. get texturesEnabled(): boolean;
  120253. /**
  120254. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120255. */
  120256. physicsEnabled: boolean;
  120257. /**
  120258. * Gets or sets a boolean indicating if particles are enabled on this scene
  120259. */
  120260. particlesEnabled: boolean;
  120261. /**
  120262. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120263. */
  120264. spritesEnabled: boolean;
  120265. private _skeletonsEnabled;
  120266. /**
  120267. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120268. */
  120269. set skeletonsEnabled(value: boolean);
  120270. get skeletonsEnabled(): boolean;
  120271. /**
  120272. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120273. */
  120274. lensFlaresEnabled: boolean;
  120275. /**
  120276. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120277. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120278. */
  120279. collisionsEnabled: boolean;
  120280. private _collisionCoordinator;
  120281. /** @hidden */
  120282. get collisionCoordinator(): ICollisionCoordinator;
  120283. /**
  120284. * Defines the gravity applied to this scene (used only for collisions)
  120285. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120286. */
  120287. gravity: Vector3;
  120288. /**
  120289. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120290. */
  120291. postProcessesEnabled: boolean;
  120292. /**
  120293. * Gets the current postprocess manager
  120294. */
  120295. postProcessManager: PostProcessManager;
  120296. /**
  120297. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120298. */
  120299. renderTargetsEnabled: boolean;
  120300. /**
  120301. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120302. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120303. */
  120304. dumpNextRenderTargets: boolean;
  120305. /**
  120306. * The list of user defined render targets added to the scene
  120307. */
  120308. customRenderTargets: RenderTargetTexture[];
  120309. /**
  120310. * Defines if texture loading must be delayed
  120311. * If true, textures will only be loaded when they need to be rendered
  120312. */
  120313. useDelayedTextureLoading: boolean;
  120314. /**
  120315. * Gets the list of meshes imported to the scene through SceneLoader
  120316. */
  120317. importedMeshesFiles: String[];
  120318. /**
  120319. * Gets or sets a boolean indicating if probes are enabled on this scene
  120320. */
  120321. probesEnabled: boolean;
  120322. /**
  120323. * Gets or sets the current offline provider to use to store scene data
  120324. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120325. */
  120326. offlineProvider: IOfflineProvider;
  120327. /**
  120328. * Gets or sets the action manager associated with the scene
  120329. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120330. */
  120331. actionManager: AbstractActionManager;
  120332. private _meshesForIntersections;
  120333. /**
  120334. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120335. */
  120336. proceduralTexturesEnabled: boolean;
  120337. private _engine;
  120338. private _totalVertices;
  120339. /** @hidden */
  120340. _activeIndices: PerfCounter;
  120341. /** @hidden */
  120342. _activeParticles: PerfCounter;
  120343. /** @hidden */
  120344. _activeBones: PerfCounter;
  120345. private _animationRatio;
  120346. /** @hidden */
  120347. _animationTimeLast: number;
  120348. /** @hidden */
  120349. _animationTime: number;
  120350. /**
  120351. * Gets or sets a general scale for animation speed
  120352. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120353. */
  120354. animationTimeScale: number;
  120355. /** @hidden */
  120356. _cachedMaterial: Nullable<Material>;
  120357. /** @hidden */
  120358. _cachedEffect: Nullable<Effect>;
  120359. /** @hidden */
  120360. _cachedVisibility: Nullable<number>;
  120361. private _renderId;
  120362. private _frameId;
  120363. private _executeWhenReadyTimeoutId;
  120364. private _intermediateRendering;
  120365. private _viewUpdateFlag;
  120366. private _projectionUpdateFlag;
  120367. /** @hidden */
  120368. _toBeDisposed: Nullable<IDisposable>[];
  120369. private _activeRequests;
  120370. /** @hidden */
  120371. _pendingData: any[];
  120372. private _isDisposed;
  120373. /**
  120374. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120375. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120376. */
  120377. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120378. private _activeMeshes;
  120379. private _processedMaterials;
  120380. private _renderTargets;
  120381. /** @hidden */
  120382. _activeParticleSystems: SmartArray<IParticleSystem>;
  120383. private _activeSkeletons;
  120384. private _softwareSkinnedMeshes;
  120385. private _renderingManager;
  120386. /** @hidden */
  120387. _activeAnimatables: Animatable[];
  120388. private _transformMatrix;
  120389. private _sceneUbo;
  120390. /** @hidden */
  120391. _viewMatrix: Matrix;
  120392. private _projectionMatrix;
  120393. /** @hidden */
  120394. _forcedViewPosition: Nullable<Vector3>;
  120395. /** @hidden */
  120396. _frustumPlanes: Plane[];
  120397. /**
  120398. * Gets the list of frustum planes (built from the active camera)
  120399. */
  120400. get frustumPlanes(): Plane[];
  120401. /**
  120402. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120403. * This is useful if there are more lights that the maximum simulteanous authorized
  120404. */
  120405. requireLightSorting: boolean;
  120406. /** @hidden */
  120407. readonly useMaterialMeshMap: boolean;
  120408. /** @hidden */
  120409. readonly useClonedMeshMap: boolean;
  120410. private _externalData;
  120411. private _uid;
  120412. /**
  120413. * @hidden
  120414. * Backing store of defined scene components.
  120415. */
  120416. _components: ISceneComponent[];
  120417. /**
  120418. * @hidden
  120419. * Backing store of defined scene components.
  120420. */
  120421. _serializableComponents: ISceneSerializableComponent[];
  120422. /**
  120423. * List of components to register on the next registration step.
  120424. */
  120425. private _transientComponents;
  120426. /**
  120427. * Registers the transient components if needed.
  120428. */
  120429. private _registerTransientComponents;
  120430. /**
  120431. * @hidden
  120432. * Add a component to the scene.
  120433. * Note that the ccomponent could be registered on th next frame if this is called after
  120434. * the register component stage.
  120435. * @param component Defines the component to add to the scene
  120436. */
  120437. _addComponent(component: ISceneComponent): void;
  120438. /**
  120439. * @hidden
  120440. * Gets a component from the scene.
  120441. * @param name defines the name of the component to retrieve
  120442. * @returns the component or null if not present
  120443. */
  120444. _getComponent(name: string): Nullable<ISceneComponent>;
  120445. /**
  120446. * @hidden
  120447. * Defines the actions happening before camera updates.
  120448. */
  120449. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120450. /**
  120451. * @hidden
  120452. * Defines the actions happening before clear the canvas.
  120453. */
  120454. _beforeClearStage: Stage<SimpleStageAction>;
  120455. /**
  120456. * @hidden
  120457. * Defines the actions when collecting render targets for the frame.
  120458. */
  120459. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120460. /**
  120461. * @hidden
  120462. * Defines the actions happening for one camera in the frame.
  120463. */
  120464. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120465. /**
  120466. * @hidden
  120467. * Defines the actions happening during the per mesh ready checks.
  120468. */
  120469. _isReadyForMeshStage: Stage<MeshStageAction>;
  120470. /**
  120471. * @hidden
  120472. * Defines the actions happening before evaluate active mesh checks.
  120473. */
  120474. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120475. /**
  120476. * @hidden
  120477. * Defines the actions happening during the evaluate sub mesh checks.
  120478. */
  120479. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120480. /**
  120481. * @hidden
  120482. * Defines the actions happening during the active mesh stage.
  120483. */
  120484. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120485. /**
  120486. * @hidden
  120487. * Defines the actions happening during the per camera render target step.
  120488. */
  120489. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120490. /**
  120491. * @hidden
  120492. * Defines the actions happening just before the active camera is drawing.
  120493. */
  120494. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120495. /**
  120496. * @hidden
  120497. * Defines the actions happening just before a render target is drawing.
  120498. */
  120499. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120500. /**
  120501. * @hidden
  120502. * Defines the actions happening just before a rendering group is drawing.
  120503. */
  120504. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120505. /**
  120506. * @hidden
  120507. * Defines the actions happening just before a mesh is drawing.
  120508. */
  120509. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120510. /**
  120511. * @hidden
  120512. * Defines the actions happening just after a mesh has been drawn.
  120513. */
  120514. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120515. /**
  120516. * @hidden
  120517. * Defines the actions happening just after a rendering group has been drawn.
  120518. */
  120519. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120520. /**
  120521. * @hidden
  120522. * Defines the actions happening just after the active camera has been drawn.
  120523. */
  120524. _afterCameraDrawStage: Stage<CameraStageAction>;
  120525. /**
  120526. * @hidden
  120527. * Defines the actions happening just after a render target has been drawn.
  120528. */
  120529. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120530. /**
  120531. * @hidden
  120532. * Defines the actions happening just after rendering all cameras and computing intersections.
  120533. */
  120534. _afterRenderStage: Stage<SimpleStageAction>;
  120535. /**
  120536. * @hidden
  120537. * Defines the actions happening when a pointer move event happens.
  120538. */
  120539. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120540. /**
  120541. * @hidden
  120542. * Defines the actions happening when a pointer down event happens.
  120543. */
  120544. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120545. /**
  120546. * @hidden
  120547. * Defines the actions happening when a pointer up event happens.
  120548. */
  120549. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120550. /**
  120551. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120552. */
  120553. private geometriesByUniqueId;
  120554. /**
  120555. * Creates a new Scene
  120556. * @param engine defines the engine to use to render this scene
  120557. * @param options defines the scene options
  120558. */
  120559. constructor(engine: Engine, options?: SceneOptions);
  120560. /**
  120561. * Gets a string identifying the name of the class
  120562. * @returns "Scene" string
  120563. */
  120564. getClassName(): string;
  120565. private _defaultMeshCandidates;
  120566. /**
  120567. * @hidden
  120568. */
  120569. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120570. private _defaultSubMeshCandidates;
  120571. /**
  120572. * @hidden
  120573. */
  120574. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120575. /**
  120576. * Sets the default candidate providers for the scene.
  120577. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120578. * and getCollidingSubMeshCandidates to their default function
  120579. */
  120580. setDefaultCandidateProviders(): void;
  120581. /**
  120582. * Gets the mesh that is currently under the pointer
  120583. */
  120584. get meshUnderPointer(): Nullable<AbstractMesh>;
  120585. /**
  120586. * Gets or sets the current on-screen X position of the pointer
  120587. */
  120588. get pointerX(): number;
  120589. set pointerX(value: number);
  120590. /**
  120591. * Gets or sets the current on-screen Y position of the pointer
  120592. */
  120593. get pointerY(): number;
  120594. set pointerY(value: number);
  120595. /**
  120596. * Gets the cached material (ie. the latest rendered one)
  120597. * @returns the cached material
  120598. */
  120599. getCachedMaterial(): Nullable<Material>;
  120600. /**
  120601. * Gets the cached effect (ie. the latest rendered one)
  120602. * @returns the cached effect
  120603. */
  120604. getCachedEffect(): Nullable<Effect>;
  120605. /**
  120606. * Gets the cached visibility state (ie. the latest rendered one)
  120607. * @returns the cached visibility state
  120608. */
  120609. getCachedVisibility(): Nullable<number>;
  120610. /**
  120611. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120612. * @param material defines the current material
  120613. * @param effect defines the current effect
  120614. * @param visibility defines the current visibility state
  120615. * @returns true if one parameter is not cached
  120616. */
  120617. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120618. /**
  120619. * Gets the engine associated with the scene
  120620. * @returns an Engine
  120621. */
  120622. getEngine(): Engine;
  120623. /**
  120624. * Gets the total number of vertices rendered per frame
  120625. * @returns the total number of vertices rendered per frame
  120626. */
  120627. getTotalVertices(): number;
  120628. /**
  120629. * Gets the performance counter for total vertices
  120630. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120631. */
  120632. get totalVerticesPerfCounter(): PerfCounter;
  120633. /**
  120634. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120635. * @returns the total number of active indices rendered per frame
  120636. */
  120637. getActiveIndices(): number;
  120638. /**
  120639. * Gets the performance counter for active indices
  120640. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120641. */
  120642. get totalActiveIndicesPerfCounter(): PerfCounter;
  120643. /**
  120644. * Gets the total number of active particles rendered per frame
  120645. * @returns the total number of active particles rendered per frame
  120646. */
  120647. getActiveParticles(): number;
  120648. /**
  120649. * Gets the performance counter for active particles
  120650. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120651. */
  120652. get activeParticlesPerfCounter(): PerfCounter;
  120653. /**
  120654. * Gets the total number of active bones rendered per frame
  120655. * @returns the total number of active bones rendered per frame
  120656. */
  120657. getActiveBones(): number;
  120658. /**
  120659. * Gets the performance counter for active bones
  120660. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120661. */
  120662. get activeBonesPerfCounter(): PerfCounter;
  120663. /**
  120664. * Gets the array of active meshes
  120665. * @returns an array of AbstractMesh
  120666. */
  120667. getActiveMeshes(): SmartArray<AbstractMesh>;
  120668. /**
  120669. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  120670. * @returns a number
  120671. */
  120672. getAnimationRatio(): number;
  120673. /**
  120674. * Gets an unique Id for the current render phase
  120675. * @returns a number
  120676. */
  120677. getRenderId(): number;
  120678. /**
  120679. * Gets an unique Id for the current frame
  120680. * @returns a number
  120681. */
  120682. getFrameId(): number;
  120683. /** Call this function if you want to manually increment the render Id*/
  120684. incrementRenderId(): void;
  120685. private _createUbo;
  120686. /**
  120687. * Use this method to simulate a pointer move on a mesh
  120688. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120689. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120690. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120691. * @returns the current scene
  120692. */
  120693. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120694. /**
  120695. * Use this method to simulate a pointer down on a mesh
  120696. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120697. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120698. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120699. * @returns the current scene
  120700. */
  120701. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  120702. /**
  120703. * Use this method to simulate a pointer up on a mesh
  120704. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  120705. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  120706. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  120707. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  120708. * @returns the current scene
  120709. */
  120710. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  120711. /**
  120712. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  120713. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  120714. * @returns true if the pointer was captured
  120715. */
  120716. isPointerCaptured(pointerId?: number): boolean;
  120717. /**
  120718. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  120719. * @param attachUp defines if you want to attach events to pointerup
  120720. * @param attachDown defines if you want to attach events to pointerdown
  120721. * @param attachMove defines if you want to attach events to pointermove
  120722. */
  120723. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  120724. /** Detaches all event handlers*/
  120725. detachControl(): void;
  120726. /**
  120727. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  120728. * Delay loaded resources are not taking in account
  120729. * @return true if all required resources are ready
  120730. */
  120731. isReady(): boolean;
  120732. /** Resets all cached information relative to material (including effect and visibility) */
  120733. resetCachedMaterial(): void;
  120734. /**
  120735. * Registers a function to be called before every frame render
  120736. * @param func defines the function to register
  120737. */
  120738. registerBeforeRender(func: () => void): void;
  120739. /**
  120740. * Unregisters a function called before every frame render
  120741. * @param func defines the function to unregister
  120742. */
  120743. unregisterBeforeRender(func: () => void): void;
  120744. /**
  120745. * Registers a function to be called after every frame render
  120746. * @param func defines the function to register
  120747. */
  120748. registerAfterRender(func: () => void): void;
  120749. /**
  120750. * Unregisters a function called after every frame render
  120751. * @param func defines the function to unregister
  120752. */
  120753. unregisterAfterRender(func: () => void): void;
  120754. private _executeOnceBeforeRender;
  120755. /**
  120756. * The provided function will run before render once and will be disposed afterwards.
  120757. * A timeout delay can be provided so that the function will be executed in N ms.
  120758. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  120759. * @param func The function to be executed.
  120760. * @param timeout optional delay in ms
  120761. */
  120762. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  120763. /** @hidden */
  120764. _addPendingData(data: any): void;
  120765. /** @hidden */
  120766. _removePendingData(data: any): void;
  120767. /**
  120768. * Returns the number of items waiting to be loaded
  120769. * @returns the number of items waiting to be loaded
  120770. */
  120771. getWaitingItemsCount(): number;
  120772. /**
  120773. * Returns a boolean indicating if the scene is still loading data
  120774. */
  120775. get isLoading(): boolean;
  120776. /**
  120777. * Registers a function to be executed when the scene is ready
  120778. * @param {Function} func - the function to be executed
  120779. */
  120780. executeWhenReady(func: () => void): void;
  120781. /**
  120782. * Returns a promise that resolves when the scene is ready
  120783. * @returns A promise that resolves when the scene is ready
  120784. */
  120785. whenReadyAsync(): Promise<void>;
  120786. /** @hidden */
  120787. _checkIsReady(): void;
  120788. /**
  120789. * Gets all animatable attached to the scene
  120790. */
  120791. get animatables(): Animatable[];
  120792. /**
  120793. * Resets the last animation time frame.
  120794. * Useful to override when animations start running when loading a scene for the first time.
  120795. */
  120796. resetLastAnimationTimeFrame(): void;
  120797. /**
  120798. * Gets the current view matrix
  120799. * @returns a Matrix
  120800. */
  120801. getViewMatrix(): Matrix;
  120802. /**
  120803. * Gets the current projection matrix
  120804. * @returns a Matrix
  120805. */
  120806. getProjectionMatrix(): Matrix;
  120807. /**
  120808. * Gets the current transform matrix
  120809. * @returns a Matrix made of View * Projection
  120810. */
  120811. getTransformMatrix(): Matrix;
  120812. /**
  120813. * Sets the current transform matrix
  120814. * @param viewL defines the View matrix to use
  120815. * @param projectionL defines the Projection matrix to use
  120816. * @param viewR defines the right View matrix to use (if provided)
  120817. * @param projectionR defines the right Projection matrix to use (if provided)
  120818. */
  120819. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  120820. /**
  120821. * Gets the uniform buffer used to store scene data
  120822. * @returns a UniformBuffer
  120823. */
  120824. getSceneUniformBuffer(): UniformBuffer;
  120825. /**
  120826. * Gets an unique (relatively to the current scene) Id
  120827. * @returns an unique number for the scene
  120828. */
  120829. getUniqueId(): number;
  120830. /**
  120831. * Add a mesh to the list of scene's meshes
  120832. * @param newMesh defines the mesh to add
  120833. * @param recursive if all child meshes should also be added to the scene
  120834. */
  120835. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  120836. /**
  120837. * Remove a mesh for the list of scene's meshes
  120838. * @param toRemove defines the mesh to remove
  120839. * @param recursive if all child meshes should also be removed from the scene
  120840. * @returns the index where the mesh was in the mesh list
  120841. */
  120842. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  120843. /**
  120844. * Add a transform node to the list of scene's transform nodes
  120845. * @param newTransformNode defines the transform node to add
  120846. */
  120847. addTransformNode(newTransformNode: TransformNode): void;
  120848. /**
  120849. * Remove a transform node for the list of scene's transform nodes
  120850. * @param toRemove defines the transform node to remove
  120851. * @returns the index where the transform node was in the transform node list
  120852. */
  120853. removeTransformNode(toRemove: TransformNode): number;
  120854. /**
  120855. * Remove a skeleton for the list of scene's skeletons
  120856. * @param toRemove defines the skeleton to remove
  120857. * @returns the index where the skeleton was in the skeleton list
  120858. */
  120859. removeSkeleton(toRemove: Skeleton): number;
  120860. /**
  120861. * Remove a morph target for the list of scene's morph targets
  120862. * @param toRemove defines the morph target to remove
  120863. * @returns the index where the morph target was in the morph target list
  120864. */
  120865. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  120866. /**
  120867. * Remove a light for the list of scene's lights
  120868. * @param toRemove defines the light to remove
  120869. * @returns the index where the light was in the light list
  120870. */
  120871. removeLight(toRemove: Light): number;
  120872. /**
  120873. * Remove a camera for the list of scene's cameras
  120874. * @param toRemove defines the camera to remove
  120875. * @returns the index where the camera was in the camera list
  120876. */
  120877. removeCamera(toRemove: Camera): number;
  120878. /**
  120879. * Remove a particle system for the list of scene's particle systems
  120880. * @param toRemove defines the particle system to remove
  120881. * @returns the index where the particle system was in the particle system list
  120882. */
  120883. removeParticleSystem(toRemove: IParticleSystem): number;
  120884. /**
  120885. * Remove a animation for the list of scene's animations
  120886. * @param toRemove defines the animation to remove
  120887. * @returns the index where the animation was in the animation list
  120888. */
  120889. removeAnimation(toRemove: Animation): number;
  120890. /**
  120891. * Will stop the animation of the given target
  120892. * @param target - the target
  120893. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  120894. * @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)
  120895. */
  120896. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  120897. /**
  120898. * Removes the given animation group from this scene.
  120899. * @param toRemove The animation group to remove
  120900. * @returns The index of the removed animation group
  120901. */
  120902. removeAnimationGroup(toRemove: AnimationGroup): number;
  120903. /**
  120904. * Removes the given multi-material from this scene.
  120905. * @param toRemove The multi-material to remove
  120906. * @returns The index of the removed multi-material
  120907. */
  120908. removeMultiMaterial(toRemove: MultiMaterial): number;
  120909. /**
  120910. * Removes the given material from this scene.
  120911. * @param toRemove The material to remove
  120912. * @returns The index of the removed material
  120913. */
  120914. removeMaterial(toRemove: Material): number;
  120915. /**
  120916. * Removes the given action manager from this scene.
  120917. * @param toRemove The action manager to remove
  120918. * @returns The index of the removed action manager
  120919. */
  120920. removeActionManager(toRemove: AbstractActionManager): number;
  120921. /**
  120922. * Removes the given texture from this scene.
  120923. * @param toRemove The texture to remove
  120924. * @returns The index of the removed texture
  120925. */
  120926. removeTexture(toRemove: BaseTexture): number;
  120927. /**
  120928. * Adds the given light to this scene
  120929. * @param newLight The light to add
  120930. */
  120931. addLight(newLight: Light): void;
  120932. /**
  120933. * Sorts the list list based on light priorities
  120934. */
  120935. sortLightsByPriority(): void;
  120936. /**
  120937. * Adds the given camera to this scene
  120938. * @param newCamera The camera to add
  120939. */
  120940. addCamera(newCamera: Camera): void;
  120941. /**
  120942. * Adds the given skeleton to this scene
  120943. * @param newSkeleton The skeleton to add
  120944. */
  120945. addSkeleton(newSkeleton: Skeleton): void;
  120946. /**
  120947. * Adds the given particle system to this scene
  120948. * @param newParticleSystem The particle system to add
  120949. */
  120950. addParticleSystem(newParticleSystem: IParticleSystem): void;
  120951. /**
  120952. * Adds the given animation to this scene
  120953. * @param newAnimation The animation to add
  120954. */
  120955. addAnimation(newAnimation: Animation): void;
  120956. /**
  120957. * Adds the given animation group to this scene.
  120958. * @param newAnimationGroup The animation group to add
  120959. */
  120960. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  120961. /**
  120962. * Adds the given multi-material to this scene
  120963. * @param newMultiMaterial The multi-material to add
  120964. */
  120965. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  120966. /**
  120967. * Adds the given material to this scene
  120968. * @param newMaterial The material to add
  120969. */
  120970. addMaterial(newMaterial: Material): void;
  120971. /**
  120972. * Adds the given morph target to this scene
  120973. * @param newMorphTargetManager The morph target to add
  120974. */
  120975. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  120976. /**
  120977. * Adds the given geometry to this scene
  120978. * @param newGeometry The geometry to add
  120979. */
  120980. addGeometry(newGeometry: Geometry): void;
  120981. /**
  120982. * Adds the given action manager to this scene
  120983. * @param newActionManager The action manager to add
  120984. */
  120985. addActionManager(newActionManager: AbstractActionManager): void;
  120986. /**
  120987. * Adds the given texture to this scene.
  120988. * @param newTexture The texture to add
  120989. */
  120990. addTexture(newTexture: BaseTexture): void;
  120991. /**
  120992. * Switch active camera
  120993. * @param newCamera defines the new active camera
  120994. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  120995. */
  120996. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  120997. /**
  120998. * sets the active camera of the scene using its ID
  120999. * @param id defines the camera's ID
  121000. * @return the new active camera or null if none found.
  121001. */
  121002. setActiveCameraByID(id: string): Nullable<Camera>;
  121003. /**
  121004. * sets the active camera of the scene using its name
  121005. * @param name defines the camera's name
  121006. * @returns the new active camera or null if none found.
  121007. */
  121008. setActiveCameraByName(name: string): Nullable<Camera>;
  121009. /**
  121010. * get an animation group using its name
  121011. * @param name defines the material's name
  121012. * @return the animation group or null if none found.
  121013. */
  121014. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121015. /**
  121016. * Get a material using its unique id
  121017. * @param uniqueId defines the material's unique id
  121018. * @return the material or null if none found.
  121019. */
  121020. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121021. /**
  121022. * get a material using its id
  121023. * @param id defines the material's ID
  121024. * @return the material or null if none found.
  121025. */
  121026. getMaterialByID(id: string): Nullable<Material>;
  121027. /**
  121028. * Gets a the last added material using a given id
  121029. * @param id defines the material's ID
  121030. * @return the last material with the given id or null if none found.
  121031. */
  121032. getLastMaterialByID(id: string): Nullable<Material>;
  121033. /**
  121034. * Gets a material using its name
  121035. * @param name defines the material's name
  121036. * @return the material or null if none found.
  121037. */
  121038. getMaterialByName(name: string): Nullable<Material>;
  121039. /**
  121040. * Get a texture using its unique id
  121041. * @param uniqueId defines the texture's unique id
  121042. * @return the texture or null if none found.
  121043. */
  121044. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121045. /**
  121046. * Gets a camera using its id
  121047. * @param id defines the id to look for
  121048. * @returns the camera or null if not found
  121049. */
  121050. getCameraByID(id: string): Nullable<Camera>;
  121051. /**
  121052. * Gets a camera using its unique id
  121053. * @param uniqueId defines the unique id to look for
  121054. * @returns the camera or null if not found
  121055. */
  121056. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121057. /**
  121058. * Gets a camera using its name
  121059. * @param name defines the camera's name
  121060. * @return the camera or null if none found.
  121061. */
  121062. getCameraByName(name: string): Nullable<Camera>;
  121063. /**
  121064. * Gets a bone using its id
  121065. * @param id defines the bone's id
  121066. * @return the bone or null if not found
  121067. */
  121068. getBoneByID(id: string): Nullable<Bone>;
  121069. /**
  121070. * Gets a bone using its id
  121071. * @param name defines the bone's name
  121072. * @return the bone or null if not found
  121073. */
  121074. getBoneByName(name: string): Nullable<Bone>;
  121075. /**
  121076. * Gets a light node using its name
  121077. * @param name defines the the light's name
  121078. * @return the light or null if none found.
  121079. */
  121080. getLightByName(name: string): Nullable<Light>;
  121081. /**
  121082. * Gets a light node using its id
  121083. * @param id defines the light's id
  121084. * @return the light or null if none found.
  121085. */
  121086. getLightByID(id: string): Nullable<Light>;
  121087. /**
  121088. * Gets a light node using its scene-generated unique ID
  121089. * @param uniqueId defines the light's unique id
  121090. * @return the light or null if none found.
  121091. */
  121092. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121093. /**
  121094. * Gets a particle system by id
  121095. * @param id defines the particle system id
  121096. * @return the corresponding system or null if none found
  121097. */
  121098. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121099. /**
  121100. * Gets a geometry using its ID
  121101. * @param id defines the geometry's id
  121102. * @return the geometry or null if none found.
  121103. */
  121104. getGeometryByID(id: string): Nullable<Geometry>;
  121105. private _getGeometryByUniqueID;
  121106. /**
  121107. * Add a new geometry to this scene
  121108. * @param geometry defines the geometry to be added to the scene.
  121109. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121110. * @return a boolean defining if the geometry was added or not
  121111. */
  121112. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121113. /**
  121114. * Removes an existing geometry
  121115. * @param geometry defines the geometry to be removed from the scene
  121116. * @return a boolean defining if the geometry was removed or not
  121117. */
  121118. removeGeometry(geometry: Geometry): boolean;
  121119. /**
  121120. * Gets the list of geometries attached to the scene
  121121. * @returns an array of Geometry
  121122. */
  121123. getGeometries(): Geometry[];
  121124. /**
  121125. * Gets the first added mesh found of a given ID
  121126. * @param id defines the id to search for
  121127. * @return the mesh found or null if not found at all
  121128. */
  121129. getMeshByID(id: string): Nullable<AbstractMesh>;
  121130. /**
  121131. * Gets a list of meshes using their id
  121132. * @param id defines the id to search for
  121133. * @returns a list of meshes
  121134. */
  121135. getMeshesByID(id: string): Array<AbstractMesh>;
  121136. /**
  121137. * Gets the first added transform node found of a given ID
  121138. * @param id defines the id to search for
  121139. * @return the found transform node or null if not found at all.
  121140. */
  121141. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121142. /**
  121143. * Gets a transform node with its auto-generated unique id
  121144. * @param uniqueId efines the unique id to search for
  121145. * @return the found transform node or null if not found at all.
  121146. */
  121147. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121148. /**
  121149. * Gets a list of transform nodes using their id
  121150. * @param id defines the id to search for
  121151. * @returns a list of transform nodes
  121152. */
  121153. getTransformNodesByID(id: string): Array<TransformNode>;
  121154. /**
  121155. * Gets a mesh with its auto-generated unique id
  121156. * @param uniqueId defines the unique id to search for
  121157. * @return the found mesh or null if not found at all.
  121158. */
  121159. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121160. /**
  121161. * Gets a the last added mesh using a given id
  121162. * @param id defines the id to search for
  121163. * @return the found mesh or null if not found at all.
  121164. */
  121165. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121166. /**
  121167. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121168. * @param id defines the id to search for
  121169. * @return the found node or null if not found at all
  121170. */
  121171. getLastEntryByID(id: string): Nullable<Node>;
  121172. /**
  121173. * Gets a node (Mesh, Camera, Light) using a given id
  121174. * @param id defines the id to search for
  121175. * @return the found node or null if not found at all
  121176. */
  121177. getNodeByID(id: string): Nullable<Node>;
  121178. /**
  121179. * Gets a node (Mesh, Camera, Light) using a given name
  121180. * @param name defines the name to search for
  121181. * @return the found node or null if not found at all.
  121182. */
  121183. getNodeByName(name: string): Nullable<Node>;
  121184. /**
  121185. * Gets a mesh using a given name
  121186. * @param name defines the name to search for
  121187. * @return the found mesh or null if not found at all.
  121188. */
  121189. getMeshByName(name: string): Nullable<AbstractMesh>;
  121190. /**
  121191. * Gets a transform node using a given name
  121192. * @param name defines the name to search for
  121193. * @return the found transform node or null if not found at all.
  121194. */
  121195. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121196. /**
  121197. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121198. * @param id defines the id to search for
  121199. * @return the found skeleton or null if not found at all.
  121200. */
  121201. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121202. /**
  121203. * Gets a skeleton using a given auto generated unique id
  121204. * @param uniqueId defines the unique id to search for
  121205. * @return the found skeleton or null if not found at all.
  121206. */
  121207. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121208. /**
  121209. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121210. * @param id defines the id to search for
  121211. * @return the found skeleton or null if not found at all.
  121212. */
  121213. getSkeletonById(id: string): Nullable<Skeleton>;
  121214. /**
  121215. * Gets a skeleton using a given name
  121216. * @param name defines the name to search for
  121217. * @return the found skeleton or null if not found at all.
  121218. */
  121219. getSkeletonByName(name: string): Nullable<Skeleton>;
  121220. /**
  121221. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121222. * @param id defines the id to search for
  121223. * @return the found morph target manager or null if not found at all.
  121224. */
  121225. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121226. /**
  121227. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121228. * @param id defines the id to search for
  121229. * @return the found morph target or null if not found at all.
  121230. */
  121231. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121232. /**
  121233. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121234. * @param name defines the name to search for
  121235. * @return the found morph target or null if not found at all.
  121236. */
  121237. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121238. /**
  121239. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121240. * @param name defines the name to search for
  121241. * @return the found post process or null if not found at all.
  121242. */
  121243. getPostProcessByName(name: string): Nullable<PostProcess>;
  121244. /**
  121245. * Gets a boolean indicating if the given mesh is active
  121246. * @param mesh defines the mesh to look for
  121247. * @returns true if the mesh is in the active list
  121248. */
  121249. isActiveMesh(mesh: AbstractMesh): boolean;
  121250. /**
  121251. * Return a unique id as a string which can serve as an identifier for the scene
  121252. */
  121253. get uid(): string;
  121254. /**
  121255. * Add an externaly attached data from its key.
  121256. * This method call will fail and return false, if such key already exists.
  121257. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121258. * @param key the unique key that identifies the data
  121259. * @param data the data object to associate to the key for this Engine instance
  121260. * @return true if no such key were already present and the data was added successfully, false otherwise
  121261. */
  121262. addExternalData<T>(key: string, data: T): boolean;
  121263. /**
  121264. * Get an externaly attached data from its key
  121265. * @param key the unique key that identifies the data
  121266. * @return the associated data, if present (can be null), or undefined if not present
  121267. */
  121268. getExternalData<T>(key: string): Nullable<T>;
  121269. /**
  121270. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121271. * @param key the unique key that identifies the data
  121272. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121273. * @return the associated data, can be null if the factory returned null.
  121274. */
  121275. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121276. /**
  121277. * Remove an externaly attached data from the Engine instance
  121278. * @param key the unique key that identifies the data
  121279. * @return true if the data was successfully removed, false if it doesn't exist
  121280. */
  121281. removeExternalData(key: string): boolean;
  121282. private _evaluateSubMesh;
  121283. /**
  121284. * Clear the processed materials smart array preventing retention point in material dispose.
  121285. */
  121286. freeProcessedMaterials(): void;
  121287. private _preventFreeActiveMeshesAndRenderingGroups;
  121288. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121289. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121290. * when disposing several meshes in a row or a hierarchy of meshes.
  121291. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121292. */
  121293. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121294. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121295. /**
  121296. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121297. */
  121298. freeActiveMeshes(): void;
  121299. /**
  121300. * Clear the info related to rendering groups preventing retention points during dispose.
  121301. */
  121302. freeRenderingGroups(): void;
  121303. /** @hidden */
  121304. _isInIntermediateRendering(): boolean;
  121305. /**
  121306. * Lambda returning the list of potentially active meshes.
  121307. */
  121308. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121309. /**
  121310. * Lambda returning the list of potentially active sub meshes.
  121311. */
  121312. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121313. /**
  121314. * Lambda returning the list of potentially intersecting sub meshes.
  121315. */
  121316. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121317. /**
  121318. * Lambda returning the list of potentially colliding sub meshes.
  121319. */
  121320. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121321. private _activeMeshesFrozen;
  121322. private _skipEvaluateActiveMeshesCompletely;
  121323. /**
  121324. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121325. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121326. * @returns the current scene
  121327. */
  121328. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121329. /**
  121330. * Use this function to restart evaluating active meshes on every frame
  121331. * @returns the current scene
  121332. */
  121333. unfreezeActiveMeshes(): Scene;
  121334. private _evaluateActiveMeshes;
  121335. private _activeMesh;
  121336. /**
  121337. * Update the transform matrix to update from the current active camera
  121338. * @param force defines a boolean used to force the update even if cache is up to date
  121339. */
  121340. updateTransformMatrix(force?: boolean): void;
  121341. private _bindFrameBuffer;
  121342. /** @hidden */
  121343. _allowPostProcessClearColor: boolean;
  121344. /** @hidden */
  121345. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121346. private _processSubCameras;
  121347. private _checkIntersections;
  121348. /** @hidden */
  121349. _advancePhysicsEngineStep(step: number): void;
  121350. /**
  121351. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121352. */
  121353. getDeterministicFrameTime: () => number;
  121354. /** @hidden */
  121355. _animate(): void;
  121356. /** Execute all animations (for a frame) */
  121357. animate(): void;
  121358. /**
  121359. * Render the scene
  121360. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121361. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121362. */
  121363. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121364. /**
  121365. * Freeze all materials
  121366. * A frozen material will not be updatable but should be faster to render
  121367. */
  121368. freezeMaterials(): void;
  121369. /**
  121370. * Unfreeze all materials
  121371. * A frozen material will not be updatable but should be faster to render
  121372. */
  121373. unfreezeMaterials(): void;
  121374. /**
  121375. * Releases all held ressources
  121376. */
  121377. dispose(): void;
  121378. /**
  121379. * Gets if the scene is already disposed
  121380. */
  121381. get isDisposed(): boolean;
  121382. /**
  121383. * Call this function to reduce memory footprint of the scene.
  121384. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121385. */
  121386. clearCachedVertexData(): void;
  121387. /**
  121388. * This function will remove the local cached buffer data from texture.
  121389. * It will save memory but will prevent the texture from being rebuilt
  121390. */
  121391. cleanCachedTextureBuffer(): void;
  121392. /**
  121393. * Get the world extend vectors with an optional filter
  121394. *
  121395. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121396. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121397. */
  121398. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121399. min: Vector3;
  121400. max: Vector3;
  121401. };
  121402. /**
  121403. * Creates a ray that can be used to pick in the scene
  121404. * @param x defines the x coordinate of the origin (on-screen)
  121405. * @param y defines the y coordinate of the origin (on-screen)
  121406. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121407. * @param camera defines the camera to use for the picking
  121408. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121409. * @returns a Ray
  121410. */
  121411. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121412. /**
  121413. * Creates a ray that can be used to pick in the scene
  121414. * @param x defines the x coordinate of the origin (on-screen)
  121415. * @param y defines the y coordinate of the origin (on-screen)
  121416. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121417. * @param result defines the ray where to store the picking ray
  121418. * @param camera defines the camera to use for the picking
  121419. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121420. * @returns the current scene
  121421. */
  121422. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121423. /**
  121424. * Creates a ray that can be used to pick in the scene
  121425. * @param x defines the x coordinate of the origin (on-screen)
  121426. * @param y defines the y coordinate of the origin (on-screen)
  121427. * @param camera defines the camera to use for the picking
  121428. * @returns a Ray
  121429. */
  121430. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121431. /**
  121432. * Creates a ray that can be used to pick in the scene
  121433. * @param x defines the x coordinate of the origin (on-screen)
  121434. * @param y defines the y coordinate of the origin (on-screen)
  121435. * @param result defines the ray where to store the picking ray
  121436. * @param camera defines the camera to use for the picking
  121437. * @returns the current scene
  121438. */
  121439. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121440. /** Launch a ray to try to pick a mesh in the scene
  121441. * @param x position on screen
  121442. * @param y position on screen
  121443. * @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
  121444. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121445. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121446. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121447. * @returns a PickingInfo
  121448. */
  121449. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121450. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121451. * @param x position on screen
  121452. * @param y position on screen
  121453. * @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
  121454. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121455. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121456. * @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)
  121457. */
  121458. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121459. /** Use the given ray to pick a mesh in the scene
  121460. * @param ray The ray to use to pick meshes
  121461. * @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
  121462. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121463. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121464. * @returns a PickingInfo
  121465. */
  121466. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121467. /**
  121468. * Launch a ray to try to pick a mesh in the scene
  121469. * @param x X position on screen
  121470. * @param y Y position on screen
  121471. * @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
  121472. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121473. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121474. * @returns an array of PickingInfo
  121475. */
  121476. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121477. /**
  121478. * Launch a ray to try to pick a mesh in the scene
  121479. * @param ray Ray to use
  121480. * @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
  121481. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121482. * @returns an array of PickingInfo
  121483. */
  121484. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121485. /**
  121486. * Force the value of meshUnderPointer
  121487. * @param mesh defines the mesh to use
  121488. * @param pointerId optional pointer id when using more than one pointer
  121489. */
  121490. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121491. /**
  121492. * Gets the mesh under the pointer
  121493. * @returns a Mesh or null if no mesh is under the pointer
  121494. */
  121495. getPointerOverMesh(): Nullable<AbstractMesh>;
  121496. /** @hidden */
  121497. _rebuildGeometries(): void;
  121498. /** @hidden */
  121499. _rebuildTextures(): void;
  121500. private _getByTags;
  121501. /**
  121502. * Get a list of meshes by tags
  121503. * @param tagsQuery defines the tags query to use
  121504. * @param forEach defines a predicate used to filter results
  121505. * @returns an array of Mesh
  121506. */
  121507. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121508. /**
  121509. * Get a list of cameras by tags
  121510. * @param tagsQuery defines the tags query to use
  121511. * @param forEach defines a predicate used to filter results
  121512. * @returns an array of Camera
  121513. */
  121514. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121515. /**
  121516. * Get a list of lights by tags
  121517. * @param tagsQuery defines the tags query to use
  121518. * @param forEach defines a predicate used to filter results
  121519. * @returns an array of Light
  121520. */
  121521. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121522. /**
  121523. * Get a list of materials by tags
  121524. * @param tagsQuery defines the tags query to use
  121525. * @param forEach defines a predicate used to filter results
  121526. * @returns an array of Material
  121527. */
  121528. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121529. /**
  121530. * Get a list of transform nodes by tags
  121531. * @param tagsQuery defines the tags query to use
  121532. * @param forEach defines a predicate used to filter results
  121533. * @returns an array of TransformNode
  121534. */
  121535. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121536. /**
  121537. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121538. * This allowed control for front to back rendering or reversly depending of the special needs.
  121539. *
  121540. * @param renderingGroupId The rendering group id corresponding to its index
  121541. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121542. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121543. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121544. */
  121545. 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;
  121546. /**
  121547. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121548. *
  121549. * @param renderingGroupId The rendering group id corresponding to its index
  121550. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121551. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121552. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121553. */
  121554. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121555. /**
  121556. * Gets the current auto clear configuration for one rendering group of the rendering
  121557. * manager.
  121558. * @param index the rendering group index to get the information for
  121559. * @returns The auto clear setup for the requested rendering group
  121560. */
  121561. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121562. private _blockMaterialDirtyMechanism;
  121563. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121564. get blockMaterialDirtyMechanism(): boolean;
  121565. set blockMaterialDirtyMechanism(value: boolean);
  121566. /**
  121567. * Will flag all materials as dirty to trigger new shader compilation
  121568. * @param flag defines the flag used to specify which material part must be marked as dirty
  121569. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121570. */
  121571. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121572. /** @hidden */
  121573. _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;
  121574. /** @hidden */
  121575. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121576. /** @hidden */
  121577. _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;
  121578. /** @hidden */
  121579. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121580. /** @hidden */
  121581. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121582. /** @hidden */
  121583. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121584. }
  121585. }
  121586. declare module BABYLON {
  121587. /**
  121588. * Set of assets to keep when moving a scene into an asset container.
  121589. */
  121590. export class KeepAssets extends AbstractScene {
  121591. }
  121592. /**
  121593. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121594. */
  121595. export class InstantiatedEntries {
  121596. /**
  121597. * List of new root nodes (eg. nodes with no parent)
  121598. */
  121599. rootNodes: TransformNode[];
  121600. /**
  121601. * List of new skeletons
  121602. */
  121603. skeletons: Skeleton[];
  121604. /**
  121605. * List of new animation groups
  121606. */
  121607. animationGroups: AnimationGroup[];
  121608. }
  121609. /**
  121610. * Container with a set of assets that can be added or removed from a scene.
  121611. */
  121612. export class AssetContainer extends AbstractScene {
  121613. private _wasAddedToScene;
  121614. /**
  121615. * The scene the AssetContainer belongs to.
  121616. */
  121617. scene: Scene;
  121618. /**
  121619. * Instantiates an AssetContainer.
  121620. * @param scene The scene the AssetContainer belongs to.
  121621. */
  121622. constructor(scene: Scene);
  121623. /**
  121624. * Instantiate or clone all meshes and add the new ones to the scene.
  121625. * Skeletons and animation groups will all be cloned
  121626. * @param nameFunction defines an optional function used to get new names for clones
  121627. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121628. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121629. */
  121630. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121631. /**
  121632. * Adds all the assets from the container to the scene.
  121633. */
  121634. addAllToScene(): void;
  121635. /**
  121636. * Removes all the assets in the container from the scene
  121637. */
  121638. removeAllFromScene(): void;
  121639. /**
  121640. * Disposes all the assets in the container
  121641. */
  121642. dispose(): void;
  121643. private _moveAssets;
  121644. /**
  121645. * Removes all the assets contained in the scene and adds them to the container.
  121646. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121647. */
  121648. moveAllFromScene(keepAssets?: KeepAssets): void;
  121649. /**
  121650. * 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.
  121651. * @returns the root mesh
  121652. */
  121653. createRootMesh(): Mesh;
  121654. /**
  121655. * Merge animations (direct and animation groups) from this asset container into a scene
  121656. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  121657. * @param animatables set of animatables to retarget to a node from the scene
  121658. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  121659. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  121660. */
  121661. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  121662. }
  121663. }
  121664. declare module BABYLON {
  121665. /**
  121666. * Defines how the parser contract is defined.
  121667. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  121668. */
  121669. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  121670. /**
  121671. * Defines how the individual parser contract is defined.
  121672. * These parser can parse an individual asset
  121673. */
  121674. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  121675. /**
  121676. * Base class of the scene acting as a container for the different elements composing a scene.
  121677. * This class is dynamically extended by the different components of the scene increasing
  121678. * flexibility and reducing coupling
  121679. */
  121680. export abstract class AbstractScene {
  121681. /**
  121682. * Stores the list of available parsers in the application.
  121683. */
  121684. private static _BabylonFileParsers;
  121685. /**
  121686. * Stores the list of available individual parsers in the application.
  121687. */
  121688. private static _IndividualBabylonFileParsers;
  121689. /**
  121690. * Adds a parser in the list of available ones
  121691. * @param name Defines the name of the parser
  121692. * @param parser Defines the parser to add
  121693. */
  121694. static AddParser(name: string, parser: BabylonFileParser): void;
  121695. /**
  121696. * Gets a general parser from the list of avaialble ones
  121697. * @param name Defines the name of the parser
  121698. * @returns the requested parser or null
  121699. */
  121700. static GetParser(name: string): Nullable<BabylonFileParser>;
  121701. /**
  121702. * Adds n individual parser in the list of available ones
  121703. * @param name Defines the name of the parser
  121704. * @param parser Defines the parser to add
  121705. */
  121706. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  121707. /**
  121708. * Gets an individual parser from the list of avaialble ones
  121709. * @param name Defines the name of the parser
  121710. * @returns the requested parser or null
  121711. */
  121712. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  121713. /**
  121714. * Parser json data and populate both a scene and its associated container object
  121715. * @param jsonData Defines the data to parse
  121716. * @param scene Defines the scene to parse the data for
  121717. * @param container Defines the container attached to the parsing sequence
  121718. * @param rootUrl Defines the root url of the data
  121719. */
  121720. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  121721. /**
  121722. * Gets the list of root nodes (ie. nodes with no parent)
  121723. */
  121724. rootNodes: Node[];
  121725. /** All of the cameras added to this scene
  121726. * @see https://doc.babylonjs.com/babylon101/cameras
  121727. */
  121728. cameras: Camera[];
  121729. /**
  121730. * All of the lights added to this scene
  121731. * @see https://doc.babylonjs.com/babylon101/lights
  121732. */
  121733. lights: Light[];
  121734. /**
  121735. * All of the (abstract) meshes added to this scene
  121736. */
  121737. meshes: AbstractMesh[];
  121738. /**
  121739. * The list of skeletons added to the scene
  121740. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  121741. */
  121742. skeletons: Skeleton[];
  121743. /**
  121744. * All of the particle systems added to this scene
  121745. * @see https://doc.babylonjs.com/babylon101/particles
  121746. */
  121747. particleSystems: IParticleSystem[];
  121748. /**
  121749. * Gets a list of Animations associated with the scene
  121750. */
  121751. animations: Animation[];
  121752. /**
  121753. * All of the animation groups added to this scene
  121754. * @see https://doc.babylonjs.com/how_to/group
  121755. */
  121756. animationGroups: AnimationGroup[];
  121757. /**
  121758. * All of the multi-materials added to this scene
  121759. * @see https://doc.babylonjs.com/how_to/multi_materials
  121760. */
  121761. multiMaterials: MultiMaterial[];
  121762. /**
  121763. * All of the materials added to this scene
  121764. * In the context of a Scene, it is not supposed to be modified manually.
  121765. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  121766. * Note also that the order of the Material within the array is not significant and might change.
  121767. * @see https://doc.babylonjs.com/babylon101/materials
  121768. */
  121769. materials: Material[];
  121770. /**
  121771. * The list of morph target managers added to the scene
  121772. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  121773. */
  121774. morphTargetManagers: MorphTargetManager[];
  121775. /**
  121776. * The list of geometries used in the scene.
  121777. */
  121778. geometries: Geometry[];
  121779. /**
  121780. * All of the tranform nodes added to this scene
  121781. * In the context of a Scene, it is not supposed to be modified manually.
  121782. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  121783. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  121784. * @see https://doc.babylonjs.com/how_to/transformnode
  121785. */
  121786. transformNodes: TransformNode[];
  121787. /**
  121788. * ActionManagers available on the scene.
  121789. */
  121790. actionManagers: AbstractActionManager[];
  121791. /**
  121792. * Textures to keep.
  121793. */
  121794. textures: BaseTexture[];
  121795. /** @hidden */
  121796. protected _environmentTexture: Nullable<BaseTexture>;
  121797. /**
  121798. * Texture used in all pbr material as the reflection texture.
  121799. * As in the majority of the scene they are the same (exception for multi room and so on),
  121800. * this is easier to reference from here than from all the materials.
  121801. */
  121802. get environmentTexture(): Nullable<BaseTexture>;
  121803. set environmentTexture(value: Nullable<BaseTexture>);
  121804. /**
  121805. * The list of postprocesses added to the scene
  121806. */
  121807. postProcesses: PostProcess[];
  121808. /**
  121809. * @returns all meshes, lights, cameras, transformNodes and bones
  121810. */
  121811. getNodes(): Array<Node>;
  121812. }
  121813. }
  121814. declare module BABYLON {
  121815. /**
  121816. * Interface used to define options for Sound class
  121817. */
  121818. export interface ISoundOptions {
  121819. /**
  121820. * Does the sound autoplay once loaded.
  121821. */
  121822. autoplay?: boolean;
  121823. /**
  121824. * Does the sound loop after it finishes playing once.
  121825. */
  121826. loop?: boolean;
  121827. /**
  121828. * Sound's volume
  121829. */
  121830. volume?: number;
  121831. /**
  121832. * Is it a spatial sound?
  121833. */
  121834. spatialSound?: boolean;
  121835. /**
  121836. * Maximum distance to hear that sound
  121837. */
  121838. maxDistance?: number;
  121839. /**
  121840. * Uses user defined attenuation function
  121841. */
  121842. useCustomAttenuation?: boolean;
  121843. /**
  121844. * Define the roll off factor of spatial sounds.
  121845. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121846. */
  121847. rolloffFactor?: number;
  121848. /**
  121849. * Define the reference distance the sound should be heard perfectly.
  121850. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121851. */
  121852. refDistance?: number;
  121853. /**
  121854. * Define the distance attenuation model the sound will follow.
  121855. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121856. */
  121857. distanceModel?: string;
  121858. /**
  121859. * Defines the playback speed (1 by default)
  121860. */
  121861. playbackRate?: number;
  121862. /**
  121863. * Defines if the sound is from a streaming source
  121864. */
  121865. streaming?: boolean;
  121866. /**
  121867. * Defines an optional length (in seconds) inside the sound file
  121868. */
  121869. length?: number;
  121870. /**
  121871. * Defines an optional offset (in seconds) inside the sound file
  121872. */
  121873. offset?: number;
  121874. /**
  121875. * If true, URLs will not be required to state the audio file codec to use.
  121876. */
  121877. skipCodecCheck?: boolean;
  121878. }
  121879. /**
  121880. * Defines a sound that can be played in the application.
  121881. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  121882. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  121883. */
  121884. export class Sound {
  121885. /**
  121886. * The name of the sound in the scene.
  121887. */
  121888. name: string;
  121889. /**
  121890. * Does the sound autoplay once loaded.
  121891. */
  121892. autoplay: boolean;
  121893. /**
  121894. * Does the sound loop after it finishes playing once.
  121895. */
  121896. loop: boolean;
  121897. /**
  121898. * Does the sound use a custom attenuation curve to simulate the falloff
  121899. * happening when the source gets further away from the camera.
  121900. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  121901. */
  121902. useCustomAttenuation: boolean;
  121903. /**
  121904. * The sound track id this sound belongs to.
  121905. */
  121906. soundTrackId: number;
  121907. /**
  121908. * Is this sound currently played.
  121909. */
  121910. isPlaying: boolean;
  121911. /**
  121912. * Is this sound currently paused.
  121913. */
  121914. isPaused: boolean;
  121915. /**
  121916. * Does this sound enables spatial sound.
  121917. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121918. */
  121919. spatialSound: boolean;
  121920. /**
  121921. * Define the reference distance the sound should be heard perfectly.
  121922. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121923. */
  121924. refDistance: number;
  121925. /**
  121926. * Define the roll off factor of spatial sounds.
  121927. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121928. */
  121929. rolloffFactor: number;
  121930. /**
  121931. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  121932. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121933. */
  121934. maxDistance: number;
  121935. /**
  121936. * Define the distance attenuation model the sound will follow.
  121937. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  121938. */
  121939. distanceModel: string;
  121940. /**
  121941. * @hidden
  121942. * Back Compat
  121943. **/
  121944. onended: () => any;
  121945. /**
  121946. * Gets or sets an object used to store user defined information for the sound.
  121947. */
  121948. metadata: any;
  121949. /**
  121950. * Observable event when the current playing sound finishes.
  121951. */
  121952. onEndedObservable: Observable<Sound>;
  121953. private _panningModel;
  121954. private _playbackRate;
  121955. private _streaming;
  121956. private _startTime;
  121957. private _startOffset;
  121958. private _position;
  121959. /** @hidden */
  121960. _positionInEmitterSpace: boolean;
  121961. private _localDirection;
  121962. private _volume;
  121963. private _isReadyToPlay;
  121964. private _isDirectional;
  121965. private _readyToPlayCallback;
  121966. private _audioBuffer;
  121967. private _soundSource;
  121968. private _streamingSource;
  121969. private _soundPanner;
  121970. private _soundGain;
  121971. private _inputAudioNode;
  121972. private _outputAudioNode;
  121973. private _coneInnerAngle;
  121974. private _coneOuterAngle;
  121975. private _coneOuterGain;
  121976. private _scene;
  121977. private _connectedTransformNode;
  121978. private _customAttenuationFunction;
  121979. private _registerFunc;
  121980. private _isOutputConnected;
  121981. private _htmlAudioElement;
  121982. private _urlType;
  121983. private _length?;
  121984. private _offset?;
  121985. /** @hidden */
  121986. static _SceneComponentInitialization: (scene: Scene) => void;
  121987. /**
  121988. * Create a sound and attach it to a scene
  121989. * @param name Name of your sound
  121990. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  121991. * @param scene defines the scene the sound belongs to
  121992. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  121993. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  121994. */
  121995. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  121996. /**
  121997. * Release the sound and its associated resources
  121998. */
  121999. dispose(): void;
  122000. /**
  122001. * Gets if the sounds is ready to be played or not.
  122002. * @returns true if ready, otherwise false
  122003. */
  122004. isReady(): boolean;
  122005. private _soundLoaded;
  122006. /**
  122007. * Sets the data of the sound from an audiobuffer
  122008. * @param audioBuffer The audioBuffer containing the data
  122009. */
  122010. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122011. /**
  122012. * Updates the current sounds options such as maxdistance, loop...
  122013. * @param options A JSON object containing values named as the object properties
  122014. */
  122015. updateOptions(options: ISoundOptions): void;
  122016. private _createSpatialParameters;
  122017. private _updateSpatialParameters;
  122018. /**
  122019. * Switch the panning model to HRTF:
  122020. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122021. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122022. */
  122023. switchPanningModelToHRTF(): void;
  122024. /**
  122025. * Switch the panning model to Equal Power:
  122026. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122027. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122028. */
  122029. switchPanningModelToEqualPower(): void;
  122030. private _switchPanningModel;
  122031. /**
  122032. * Connect this sound to a sound track audio node like gain...
  122033. * @param soundTrackAudioNode the sound track audio node to connect to
  122034. */
  122035. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122036. /**
  122037. * Transform this sound into a directional source
  122038. * @param coneInnerAngle Size of the inner cone in degree
  122039. * @param coneOuterAngle Size of the outer cone in degree
  122040. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122041. */
  122042. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122043. /**
  122044. * Gets or sets the inner angle for the directional cone.
  122045. */
  122046. get directionalConeInnerAngle(): number;
  122047. /**
  122048. * Gets or sets the inner angle for the directional cone.
  122049. */
  122050. set directionalConeInnerAngle(value: number);
  122051. /**
  122052. * Gets or sets the outer angle for the directional cone.
  122053. */
  122054. get directionalConeOuterAngle(): number;
  122055. /**
  122056. * Gets or sets the outer angle for the directional cone.
  122057. */
  122058. set directionalConeOuterAngle(value: number);
  122059. /**
  122060. * Sets the position of the emitter if spatial sound is enabled
  122061. * @param newPosition Defines the new posisiton
  122062. */
  122063. setPosition(newPosition: Vector3): void;
  122064. /**
  122065. * Sets the local direction of the emitter if spatial sound is enabled
  122066. * @param newLocalDirection Defines the new local direction
  122067. */
  122068. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122069. private _updateDirection;
  122070. /** @hidden */
  122071. updateDistanceFromListener(): void;
  122072. /**
  122073. * Sets a new custom attenuation function for the sound.
  122074. * @param callback Defines the function used for the attenuation
  122075. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122076. */
  122077. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122078. /**
  122079. * Play the sound
  122080. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122081. * @param offset (optional) Start the sound at a specific time in seconds
  122082. * @param length (optional) Sound duration (in seconds)
  122083. */
  122084. play(time?: number, offset?: number, length?: number): void;
  122085. private _onended;
  122086. /**
  122087. * Stop the sound
  122088. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122089. */
  122090. stop(time?: number): void;
  122091. /**
  122092. * Put the sound in pause
  122093. */
  122094. pause(): void;
  122095. /**
  122096. * Sets a dedicated volume for this sounds
  122097. * @param newVolume Define the new volume of the sound
  122098. * @param time Define time for gradual change to new volume
  122099. */
  122100. setVolume(newVolume: number, time?: number): void;
  122101. /**
  122102. * Set the sound play back rate
  122103. * @param newPlaybackRate Define the playback rate the sound should be played at
  122104. */
  122105. setPlaybackRate(newPlaybackRate: number): void;
  122106. /**
  122107. * Gets the volume of the sound.
  122108. * @returns the volume of the sound
  122109. */
  122110. getVolume(): number;
  122111. /**
  122112. * Attach the sound to a dedicated mesh
  122113. * @param transformNode The transform node to connect the sound with
  122114. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122115. */
  122116. attachToMesh(transformNode: TransformNode): void;
  122117. /**
  122118. * Detach the sound from the previously attached mesh
  122119. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122120. */
  122121. detachFromMesh(): void;
  122122. private _onRegisterAfterWorldMatrixUpdate;
  122123. /**
  122124. * Clone the current sound in the scene.
  122125. * @returns the new sound clone
  122126. */
  122127. clone(): Nullable<Sound>;
  122128. /**
  122129. * Gets the current underlying audio buffer containing the data
  122130. * @returns the audio buffer
  122131. */
  122132. getAudioBuffer(): Nullable<AudioBuffer>;
  122133. /**
  122134. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122135. * @returns the source node
  122136. */
  122137. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122138. /**
  122139. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122140. * @returns the gain node
  122141. */
  122142. getSoundGain(): Nullable<GainNode>;
  122143. /**
  122144. * Serializes the Sound in a JSON representation
  122145. * @returns the JSON representation of the sound
  122146. */
  122147. serialize(): any;
  122148. /**
  122149. * Parse a JSON representation of a sound to innstantiate in a given scene
  122150. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122151. * @param scene Define the scene the new parsed sound should be created in
  122152. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122153. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122154. * @returns the newly parsed sound
  122155. */
  122156. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122157. }
  122158. }
  122159. declare module BABYLON {
  122160. /**
  122161. * This defines an action helpful to play a defined sound on a triggered action.
  122162. */
  122163. export class PlaySoundAction extends Action {
  122164. private _sound;
  122165. /**
  122166. * Instantiate the action
  122167. * @param triggerOptions defines the trigger options
  122168. * @param sound defines the sound to play
  122169. * @param condition defines the trigger related conditions
  122170. */
  122171. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122172. /** @hidden */
  122173. _prepare(): void;
  122174. /**
  122175. * Execute the action and play the sound.
  122176. */
  122177. execute(): void;
  122178. /**
  122179. * Serializes the actions and its related information.
  122180. * @param parent defines the object to serialize in
  122181. * @returns the serialized object
  122182. */
  122183. serialize(parent: any): any;
  122184. }
  122185. /**
  122186. * This defines an action helpful to stop a defined sound on a triggered action.
  122187. */
  122188. export class StopSoundAction extends Action {
  122189. private _sound;
  122190. /**
  122191. * Instantiate the action
  122192. * @param triggerOptions defines the trigger options
  122193. * @param sound defines the sound to stop
  122194. * @param condition defines the trigger related conditions
  122195. */
  122196. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122197. /** @hidden */
  122198. _prepare(): void;
  122199. /**
  122200. * Execute the action and stop the sound.
  122201. */
  122202. execute(): void;
  122203. /**
  122204. * Serializes the actions and its related information.
  122205. * @param parent defines the object to serialize in
  122206. * @returns the serialized object
  122207. */
  122208. serialize(parent: any): any;
  122209. }
  122210. }
  122211. declare module BABYLON {
  122212. /**
  122213. * This defines an action responsible to change the value of a property
  122214. * by interpolating between its current value and the newly set one once triggered.
  122215. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122216. */
  122217. export class InterpolateValueAction extends Action {
  122218. /**
  122219. * Defines the path of the property where the value should be interpolated
  122220. */
  122221. propertyPath: string;
  122222. /**
  122223. * Defines the target value at the end of the interpolation.
  122224. */
  122225. value: any;
  122226. /**
  122227. * Defines the time it will take for the property to interpolate to the value.
  122228. */
  122229. duration: number;
  122230. /**
  122231. * Defines if the other scene animations should be stopped when the action has been triggered
  122232. */
  122233. stopOtherAnimations?: boolean;
  122234. /**
  122235. * Defines a callback raised once the interpolation animation has been done.
  122236. */
  122237. onInterpolationDone?: () => void;
  122238. /**
  122239. * Observable triggered once the interpolation animation has been done.
  122240. */
  122241. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122242. private _target;
  122243. private _effectiveTarget;
  122244. private _property;
  122245. /**
  122246. * Instantiate the action
  122247. * @param triggerOptions defines the trigger options
  122248. * @param target defines the object containing the value to interpolate
  122249. * @param propertyPath defines the path to the property in the target object
  122250. * @param value defines the target value at the end of the interpolation
  122251. * @param duration deines the time it will take for the property to interpolate to the value.
  122252. * @param condition defines the trigger related conditions
  122253. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122254. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122255. */
  122256. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122257. /** @hidden */
  122258. _prepare(): void;
  122259. /**
  122260. * Execute the action starts the value interpolation.
  122261. */
  122262. execute(): void;
  122263. /**
  122264. * Serializes the actions and its related information.
  122265. * @param parent defines the object to serialize in
  122266. * @returns the serialized object
  122267. */
  122268. serialize(parent: any): any;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /**
  122273. * Options allowed during the creation of a sound track.
  122274. */
  122275. export interface ISoundTrackOptions {
  122276. /**
  122277. * The volume the sound track should take during creation
  122278. */
  122279. volume?: number;
  122280. /**
  122281. * Define if the sound track is the main sound track of the scene
  122282. */
  122283. mainTrack?: boolean;
  122284. }
  122285. /**
  122286. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122287. * It will be also used in a future release to apply effects on a specific track.
  122288. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122289. */
  122290. export class SoundTrack {
  122291. /**
  122292. * The unique identifier of the sound track in the scene.
  122293. */
  122294. id: number;
  122295. /**
  122296. * The list of sounds included in the sound track.
  122297. */
  122298. soundCollection: Array<Sound>;
  122299. private _outputAudioNode;
  122300. private _scene;
  122301. private _connectedAnalyser;
  122302. private _options;
  122303. private _isInitialized;
  122304. /**
  122305. * Creates a new sound track.
  122306. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122307. * @param scene Define the scene the sound track belongs to
  122308. * @param options
  122309. */
  122310. constructor(scene: Scene, options?: ISoundTrackOptions);
  122311. private _initializeSoundTrackAudioGraph;
  122312. /**
  122313. * Release the sound track and its associated resources
  122314. */
  122315. dispose(): void;
  122316. /**
  122317. * Adds a sound to this sound track
  122318. * @param sound define the cound to add
  122319. * @ignoreNaming
  122320. */
  122321. AddSound(sound: Sound): void;
  122322. /**
  122323. * Removes a sound to this sound track
  122324. * @param sound define the cound to remove
  122325. * @ignoreNaming
  122326. */
  122327. RemoveSound(sound: Sound): void;
  122328. /**
  122329. * Set a global volume for the full sound track.
  122330. * @param newVolume Define the new volume of the sound track
  122331. */
  122332. setVolume(newVolume: number): void;
  122333. /**
  122334. * Switch the panning model to HRTF:
  122335. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122336. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122337. */
  122338. switchPanningModelToHRTF(): void;
  122339. /**
  122340. * Switch the panning model to Equal Power:
  122341. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122342. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122343. */
  122344. switchPanningModelToEqualPower(): void;
  122345. /**
  122346. * Connect the sound track to an audio analyser allowing some amazing
  122347. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122348. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122349. * @param analyser The analyser to connect to the engine
  122350. */
  122351. connectToAnalyser(analyser: Analyser): void;
  122352. }
  122353. }
  122354. declare module BABYLON {
  122355. interface AbstractScene {
  122356. /**
  122357. * The list of sounds used in the scene.
  122358. */
  122359. sounds: Nullable<Array<Sound>>;
  122360. }
  122361. interface Scene {
  122362. /**
  122363. * @hidden
  122364. * Backing field
  122365. */
  122366. _mainSoundTrack: SoundTrack;
  122367. /**
  122368. * The main sound track played by the scene.
  122369. * It cotains your primary collection of sounds.
  122370. */
  122371. mainSoundTrack: SoundTrack;
  122372. /**
  122373. * The list of sound tracks added to the scene
  122374. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122375. */
  122376. soundTracks: Nullable<Array<SoundTrack>>;
  122377. /**
  122378. * Gets a sound using a given name
  122379. * @param name defines the name to search for
  122380. * @return the found sound or null if not found at all.
  122381. */
  122382. getSoundByName(name: string): Nullable<Sound>;
  122383. /**
  122384. * Gets or sets if audio support is enabled
  122385. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122386. */
  122387. audioEnabled: boolean;
  122388. /**
  122389. * Gets or sets if audio will be output to headphones
  122390. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122391. */
  122392. headphone: boolean;
  122393. /**
  122394. * Gets or sets custom audio listener position provider
  122395. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122396. */
  122397. audioListenerPositionProvider: Nullable<() => Vector3>;
  122398. /**
  122399. * Gets or sets a refresh rate when using 3D audio positioning
  122400. */
  122401. audioPositioningRefreshRate: number;
  122402. }
  122403. /**
  122404. * Defines the sound scene component responsible to manage any sounds
  122405. * in a given scene.
  122406. */
  122407. export class AudioSceneComponent implements ISceneSerializableComponent {
  122408. private static _CameraDirectionLH;
  122409. private static _CameraDirectionRH;
  122410. /**
  122411. * The component name helpfull to identify the component in the list of scene components.
  122412. */
  122413. readonly name: string;
  122414. /**
  122415. * The scene the component belongs to.
  122416. */
  122417. scene: Scene;
  122418. private _audioEnabled;
  122419. /**
  122420. * Gets whether audio is enabled or not.
  122421. * Please use related enable/disable method to switch state.
  122422. */
  122423. get audioEnabled(): boolean;
  122424. private _headphone;
  122425. /**
  122426. * Gets whether audio is outputing to headphone or not.
  122427. * Please use the according Switch methods to change output.
  122428. */
  122429. get headphone(): boolean;
  122430. /**
  122431. * Gets or sets a refresh rate when using 3D audio positioning
  122432. */
  122433. audioPositioningRefreshRate: number;
  122434. private _audioListenerPositionProvider;
  122435. /**
  122436. * Gets the current audio listener position provider
  122437. */
  122438. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122439. /**
  122440. * Sets a custom listener position for all sounds in the scene
  122441. * By default, this is the position of the first active camera
  122442. */
  122443. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122444. /**
  122445. * Creates a new instance of the component for the given scene
  122446. * @param scene Defines the scene to register the component in
  122447. */
  122448. constructor(scene: Scene);
  122449. /**
  122450. * Registers the component in a given scene
  122451. */
  122452. register(): void;
  122453. /**
  122454. * Rebuilds the elements related to this component in case of
  122455. * context lost for instance.
  122456. */
  122457. rebuild(): void;
  122458. /**
  122459. * Serializes the component data to the specified json object
  122460. * @param serializationObject The object to serialize to
  122461. */
  122462. serialize(serializationObject: any): void;
  122463. /**
  122464. * Adds all the elements from the container to the scene
  122465. * @param container the container holding the elements
  122466. */
  122467. addFromContainer(container: AbstractScene): void;
  122468. /**
  122469. * Removes all the elements in the container from the scene
  122470. * @param container contains the elements to remove
  122471. * @param dispose if the removed element should be disposed (default: false)
  122472. */
  122473. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122474. /**
  122475. * Disposes the component and the associated ressources.
  122476. */
  122477. dispose(): void;
  122478. /**
  122479. * Disables audio in the associated scene.
  122480. */
  122481. disableAudio(): void;
  122482. /**
  122483. * Enables audio in the associated scene.
  122484. */
  122485. enableAudio(): void;
  122486. /**
  122487. * Switch audio to headphone output.
  122488. */
  122489. switchAudioModeForHeadphones(): void;
  122490. /**
  122491. * Switch audio to normal speakers.
  122492. */
  122493. switchAudioModeForNormalSpeakers(): void;
  122494. private _cachedCameraDirection;
  122495. private _cachedCameraPosition;
  122496. private _lastCheck;
  122497. private _afterRender;
  122498. }
  122499. }
  122500. declare module BABYLON {
  122501. /**
  122502. * Wraps one or more Sound objects and selects one with random weight for playback.
  122503. */
  122504. export class WeightedSound {
  122505. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122506. loop: boolean;
  122507. private _coneInnerAngle;
  122508. private _coneOuterAngle;
  122509. private _volume;
  122510. /** A Sound is currently playing. */
  122511. isPlaying: boolean;
  122512. /** A Sound is currently paused. */
  122513. isPaused: boolean;
  122514. private _sounds;
  122515. private _weights;
  122516. private _currentIndex?;
  122517. /**
  122518. * Creates a new WeightedSound from the list of sounds given.
  122519. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122520. * @param sounds Array of Sounds that will be selected from.
  122521. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122522. */
  122523. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122524. /**
  122525. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122526. */
  122527. get directionalConeInnerAngle(): number;
  122528. /**
  122529. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122530. */
  122531. set directionalConeInnerAngle(value: number);
  122532. /**
  122533. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122534. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122535. */
  122536. get directionalConeOuterAngle(): number;
  122537. /**
  122538. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122539. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122540. */
  122541. set directionalConeOuterAngle(value: number);
  122542. /**
  122543. * Playback volume.
  122544. */
  122545. get volume(): number;
  122546. /**
  122547. * Playback volume.
  122548. */
  122549. set volume(value: number);
  122550. private _onended;
  122551. /**
  122552. * Suspend playback
  122553. */
  122554. pause(): void;
  122555. /**
  122556. * Stop playback
  122557. */
  122558. stop(): void;
  122559. /**
  122560. * Start playback.
  122561. * @param startOffset Position the clip head at a specific time in seconds.
  122562. */
  122563. play(startOffset?: number): void;
  122564. }
  122565. }
  122566. declare module BABYLON {
  122567. /**
  122568. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122569. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122570. */
  122571. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122572. /**
  122573. * Gets the name of the behavior.
  122574. */
  122575. get name(): string;
  122576. /**
  122577. * The easing function used by animations
  122578. */
  122579. static EasingFunction: BackEase;
  122580. /**
  122581. * The easing mode used by animations
  122582. */
  122583. static EasingMode: number;
  122584. /**
  122585. * The duration of the animation, in milliseconds
  122586. */
  122587. transitionDuration: number;
  122588. /**
  122589. * Length of the distance animated by the transition when lower radius is reached
  122590. */
  122591. lowerRadiusTransitionRange: number;
  122592. /**
  122593. * Length of the distance animated by the transition when upper radius is reached
  122594. */
  122595. upperRadiusTransitionRange: number;
  122596. private _autoTransitionRange;
  122597. /**
  122598. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122599. */
  122600. get autoTransitionRange(): boolean;
  122601. /**
  122602. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122603. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122604. */
  122605. set autoTransitionRange(value: boolean);
  122606. private _attachedCamera;
  122607. private _onAfterCheckInputsObserver;
  122608. private _onMeshTargetChangedObserver;
  122609. /**
  122610. * Initializes the behavior.
  122611. */
  122612. init(): void;
  122613. /**
  122614. * Attaches the behavior to its arc rotate camera.
  122615. * @param camera Defines the camera to attach the behavior to
  122616. */
  122617. attach(camera: ArcRotateCamera): void;
  122618. /**
  122619. * Detaches the behavior from its current arc rotate camera.
  122620. */
  122621. detach(): void;
  122622. private _radiusIsAnimating;
  122623. private _radiusBounceTransition;
  122624. private _animatables;
  122625. private _cachedWheelPrecision;
  122626. /**
  122627. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122628. * @param radiusLimit The limit to check against.
  122629. * @return Bool to indicate if at limit.
  122630. */
  122631. private _isRadiusAtLimit;
  122632. /**
  122633. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122634. * @param radiusDelta The delta by which to animate to. Can be negative.
  122635. */
  122636. private _applyBoundRadiusAnimation;
  122637. /**
  122638. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122639. */
  122640. protected _clearAnimationLocks(): void;
  122641. /**
  122642. * Stops and removes all animations that have been applied to the camera
  122643. */
  122644. stopAllAnimations(): void;
  122645. }
  122646. }
  122647. declare module BABYLON {
  122648. /**
  122649. * 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.
  122650. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122651. */
  122652. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  122653. /**
  122654. * Gets the name of the behavior.
  122655. */
  122656. get name(): string;
  122657. private _mode;
  122658. private _radiusScale;
  122659. private _positionScale;
  122660. private _defaultElevation;
  122661. private _elevationReturnTime;
  122662. private _elevationReturnWaitTime;
  122663. private _zoomStopsAnimation;
  122664. private _framingTime;
  122665. /**
  122666. * The easing function used by animations
  122667. */
  122668. static EasingFunction: ExponentialEase;
  122669. /**
  122670. * The easing mode used by animations
  122671. */
  122672. static EasingMode: number;
  122673. /**
  122674. * Sets the current mode used by the behavior
  122675. */
  122676. set mode(mode: number);
  122677. /**
  122678. * Gets current mode used by the behavior.
  122679. */
  122680. get mode(): number;
  122681. /**
  122682. * Sets the scale applied to the radius (1 by default)
  122683. */
  122684. set radiusScale(radius: number);
  122685. /**
  122686. * Gets the scale applied to the radius
  122687. */
  122688. get radiusScale(): number;
  122689. /**
  122690. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122691. */
  122692. set positionScale(scale: number);
  122693. /**
  122694. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  122695. */
  122696. get positionScale(): number;
  122697. /**
  122698. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122699. * behaviour is triggered, in radians.
  122700. */
  122701. set defaultElevation(elevation: number);
  122702. /**
  122703. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  122704. * behaviour is triggered, in radians.
  122705. */
  122706. get defaultElevation(): number;
  122707. /**
  122708. * Sets the time (in milliseconds) taken to return to the default beta position.
  122709. * Negative value indicates camera should not return to default.
  122710. */
  122711. set elevationReturnTime(speed: number);
  122712. /**
  122713. * Gets the time (in milliseconds) taken to return to the default beta position.
  122714. * Negative value indicates camera should not return to default.
  122715. */
  122716. get elevationReturnTime(): number;
  122717. /**
  122718. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122719. */
  122720. set elevationReturnWaitTime(time: number);
  122721. /**
  122722. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  122723. */
  122724. get elevationReturnWaitTime(): number;
  122725. /**
  122726. * Sets the flag that indicates if user zooming should stop animation.
  122727. */
  122728. set zoomStopsAnimation(flag: boolean);
  122729. /**
  122730. * Gets the flag that indicates if user zooming should stop animation.
  122731. */
  122732. get zoomStopsAnimation(): boolean;
  122733. /**
  122734. * Sets the transition time when framing the mesh, in milliseconds
  122735. */
  122736. set framingTime(time: number);
  122737. /**
  122738. * Gets the transition time when framing the mesh, in milliseconds
  122739. */
  122740. get framingTime(): number;
  122741. /**
  122742. * Define if the behavior should automatically change the configured
  122743. * camera limits and sensibilities.
  122744. */
  122745. autoCorrectCameraLimitsAndSensibility: boolean;
  122746. private _onPrePointerObservableObserver;
  122747. private _onAfterCheckInputsObserver;
  122748. private _onMeshTargetChangedObserver;
  122749. private _attachedCamera;
  122750. private _isPointerDown;
  122751. private _lastInteractionTime;
  122752. /**
  122753. * Initializes the behavior.
  122754. */
  122755. init(): void;
  122756. /**
  122757. * Attaches the behavior to its arc rotate camera.
  122758. * @param camera Defines the camera to attach the behavior to
  122759. */
  122760. attach(camera: ArcRotateCamera): void;
  122761. /**
  122762. * Detaches the behavior from its current arc rotate camera.
  122763. */
  122764. detach(): void;
  122765. private _animatables;
  122766. private _betaIsAnimating;
  122767. private _betaTransition;
  122768. private _radiusTransition;
  122769. private _vectorTransition;
  122770. /**
  122771. * Targets the given mesh and updates zoom level accordingly.
  122772. * @param mesh The mesh to target.
  122773. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122774. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122775. */
  122776. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122777. /**
  122778. * Targets the given mesh with its children and updates zoom level accordingly.
  122779. * @param mesh The mesh to target.
  122780. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122781. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122782. */
  122783. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122784. /**
  122785. * Targets the given meshes with their children and updates zoom level accordingly.
  122786. * @param meshes The mesh to target.
  122787. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122788. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122789. */
  122790. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122791. /**
  122792. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  122793. * @param minimumWorld Determines the smaller position of the bounding box extend
  122794. * @param maximumWorld Determines the bigger position of the bounding box extend
  122795. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  122796. * @param onAnimationEnd Callback triggered at the end of the framing animation
  122797. */
  122798. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  122799. /**
  122800. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  122801. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  122802. * frustum width.
  122803. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  122804. * to fully enclose the mesh in the viewing frustum.
  122805. */
  122806. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  122807. /**
  122808. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  122809. * is automatically returned to its default position (expected to be above ground plane).
  122810. */
  122811. private _maintainCameraAboveGround;
  122812. /**
  122813. * Returns the frustum slope based on the canvas ratio and camera FOV
  122814. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  122815. */
  122816. private _getFrustumSlope;
  122817. /**
  122818. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  122819. */
  122820. private _clearAnimationLocks;
  122821. /**
  122822. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  122823. */
  122824. private _applyUserInteraction;
  122825. /**
  122826. * Stops and removes all animations that have been applied to the camera
  122827. */
  122828. stopAllAnimations(): void;
  122829. /**
  122830. * Gets a value indicating if the user is moving the camera
  122831. */
  122832. get isUserIsMoving(): boolean;
  122833. /**
  122834. * The camera can move all the way towards the mesh.
  122835. */
  122836. static IgnoreBoundsSizeMode: number;
  122837. /**
  122838. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  122839. */
  122840. static FitFrustumSidesMode: number;
  122841. }
  122842. }
  122843. declare module BABYLON {
  122844. /**
  122845. * Base class for Camera Pointer Inputs.
  122846. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  122847. * for example usage.
  122848. */
  122849. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  122850. /**
  122851. * Defines the camera the input is attached to.
  122852. */
  122853. abstract camera: Camera;
  122854. /**
  122855. * Whether keyboard modifier keys are pressed at time of last mouse event.
  122856. */
  122857. protected _altKey: boolean;
  122858. protected _ctrlKey: boolean;
  122859. protected _metaKey: boolean;
  122860. protected _shiftKey: boolean;
  122861. /**
  122862. * Which mouse buttons were pressed at time of last mouse event.
  122863. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  122864. */
  122865. protected _buttonsPressed: number;
  122866. /**
  122867. * Defines the buttons associated with the input to handle camera move.
  122868. */
  122869. buttons: number[];
  122870. /**
  122871. * Attach the input controls to a specific dom element to get the input from.
  122872. * @param element Defines the element the controls should be listened from
  122873. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  122874. */
  122875. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  122876. /**
  122877. * Detach the current controls from the specified dom element.
  122878. * @param element Defines the element to stop listening the inputs from
  122879. */
  122880. detachControl(element: Nullable<HTMLElement>): void;
  122881. /**
  122882. * Gets the class name of the current input.
  122883. * @returns the class name
  122884. */
  122885. getClassName(): string;
  122886. /**
  122887. * Get the friendly name associated with the input class.
  122888. * @returns the input friendly name
  122889. */
  122890. getSimpleName(): string;
  122891. /**
  122892. * Called on pointer POINTERDOUBLETAP event.
  122893. * Override this method to provide functionality on POINTERDOUBLETAP event.
  122894. */
  122895. protected onDoubleTap(type: string): void;
  122896. /**
  122897. * Called on pointer POINTERMOVE event if only a single touch is active.
  122898. * Override this method to provide functionality.
  122899. */
  122900. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  122901. /**
  122902. * Called on pointer POINTERMOVE event if multiple touches are active.
  122903. * Override this method to provide functionality.
  122904. */
  122905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  122906. /**
  122907. * Called on JS contextmenu event.
  122908. * Override this method to provide functionality.
  122909. */
  122910. protected onContextMenu(evt: PointerEvent): void;
  122911. /**
  122912. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  122913. * press.
  122914. * Override this method to provide functionality.
  122915. */
  122916. protected onButtonDown(evt: PointerEvent): void;
  122917. /**
  122918. * Called each time a new POINTERUP event occurs. Ie, for each button
  122919. * release.
  122920. * Override this method to provide functionality.
  122921. */
  122922. protected onButtonUp(evt: PointerEvent): void;
  122923. /**
  122924. * Called when window becomes inactive.
  122925. * Override this method to provide functionality.
  122926. */
  122927. protected onLostFocus(): void;
  122928. private _pointerInput;
  122929. private _observer;
  122930. private _onLostFocus;
  122931. private pointA;
  122932. private pointB;
  122933. }
  122934. }
  122935. declare module BABYLON {
  122936. /**
  122937. * Manage the pointers inputs to control an arc rotate camera.
  122938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  122939. */
  122940. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  122941. /**
  122942. * Defines the camera the input is attached to.
  122943. */
  122944. camera: ArcRotateCamera;
  122945. /**
  122946. * Gets the class name of the current input.
  122947. * @returns the class name
  122948. */
  122949. getClassName(): string;
  122950. /**
  122951. * Defines the buttons associated with the input to handle camera move.
  122952. */
  122953. buttons: number[];
  122954. /**
  122955. * Defines the pointer angular sensibility along the X axis or how fast is
  122956. * the camera rotating.
  122957. */
  122958. angularSensibilityX: number;
  122959. /**
  122960. * Defines the pointer angular sensibility along the Y axis or how fast is
  122961. * the camera rotating.
  122962. */
  122963. angularSensibilityY: number;
  122964. /**
  122965. * Defines the pointer pinch precision or how fast is the camera zooming.
  122966. */
  122967. pinchPrecision: number;
  122968. /**
  122969. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  122970. * from 0.
  122971. * It defines the percentage of current camera.radius to use as delta when
  122972. * pinch zoom is used.
  122973. */
  122974. pinchDeltaPercentage: number;
  122975. /**
  122976. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  122977. * that any object in the plane at the camera's target point will scale
  122978. * perfectly with finger motion.
  122979. * Overrides pinchDeltaPercentage and pinchPrecision.
  122980. */
  122981. useNaturalPinchZoom: boolean;
  122982. /**
  122983. * Defines the pointer panning sensibility or how fast is the camera moving.
  122984. */
  122985. panningSensibility: number;
  122986. /**
  122987. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  122988. */
  122989. multiTouchPanning: boolean;
  122990. /**
  122991. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  122992. * zoom (pinch) through multitouch.
  122993. */
  122994. multiTouchPanAndZoom: boolean;
  122995. /**
  122996. * Revers pinch action direction.
  122997. */
  122998. pinchInwards: boolean;
  122999. private _isPanClick;
  123000. private _twoFingerActivityCount;
  123001. private _isPinching;
  123002. /**
  123003. * Called on pointer POINTERMOVE event if only a single touch is active.
  123004. */
  123005. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123006. /**
  123007. * Called on pointer POINTERDOUBLETAP event.
  123008. */
  123009. protected onDoubleTap(type: string): void;
  123010. /**
  123011. * Called on pointer POINTERMOVE event if multiple touches are active.
  123012. */
  123013. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123014. /**
  123015. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123016. * press.
  123017. */
  123018. protected onButtonDown(evt: PointerEvent): void;
  123019. /**
  123020. * Called each time a new POINTERUP event occurs. Ie, for each button
  123021. * release.
  123022. */
  123023. protected onButtonUp(evt: PointerEvent): void;
  123024. /**
  123025. * Called when window becomes inactive.
  123026. */
  123027. protected onLostFocus(): void;
  123028. }
  123029. }
  123030. declare module BABYLON {
  123031. /**
  123032. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123033. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123034. */
  123035. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123036. /**
  123037. * Defines the camera the input is attached to.
  123038. */
  123039. camera: ArcRotateCamera;
  123040. /**
  123041. * Defines the list of key codes associated with the up action (increase alpha)
  123042. */
  123043. keysUp: number[];
  123044. /**
  123045. * Defines the list of key codes associated with the down action (decrease alpha)
  123046. */
  123047. keysDown: number[];
  123048. /**
  123049. * Defines the list of key codes associated with the left action (increase beta)
  123050. */
  123051. keysLeft: number[];
  123052. /**
  123053. * Defines the list of key codes associated with the right action (decrease beta)
  123054. */
  123055. keysRight: number[];
  123056. /**
  123057. * Defines the list of key codes associated with the reset action.
  123058. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123059. */
  123060. keysReset: number[];
  123061. /**
  123062. * Defines the panning sensibility of the inputs.
  123063. * (How fast is the camera panning)
  123064. */
  123065. panningSensibility: number;
  123066. /**
  123067. * Defines the zooming sensibility of the inputs.
  123068. * (How fast is the camera zooming)
  123069. */
  123070. zoomingSensibility: number;
  123071. /**
  123072. * Defines whether maintaining the alt key down switch the movement mode from
  123073. * orientation to zoom.
  123074. */
  123075. useAltToZoom: boolean;
  123076. /**
  123077. * Rotation speed of the camera
  123078. */
  123079. angularSpeed: number;
  123080. private _keys;
  123081. private _ctrlPressed;
  123082. private _altPressed;
  123083. private _onCanvasBlurObserver;
  123084. private _onKeyboardObserver;
  123085. private _engine;
  123086. private _scene;
  123087. /**
  123088. * Attach the input controls to a specific dom element to get the input from.
  123089. * @param element Defines the element the controls should be listened from
  123090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123091. */
  123092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123093. /**
  123094. * Detach the current controls from the specified dom element.
  123095. * @param element Defines the element to stop listening the inputs from
  123096. */
  123097. detachControl(element: Nullable<HTMLElement>): void;
  123098. /**
  123099. * Update the current camera state depending on the inputs that have been used this frame.
  123100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123101. */
  123102. checkInputs(): void;
  123103. /**
  123104. * Gets the class name of the current intput.
  123105. * @returns the class name
  123106. */
  123107. getClassName(): string;
  123108. /**
  123109. * Get the friendly name associated with the input class.
  123110. * @returns the input friendly name
  123111. */
  123112. getSimpleName(): string;
  123113. }
  123114. }
  123115. declare module BABYLON {
  123116. /**
  123117. * Manage the mouse wheel inputs to control an arc rotate camera.
  123118. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123119. */
  123120. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123121. /**
  123122. * Defines the camera the input is attached to.
  123123. */
  123124. camera: ArcRotateCamera;
  123125. /**
  123126. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123127. */
  123128. wheelPrecision: number;
  123129. /**
  123130. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123131. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123132. */
  123133. wheelDeltaPercentage: number;
  123134. private _wheel;
  123135. private _observer;
  123136. private computeDeltaFromMouseWheelLegacyEvent;
  123137. /**
  123138. * Attach the input controls to a specific dom element to get the input from.
  123139. * @param element Defines the element the controls should be listened from
  123140. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123141. */
  123142. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123143. /**
  123144. * Detach the current controls from the specified dom element.
  123145. * @param element Defines the element to stop listening the inputs from
  123146. */
  123147. detachControl(element: Nullable<HTMLElement>): void;
  123148. /**
  123149. * Gets the class name of the current intput.
  123150. * @returns the class name
  123151. */
  123152. getClassName(): string;
  123153. /**
  123154. * Get the friendly name associated with the input class.
  123155. * @returns the input friendly name
  123156. */
  123157. getSimpleName(): string;
  123158. }
  123159. }
  123160. declare module BABYLON {
  123161. /**
  123162. * Default Inputs manager for the ArcRotateCamera.
  123163. * It groups all the default supported inputs for ease of use.
  123164. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123165. */
  123166. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123167. /**
  123168. * Instantiates a new ArcRotateCameraInputsManager.
  123169. * @param camera Defines the camera the inputs belong to
  123170. */
  123171. constructor(camera: ArcRotateCamera);
  123172. /**
  123173. * Add mouse wheel input support to the input manager.
  123174. * @returns the current input manager
  123175. */
  123176. addMouseWheel(): ArcRotateCameraInputsManager;
  123177. /**
  123178. * Add pointers input support to the input manager.
  123179. * @returns the current input manager
  123180. */
  123181. addPointers(): ArcRotateCameraInputsManager;
  123182. /**
  123183. * Add keyboard input support to the input manager.
  123184. * @returns the current input manager
  123185. */
  123186. addKeyboard(): ArcRotateCameraInputsManager;
  123187. }
  123188. }
  123189. declare module BABYLON {
  123190. /**
  123191. * This represents an orbital type of camera.
  123192. *
  123193. * 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.
  123194. * 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.
  123195. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123196. */
  123197. export class ArcRotateCamera extends TargetCamera {
  123198. /**
  123199. * Defines the rotation angle of the camera along the longitudinal axis.
  123200. */
  123201. alpha: number;
  123202. /**
  123203. * Defines the rotation angle of the camera along the latitudinal axis.
  123204. */
  123205. beta: number;
  123206. /**
  123207. * Defines the radius of the camera from it s target point.
  123208. */
  123209. radius: number;
  123210. protected _target: Vector3;
  123211. protected _targetHost: Nullable<AbstractMesh>;
  123212. /**
  123213. * Defines the target point of the camera.
  123214. * The camera looks towards it form the radius distance.
  123215. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123216. */
  123217. get target(): Vector3;
  123218. set target(value: Vector3);
  123219. /**
  123220. * Define the current local position of the camera in the scene
  123221. */
  123222. get position(): Vector3;
  123223. set position(newPosition: Vector3);
  123224. protected _upToYMatrix: Matrix;
  123225. protected _YToUpMatrix: Matrix;
  123226. /**
  123227. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123228. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123229. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123230. */
  123231. set upVector(vec: Vector3);
  123232. get upVector(): Vector3;
  123233. /**
  123234. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123235. */
  123236. setMatUp(): void;
  123237. /**
  123238. * Current inertia value on the longitudinal axis.
  123239. * The bigger this number the longer it will take for the camera to stop.
  123240. */
  123241. inertialAlphaOffset: number;
  123242. /**
  123243. * Current inertia value on the latitudinal axis.
  123244. * The bigger this number the longer it will take for the camera to stop.
  123245. */
  123246. inertialBetaOffset: number;
  123247. /**
  123248. * Current inertia value on the radius axis.
  123249. * The bigger this number the longer it will take for the camera to stop.
  123250. */
  123251. inertialRadiusOffset: number;
  123252. /**
  123253. * Minimum allowed angle on the longitudinal axis.
  123254. * This can help limiting how the Camera is able to move in the scene.
  123255. */
  123256. lowerAlphaLimit: Nullable<number>;
  123257. /**
  123258. * Maximum allowed angle on the longitudinal axis.
  123259. * This can help limiting how the Camera is able to move in the scene.
  123260. */
  123261. upperAlphaLimit: Nullable<number>;
  123262. /**
  123263. * Minimum allowed angle on the latitudinal axis.
  123264. * This can help limiting how the Camera is able to move in the scene.
  123265. */
  123266. lowerBetaLimit: number;
  123267. /**
  123268. * Maximum allowed angle on the latitudinal axis.
  123269. * This can help limiting how the Camera is able to move in the scene.
  123270. */
  123271. upperBetaLimit: number;
  123272. /**
  123273. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123274. * This can help limiting how the Camera is able to move in the scene.
  123275. */
  123276. lowerRadiusLimit: Nullable<number>;
  123277. /**
  123278. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123279. * This can help limiting how the Camera is able to move in the scene.
  123280. */
  123281. upperRadiusLimit: Nullable<number>;
  123282. /**
  123283. * Defines the current inertia value used during panning of the camera along the X axis.
  123284. */
  123285. inertialPanningX: number;
  123286. /**
  123287. * Defines the current inertia value used during panning of the camera along the Y axis.
  123288. */
  123289. inertialPanningY: number;
  123290. /**
  123291. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123292. * Basically if your fingers moves away from more than this distance you will be considered
  123293. * in pinch mode.
  123294. */
  123295. pinchToPanMaxDistance: number;
  123296. /**
  123297. * Defines the maximum distance the camera can pan.
  123298. * This could help keeping the cammera always in your scene.
  123299. */
  123300. panningDistanceLimit: Nullable<number>;
  123301. /**
  123302. * Defines the target of the camera before paning.
  123303. */
  123304. panningOriginTarget: Vector3;
  123305. /**
  123306. * Defines the value of the inertia used during panning.
  123307. * 0 would mean stop inertia and one would mean no decelleration at all.
  123308. */
  123309. panningInertia: number;
  123310. /**
  123311. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123312. */
  123313. get angularSensibilityX(): number;
  123314. set angularSensibilityX(value: number);
  123315. /**
  123316. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123317. */
  123318. get angularSensibilityY(): number;
  123319. set angularSensibilityY(value: number);
  123320. /**
  123321. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123322. */
  123323. get pinchPrecision(): number;
  123324. set pinchPrecision(value: number);
  123325. /**
  123326. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123327. * It will be used instead of pinchDeltaPrecision if different from 0.
  123328. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123329. */
  123330. get pinchDeltaPercentage(): number;
  123331. set pinchDeltaPercentage(value: number);
  123332. /**
  123333. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123334. * and pinch delta percentage.
  123335. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123336. * that any object in the plane at the camera's target point will scale
  123337. * perfectly with finger motion.
  123338. */
  123339. get useNaturalPinchZoom(): boolean;
  123340. set useNaturalPinchZoom(value: boolean);
  123341. /**
  123342. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123343. */
  123344. get panningSensibility(): number;
  123345. set panningSensibility(value: number);
  123346. /**
  123347. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123348. */
  123349. get keysUp(): number[];
  123350. set keysUp(value: number[]);
  123351. /**
  123352. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123353. */
  123354. get keysDown(): number[];
  123355. set keysDown(value: number[]);
  123356. /**
  123357. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123358. */
  123359. get keysLeft(): number[];
  123360. set keysLeft(value: number[]);
  123361. /**
  123362. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123363. */
  123364. get keysRight(): number[];
  123365. set keysRight(value: number[]);
  123366. /**
  123367. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123368. */
  123369. get wheelPrecision(): number;
  123370. set wheelPrecision(value: number);
  123371. /**
  123372. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123373. * It will be used instead of pinchDeltaPrecision if different from 0.
  123374. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123375. */
  123376. get wheelDeltaPercentage(): number;
  123377. set wheelDeltaPercentage(value: number);
  123378. /**
  123379. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123380. */
  123381. zoomOnFactor: number;
  123382. /**
  123383. * Defines a screen offset for the camera position.
  123384. */
  123385. targetScreenOffset: Vector2;
  123386. /**
  123387. * Allows the camera to be completely reversed.
  123388. * If false the camera can not arrive upside down.
  123389. */
  123390. allowUpsideDown: boolean;
  123391. /**
  123392. * Define if double tap/click is used to restore the previously saved state of the camera.
  123393. */
  123394. useInputToRestoreState: boolean;
  123395. /** @hidden */
  123396. _viewMatrix: Matrix;
  123397. /** @hidden */
  123398. _useCtrlForPanning: boolean;
  123399. /** @hidden */
  123400. _panningMouseButton: number;
  123401. /**
  123402. * Defines the input associated to the camera.
  123403. */
  123404. inputs: ArcRotateCameraInputsManager;
  123405. /** @hidden */
  123406. _reset: () => void;
  123407. /**
  123408. * Defines the allowed panning axis.
  123409. */
  123410. panningAxis: Vector3;
  123411. protected _localDirection: Vector3;
  123412. protected _transformedDirection: Vector3;
  123413. private _bouncingBehavior;
  123414. /**
  123415. * Gets the bouncing behavior of the camera if it has been enabled.
  123416. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123417. */
  123418. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123419. /**
  123420. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123421. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123422. */
  123423. get useBouncingBehavior(): boolean;
  123424. set useBouncingBehavior(value: boolean);
  123425. private _framingBehavior;
  123426. /**
  123427. * Gets the framing behavior of the camera if it has been enabled.
  123428. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123429. */
  123430. get framingBehavior(): Nullable<FramingBehavior>;
  123431. /**
  123432. * Defines if the framing behavior of the camera is enabled on the camera.
  123433. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123434. */
  123435. get useFramingBehavior(): boolean;
  123436. set useFramingBehavior(value: boolean);
  123437. private _autoRotationBehavior;
  123438. /**
  123439. * Gets the auto rotation behavior of the camera if it has been enabled.
  123440. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123441. */
  123442. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123443. /**
  123444. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123445. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123446. */
  123447. get useAutoRotationBehavior(): boolean;
  123448. set useAutoRotationBehavior(value: boolean);
  123449. /**
  123450. * Observable triggered when the mesh target has been changed on the camera.
  123451. */
  123452. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123453. /**
  123454. * Event raised when the camera is colliding with a mesh.
  123455. */
  123456. onCollide: (collidedMesh: AbstractMesh) => void;
  123457. /**
  123458. * Defines whether the camera should check collision with the objects oh the scene.
  123459. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123460. */
  123461. checkCollisions: boolean;
  123462. /**
  123463. * Defines the collision radius of the camera.
  123464. * This simulates a sphere around the camera.
  123465. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123466. */
  123467. collisionRadius: Vector3;
  123468. protected _collider: Collider;
  123469. protected _previousPosition: Vector3;
  123470. protected _collisionVelocity: Vector3;
  123471. protected _newPosition: Vector3;
  123472. protected _previousAlpha: number;
  123473. protected _previousBeta: number;
  123474. protected _previousRadius: number;
  123475. protected _collisionTriggered: boolean;
  123476. protected _targetBoundingCenter: Nullable<Vector3>;
  123477. private _computationVector;
  123478. /**
  123479. * Instantiates a new ArcRotateCamera in a given scene
  123480. * @param name Defines the name of the camera
  123481. * @param alpha Defines the camera rotation along the logitudinal axis
  123482. * @param beta Defines the camera rotation along the latitudinal axis
  123483. * @param radius Defines the camera distance from its target
  123484. * @param target Defines the camera target
  123485. * @param scene Defines the scene the camera belongs to
  123486. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123487. */
  123488. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123489. /** @hidden */
  123490. _initCache(): void;
  123491. /** @hidden */
  123492. _updateCache(ignoreParentClass?: boolean): void;
  123493. protected _getTargetPosition(): Vector3;
  123494. private _storedAlpha;
  123495. private _storedBeta;
  123496. private _storedRadius;
  123497. private _storedTarget;
  123498. private _storedTargetScreenOffset;
  123499. /**
  123500. * Stores the current state of the camera (alpha, beta, radius and target)
  123501. * @returns the camera itself
  123502. */
  123503. storeState(): Camera;
  123504. /**
  123505. * @hidden
  123506. * Restored camera state. You must call storeState() first
  123507. */
  123508. _restoreStateValues(): boolean;
  123509. /** @hidden */
  123510. _isSynchronizedViewMatrix(): boolean;
  123511. /**
  123512. * Attached controls to the current camera.
  123513. * @param element Defines the element the controls should be listened from
  123514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123515. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123516. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123517. */
  123518. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123519. /**
  123520. * Detach the current controls from the camera.
  123521. * The camera will stop reacting to inputs.
  123522. * @param element Defines the element to stop listening the inputs from
  123523. */
  123524. detachControl(element: HTMLElement): void;
  123525. /** @hidden */
  123526. _checkInputs(): void;
  123527. protected _checkLimits(): void;
  123528. /**
  123529. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123530. */
  123531. rebuildAnglesAndRadius(): void;
  123532. /**
  123533. * Use a position to define the current camera related information like alpha, beta and radius
  123534. * @param position Defines the position to set the camera at
  123535. */
  123536. setPosition(position: Vector3): void;
  123537. /**
  123538. * Defines the target the camera should look at.
  123539. * This will automatically adapt alpha beta and radius to fit within the new target.
  123540. * @param target Defines the new target as a Vector or a mesh
  123541. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123542. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123543. */
  123544. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123545. /** @hidden */
  123546. _getViewMatrix(): Matrix;
  123547. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123548. /**
  123549. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123550. * @param meshes Defines the mesh to zoom on
  123551. * @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)
  123552. */
  123553. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123554. /**
  123555. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123556. * The target will be changed but the radius
  123557. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123558. * @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)
  123559. */
  123560. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123561. min: Vector3;
  123562. max: Vector3;
  123563. distance: number;
  123564. }, doNotUpdateMaxZ?: boolean): void;
  123565. /**
  123566. * @override
  123567. * Override Camera.createRigCamera
  123568. */
  123569. createRigCamera(name: string, cameraIndex: number): Camera;
  123570. /**
  123571. * @hidden
  123572. * @override
  123573. * Override Camera._updateRigCameras
  123574. */
  123575. _updateRigCameras(): void;
  123576. /**
  123577. * Destroy the camera and release the current resources hold by it.
  123578. */
  123579. dispose(): void;
  123580. /**
  123581. * Gets the current object class name.
  123582. * @return the class name
  123583. */
  123584. getClassName(): string;
  123585. }
  123586. }
  123587. declare module BABYLON {
  123588. /**
  123589. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123590. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123591. */
  123592. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123593. /**
  123594. * Gets the name of the behavior.
  123595. */
  123596. get name(): string;
  123597. private _zoomStopsAnimation;
  123598. private _idleRotationSpeed;
  123599. private _idleRotationWaitTime;
  123600. private _idleRotationSpinupTime;
  123601. /**
  123602. * Sets the flag that indicates if user zooming should stop animation.
  123603. */
  123604. set zoomStopsAnimation(flag: boolean);
  123605. /**
  123606. * Gets the flag that indicates if user zooming should stop animation.
  123607. */
  123608. get zoomStopsAnimation(): boolean;
  123609. /**
  123610. * Sets the default speed at which the camera rotates around the model.
  123611. */
  123612. set idleRotationSpeed(speed: number);
  123613. /**
  123614. * Gets the default speed at which the camera rotates around the model.
  123615. */
  123616. get idleRotationSpeed(): number;
  123617. /**
  123618. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123619. */
  123620. set idleRotationWaitTime(time: number);
  123621. /**
  123622. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123623. */
  123624. get idleRotationWaitTime(): number;
  123625. /**
  123626. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123627. */
  123628. set idleRotationSpinupTime(time: number);
  123629. /**
  123630. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123631. */
  123632. get idleRotationSpinupTime(): number;
  123633. /**
  123634. * Gets a value indicating if the camera is currently rotating because of this behavior
  123635. */
  123636. get rotationInProgress(): boolean;
  123637. private _onPrePointerObservableObserver;
  123638. private _onAfterCheckInputsObserver;
  123639. private _attachedCamera;
  123640. private _isPointerDown;
  123641. private _lastFrameTime;
  123642. private _lastInteractionTime;
  123643. private _cameraRotationSpeed;
  123644. /**
  123645. * Initializes the behavior.
  123646. */
  123647. init(): void;
  123648. /**
  123649. * Attaches the behavior to its arc rotate camera.
  123650. * @param camera Defines the camera to attach the behavior to
  123651. */
  123652. attach(camera: ArcRotateCamera): void;
  123653. /**
  123654. * Detaches the behavior from its current arc rotate camera.
  123655. */
  123656. detach(): void;
  123657. /**
  123658. * Returns true if user is scrolling.
  123659. * @return true if user is scrolling.
  123660. */
  123661. private _userIsZooming;
  123662. private _lastFrameRadius;
  123663. private _shouldAnimationStopForInteraction;
  123664. /**
  123665. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123666. */
  123667. private _applyUserInteraction;
  123668. private _userIsMoving;
  123669. }
  123670. }
  123671. declare module BABYLON {
  123672. /**
  123673. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  123674. */
  123675. export class AttachToBoxBehavior implements Behavior<Mesh> {
  123676. private ui;
  123677. /**
  123678. * The name of the behavior
  123679. */
  123680. name: string;
  123681. /**
  123682. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  123683. */
  123684. distanceAwayFromFace: number;
  123685. /**
  123686. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  123687. */
  123688. distanceAwayFromBottomOfFace: number;
  123689. private _faceVectors;
  123690. private _target;
  123691. private _scene;
  123692. private _onRenderObserver;
  123693. private _tmpMatrix;
  123694. private _tmpVector;
  123695. /**
  123696. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  123697. * @param ui The transform node that should be attched to the mesh
  123698. */
  123699. constructor(ui: TransformNode);
  123700. /**
  123701. * Initializes the behavior
  123702. */
  123703. init(): void;
  123704. private _closestFace;
  123705. private _zeroVector;
  123706. private _lookAtTmpMatrix;
  123707. private _lookAtToRef;
  123708. /**
  123709. * Attaches the AttachToBoxBehavior to the passed in mesh
  123710. * @param target The mesh that the specified node will be attached to
  123711. */
  123712. attach(target: Mesh): void;
  123713. /**
  123714. * Detaches the behavior from the mesh
  123715. */
  123716. detach(): void;
  123717. }
  123718. }
  123719. declare module BABYLON {
  123720. /**
  123721. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  123722. */
  123723. export class FadeInOutBehavior implements Behavior<Mesh> {
  123724. /**
  123725. * Time in milliseconds to delay before fading in (Default: 0)
  123726. */
  123727. delay: number;
  123728. /**
  123729. * Time in milliseconds for the mesh to fade in (Default: 300)
  123730. */
  123731. fadeInTime: number;
  123732. private _millisecondsPerFrame;
  123733. private _hovered;
  123734. private _hoverValue;
  123735. private _ownerNode;
  123736. /**
  123737. * Instatiates the FadeInOutBehavior
  123738. */
  123739. constructor();
  123740. /**
  123741. * The name of the behavior
  123742. */
  123743. get name(): string;
  123744. /**
  123745. * Initializes the behavior
  123746. */
  123747. init(): void;
  123748. /**
  123749. * Attaches the fade behavior on the passed in mesh
  123750. * @param ownerNode The mesh that will be faded in/out once attached
  123751. */
  123752. attach(ownerNode: Mesh): void;
  123753. /**
  123754. * Detaches the behavior from the mesh
  123755. */
  123756. detach(): void;
  123757. /**
  123758. * Triggers the mesh to begin fading in or out
  123759. * @param value if the object should fade in or out (true to fade in)
  123760. */
  123761. fadeIn(value: boolean): void;
  123762. private _update;
  123763. private _setAllVisibility;
  123764. }
  123765. }
  123766. declare module BABYLON {
  123767. /**
  123768. * Class containing a set of static utilities functions for managing Pivots
  123769. * @hidden
  123770. */
  123771. export class PivotTools {
  123772. private static _PivotCached;
  123773. private static _OldPivotPoint;
  123774. private static _PivotTranslation;
  123775. private static _PivotTmpVector;
  123776. private static _PivotPostMultiplyPivotMatrix;
  123777. /** @hidden */
  123778. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  123779. /** @hidden */
  123780. static _RestorePivotPoint(mesh: AbstractMesh): void;
  123781. }
  123782. }
  123783. declare module BABYLON {
  123784. /**
  123785. * Class containing static functions to help procedurally build meshes
  123786. */
  123787. export class PlaneBuilder {
  123788. /**
  123789. * Creates a plane mesh
  123790. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123791. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123792. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123794. * * 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
  123795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123796. * @param name defines the name of the mesh
  123797. * @param options defines the options used to create the mesh
  123798. * @param scene defines the hosting scene
  123799. * @returns the plane mesh
  123800. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123801. */
  123802. static CreatePlane(name: string, options: {
  123803. size?: number;
  123804. width?: number;
  123805. height?: number;
  123806. sideOrientation?: number;
  123807. frontUVs?: Vector4;
  123808. backUVs?: Vector4;
  123809. updatable?: boolean;
  123810. sourcePlane?: Plane;
  123811. }, scene?: Nullable<Scene>): Mesh;
  123812. }
  123813. }
  123814. declare module BABYLON {
  123815. /**
  123816. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  123817. */
  123818. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  123819. private static _AnyMouseID;
  123820. /**
  123821. * Abstract mesh the behavior is set on
  123822. */
  123823. attachedNode: AbstractMesh;
  123824. private _dragPlane;
  123825. private _scene;
  123826. private _pointerObserver;
  123827. private _beforeRenderObserver;
  123828. private static _planeScene;
  123829. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  123830. /**
  123831. * 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)
  123832. */
  123833. maxDragAngle: number;
  123834. /**
  123835. * @hidden
  123836. */
  123837. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  123838. /**
  123839. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  123840. */
  123841. currentDraggingPointerID: number;
  123842. /**
  123843. * The last position where the pointer hit the drag plane in world space
  123844. */
  123845. lastDragPosition: Vector3;
  123846. /**
  123847. * If the behavior is currently in a dragging state
  123848. */
  123849. dragging: boolean;
  123850. /**
  123851. * 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)
  123852. */
  123853. dragDeltaRatio: number;
  123854. /**
  123855. * If the drag plane orientation should be updated during the dragging (Default: true)
  123856. */
  123857. updateDragPlane: boolean;
  123858. private _debugMode;
  123859. private _moving;
  123860. /**
  123861. * Fires each time the attached mesh is dragged with the pointer
  123862. * * delta between last drag position and current drag position in world space
  123863. * * dragDistance along the drag axis
  123864. * * dragPlaneNormal normal of the current drag plane used during the drag
  123865. * * dragPlanePoint in world space where the drag intersects the drag plane
  123866. */
  123867. onDragObservable: Observable<{
  123868. delta: Vector3;
  123869. dragPlanePoint: Vector3;
  123870. dragPlaneNormal: Vector3;
  123871. dragDistance: number;
  123872. pointerId: number;
  123873. }>;
  123874. /**
  123875. * Fires each time a drag begins (eg. mouse down on mesh)
  123876. */
  123877. onDragStartObservable: Observable<{
  123878. dragPlanePoint: Vector3;
  123879. pointerId: number;
  123880. }>;
  123881. /**
  123882. * Fires each time a drag ends (eg. mouse release after drag)
  123883. */
  123884. onDragEndObservable: Observable<{
  123885. dragPlanePoint: Vector3;
  123886. pointerId: number;
  123887. }>;
  123888. /**
  123889. * If the attached mesh should be moved when dragged
  123890. */
  123891. moveAttached: boolean;
  123892. /**
  123893. * If the drag behavior will react to drag events (Default: true)
  123894. */
  123895. enabled: boolean;
  123896. /**
  123897. * If pointer events should start and release the drag (Default: true)
  123898. */
  123899. startAndReleaseDragOnPointerEvents: boolean;
  123900. /**
  123901. * If camera controls should be detached during the drag
  123902. */
  123903. detachCameraControls: boolean;
  123904. /**
  123905. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  123906. */
  123907. useObjectOrientationForDragging: boolean;
  123908. private _options;
  123909. /**
  123910. * Gets the options used by the behavior
  123911. */
  123912. get options(): {
  123913. dragAxis?: Vector3;
  123914. dragPlaneNormal?: Vector3;
  123915. };
  123916. /**
  123917. * Sets the options used by the behavior
  123918. */
  123919. set options(options: {
  123920. dragAxis?: Vector3;
  123921. dragPlaneNormal?: Vector3;
  123922. });
  123923. /**
  123924. * Creates a pointer drag behavior that can be attached to a mesh
  123925. * @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)
  123926. */
  123927. constructor(options?: {
  123928. dragAxis?: Vector3;
  123929. dragPlaneNormal?: Vector3;
  123930. });
  123931. /**
  123932. * Predicate to determine if it is valid to move the object to a new position when it is moved
  123933. */
  123934. validateDrag: (targetPosition: Vector3) => boolean;
  123935. /**
  123936. * The name of the behavior
  123937. */
  123938. get name(): string;
  123939. /**
  123940. * Initializes the behavior
  123941. */
  123942. init(): void;
  123943. private _tmpVector;
  123944. private _alternatePickedPoint;
  123945. private _worldDragAxis;
  123946. private _targetPosition;
  123947. private _attachedElement;
  123948. /**
  123949. * Attaches the drag behavior the passed in mesh
  123950. * @param ownerNode The mesh that will be dragged around once attached
  123951. * @param predicate Predicate to use for pick filtering
  123952. */
  123953. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  123954. /**
  123955. * Force relase the drag action by code.
  123956. */
  123957. releaseDrag(): void;
  123958. private _startDragRay;
  123959. private _lastPointerRay;
  123960. /**
  123961. * Simulates the start of a pointer drag event on the behavior
  123962. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  123963. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  123964. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  123965. */
  123966. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123967. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  123968. private _dragDelta;
  123969. protected _moveDrag(ray: Ray): void;
  123970. private _pickWithRayOnDragPlane;
  123971. private _pointA;
  123972. private _pointC;
  123973. private _localAxis;
  123974. private _lookAt;
  123975. private _updateDragPlanePosition;
  123976. /**
  123977. * Detaches the behavior from the mesh
  123978. */
  123979. detach(): void;
  123980. }
  123981. }
  123982. declare module BABYLON {
  123983. /**
  123984. * A behavior that when attached to a mesh will allow the mesh to be scaled
  123985. */
  123986. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  123987. private _dragBehaviorA;
  123988. private _dragBehaviorB;
  123989. private _startDistance;
  123990. private _initialScale;
  123991. private _targetScale;
  123992. private _ownerNode;
  123993. private _sceneRenderObserver;
  123994. /**
  123995. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  123996. */
  123997. constructor();
  123998. /**
  123999. * The name of the behavior
  124000. */
  124001. get name(): string;
  124002. /**
  124003. * Initializes the behavior
  124004. */
  124005. init(): void;
  124006. private _getCurrentDistance;
  124007. /**
  124008. * Attaches the scale behavior the passed in mesh
  124009. * @param ownerNode The mesh that will be scaled around once attached
  124010. */
  124011. attach(ownerNode: Mesh): void;
  124012. /**
  124013. * Detaches the behavior from the mesh
  124014. */
  124015. detach(): void;
  124016. }
  124017. }
  124018. declare module BABYLON {
  124019. /**
  124020. * 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
  124021. */
  124022. export class SixDofDragBehavior implements Behavior<Mesh> {
  124023. private static _virtualScene;
  124024. private _ownerNode;
  124025. private _sceneRenderObserver;
  124026. private _scene;
  124027. private _targetPosition;
  124028. private _virtualOriginMesh;
  124029. private _virtualDragMesh;
  124030. private _pointerObserver;
  124031. private _moving;
  124032. private _startingOrientation;
  124033. private _attachedElement;
  124034. /**
  124035. * 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)
  124036. */
  124037. private zDragFactor;
  124038. /**
  124039. * If the object should rotate to face the drag origin
  124040. */
  124041. rotateDraggedObject: boolean;
  124042. /**
  124043. * If the behavior is currently in a dragging state
  124044. */
  124045. dragging: boolean;
  124046. /**
  124047. * 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)
  124048. */
  124049. dragDeltaRatio: number;
  124050. /**
  124051. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124052. */
  124053. currentDraggingPointerID: number;
  124054. /**
  124055. * If camera controls should be detached during the drag
  124056. */
  124057. detachCameraControls: boolean;
  124058. /**
  124059. * Fires each time a drag starts
  124060. */
  124061. onDragStartObservable: Observable<{}>;
  124062. /**
  124063. * Fires each time a drag ends (eg. mouse release after drag)
  124064. */
  124065. onDragEndObservable: Observable<{}>;
  124066. /**
  124067. * 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
  124068. */
  124069. constructor();
  124070. /**
  124071. * The name of the behavior
  124072. */
  124073. get name(): string;
  124074. /**
  124075. * Initializes the behavior
  124076. */
  124077. init(): void;
  124078. /**
  124079. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124080. */
  124081. private get _pointerCamera();
  124082. /**
  124083. * Attaches the scale behavior the passed in mesh
  124084. * @param ownerNode The mesh that will be scaled around once attached
  124085. */
  124086. attach(ownerNode: Mesh): void;
  124087. /**
  124088. * Detaches the behavior from the mesh
  124089. */
  124090. detach(): void;
  124091. }
  124092. }
  124093. declare module BABYLON {
  124094. /**
  124095. * Class used to apply inverse kinematics to bones
  124096. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124097. */
  124098. export class BoneIKController {
  124099. private static _tmpVecs;
  124100. private static _tmpQuat;
  124101. private static _tmpMats;
  124102. /**
  124103. * Gets or sets the target mesh
  124104. */
  124105. targetMesh: AbstractMesh;
  124106. /** Gets or sets the mesh used as pole */
  124107. poleTargetMesh: AbstractMesh;
  124108. /**
  124109. * Gets or sets the bone used as pole
  124110. */
  124111. poleTargetBone: Nullable<Bone>;
  124112. /**
  124113. * Gets or sets the target position
  124114. */
  124115. targetPosition: Vector3;
  124116. /**
  124117. * Gets or sets the pole target position
  124118. */
  124119. poleTargetPosition: Vector3;
  124120. /**
  124121. * Gets or sets the pole target local offset
  124122. */
  124123. poleTargetLocalOffset: Vector3;
  124124. /**
  124125. * Gets or sets the pole angle
  124126. */
  124127. poleAngle: number;
  124128. /**
  124129. * Gets or sets the mesh associated with the controller
  124130. */
  124131. mesh: AbstractMesh;
  124132. /**
  124133. * 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)
  124134. */
  124135. slerpAmount: number;
  124136. private _bone1Quat;
  124137. private _bone1Mat;
  124138. private _bone2Ang;
  124139. private _bone1;
  124140. private _bone2;
  124141. private _bone1Length;
  124142. private _bone2Length;
  124143. private _maxAngle;
  124144. private _maxReach;
  124145. private _rightHandedSystem;
  124146. private _bendAxis;
  124147. private _slerping;
  124148. private _adjustRoll;
  124149. /**
  124150. * Gets or sets maximum allowed angle
  124151. */
  124152. get maxAngle(): number;
  124153. set maxAngle(value: number);
  124154. /**
  124155. * Creates a new BoneIKController
  124156. * @param mesh defines the mesh to control
  124157. * @param bone defines the bone to control
  124158. * @param options defines options to set up the controller
  124159. */
  124160. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124161. targetMesh?: AbstractMesh;
  124162. poleTargetMesh?: AbstractMesh;
  124163. poleTargetBone?: Bone;
  124164. poleTargetLocalOffset?: Vector3;
  124165. poleAngle?: number;
  124166. bendAxis?: Vector3;
  124167. maxAngle?: number;
  124168. slerpAmount?: number;
  124169. });
  124170. private _setMaxAngle;
  124171. /**
  124172. * Force the controller to update the bones
  124173. */
  124174. update(): void;
  124175. }
  124176. }
  124177. declare module BABYLON {
  124178. /**
  124179. * Class used to make a bone look toward a point in space
  124180. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124181. */
  124182. export class BoneLookController {
  124183. private static _tmpVecs;
  124184. private static _tmpQuat;
  124185. private static _tmpMats;
  124186. /**
  124187. * The target Vector3 that the bone will look at
  124188. */
  124189. target: Vector3;
  124190. /**
  124191. * The mesh that the bone is attached to
  124192. */
  124193. mesh: AbstractMesh;
  124194. /**
  124195. * The bone that will be looking to the target
  124196. */
  124197. bone: Bone;
  124198. /**
  124199. * The up axis of the coordinate system that is used when the bone is rotated
  124200. */
  124201. upAxis: Vector3;
  124202. /**
  124203. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124204. */
  124205. upAxisSpace: Space;
  124206. /**
  124207. * Used to make an adjustment to the yaw of the bone
  124208. */
  124209. adjustYaw: number;
  124210. /**
  124211. * Used to make an adjustment to the pitch of the bone
  124212. */
  124213. adjustPitch: number;
  124214. /**
  124215. * Used to make an adjustment to the roll of the bone
  124216. */
  124217. adjustRoll: number;
  124218. /**
  124219. * 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)
  124220. */
  124221. slerpAmount: number;
  124222. private _minYaw;
  124223. private _maxYaw;
  124224. private _minPitch;
  124225. private _maxPitch;
  124226. private _minYawSin;
  124227. private _minYawCos;
  124228. private _maxYawSin;
  124229. private _maxYawCos;
  124230. private _midYawConstraint;
  124231. private _minPitchTan;
  124232. private _maxPitchTan;
  124233. private _boneQuat;
  124234. private _slerping;
  124235. private _transformYawPitch;
  124236. private _transformYawPitchInv;
  124237. private _firstFrameSkipped;
  124238. private _yawRange;
  124239. private _fowardAxis;
  124240. /**
  124241. * Gets or sets the minimum yaw angle that the bone can look to
  124242. */
  124243. get minYaw(): number;
  124244. set minYaw(value: number);
  124245. /**
  124246. * Gets or sets the maximum yaw angle that the bone can look to
  124247. */
  124248. get maxYaw(): number;
  124249. set maxYaw(value: number);
  124250. /**
  124251. * Gets or sets the minimum pitch angle that the bone can look to
  124252. */
  124253. get minPitch(): number;
  124254. set minPitch(value: number);
  124255. /**
  124256. * Gets or sets the maximum pitch angle that the bone can look to
  124257. */
  124258. get maxPitch(): number;
  124259. set maxPitch(value: number);
  124260. /**
  124261. * Create a BoneLookController
  124262. * @param mesh the mesh that the bone belongs to
  124263. * @param bone the bone that will be looking to the target
  124264. * @param target the target Vector3 to look at
  124265. * @param options optional settings:
  124266. * * maxYaw: the maximum angle the bone will yaw to
  124267. * * minYaw: the minimum angle the bone will yaw to
  124268. * * maxPitch: the maximum angle the bone will pitch to
  124269. * * minPitch: the minimum angle the bone will yaw to
  124270. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124271. * * upAxis: the up axis of the coordinate system
  124272. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124273. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124274. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124275. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124276. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124277. * * adjustRoll: used to make an adjustment to the roll of the bone
  124278. **/
  124279. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124280. maxYaw?: number;
  124281. minYaw?: number;
  124282. maxPitch?: number;
  124283. minPitch?: number;
  124284. slerpAmount?: number;
  124285. upAxis?: Vector3;
  124286. upAxisSpace?: Space;
  124287. yawAxis?: Vector3;
  124288. pitchAxis?: Vector3;
  124289. adjustYaw?: number;
  124290. adjustPitch?: number;
  124291. adjustRoll?: number;
  124292. });
  124293. /**
  124294. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124295. */
  124296. update(): void;
  124297. private _getAngleDiff;
  124298. private _getAngleBetween;
  124299. private _isAngleBetween;
  124300. }
  124301. }
  124302. declare module BABYLON {
  124303. /**
  124304. * Manage the gamepad inputs to control an arc rotate camera.
  124305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124306. */
  124307. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124308. /**
  124309. * Defines the camera the input is attached to.
  124310. */
  124311. camera: ArcRotateCamera;
  124312. /**
  124313. * Defines the gamepad the input is gathering event from.
  124314. */
  124315. gamepad: Nullable<Gamepad>;
  124316. /**
  124317. * Defines the gamepad rotation sensiblity.
  124318. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124319. */
  124320. gamepadRotationSensibility: number;
  124321. /**
  124322. * Defines the gamepad move sensiblity.
  124323. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124324. */
  124325. gamepadMoveSensibility: number;
  124326. private _yAxisScale;
  124327. /**
  124328. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124329. */
  124330. get invertYAxis(): boolean;
  124331. set invertYAxis(value: boolean);
  124332. private _onGamepadConnectedObserver;
  124333. private _onGamepadDisconnectedObserver;
  124334. /**
  124335. * Attach the input controls to a specific dom element to get the input from.
  124336. * @param element Defines the element the controls should be listened from
  124337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124338. */
  124339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124340. /**
  124341. * Detach the current controls from the specified dom element.
  124342. * @param element Defines the element to stop listening the inputs from
  124343. */
  124344. detachControl(element: Nullable<HTMLElement>): void;
  124345. /**
  124346. * Update the current camera state depending on the inputs that have been used this frame.
  124347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124348. */
  124349. checkInputs(): void;
  124350. /**
  124351. * Gets the class name of the current intput.
  124352. * @returns the class name
  124353. */
  124354. getClassName(): string;
  124355. /**
  124356. * Get the friendly name associated with the input class.
  124357. * @returns the input friendly name
  124358. */
  124359. getSimpleName(): string;
  124360. }
  124361. }
  124362. declare module BABYLON {
  124363. interface ArcRotateCameraInputsManager {
  124364. /**
  124365. * Add orientation input support to the input manager.
  124366. * @returns the current input manager
  124367. */
  124368. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124369. }
  124370. /**
  124371. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124372. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124373. */
  124374. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124375. /**
  124376. * Defines the camera the input is attached to.
  124377. */
  124378. camera: ArcRotateCamera;
  124379. /**
  124380. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124381. */
  124382. alphaCorrection: number;
  124383. /**
  124384. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124385. */
  124386. gammaCorrection: number;
  124387. private _alpha;
  124388. private _gamma;
  124389. private _dirty;
  124390. private _deviceOrientationHandler;
  124391. /**
  124392. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124393. */
  124394. constructor();
  124395. /**
  124396. * Attach the input controls to a specific dom element to get the input from.
  124397. * @param element Defines the element the controls should be listened from
  124398. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124399. */
  124400. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124401. /** @hidden */
  124402. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124403. /**
  124404. * Update the current camera state depending on the inputs that have been used this frame.
  124405. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124406. */
  124407. checkInputs(): void;
  124408. /**
  124409. * Detach the current controls from the specified dom element.
  124410. * @param element Defines the element to stop listening the inputs from
  124411. */
  124412. detachControl(element: Nullable<HTMLElement>): void;
  124413. /**
  124414. * Gets the class name of the current intput.
  124415. * @returns the class name
  124416. */
  124417. getClassName(): string;
  124418. /**
  124419. * Get the friendly name associated with the input class.
  124420. * @returns the input friendly name
  124421. */
  124422. getSimpleName(): string;
  124423. }
  124424. }
  124425. declare module BABYLON {
  124426. /**
  124427. * Listen to mouse events to control the camera.
  124428. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124429. */
  124430. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124431. /**
  124432. * Defines the camera the input is attached to.
  124433. */
  124434. camera: FlyCamera;
  124435. /**
  124436. * Defines if touch is enabled. (Default is true.)
  124437. */
  124438. touchEnabled: boolean;
  124439. /**
  124440. * Defines the buttons associated with the input to handle camera rotation.
  124441. */
  124442. buttons: number[];
  124443. /**
  124444. * Assign buttons for Yaw control.
  124445. */
  124446. buttonsYaw: number[];
  124447. /**
  124448. * Assign buttons for Pitch control.
  124449. */
  124450. buttonsPitch: number[];
  124451. /**
  124452. * Assign buttons for Roll control.
  124453. */
  124454. buttonsRoll: number[];
  124455. /**
  124456. * Detect if any button is being pressed while mouse is moved.
  124457. * -1 = Mouse locked.
  124458. * 0 = Left button.
  124459. * 1 = Middle Button.
  124460. * 2 = Right Button.
  124461. */
  124462. activeButton: number;
  124463. /**
  124464. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124465. * Higher values reduce its sensitivity.
  124466. */
  124467. angularSensibility: number;
  124468. private _mousemoveCallback;
  124469. private _observer;
  124470. private _rollObserver;
  124471. private previousPosition;
  124472. private noPreventDefault;
  124473. private element;
  124474. /**
  124475. * Listen to mouse events to control the camera.
  124476. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124477. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124478. */
  124479. constructor(touchEnabled?: boolean);
  124480. /**
  124481. * Attach the mouse control to the HTML DOM element.
  124482. * @param element Defines the element that listens to the input events.
  124483. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124484. */
  124485. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124486. /**
  124487. * Detach the current controls from the specified dom element.
  124488. * @param element Defines the element to stop listening the inputs from
  124489. */
  124490. detachControl(element: Nullable<HTMLElement>): void;
  124491. /**
  124492. * Gets the class name of the current input.
  124493. * @returns the class name.
  124494. */
  124495. getClassName(): string;
  124496. /**
  124497. * Get the friendly name associated with the input class.
  124498. * @returns the input's friendly name.
  124499. */
  124500. getSimpleName(): string;
  124501. private _pointerInput;
  124502. private _onMouseMove;
  124503. /**
  124504. * Rotate camera by mouse offset.
  124505. */
  124506. private rotateCamera;
  124507. }
  124508. }
  124509. declare module BABYLON {
  124510. /**
  124511. * Default Inputs manager for the FlyCamera.
  124512. * It groups all the default supported inputs for ease of use.
  124513. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124514. */
  124515. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124516. /**
  124517. * Instantiates a new FlyCameraInputsManager.
  124518. * @param camera Defines the camera the inputs belong to.
  124519. */
  124520. constructor(camera: FlyCamera);
  124521. /**
  124522. * Add keyboard input support to the input manager.
  124523. * @returns the new FlyCameraKeyboardMoveInput().
  124524. */
  124525. addKeyboard(): FlyCameraInputsManager;
  124526. /**
  124527. * Add mouse input support to the input manager.
  124528. * @param touchEnabled Enable touch screen support.
  124529. * @returns the new FlyCameraMouseInput().
  124530. */
  124531. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124532. }
  124533. }
  124534. declare module BABYLON {
  124535. /**
  124536. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124537. * such as in a 3D Space Shooter or a Flight Simulator.
  124538. */
  124539. export class FlyCamera extends TargetCamera {
  124540. /**
  124541. * Define the collision ellipsoid of the camera.
  124542. * This is helpful for simulating a camera body, like a player's body.
  124543. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124544. */
  124545. ellipsoid: Vector3;
  124546. /**
  124547. * Define an offset for the position of the ellipsoid around the camera.
  124548. * This can be helpful if the camera is attached away from the player's body center,
  124549. * such as at its head.
  124550. */
  124551. ellipsoidOffset: Vector3;
  124552. /**
  124553. * Enable or disable collisions of the camera with the rest of the scene objects.
  124554. */
  124555. checkCollisions: boolean;
  124556. /**
  124557. * Enable or disable gravity on the camera.
  124558. */
  124559. applyGravity: boolean;
  124560. /**
  124561. * Define the current direction the camera is moving to.
  124562. */
  124563. cameraDirection: Vector3;
  124564. /**
  124565. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124566. * This overrides and empties cameraRotation.
  124567. */
  124568. rotationQuaternion: Quaternion;
  124569. /**
  124570. * Track Roll to maintain the wanted Rolling when looking around.
  124571. */
  124572. _trackRoll: number;
  124573. /**
  124574. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124575. */
  124576. rollCorrect: number;
  124577. /**
  124578. * Mimic a banked turn, Rolling the camera when Yawing.
  124579. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124580. */
  124581. bankedTurn: boolean;
  124582. /**
  124583. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124584. */
  124585. bankedTurnLimit: number;
  124586. /**
  124587. * Value of 0 disables the banked Roll.
  124588. * Value of 1 is equal to the Yaw angle in radians.
  124589. */
  124590. bankedTurnMultiplier: number;
  124591. /**
  124592. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124593. */
  124594. inputs: FlyCameraInputsManager;
  124595. /**
  124596. * Gets the input sensibility for mouse input.
  124597. * Higher values reduce sensitivity.
  124598. */
  124599. get angularSensibility(): number;
  124600. /**
  124601. * Sets the input sensibility for a mouse input.
  124602. * Higher values reduce sensitivity.
  124603. */
  124604. set angularSensibility(value: number);
  124605. /**
  124606. * Get the keys for camera movement forward.
  124607. */
  124608. get keysForward(): number[];
  124609. /**
  124610. * Set the keys for camera movement forward.
  124611. */
  124612. set keysForward(value: number[]);
  124613. /**
  124614. * Get the keys for camera movement backward.
  124615. */
  124616. get keysBackward(): number[];
  124617. set keysBackward(value: number[]);
  124618. /**
  124619. * Get the keys for camera movement up.
  124620. */
  124621. get keysUp(): number[];
  124622. /**
  124623. * Set the keys for camera movement up.
  124624. */
  124625. set keysUp(value: number[]);
  124626. /**
  124627. * Get the keys for camera movement down.
  124628. */
  124629. get keysDown(): number[];
  124630. /**
  124631. * Set the keys for camera movement down.
  124632. */
  124633. set keysDown(value: number[]);
  124634. /**
  124635. * Get the keys for camera movement left.
  124636. */
  124637. get keysLeft(): number[];
  124638. /**
  124639. * Set the keys for camera movement left.
  124640. */
  124641. set keysLeft(value: number[]);
  124642. /**
  124643. * Set the keys for camera movement right.
  124644. */
  124645. get keysRight(): number[];
  124646. /**
  124647. * Set the keys for camera movement right.
  124648. */
  124649. set keysRight(value: number[]);
  124650. /**
  124651. * Event raised when the camera collides with a mesh in the scene.
  124652. */
  124653. onCollide: (collidedMesh: AbstractMesh) => void;
  124654. private _collider;
  124655. private _needMoveForGravity;
  124656. private _oldPosition;
  124657. private _diffPosition;
  124658. private _newPosition;
  124659. /** @hidden */
  124660. _localDirection: Vector3;
  124661. /** @hidden */
  124662. _transformedDirection: Vector3;
  124663. /**
  124664. * Instantiates a FlyCamera.
  124665. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124666. * such as in a 3D Space Shooter or a Flight Simulator.
  124667. * @param name Define the name of the camera in the scene.
  124668. * @param position Define the starting position of the camera in the scene.
  124669. * @param scene Define the scene the camera belongs to.
  124670. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  124671. */
  124672. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  124673. /**
  124674. * Attach a control to the HTML DOM element.
  124675. * @param element Defines the element that listens to the input events.
  124676. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  124677. */
  124678. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124679. /**
  124680. * Detach a control from the HTML DOM element.
  124681. * The camera will stop reacting to that input.
  124682. * @param element Defines the element that listens to the input events.
  124683. */
  124684. detachControl(element: HTMLElement): void;
  124685. private _collisionMask;
  124686. /**
  124687. * Get the mask that the camera ignores in collision events.
  124688. */
  124689. get collisionMask(): number;
  124690. /**
  124691. * Set the mask that the camera ignores in collision events.
  124692. */
  124693. set collisionMask(mask: number);
  124694. /** @hidden */
  124695. _collideWithWorld(displacement: Vector3): void;
  124696. /** @hidden */
  124697. private _onCollisionPositionChange;
  124698. /** @hidden */
  124699. _checkInputs(): void;
  124700. /** @hidden */
  124701. _decideIfNeedsToMove(): boolean;
  124702. /** @hidden */
  124703. _updatePosition(): void;
  124704. /**
  124705. * Restore the Roll to its target value at the rate specified.
  124706. * @param rate - Higher means slower restoring.
  124707. * @hidden
  124708. */
  124709. restoreRoll(rate: number): void;
  124710. /**
  124711. * Destroy the camera and release the current resources held by it.
  124712. */
  124713. dispose(): void;
  124714. /**
  124715. * Get the current object class name.
  124716. * @returns the class name.
  124717. */
  124718. getClassName(): string;
  124719. }
  124720. }
  124721. declare module BABYLON {
  124722. /**
  124723. * Listen to keyboard events to control the camera.
  124724. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124725. */
  124726. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  124727. /**
  124728. * Defines the camera the input is attached to.
  124729. */
  124730. camera: FlyCamera;
  124731. /**
  124732. * The list of keyboard keys used to control the forward move of the camera.
  124733. */
  124734. keysForward: number[];
  124735. /**
  124736. * The list of keyboard keys used to control the backward move of the camera.
  124737. */
  124738. keysBackward: number[];
  124739. /**
  124740. * The list of keyboard keys used to control the forward move of the camera.
  124741. */
  124742. keysUp: number[];
  124743. /**
  124744. * The list of keyboard keys used to control the backward move of the camera.
  124745. */
  124746. keysDown: number[];
  124747. /**
  124748. * The list of keyboard keys used to control the right strafe move of the camera.
  124749. */
  124750. keysRight: number[];
  124751. /**
  124752. * The list of keyboard keys used to control the left strafe move of the camera.
  124753. */
  124754. keysLeft: number[];
  124755. private _keys;
  124756. private _onCanvasBlurObserver;
  124757. private _onKeyboardObserver;
  124758. private _engine;
  124759. private _scene;
  124760. /**
  124761. * Attach the input controls to a specific dom element to get the input from.
  124762. * @param element Defines the element the controls should be listened from
  124763. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124764. */
  124765. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124766. /**
  124767. * Detach the current controls from the specified dom element.
  124768. * @param element Defines the element to stop listening the inputs from
  124769. */
  124770. detachControl(element: Nullable<HTMLElement>): void;
  124771. /**
  124772. * Gets the class name of the current intput.
  124773. * @returns the class name
  124774. */
  124775. getClassName(): string;
  124776. /** @hidden */
  124777. _onLostFocus(e: FocusEvent): void;
  124778. /**
  124779. * Get the friendly name associated with the input class.
  124780. * @returns the input friendly name
  124781. */
  124782. getSimpleName(): string;
  124783. /**
  124784. * Update the current camera state depending on the inputs that have been used this frame.
  124785. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124786. */
  124787. checkInputs(): void;
  124788. }
  124789. }
  124790. declare module BABYLON {
  124791. /**
  124792. * Manage the mouse wheel inputs to control a follow camera.
  124793. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124794. */
  124795. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  124796. /**
  124797. * Defines the camera the input is attached to.
  124798. */
  124799. camera: FollowCamera;
  124800. /**
  124801. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  124802. */
  124803. axisControlRadius: boolean;
  124804. /**
  124805. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  124806. */
  124807. axisControlHeight: boolean;
  124808. /**
  124809. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  124810. */
  124811. axisControlRotation: boolean;
  124812. /**
  124813. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  124814. * relation to mouseWheel events.
  124815. */
  124816. wheelPrecision: number;
  124817. /**
  124818. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  124819. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  124820. */
  124821. wheelDeltaPercentage: number;
  124822. private _wheel;
  124823. private _observer;
  124824. /**
  124825. * Attach the input controls to a specific dom element to get the input from.
  124826. * @param element Defines the element the controls should be listened from
  124827. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124828. */
  124829. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124830. /**
  124831. * Detach the current controls from the specified dom element.
  124832. * @param element Defines the element to stop listening the inputs from
  124833. */
  124834. detachControl(element: Nullable<HTMLElement>): void;
  124835. /**
  124836. * Gets the class name of the current intput.
  124837. * @returns the class name
  124838. */
  124839. getClassName(): string;
  124840. /**
  124841. * Get the friendly name associated with the input class.
  124842. * @returns the input friendly name
  124843. */
  124844. getSimpleName(): string;
  124845. }
  124846. }
  124847. declare module BABYLON {
  124848. /**
  124849. * Manage the pointers inputs to control an follow camera.
  124850. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124851. */
  124852. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  124853. /**
  124854. * Defines the camera the input is attached to.
  124855. */
  124856. camera: FollowCamera;
  124857. /**
  124858. * Gets the class name of the current input.
  124859. * @returns the class name
  124860. */
  124861. getClassName(): string;
  124862. /**
  124863. * Defines the pointer angular sensibility along the X axis or how fast is
  124864. * the camera rotating.
  124865. * A negative number will reverse the axis direction.
  124866. */
  124867. angularSensibilityX: number;
  124868. /**
  124869. * Defines the pointer angular sensibility along the Y axis or how fast is
  124870. * the camera rotating.
  124871. * A negative number will reverse the axis direction.
  124872. */
  124873. angularSensibilityY: number;
  124874. /**
  124875. * Defines the pointer pinch precision or how fast is the camera zooming.
  124876. * A negative number will reverse the axis direction.
  124877. */
  124878. pinchPrecision: number;
  124879. /**
  124880. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  124881. * from 0.
  124882. * It defines the percentage of current camera.radius to use as delta when
  124883. * pinch zoom is used.
  124884. */
  124885. pinchDeltaPercentage: number;
  124886. /**
  124887. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  124888. */
  124889. axisXControlRadius: boolean;
  124890. /**
  124891. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  124892. */
  124893. axisXControlHeight: boolean;
  124894. /**
  124895. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  124896. */
  124897. axisXControlRotation: boolean;
  124898. /**
  124899. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  124900. */
  124901. axisYControlRadius: boolean;
  124902. /**
  124903. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  124904. */
  124905. axisYControlHeight: boolean;
  124906. /**
  124907. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  124908. */
  124909. axisYControlRotation: boolean;
  124910. /**
  124911. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  124912. */
  124913. axisPinchControlRadius: boolean;
  124914. /**
  124915. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  124916. */
  124917. axisPinchControlHeight: boolean;
  124918. /**
  124919. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  124920. */
  124921. axisPinchControlRotation: boolean;
  124922. /**
  124923. * Log error messages if basic misconfiguration has occurred.
  124924. */
  124925. warningEnable: boolean;
  124926. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  124927. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  124928. private _warningCounter;
  124929. private _warning;
  124930. }
  124931. }
  124932. declare module BABYLON {
  124933. /**
  124934. * Default Inputs manager for the FollowCamera.
  124935. * It groups all the default supported inputs for ease of use.
  124936. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124937. */
  124938. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  124939. /**
  124940. * Instantiates a new FollowCameraInputsManager.
  124941. * @param camera Defines the camera the inputs belong to
  124942. */
  124943. constructor(camera: FollowCamera);
  124944. /**
  124945. * Add keyboard input support to the input manager.
  124946. * @returns the current input manager
  124947. */
  124948. addKeyboard(): FollowCameraInputsManager;
  124949. /**
  124950. * Add mouse wheel input support to the input manager.
  124951. * @returns the current input manager
  124952. */
  124953. addMouseWheel(): FollowCameraInputsManager;
  124954. /**
  124955. * Add pointers input support to the input manager.
  124956. * @returns the current input manager
  124957. */
  124958. addPointers(): FollowCameraInputsManager;
  124959. /**
  124960. * Add orientation input support to the input manager.
  124961. * @returns the current input manager
  124962. */
  124963. addVRDeviceOrientation(): FollowCameraInputsManager;
  124964. }
  124965. }
  124966. declare module BABYLON {
  124967. /**
  124968. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  124969. * an arc rotate version arcFollowCamera are available.
  124970. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  124971. */
  124972. export class FollowCamera extends TargetCamera {
  124973. /**
  124974. * Distance the follow camera should follow an object at
  124975. */
  124976. radius: number;
  124977. /**
  124978. * Minimum allowed distance of the camera to the axis of rotation
  124979. * (The camera can not get closer).
  124980. * This can help limiting how the Camera is able to move in the scene.
  124981. */
  124982. lowerRadiusLimit: Nullable<number>;
  124983. /**
  124984. * Maximum allowed distance of the camera to the axis of rotation
  124985. * (The camera can not get further).
  124986. * This can help limiting how the Camera is able to move in the scene.
  124987. */
  124988. upperRadiusLimit: Nullable<number>;
  124989. /**
  124990. * Define a rotation offset between the camera and the object it follows
  124991. */
  124992. rotationOffset: number;
  124993. /**
  124994. * Minimum allowed angle to camera position relative to target object.
  124995. * This can help limiting how the Camera is able to move in the scene.
  124996. */
  124997. lowerRotationOffsetLimit: Nullable<number>;
  124998. /**
  124999. * Maximum allowed angle to camera position relative to target object.
  125000. * This can help limiting how the Camera is able to move in the scene.
  125001. */
  125002. upperRotationOffsetLimit: Nullable<number>;
  125003. /**
  125004. * Define a height offset between the camera and the object it follows.
  125005. * It can help following an object from the top (like a car chaing a plane)
  125006. */
  125007. heightOffset: number;
  125008. /**
  125009. * Minimum allowed height of camera position relative to target object.
  125010. * This can help limiting how the Camera is able to move in the scene.
  125011. */
  125012. lowerHeightOffsetLimit: Nullable<number>;
  125013. /**
  125014. * Maximum allowed height of camera position relative to target object.
  125015. * This can help limiting how the Camera is able to move in the scene.
  125016. */
  125017. upperHeightOffsetLimit: Nullable<number>;
  125018. /**
  125019. * Define how fast the camera can accelerate to follow it s target.
  125020. */
  125021. cameraAcceleration: number;
  125022. /**
  125023. * Define the speed limit of the camera following an object.
  125024. */
  125025. maxCameraSpeed: number;
  125026. /**
  125027. * Define the target of the camera.
  125028. */
  125029. lockedTarget: Nullable<AbstractMesh>;
  125030. /**
  125031. * Defines the input associated with the camera.
  125032. */
  125033. inputs: FollowCameraInputsManager;
  125034. /**
  125035. * Instantiates the follow camera.
  125036. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125037. * @param name Define the name of the camera in the scene
  125038. * @param position Define the position of the camera
  125039. * @param scene Define the scene the camera belong to
  125040. * @param lockedTarget Define the target of the camera
  125041. */
  125042. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125043. private _follow;
  125044. /**
  125045. * Attached controls to the current camera.
  125046. * @param element Defines the element the controls should be listened from
  125047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125048. */
  125049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125050. /**
  125051. * Detach the current controls from the camera.
  125052. * The camera will stop reacting to inputs.
  125053. * @param element Defines the element to stop listening the inputs from
  125054. */
  125055. detachControl(element: HTMLElement): void;
  125056. /** @hidden */
  125057. _checkInputs(): void;
  125058. private _checkLimits;
  125059. /**
  125060. * Gets the camera class name.
  125061. * @returns the class name
  125062. */
  125063. getClassName(): string;
  125064. }
  125065. /**
  125066. * Arc Rotate version of the follow camera.
  125067. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125068. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125069. */
  125070. export class ArcFollowCamera extends TargetCamera {
  125071. /** The longitudinal angle of the camera */
  125072. alpha: number;
  125073. /** The latitudinal angle of the camera */
  125074. beta: number;
  125075. /** The radius of the camera from its target */
  125076. radius: number;
  125077. private _cartesianCoordinates;
  125078. /** Define the camera target (the mesh it should follow) */
  125079. private _meshTarget;
  125080. /**
  125081. * Instantiates a new ArcFollowCamera
  125082. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125083. * @param name Define the name of the camera
  125084. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125085. * @param beta Define the rotation angle of the camera around the elevation axis
  125086. * @param radius Define the radius of the camera from its target point
  125087. * @param target Define the target of the camera
  125088. * @param scene Define the scene the camera belongs to
  125089. */
  125090. constructor(name: string,
  125091. /** The longitudinal angle of the camera */
  125092. alpha: number,
  125093. /** The latitudinal angle of the camera */
  125094. beta: number,
  125095. /** The radius of the camera from its target */
  125096. radius: number,
  125097. /** Define the camera target (the mesh it should follow) */
  125098. target: Nullable<AbstractMesh>, scene: Scene);
  125099. private _follow;
  125100. /** @hidden */
  125101. _checkInputs(): void;
  125102. /**
  125103. * Returns the class name of the object.
  125104. * It is mostly used internally for serialization purposes.
  125105. */
  125106. getClassName(): string;
  125107. }
  125108. }
  125109. declare module BABYLON {
  125110. /**
  125111. * Manage the keyboard inputs to control the movement of a follow camera.
  125112. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125113. */
  125114. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125115. /**
  125116. * Defines the camera the input is attached to.
  125117. */
  125118. camera: FollowCamera;
  125119. /**
  125120. * Defines the list of key codes associated with the up action (increase heightOffset)
  125121. */
  125122. keysHeightOffsetIncr: number[];
  125123. /**
  125124. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125125. */
  125126. keysHeightOffsetDecr: number[];
  125127. /**
  125128. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125129. */
  125130. keysHeightOffsetModifierAlt: boolean;
  125131. /**
  125132. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125133. */
  125134. keysHeightOffsetModifierCtrl: boolean;
  125135. /**
  125136. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125137. */
  125138. keysHeightOffsetModifierShift: boolean;
  125139. /**
  125140. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125141. */
  125142. keysRotationOffsetIncr: number[];
  125143. /**
  125144. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125145. */
  125146. keysRotationOffsetDecr: number[];
  125147. /**
  125148. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125149. */
  125150. keysRotationOffsetModifierAlt: boolean;
  125151. /**
  125152. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125153. */
  125154. keysRotationOffsetModifierCtrl: boolean;
  125155. /**
  125156. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125157. */
  125158. keysRotationOffsetModifierShift: boolean;
  125159. /**
  125160. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125161. */
  125162. keysRadiusIncr: number[];
  125163. /**
  125164. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125165. */
  125166. keysRadiusDecr: number[];
  125167. /**
  125168. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125169. */
  125170. keysRadiusModifierAlt: boolean;
  125171. /**
  125172. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125173. */
  125174. keysRadiusModifierCtrl: boolean;
  125175. /**
  125176. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125177. */
  125178. keysRadiusModifierShift: boolean;
  125179. /**
  125180. * Defines the rate of change of heightOffset.
  125181. */
  125182. heightSensibility: number;
  125183. /**
  125184. * Defines the rate of change of rotationOffset.
  125185. */
  125186. rotationSensibility: number;
  125187. /**
  125188. * Defines the rate of change of radius.
  125189. */
  125190. radiusSensibility: number;
  125191. private _keys;
  125192. private _ctrlPressed;
  125193. private _altPressed;
  125194. private _shiftPressed;
  125195. private _onCanvasBlurObserver;
  125196. private _onKeyboardObserver;
  125197. private _engine;
  125198. private _scene;
  125199. /**
  125200. * Attach the input controls to a specific dom element to get the input from.
  125201. * @param element Defines the element the controls should be listened from
  125202. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125203. */
  125204. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125205. /**
  125206. * Detach the current controls from the specified dom element.
  125207. * @param element Defines the element to stop listening the inputs from
  125208. */
  125209. detachControl(element: Nullable<HTMLElement>): void;
  125210. /**
  125211. * Update the current camera state depending on the inputs that have been used this frame.
  125212. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125213. */
  125214. checkInputs(): void;
  125215. /**
  125216. * Gets the class name of the current input.
  125217. * @returns the class name
  125218. */
  125219. getClassName(): string;
  125220. /**
  125221. * Get the friendly name associated with the input class.
  125222. * @returns the input friendly name
  125223. */
  125224. getSimpleName(): string;
  125225. /**
  125226. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125227. * allow modification of the heightOffset value.
  125228. */
  125229. private _modifierHeightOffset;
  125230. /**
  125231. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125232. * allow modification of the rotationOffset value.
  125233. */
  125234. private _modifierRotationOffset;
  125235. /**
  125236. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125237. * allow modification of the radius value.
  125238. */
  125239. private _modifierRadius;
  125240. }
  125241. }
  125242. declare module BABYLON {
  125243. interface FreeCameraInputsManager {
  125244. /**
  125245. * @hidden
  125246. */
  125247. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125248. /**
  125249. * Add orientation input support to the input manager.
  125250. * @returns the current input manager
  125251. */
  125252. addDeviceOrientation(): FreeCameraInputsManager;
  125253. }
  125254. /**
  125255. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125256. * Screen rotation is taken into account.
  125257. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125258. */
  125259. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125260. private _camera;
  125261. private _screenOrientationAngle;
  125262. private _constantTranform;
  125263. private _screenQuaternion;
  125264. private _alpha;
  125265. private _beta;
  125266. private _gamma;
  125267. /**
  125268. * Can be used to detect if a device orientation sensor is available on a device
  125269. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125270. * @returns a promise that will resolve on orientation change
  125271. */
  125272. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125273. /**
  125274. * @hidden
  125275. */
  125276. _onDeviceOrientationChangedObservable: Observable<void>;
  125277. /**
  125278. * Instantiates a new input
  125279. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125280. */
  125281. constructor();
  125282. /**
  125283. * Define the camera controlled by the input.
  125284. */
  125285. get camera(): FreeCamera;
  125286. set camera(camera: FreeCamera);
  125287. /**
  125288. * Attach the input controls to a specific dom element to get the input from.
  125289. * @param element Defines the element the controls should be listened from
  125290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125291. */
  125292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125293. private _orientationChanged;
  125294. private _deviceOrientation;
  125295. /**
  125296. * Detach the current controls from the specified dom element.
  125297. * @param element Defines the element to stop listening the inputs from
  125298. */
  125299. detachControl(element: Nullable<HTMLElement>): void;
  125300. /**
  125301. * Update the current camera state depending on the inputs that have been used this frame.
  125302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125303. */
  125304. checkInputs(): void;
  125305. /**
  125306. * Gets the class name of the current intput.
  125307. * @returns the class name
  125308. */
  125309. getClassName(): string;
  125310. /**
  125311. * Get the friendly name associated with the input class.
  125312. * @returns the input friendly name
  125313. */
  125314. getSimpleName(): string;
  125315. }
  125316. }
  125317. declare module BABYLON {
  125318. /**
  125319. * Manage the gamepad inputs to control a free camera.
  125320. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125321. */
  125322. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125323. /**
  125324. * Define the camera the input is attached to.
  125325. */
  125326. camera: FreeCamera;
  125327. /**
  125328. * Define the Gamepad controlling the input
  125329. */
  125330. gamepad: Nullable<Gamepad>;
  125331. /**
  125332. * Defines the gamepad rotation sensiblity.
  125333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125334. */
  125335. gamepadAngularSensibility: number;
  125336. /**
  125337. * Defines the gamepad move sensiblity.
  125338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125339. */
  125340. gamepadMoveSensibility: number;
  125341. private _yAxisScale;
  125342. /**
  125343. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125344. */
  125345. get invertYAxis(): boolean;
  125346. set invertYAxis(value: boolean);
  125347. private _onGamepadConnectedObserver;
  125348. private _onGamepadDisconnectedObserver;
  125349. private _cameraTransform;
  125350. private _deltaTransform;
  125351. private _vector3;
  125352. private _vector2;
  125353. /**
  125354. * Attach the input controls to a specific dom element to get the input from.
  125355. * @param element Defines the element the controls should be listened from
  125356. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125357. */
  125358. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125359. /**
  125360. * Detach the current controls from the specified dom element.
  125361. * @param element Defines the element to stop listening the inputs from
  125362. */
  125363. detachControl(element: Nullable<HTMLElement>): void;
  125364. /**
  125365. * Update the current camera state depending on the inputs that have been used this frame.
  125366. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125367. */
  125368. checkInputs(): void;
  125369. /**
  125370. * Gets the class name of the current intput.
  125371. * @returns the class name
  125372. */
  125373. getClassName(): string;
  125374. /**
  125375. * Get the friendly name associated with the input class.
  125376. * @returns the input friendly name
  125377. */
  125378. getSimpleName(): string;
  125379. }
  125380. }
  125381. declare module BABYLON {
  125382. /**
  125383. * Defines the potential axis of a Joystick
  125384. */
  125385. export enum JoystickAxis {
  125386. /** X axis */
  125387. X = 0,
  125388. /** Y axis */
  125389. Y = 1,
  125390. /** Z axis */
  125391. Z = 2
  125392. }
  125393. /**
  125394. * Represents the different customization options available
  125395. * for VirtualJoystick
  125396. */
  125397. interface VirtualJoystickCustomizations {
  125398. /**
  125399. * Size of the joystick's puck
  125400. */
  125401. puckSize: number;
  125402. /**
  125403. * Size of the joystick's container
  125404. */
  125405. containerSize: number;
  125406. /**
  125407. * Color of the joystick && puck
  125408. */
  125409. color: string;
  125410. /**
  125411. * Image URL for the joystick's puck
  125412. */
  125413. puckImage?: string;
  125414. /**
  125415. * Image URL for the joystick's container
  125416. */
  125417. containerImage?: string;
  125418. /**
  125419. * Defines the unmoving position of the joystick container
  125420. */
  125421. position?: {
  125422. x: number;
  125423. y: number;
  125424. };
  125425. /**
  125426. * Defines whether or not the joystick container is always visible
  125427. */
  125428. alwaysVisible: boolean;
  125429. /**
  125430. * Defines whether or not to limit the movement of the puck to the joystick's container
  125431. */
  125432. limitToContainer: boolean;
  125433. }
  125434. /**
  125435. * Class used to define virtual joystick (used in touch mode)
  125436. */
  125437. export class VirtualJoystick {
  125438. /**
  125439. * Gets or sets a boolean indicating that left and right values must be inverted
  125440. */
  125441. reverseLeftRight: boolean;
  125442. /**
  125443. * Gets or sets a boolean indicating that up and down values must be inverted
  125444. */
  125445. reverseUpDown: boolean;
  125446. /**
  125447. * Gets the offset value for the position (ie. the change of the position value)
  125448. */
  125449. deltaPosition: Vector3;
  125450. /**
  125451. * Gets a boolean indicating if the virtual joystick was pressed
  125452. */
  125453. pressed: boolean;
  125454. /**
  125455. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125456. */
  125457. static Canvas: Nullable<HTMLCanvasElement>;
  125458. /**
  125459. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125460. */
  125461. limitToContainer: boolean;
  125462. private static _globalJoystickIndex;
  125463. private static _alwaysVisibleSticks;
  125464. private static vjCanvasContext;
  125465. private static vjCanvasWidth;
  125466. private static vjCanvasHeight;
  125467. private static halfWidth;
  125468. private static _GetDefaultOptions;
  125469. private _action;
  125470. private _axisTargetedByLeftAndRight;
  125471. private _axisTargetedByUpAndDown;
  125472. private _joystickSensibility;
  125473. private _inversedSensibility;
  125474. private _joystickPointerID;
  125475. private _joystickColor;
  125476. private _joystickPointerPos;
  125477. private _joystickPreviousPointerPos;
  125478. private _joystickPointerStartPos;
  125479. private _deltaJoystickVector;
  125480. private _leftJoystick;
  125481. private _touches;
  125482. private _joystickPosition;
  125483. private _alwaysVisible;
  125484. private _puckImage;
  125485. private _containerImage;
  125486. private _joystickPuckSize;
  125487. private _joystickContainerSize;
  125488. private _clearPuckSize;
  125489. private _clearContainerSize;
  125490. private _clearPuckSizeOffset;
  125491. private _clearContainerSizeOffset;
  125492. private _onPointerDownHandlerRef;
  125493. private _onPointerMoveHandlerRef;
  125494. private _onPointerUpHandlerRef;
  125495. private _onResize;
  125496. /**
  125497. * Creates a new virtual joystick
  125498. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125499. * @param customizations Defines the options we want to customize the VirtualJoystick
  125500. */
  125501. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125502. /**
  125503. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125504. * @param newJoystickSensibility defines the new sensibility
  125505. */
  125506. setJoystickSensibility(newJoystickSensibility: number): void;
  125507. private _onPointerDown;
  125508. private _onPointerMove;
  125509. private _onPointerUp;
  125510. /**
  125511. * Change the color of the virtual joystick
  125512. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125513. */
  125514. setJoystickColor(newColor: string): void;
  125515. /**
  125516. * Size of the joystick's container
  125517. */
  125518. set containerSize(newSize: number);
  125519. get containerSize(): number;
  125520. /**
  125521. * Size of the joystick's puck
  125522. */
  125523. set puckSize(newSize: number);
  125524. get puckSize(): number;
  125525. /**
  125526. * Clears the set position of the joystick
  125527. */
  125528. clearPosition(): void;
  125529. /**
  125530. * Defines whether or not the joystick container is always visible
  125531. */
  125532. set alwaysVisible(value: boolean);
  125533. get alwaysVisible(): boolean;
  125534. /**
  125535. * Sets the constant position of the Joystick container
  125536. * @param x X axis coordinate
  125537. * @param y Y axis coordinate
  125538. */
  125539. setPosition(x: number, y: number): void;
  125540. /**
  125541. * Defines a callback to call when the joystick is touched
  125542. * @param action defines the callback
  125543. */
  125544. setActionOnTouch(action: () => any): void;
  125545. /**
  125546. * Defines which axis you'd like to control for left & right
  125547. * @param axis defines the axis to use
  125548. */
  125549. setAxisForLeftRight(axis: JoystickAxis): void;
  125550. /**
  125551. * Defines which axis you'd like to control for up & down
  125552. * @param axis defines the axis to use
  125553. */
  125554. setAxisForUpDown(axis: JoystickAxis): void;
  125555. /**
  125556. * Clears the canvas from the previous puck / container draw
  125557. */
  125558. private _clearPreviousDraw;
  125559. /**
  125560. * Loads `urlPath` to be used for the container's image
  125561. * @param urlPath defines the urlPath of an image to use
  125562. */
  125563. setContainerImage(urlPath: string): void;
  125564. /**
  125565. * Loads `urlPath` to be used for the puck's image
  125566. * @param urlPath defines the urlPath of an image to use
  125567. */
  125568. setPuckImage(urlPath: string): void;
  125569. /**
  125570. * Draws the Virtual Joystick's container
  125571. */
  125572. private _drawContainer;
  125573. /**
  125574. * Draws the Virtual Joystick's puck
  125575. */
  125576. private _drawPuck;
  125577. private _drawVirtualJoystick;
  125578. /**
  125579. * Release internal HTML canvas
  125580. */
  125581. releaseCanvas(): void;
  125582. }
  125583. }
  125584. declare module BABYLON {
  125585. interface FreeCameraInputsManager {
  125586. /**
  125587. * Add virtual joystick input support to the input manager.
  125588. * @returns the current input manager
  125589. */
  125590. addVirtualJoystick(): FreeCameraInputsManager;
  125591. }
  125592. /**
  125593. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125594. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125595. */
  125596. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125597. /**
  125598. * Defines the camera the input is attached to.
  125599. */
  125600. camera: FreeCamera;
  125601. private _leftjoystick;
  125602. private _rightjoystick;
  125603. /**
  125604. * Gets the left stick of the virtual joystick.
  125605. * @returns The virtual Joystick
  125606. */
  125607. getLeftJoystick(): VirtualJoystick;
  125608. /**
  125609. * Gets the right stick of the virtual joystick.
  125610. * @returns The virtual Joystick
  125611. */
  125612. getRightJoystick(): VirtualJoystick;
  125613. /**
  125614. * Update the current camera state depending on the inputs that have been used this frame.
  125615. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125616. */
  125617. checkInputs(): void;
  125618. /**
  125619. * Attach the input controls to a specific dom element to get the input from.
  125620. * @param element Defines the element the controls should be listened from
  125621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125622. */
  125623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125624. /**
  125625. * Detach the current controls from the specified dom element.
  125626. * @param element Defines the element to stop listening the inputs from
  125627. */
  125628. detachControl(element: Nullable<HTMLElement>): void;
  125629. /**
  125630. * Gets the class name of the current intput.
  125631. * @returns the class name
  125632. */
  125633. getClassName(): string;
  125634. /**
  125635. * Get the friendly name associated with the input class.
  125636. * @returns the input friendly name
  125637. */
  125638. getSimpleName(): string;
  125639. }
  125640. }
  125641. declare module BABYLON {
  125642. /**
  125643. * This represents a FPS type of camera controlled by touch.
  125644. * This is like a universal camera minus the Gamepad controls.
  125645. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125646. */
  125647. export class TouchCamera extends FreeCamera {
  125648. /**
  125649. * Defines the touch sensibility for rotation.
  125650. * The higher the faster.
  125651. */
  125652. get touchAngularSensibility(): number;
  125653. set touchAngularSensibility(value: number);
  125654. /**
  125655. * Defines the touch sensibility for move.
  125656. * The higher the faster.
  125657. */
  125658. get touchMoveSensibility(): number;
  125659. set touchMoveSensibility(value: number);
  125660. /**
  125661. * Instantiates a new touch camera.
  125662. * This represents a FPS type of camera controlled by touch.
  125663. * This is like a universal camera minus the Gamepad controls.
  125664. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125665. * @param name Define the name of the camera in the scene
  125666. * @param position Define the start position of the camera in the scene
  125667. * @param scene Define the scene the camera belongs to
  125668. */
  125669. constructor(name: string, position: Vector3, scene: Scene);
  125670. /**
  125671. * Gets the current object class name.
  125672. * @return the class name
  125673. */
  125674. getClassName(): string;
  125675. /** @hidden */
  125676. _setupInputs(): void;
  125677. }
  125678. }
  125679. declare module BABYLON {
  125680. /**
  125681. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  125682. * being tilted forward or back and left or right.
  125683. */
  125684. export class DeviceOrientationCamera extends FreeCamera {
  125685. private _initialQuaternion;
  125686. private _quaternionCache;
  125687. private _tmpDragQuaternion;
  125688. private _disablePointerInputWhenUsingDeviceOrientation;
  125689. /**
  125690. * Creates a new device orientation camera
  125691. * @param name The name of the camera
  125692. * @param position The start position camera
  125693. * @param scene The scene the camera belongs to
  125694. */
  125695. constructor(name: string, position: Vector3, scene: Scene);
  125696. /**
  125697. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  125698. */
  125699. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  125700. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  125701. private _dragFactor;
  125702. /**
  125703. * Enabled turning on the y axis when the orientation sensor is active
  125704. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  125705. */
  125706. enableHorizontalDragging(dragFactor?: number): void;
  125707. /**
  125708. * Gets the current instance class name ("DeviceOrientationCamera").
  125709. * This helps avoiding instanceof at run time.
  125710. * @returns the class name
  125711. */
  125712. getClassName(): string;
  125713. /**
  125714. * @hidden
  125715. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  125716. */
  125717. _checkInputs(): void;
  125718. /**
  125719. * Reset the camera to its default orientation on the specified axis only.
  125720. * @param axis The axis to reset
  125721. */
  125722. resetToCurrentRotation(axis?: Axis): void;
  125723. }
  125724. }
  125725. declare module BABYLON {
  125726. /**
  125727. * Defines supported buttons for XBox360 compatible gamepads
  125728. */
  125729. export enum Xbox360Button {
  125730. /** A */
  125731. A = 0,
  125732. /** B */
  125733. B = 1,
  125734. /** X */
  125735. X = 2,
  125736. /** Y */
  125737. Y = 3,
  125738. /** Left button */
  125739. LB = 4,
  125740. /** Right button */
  125741. RB = 5,
  125742. /** Back */
  125743. Back = 8,
  125744. /** Start */
  125745. Start = 9,
  125746. /** Left stick */
  125747. LeftStick = 10,
  125748. /** Right stick */
  125749. RightStick = 11
  125750. }
  125751. /** Defines values for XBox360 DPad */
  125752. export enum Xbox360Dpad {
  125753. /** Up */
  125754. Up = 12,
  125755. /** Down */
  125756. Down = 13,
  125757. /** Left */
  125758. Left = 14,
  125759. /** Right */
  125760. Right = 15
  125761. }
  125762. /**
  125763. * Defines a XBox360 gamepad
  125764. */
  125765. export class Xbox360Pad extends Gamepad {
  125766. private _leftTrigger;
  125767. private _rightTrigger;
  125768. private _onlefttriggerchanged;
  125769. private _onrighttriggerchanged;
  125770. private _onbuttondown;
  125771. private _onbuttonup;
  125772. private _ondpaddown;
  125773. private _ondpadup;
  125774. /** Observable raised when a button is pressed */
  125775. onButtonDownObservable: Observable<Xbox360Button>;
  125776. /** Observable raised when a button is released */
  125777. onButtonUpObservable: Observable<Xbox360Button>;
  125778. /** Observable raised when a pad is pressed */
  125779. onPadDownObservable: Observable<Xbox360Dpad>;
  125780. /** Observable raised when a pad is released */
  125781. onPadUpObservable: Observable<Xbox360Dpad>;
  125782. private _buttonA;
  125783. private _buttonB;
  125784. private _buttonX;
  125785. private _buttonY;
  125786. private _buttonBack;
  125787. private _buttonStart;
  125788. private _buttonLB;
  125789. private _buttonRB;
  125790. private _buttonLeftStick;
  125791. private _buttonRightStick;
  125792. private _dPadUp;
  125793. private _dPadDown;
  125794. private _dPadLeft;
  125795. private _dPadRight;
  125796. private _isXboxOnePad;
  125797. /**
  125798. * Creates a new XBox360 gamepad object
  125799. * @param id defines the id of this gamepad
  125800. * @param index defines its index
  125801. * @param gamepad defines the internal HTML gamepad object
  125802. * @param xboxOne defines if it is a XBox One gamepad
  125803. */
  125804. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  125805. /**
  125806. * Defines the callback to call when left trigger is pressed
  125807. * @param callback defines the callback to use
  125808. */
  125809. onlefttriggerchanged(callback: (value: number) => void): void;
  125810. /**
  125811. * Defines the callback to call when right trigger is pressed
  125812. * @param callback defines the callback to use
  125813. */
  125814. onrighttriggerchanged(callback: (value: number) => void): void;
  125815. /**
  125816. * Gets the left trigger value
  125817. */
  125818. get leftTrigger(): number;
  125819. /**
  125820. * Sets the left trigger value
  125821. */
  125822. set leftTrigger(newValue: number);
  125823. /**
  125824. * Gets the right trigger value
  125825. */
  125826. get rightTrigger(): number;
  125827. /**
  125828. * Sets the right trigger value
  125829. */
  125830. set rightTrigger(newValue: number);
  125831. /**
  125832. * Defines the callback to call when a button is pressed
  125833. * @param callback defines the callback to use
  125834. */
  125835. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  125836. /**
  125837. * Defines the callback to call when a button is released
  125838. * @param callback defines the callback to use
  125839. */
  125840. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  125841. /**
  125842. * Defines the callback to call when a pad is pressed
  125843. * @param callback defines the callback to use
  125844. */
  125845. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  125846. /**
  125847. * Defines the callback to call when a pad is released
  125848. * @param callback defines the callback to use
  125849. */
  125850. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  125851. private _setButtonValue;
  125852. private _setDPadValue;
  125853. /**
  125854. * Gets the value of the `A` button
  125855. */
  125856. get buttonA(): number;
  125857. /**
  125858. * Sets the value of the `A` button
  125859. */
  125860. set buttonA(value: number);
  125861. /**
  125862. * Gets the value of the `B` button
  125863. */
  125864. get buttonB(): number;
  125865. /**
  125866. * Sets the value of the `B` button
  125867. */
  125868. set buttonB(value: number);
  125869. /**
  125870. * Gets the value of the `X` button
  125871. */
  125872. get buttonX(): number;
  125873. /**
  125874. * Sets the value of the `X` button
  125875. */
  125876. set buttonX(value: number);
  125877. /**
  125878. * Gets the value of the `Y` button
  125879. */
  125880. get buttonY(): number;
  125881. /**
  125882. * Sets the value of the `Y` button
  125883. */
  125884. set buttonY(value: number);
  125885. /**
  125886. * Gets the value of the `Start` button
  125887. */
  125888. get buttonStart(): number;
  125889. /**
  125890. * Sets the value of the `Start` button
  125891. */
  125892. set buttonStart(value: number);
  125893. /**
  125894. * Gets the value of the `Back` button
  125895. */
  125896. get buttonBack(): number;
  125897. /**
  125898. * Sets the value of the `Back` button
  125899. */
  125900. set buttonBack(value: number);
  125901. /**
  125902. * Gets the value of the `Left` button
  125903. */
  125904. get buttonLB(): number;
  125905. /**
  125906. * Sets the value of the `Left` button
  125907. */
  125908. set buttonLB(value: number);
  125909. /**
  125910. * Gets the value of the `Right` button
  125911. */
  125912. get buttonRB(): number;
  125913. /**
  125914. * Sets the value of the `Right` button
  125915. */
  125916. set buttonRB(value: number);
  125917. /**
  125918. * Gets the value of the Left joystick
  125919. */
  125920. get buttonLeftStick(): number;
  125921. /**
  125922. * Sets the value of the Left joystick
  125923. */
  125924. set buttonLeftStick(value: number);
  125925. /**
  125926. * Gets the value of the Right joystick
  125927. */
  125928. get buttonRightStick(): number;
  125929. /**
  125930. * Sets the value of the Right joystick
  125931. */
  125932. set buttonRightStick(value: number);
  125933. /**
  125934. * Gets the value of D-pad up
  125935. */
  125936. get dPadUp(): number;
  125937. /**
  125938. * Sets the value of D-pad up
  125939. */
  125940. set dPadUp(value: number);
  125941. /**
  125942. * Gets the value of D-pad down
  125943. */
  125944. get dPadDown(): number;
  125945. /**
  125946. * Sets the value of D-pad down
  125947. */
  125948. set dPadDown(value: number);
  125949. /**
  125950. * Gets the value of D-pad left
  125951. */
  125952. get dPadLeft(): number;
  125953. /**
  125954. * Sets the value of D-pad left
  125955. */
  125956. set dPadLeft(value: number);
  125957. /**
  125958. * Gets the value of D-pad right
  125959. */
  125960. get dPadRight(): number;
  125961. /**
  125962. * Sets the value of D-pad right
  125963. */
  125964. set dPadRight(value: number);
  125965. /**
  125966. * Force the gamepad to synchronize with device values
  125967. */
  125968. update(): void;
  125969. /**
  125970. * Disposes the gamepad
  125971. */
  125972. dispose(): void;
  125973. }
  125974. }
  125975. declare module BABYLON {
  125976. /**
  125977. * Defines supported buttons for DualShock compatible gamepads
  125978. */
  125979. export enum DualShockButton {
  125980. /** Cross */
  125981. Cross = 0,
  125982. /** Circle */
  125983. Circle = 1,
  125984. /** Square */
  125985. Square = 2,
  125986. /** Triangle */
  125987. Triangle = 3,
  125988. /** L1 */
  125989. L1 = 4,
  125990. /** R1 */
  125991. R1 = 5,
  125992. /** Share */
  125993. Share = 8,
  125994. /** Options */
  125995. Options = 9,
  125996. /** Left stick */
  125997. LeftStick = 10,
  125998. /** Right stick */
  125999. RightStick = 11
  126000. }
  126001. /** Defines values for DualShock DPad */
  126002. export enum DualShockDpad {
  126003. /** Up */
  126004. Up = 12,
  126005. /** Down */
  126006. Down = 13,
  126007. /** Left */
  126008. Left = 14,
  126009. /** Right */
  126010. Right = 15
  126011. }
  126012. /**
  126013. * Defines a DualShock gamepad
  126014. */
  126015. export class DualShockPad extends Gamepad {
  126016. private _leftTrigger;
  126017. private _rightTrigger;
  126018. private _onlefttriggerchanged;
  126019. private _onrighttriggerchanged;
  126020. private _onbuttondown;
  126021. private _onbuttonup;
  126022. private _ondpaddown;
  126023. private _ondpadup;
  126024. /** Observable raised when a button is pressed */
  126025. onButtonDownObservable: Observable<DualShockButton>;
  126026. /** Observable raised when a button is released */
  126027. onButtonUpObservable: Observable<DualShockButton>;
  126028. /** Observable raised when a pad is pressed */
  126029. onPadDownObservable: Observable<DualShockDpad>;
  126030. /** Observable raised when a pad is released */
  126031. onPadUpObservable: Observable<DualShockDpad>;
  126032. private _buttonCross;
  126033. private _buttonCircle;
  126034. private _buttonSquare;
  126035. private _buttonTriangle;
  126036. private _buttonShare;
  126037. private _buttonOptions;
  126038. private _buttonL1;
  126039. private _buttonR1;
  126040. private _buttonLeftStick;
  126041. private _buttonRightStick;
  126042. private _dPadUp;
  126043. private _dPadDown;
  126044. private _dPadLeft;
  126045. private _dPadRight;
  126046. /**
  126047. * Creates a new DualShock gamepad object
  126048. * @param id defines the id of this gamepad
  126049. * @param index defines its index
  126050. * @param gamepad defines the internal HTML gamepad object
  126051. */
  126052. constructor(id: string, index: number, gamepad: any);
  126053. /**
  126054. * Defines the callback to call when left trigger is pressed
  126055. * @param callback defines the callback to use
  126056. */
  126057. onlefttriggerchanged(callback: (value: number) => void): void;
  126058. /**
  126059. * Defines the callback to call when right trigger is pressed
  126060. * @param callback defines the callback to use
  126061. */
  126062. onrighttriggerchanged(callback: (value: number) => void): void;
  126063. /**
  126064. * Gets the left trigger value
  126065. */
  126066. get leftTrigger(): number;
  126067. /**
  126068. * Sets the left trigger value
  126069. */
  126070. set leftTrigger(newValue: number);
  126071. /**
  126072. * Gets the right trigger value
  126073. */
  126074. get rightTrigger(): number;
  126075. /**
  126076. * Sets the right trigger value
  126077. */
  126078. set rightTrigger(newValue: number);
  126079. /**
  126080. * Defines the callback to call when a button is pressed
  126081. * @param callback defines the callback to use
  126082. */
  126083. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126084. /**
  126085. * Defines the callback to call when a button is released
  126086. * @param callback defines the callback to use
  126087. */
  126088. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126089. /**
  126090. * Defines the callback to call when a pad is pressed
  126091. * @param callback defines the callback to use
  126092. */
  126093. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126094. /**
  126095. * Defines the callback to call when a pad is released
  126096. * @param callback defines the callback to use
  126097. */
  126098. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126099. private _setButtonValue;
  126100. private _setDPadValue;
  126101. /**
  126102. * Gets the value of the `Cross` button
  126103. */
  126104. get buttonCross(): number;
  126105. /**
  126106. * Sets the value of the `Cross` button
  126107. */
  126108. set buttonCross(value: number);
  126109. /**
  126110. * Gets the value of the `Circle` button
  126111. */
  126112. get buttonCircle(): number;
  126113. /**
  126114. * Sets the value of the `Circle` button
  126115. */
  126116. set buttonCircle(value: number);
  126117. /**
  126118. * Gets the value of the `Square` button
  126119. */
  126120. get buttonSquare(): number;
  126121. /**
  126122. * Sets the value of the `Square` button
  126123. */
  126124. set buttonSquare(value: number);
  126125. /**
  126126. * Gets the value of the `Triangle` button
  126127. */
  126128. get buttonTriangle(): number;
  126129. /**
  126130. * Sets the value of the `Triangle` button
  126131. */
  126132. set buttonTriangle(value: number);
  126133. /**
  126134. * Gets the value of the `Options` button
  126135. */
  126136. get buttonOptions(): number;
  126137. /**
  126138. * Sets the value of the `Options` button
  126139. */
  126140. set buttonOptions(value: number);
  126141. /**
  126142. * Gets the value of the `Share` button
  126143. */
  126144. get buttonShare(): number;
  126145. /**
  126146. * Sets the value of the `Share` button
  126147. */
  126148. set buttonShare(value: number);
  126149. /**
  126150. * Gets the value of the `L1` button
  126151. */
  126152. get buttonL1(): number;
  126153. /**
  126154. * Sets the value of the `L1` button
  126155. */
  126156. set buttonL1(value: number);
  126157. /**
  126158. * Gets the value of the `R1` button
  126159. */
  126160. get buttonR1(): number;
  126161. /**
  126162. * Sets the value of the `R1` button
  126163. */
  126164. set buttonR1(value: number);
  126165. /**
  126166. * Gets the value of the Left joystick
  126167. */
  126168. get buttonLeftStick(): number;
  126169. /**
  126170. * Sets the value of the Left joystick
  126171. */
  126172. set buttonLeftStick(value: number);
  126173. /**
  126174. * Gets the value of the Right joystick
  126175. */
  126176. get buttonRightStick(): number;
  126177. /**
  126178. * Sets the value of the Right joystick
  126179. */
  126180. set buttonRightStick(value: number);
  126181. /**
  126182. * Gets the value of D-pad up
  126183. */
  126184. get dPadUp(): number;
  126185. /**
  126186. * Sets the value of D-pad up
  126187. */
  126188. set dPadUp(value: number);
  126189. /**
  126190. * Gets the value of D-pad down
  126191. */
  126192. get dPadDown(): number;
  126193. /**
  126194. * Sets the value of D-pad down
  126195. */
  126196. set dPadDown(value: number);
  126197. /**
  126198. * Gets the value of D-pad left
  126199. */
  126200. get dPadLeft(): number;
  126201. /**
  126202. * Sets the value of D-pad left
  126203. */
  126204. set dPadLeft(value: number);
  126205. /**
  126206. * Gets the value of D-pad right
  126207. */
  126208. get dPadRight(): number;
  126209. /**
  126210. * Sets the value of D-pad right
  126211. */
  126212. set dPadRight(value: number);
  126213. /**
  126214. * Force the gamepad to synchronize with device values
  126215. */
  126216. update(): void;
  126217. /**
  126218. * Disposes the gamepad
  126219. */
  126220. dispose(): void;
  126221. }
  126222. }
  126223. declare module BABYLON {
  126224. /**
  126225. * Manager for handling gamepads
  126226. */
  126227. export class GamepadManager {
  126228. private _scene?;
  126229. private _babylonGamepads;
  126230. private _oneGamepadConnected;
  126231. /** @hidden */
  126232. _isMonitoring: boolean;
  126233. private _gamepadEventSupported;
  126234. private _gamepadSupport?;
  126235. /**
  126236. * observable to be triggered when the gamepad controller has been connected
  126237. */
  126238. onGamepadConnectedObservable: Observable<Gamepad>;
  126239. /**
  126240. * observable to be triggered when the gamepad controller has been disconnected
  126241. */
  126242. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126243. private _onGamepadConnectedEvent;
  126244. private _onGamepadDisconnectedEvent;
  126245. /**
  126246. * Initializes the gamepad manager
  126247. * @param _scene BabylonJS scene
  126248. */
  126249. constructor(_scene?: Scene | undefined);
  126250. /**
  126251. * The gamepads in the game pad manager
  126252. */
  126253. get gamepads(): Gamepad[];
  126254. /**
  126255. * Get the gamepad controllers based on type
  126256. * @param type The type of gamepad controller
  126257. * @returns Nullable gamepad
  126258. */
  126259. getGamepadByType(type?: number): Nullable<Gamepad>;
  126260. /**
  126261. * Disposes the gamepad manager
  126262. */
  126263. dispose(): void;
  126264. private _addNewGamepad;
  126265. private _startMonitoringGamepads;
  126266. private _stopMonitoringGamepads;
  126267. /** @hidden */
  126268. _checkGamepadsStatus(): void;
  126269. private _updateGamepadObjects;
  126270. }
  126271. }
  126272. declare module BABYLON {
  126273. interface Scene {
  126274. /** @hidden */
  126275. _gamepadManager: Nullable<GamepadManager>;
  126276. /**
  126277. * Gets the gamepad manager associated with the scene
  126278. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126279. */
  126280. gamepadManager: GamepadManager;
  126281. }
  126282. /**
  126283. * Interface representing a free camera inputs manager
  126284. */
  126285. interface FreeCameraInputsManager {
  126286. /**
  126287. * Adds gamepad input support to the FreeCameraInputsManager.
  126288. * @returns the FreeCameraInputsManager
  126289. */
  126290. addGamepad(): FreeCameraInputsManager;
  126291. }
  126292. /**
  126293. * Interface representing an arc rotate camera inputs manager
  126294. */
  126295. interface ArcRotateCameraInputsManager {
  126296. /**
  126297. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126298. * @returns the camera inputs manager
  126299. */
  126300. addGamepad(): ArcRotateCameraInputsManager;
  126301. }
  126302. /**
  126303. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126304. */
  126305. export class GamepadSystemSceneComponent implements ISceneComponent {
  126306. /**
  126307. * The component name helpfull to identify the component in the list of scene components.
  126308. */
  126309. readonly name: string;
  126310. /**
  126311. * The scene the component belongs to.
  126312. */
  126313. scene: Scene;
  126314. /**
  126315. * Creates a new instance of the component for the given scene
  126316. * @param scene Defines the scene to register the component in
  126317. */
  126318. constructor(scene: Scene);
  126319. /**
  126320. * Registers the component in a given scene
  126321. */
  126322. register(): void;
  126323. /**
  126324. * Rebuilds the elements related to this component in case of
  126325. * context lost for instance.
  126326. */
  126327. rebuild(): void;
  126328. /**
  126329. * Disposes the component and the associated ressources
  126330. */
  126331. dispose(): void;
  126332. private _beforeCameraUpdate;
  126333. }
  126334. }
  126335. declare module BABYLON {
  126336. /**
  126337. * 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,
  126338. * which still works and will still be found in many Playgrounds.
  126339. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126340. */
  126341. export class UniversalCamera extends TouchCamera {
  126342. /**
  126343. * Defines the gamepad rotation sensiblity.
  126344. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126345. */
  126346. get gamepadAngularSensibility(): number;
  126347. set gamepadAngularSensibility(value: number);
  126348. /**
  126349. * Defines the gamepad move sensiblity.
  126350. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126351. */
  126352. get gamepadMoveSensibility(): number;
  126353. set gamepadMoveSensibility(value: number);
  126354. /**
  126355. * 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,
  126356. * which still works and will still be found in many Playgrounds.
  126357. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126358. * @param name Define the name of the camera in the scene
  126359. * @param position Define the start position of the camera in the scene
  126360. * @param scene Define the scene the camera belongs to
  126361. */
  126362. constructor(name: string, position: Vector3, scene: Scene);
  126363. /**
  126364. * Gets the current object class name.
  126365. * @return the class name
  126366. */
  126367. getClassName(): string;
  126368. }
  126369. }
  126370. declare module BABYLON {
  126371. /**
  126372. * This represents a FPS type of camera. This is only here for back compat purpose.
  126373. * Please use the UniversalCamera instead as both are identical.
  126374. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126375. */
  126376. export class GamepadCamera extends UniversalCamera {
  126377. /**
  126378. * Instantiates a new Gamepad Camera
  126379. * This represents a FPS type of camera. This is only here for back compat purpose.
  126380. * Please use the UniversalCamera instead as both are identical.
  126381. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126382. * @param name Define the name of the camera in the scene
  126383. * @param position Define the start position of the camera in the scene
  126384. * @param scene Define the scene the camera belongs to
  126385. */
  126386. constructor(name: string, position: Vector3, scene: Scene);
  126387. /**
  126388. * Gets the current object class name.
  126389. * @return the class name
  126390. */
  126391. getClassName(): string;
  126392. }
  126393. }
  126394. declare module BABYLON {
  126395. /** @hidden */
  126396. export var passPixelShader: {
  126397. name: string;
  126398. shader: string;
  126399. };
  126400. }
  126401. declare module BABYLON {
  126402. /** @hidden */
  126403. export var passCubePixelShader: {
  126404. name: string;
  126405. shader: string;
  126406. };
  126407. }
  126408. declare module BABYLON {
  126409. /**
  126410. * PassPostProcess which produces an output the same as it's input
  126411. */
  126412. export class PassPostProcess extends PostProcess {
  126413. /**
  126414. * Gets a string identifying the name of the class
  126415. * @returns "PassPostProcess" string
  126416. */
  126417. getClassName(): string;
  126418. /**
  126419. * Creates the PassPostProcess
  126420. * @param name The name of the effect.
  126421. * @param options The required width/height ratio to downsize to before computing the render pass.
  126422. * @param camera The camera to apply the render pass to.
  126423. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126424. * @param engine The engine which the post process will be applied. (default: current engine)
  126425. * @param reusable If the post process can be reused on the same frame. (default: false)
  126426. * @param textureType The type of texture to be used when performing the post processing.
  126427. * @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)
  126428. */
  126429. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126430. /** @hidden */
  126431. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126432. }
  126433. /**
  126434. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126435. */
  126436. export class PassCubePostProcess extends PostProcess {
  126437. private _face;
  126438. /**
  126439. * Gets or sets the cube face to display.
  126440. * * 0 is +X
  126441. * * 1 is -X
  126442. * * 2 is +Y
  126443. * * 3 is -Y
  126444. * * 4 is +Z
  126445. * * 5 is -Z
  126446. */
  126447. get face(): number;
  126448. set face(value: number);
  126449. /**
  126450. * Gets a string identifying the name of the class
  126451. * @returns "PassCubePostProcess" string
  126452. */
  126453. getClassName(): string;
  126454. /**
  126455. * Creates the PassCubePostProcess
  126456. * @param name The name of the effect.
  126457. * @param options The required width/height ratio to downsize to before computing the render pass.
  126458. * @param camera The camera to apply the render pass to.
  126459. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126460. * @param engine The engine which the post process will be applied. (default: current engine)
  126461. * @param reusable If the post process can be reused on the same frame. (default: false)
  126462. * @param textureType The type of texture to be used when performing the post processing.
  126463. * @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)
  126464. */
  126465. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126466. /** @hidden */
  126467. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126468. }
  126469. }
  126470. declare module BABYLON {
  126471. /** @hidden */
  126472. export var anaglyphPixelShader: {
  126473. name: string;
  126474. shader: string;
  126475. };
  126476. }
  126477. declare module BABYLON {
  126478. /**
  126479. * Postprocess used to generate anaglyphic rendering
  126480. */
  126481. export class AnaglyphPostProcess extends PostProcess {
  126482. private _passedProcess;
  126483. /**
  126484. * Gets a string identifying the name of the class
  126485. * @returns "AnaglyphPostProcess" string
  126486. */
  126487. getClassName(): string;
  126488. /**
  126489. * Creates a new AnaglyphPostProcess
  126490. * @param name defines postprocess name
  126491. * @param options defines creation options or target ratio scale
  126492. * @param rigCameras defines cameras using this postprocess
  126493. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126494. * @param engine defines hosting engine
  126495. * @param reusable defines if the postprocess will be reused multiple times per frame
  126496. */
  126497. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126498. }
  126499. }
  126500. declare module BABYLON {
  126501. /**
  126502. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126503. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126504. */
  126505. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126506. /**
  126507. * Creates a new AnaglyphArcRotateCamera
  126508. * @param name defines camera name
  126509. * @param alpha defines alpha angle (in radians)
  126510. * @param beta defines beta angle (in radians)
  126511. * @param radius defines radius
  126512. * @param target defines camera target
  126513. * @param interaxialDistance defines distance between each color axis
  126514. * @param scene defines the hosting scene
  126515. */
  126516. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126517. /**
  126518. * Gets camera class name
  126519. * @returns AnaglyphArcRotateCamera
  126520. */
  126521. getClassName(): string;
  126522. }
  126523. }
  126524. declare module BABYLON {
  126525. /**
  126526. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126527. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126528. */
  126529. export class AnaglyphFreeCamera extends FreeCamera {
  126530. /**
  126531. * Creates a new AnaglyphFreeCamera
  126532. * @param name defines camera name
  126533. * @param position defines initial position
  126534. * @param interaxialDistance defines distance between each color axis
  126535. * @param scene defines the hosting scene
  126536. */
  126537. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126538. /**
  126539. * Gets camera class name
  126540. * @returns AnaglyphFreeCamera
  126541. */
  126542. getClassName(): string;
  126543. }
  126544. }
  126545. declare module BABYLON {
  126546. /**
  126547. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126548. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126549. */
  126550. export class AnaglyphGamepadCamera extends GamepadCamera {
  126551. /**
  126552. * Creates a new AnaglyphGamepadCamera
  126553. * @param name defines camera name
  126554. * @param position defines initial position
  126555. * @param interaxialDistance defines distance between each color axis
  126556. * @param scene defines the hosting scene
  126557. */
  126558. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126559. /**
  126560. * Gets camera class name
  126561. * @returns AnaglyphGamepadCamera
  126562. */
  126563. getClassName(): string;
  126564. }
  126565. }
  126566. declare module BABYLON {
  126567. /**
  126568. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126569. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126570. */
  126571. export class AnaglyphUniversalCamera extends UniversalCamera {
  126572. /**
  126573. * Creates a new AnaglyphUniversalCamera
  126574. * @param name defines camera name
  126575. * @param position defines initial position
  126576. * @param interaxialDistance defines distance between each color axis
  126577. * @param scene defines the hosting scene
  126578. */
  126579. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126580. /**
  126581. * Gets camera class name
  126582. * @returns AnaglyphUniversalCamera
  126583. */
  126584. getClassName(): string;
  126585. }
  126586. }
  126587. declare module BABYLON {
  126588. /**
  126589. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126590. * @see https://doc.babylonjs.com/features/cameras
  126591. */
  126592. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126593. /**
  126594. * Creates a new StereoscopicArcRotateCamera
  126595. * @param name defines camera name
  126596. * @param alpha defines alpha angle (in radians)
  126597. * @param beta defines beta angle (in radians)
  126598. * @param radius defines radius
  126599. * @param target defines camera target
  126600. * @param interaxialDistance defines distance between each color axis
  126601. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126602. * @param scene defines the hosting scene
  126603. */
  126604. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126605. /**
  126606. * Gets camera class name
  126607. * @returns StereoscopicArcRotateCamera
  126608. */
  126609. getClassName(): string;
  126610. }
  126611. }
  126612. declare module BABYLON {
  126613. /**
  126614. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126615. * @see https://doc.babylonjs.com/features/cameras
  126616. */
  126617. export class StereoscopicFreeCamera extends FreeCamera {
  126618. /**
  126619. * Creates a new StereoscopicFreeCamera
  126620. * @param name defines camera name
  126621. * @param position defines initial position
  126622. * @param interaxialDistance defines distance between each color axis
  126623. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126624. * @param scene defines the hosting scene
  126625. */
  126626. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126627. /**
  126628. * Gets camera class name
  126629. * @returns StereoscopicFreeCamera
  126630. */
  126631. getClassName(): string;
  126632. }
  126633. }
  126634. declare module BABYLON {
  126635. /**
  126636. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126637. * @see https://doc.babylonjs.com/features/cameras
  126638. */
  126639. export class StereoscopicGamepadCamera extends GamepadCamera {
  126640. /**
  126641. * Creates a new StereoscopicGamepadCamera
  126642. * @param name defines camera name
  126643. * @param position defines initial position
  126644. * @param interaxialDistance defines distance between each color axis
  126645. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126646. * @param scene defines the hosting scene
  126647. */
  126648. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126649. /**
  126650. * Gets camera class name
  126651. * @returns StereoscopicGamepadCamera
  126652. */
  126653. getClassName(): string;
  126654. }
  126655. }
  126656. declare module BABYLON {
  126657. /**
  126658. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  126659. * @see https://doc.babylonjs.com/features/cameras
  126660. */
  126661. export class StereoscopicUniversalCamera extends UniversalCamera {
  126662. /**
  126663. * Creates a new StereoscopicUniversalCamera
  126664. * @param name defines camera name
  126665. * @param position defines initial position
  126666. * @param interaxialDistance defines distance between each color axis
  126667. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126668. * @param scene defines the hosting scene
  126669. */
  126670. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126671. /**
  126672. * Gets camera class name
  126673. * @returns StereoscopicUniversalCamera
  126674. */
  126675. getClassName(): string;
  126676. }
  126677. }
  126678. declare module BABYLON {
  126679. /**
  126680. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  126681. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126682. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126683. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126684. */
  126685. export class VirtualJoysticksCamera extends FreeCamera {
  126686. /**
  126687. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  126688. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  126689. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  126690. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  126691. * @param name Define the name of the camera in the scene
  126692. * @param position Define the start position of the camera in the scene
  126693. * @param scene Define the scene the camera belongs to
  126694. */
  126695. constructor(name: string, position: Vector3, scene: Scene);
  126696. /**
  126697. * Gets the current object class name.
  126698. * @return the class name
  126699. */
  126700. getClassName(): string;
  126701. }
  126702. }
  126703. declare module BABYLON {
  126704. /**
  126705. * This represents all the required metrics to create a VR camera.
  126706. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  126707. */
  126708. export class VRCameraMetrics {
  126709. /**
  126710. * Define the horizontal resolution off the screen.
  126711. */
  126712. hResolution: number;
  126713. /**
  126714. * Define the vertical resolution off the screen.
  126715. */
  126716. vResolution: number;
  126717. /**
  126718. * Define the horizontal screen size.
  126719. */
  126720. hScreenSize: number;
  126721. /**
  126722. * Define the vertical screen size.
  126723. */
  126724. vScreenSize: number;
  126725. /**
  126726. * Define the vertical screen center position.
  126727. */
  126728. vScreenCenter: number;
  126729. /**
  126730. * Define the distance of the eyes to the screen.
  126731. */
  126732. eyeToScreenDistance: number;
  126733. /**
  126734. * Define the distance between both lenses
  126735. */
  126736. lensSeparationDistance: number;
  126737. /**
  126738. * Define the distance between both viewer's eyes.
  126739. */
  126740. interpupillaryDistance: number;
  126741. /**
  126742. * Define the distortion factor of the VR postprocess.
  126743. * Please, touch with care.
  126744. */
  126745. distortionK: number[];
  126746. /**
  126747. * Define the chromatic aberration correction factors for the VR post process.
  126748. */
  126749. chromaAbCorrection: number[];
  126750. /**
  126751. * Define the scale factor of the post process.
  126752. * The smaller the better but the slower.
  126753. */
  126754. postProcessScaleFactor: number;
  126755. /**
  126756. * Define an offset for the lens center.
  126757. */
  126758. lensCenterOffset: number;
  126759. /**
  126760. * Define if the current vr camera should compensate the distortion of the lense or not.
  126761. */
  126762. compensateDistortion: boolean;
  126763. /**
  126764. * Defines if multiview should be enabled when rendering (Default: false)
  126765. */
  126766. multiviewEnabled: boolean;
  126767. /**
  126768. * Gets the rendering aspect ratio based on the provided resolutions.
  126769. */
  126770. get aspectRatio(): number;
  126771. /**
  126772. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  126773. */
  126774. get aspectRatioFov(): number;
  126775. /**
  126776. * @hidden
  126777. */
  126778. get leftHMatrix(): Matrix;
  126779. /**
  126780. * @hidden
  126781. */
  126782. get rightHMatrix(): Matrix;
  126783. /**
  126784. * @hidden
  126785. */
  126786. get leftPreViewMatrix(): Matrix;
  126787. /**
  126788. * @hidden
  126789. */
  126790. get rightPreViewMatrix(): Matrix;
  126791. /**
  126792. * Get the default VRMetrics based on the most generic setup.
  126793. * @returns the default vr metrics
  126794. */
  126795. static GetDefault(): VRCameraMetrics;
  126796. }
  126797. }
  126798. declare module BABYLON {
  126799. /** @hidden */
  126800. export var vrDistortionCorrectionPixelShader: {
  126801. name: string;
  126802. shader: string;
  126803. };
  126804. }
  126805. declare module BABYLON {
  126806. /**
  126807. * VRDistortionCorrectionPostProcess used for mobile VR
  126808. */
  126809. export class VRDistortionCorrectionPostProcess extends PostProcess {
  126810. private _isRightEye;
  126811. private _distortionFactors;
  126812. private _postProcessScaleFactor;
  126813. private _lensCenterOffset;
  126814. private _scaleIn;
  126815. private _scaleFactor;
  126816. private _lensCenter;
  126817. /**
  126818. * Gets a string identifying the name of the class
  126819. * @returns "VRDistortionCorrectionPostProcess" string
  126820. */
  126821. getClassName(): string;
  126822. /**
  126823. * Initializes the VRDistortionCorrectionPostProcess
  126824. * @param name The name of the effect.
  126825. * @param camera The camera to apply the render pass to.
  126826. * @param isRightEye If this is for the right eye distortion
  126827. * @param vrMetrics All the required metrics for the VR camera
  126828. */
  126829. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  126830. }
  126831. }
  126832. declare module BABYLON {
  126833. /**
  126834. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  126835. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126836. */
  126837. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  126838. /**
  126839. * Creates a new VRDeviceOrientationArcRotateCamera
  126840. * @param name defines camera name
  126841. * @param alpha defines the camera rotation along the logitudinal axis
  126842. * @param beta defines the camera rotation along the latitudinal axis
  126843. * @param radius defines the camera distance from its target
  126844. * @param target defines the camera target
  126845. * @param scene defines the scene the camera belongs to
  126846. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126847. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126848. */
  126849. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126850. /**
  126851. * Gets camera class name
  126852. * @returns VRDeviceOrientationArcRotateCamera
  126853. */
  126854. getClassName(): string;
  126855. }
  126856. }
  126857. declare module BABYLON {
  126858. /**
  126859. * Camera used to simulate VR rendering (based on FreeCamera)
  126860. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126861. */
  126862. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  126863. /**
  126864. * Creates a new VRDeviceOrientationFreeCamera
  126865. * @param name defines camera name
  126866. * @param position defines the start position of the camera
  126867. * @param scene defines the scene the camera belongs to
  126868. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126869. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126870. */
  126871. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126872. /**
  126873. * Gets camera class name
  126874. * @returns VRDeviceOrientationFreeCamera
  126875. */
  126876. getClassName(): string;
  126877. }
  126878. }
  126879. declare module BABYLON {
  126880. /**
  126881. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  126882. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  126883. */
  126884. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  126885. /**
  126886. * Creates a new VRDeviceOrientationGamepadCamera
  126887. * @param name defines camera name
  126888. * @param position defines the start position of the camera
  126889. * @param scene defines the scene the camera belongs to
  126890. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  126891. * @param vrCameraMetrics defines the vr metrics associated to the camera
  126892. */
  126893. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  126894. /**
  126895. * Gets camera class name
  126896. * @returns VRDeviceOrientationGamepadCamera
  126897. */
  126898. getClassName(): string;
  126899. }
  126900. }
  126901. declare module BABYLON {
  126902. /**
  126903. * A class extending Texture allowing drawing on a texture
  126904. * @see https://doc.babylonjs.com/how_to/dynamictexture
  126905. */
  126906. export class DynamicTexture extends Texture {
  126907. private _generateMipMaps;
  126908. private _canvas;
  126909. private _context;
  126910. /**
  126911. * Creates a DynamicTexture
  126912. * @param name defines the name of the texture
  126913. * @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
  126914. * @param scene defines the scene where you want the texture
  126915. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  126916. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  126917. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  126918. */
  126919. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  126920. /**
  126921. * Get the current class name of the texture useful for serialization or dynamic coding.
  126922. * @returns "DynamicTexture"
  126923. */
  126924. getClassName(): string;
  126925. /**
  126926. * Gets the current state of canRescale
  126927. */
  126928. get canRescale(): boolean;
  126929. private _recreate;
  126930. /**
  126931. * Scales the texture
  126932. * @param ratio the scale factor to apply to both width and height
  126933. */
  126934. scale(ratio: number): void;
  126935. /**
  126936. * Resizes the texture
  126937. * @param width the new width
  126938. * @param height the new height
  126939. */
  126940. scaleTo(width: number, height: number): void;
  126941. /**
  126942. * Gets the context of the canvas used by the texture
  126943. * @returns the canvas context of the dynamic texture
  126944. */
  126945. getContext(): CanvasRenderingContext2D;
  126946. /**
  126947. * Clears the texture
  126948. */
  126949. clear(): void;
  126950. /**
  126951. * Updates the texture
  126952. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126953. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  126954. */
  126955. update(invertY?: boolean, premulAlpha?: boolean): void;
  126956. /**
  126957. * Draws text onto the texture
  126958. * @param text defines the text to be drawn
  126959. * @param x defines the placement of the text from the left
  126960. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  126961. * @param font defines the font to be used with font-style, font-size, font-name
  126962. * @param color defines the color used for the text
  126963. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  126964. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  126965. * @param update defines whether texture is immediately update (default is true)
  126966. */
  126967. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  126968. /**
  126969. * Clones the texture
  126970. * @returns the clone of the texture.
  126971. */
  126972. clone(): DynamicTexture;
  126973. /**
  126974. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  126975. * @returns a serialized dynamic texture object
  126976. */
  126977. serialize(): any;
  126978. private _IsCanvasElement;
  126979. /** @hidden */
  126980. _rebuild(): void;
  126981. }
  126982. }
  126983. declare module BABYLON {
  126984. /**
  126985. * Class containing static functions to help procedurally build meshes
  126986. */
  126987. export class GroundBuilder {
  126988. /**
  126989. * Creates a ground mesh
  126990. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  126991. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  126992. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  126993. * @param name defines the name of the mesh
  126994. * @param options defines the options used to create the mesh
  126995. * @param scene defines the hosting scene
  126996. * @returns the ground mesh
  126997. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  126998. */
  126999. static CreateGround(name: string, options: {
  127000. width?: number;
  127001. height?: number;
  127002. subdivisions?: number;
  127003. subdivisionsX?: number;
  127004. subdivisionsY?: number;
  127005. updatable?: boolean;
  127006. }, scene: any): Mesh;
  127007. /**
  127008. * Creates a tiled ground mesh
  127009. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127010. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127011. * * 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
  127012. * * 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
  127013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127014. * @param name defines the name of the mesh
  127015. * @param options defines the options used to create the mesh
  127016. * @param scene defines the hosting scene
  127017. * @returns the tiled ground mesh
  127018. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127019. */
  127020. static CreateTiledGround(name: string, options: {
  127021. xmin: number;
  127022. zmin: number;
  127023. xmax: number;
  127024. zmax: number;
  127025. subdivisions?: {
  127026. w: number;
  127027. h: number;
  127028. };
  127029. precision?: {
  127030. w: number;
  127031. h: number;
  127032. };
  127033. updatable?: boolean;
  127034. }, scene?: Nullable<Scene>): Mesh;
  127035. /**
  127036. * Creates a ground mesh from a height map
  127037. * * The parameter `url` sets the URL of the height map image resource.
  127038. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127039. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127040. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127041. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127042. * * 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.
  127043. * * 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).
  127044. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127045. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127046. * @param name defines the name of the mesh
  127047. * @param url defines the url to the height map
  127048. * @param options defines the options used to create the mesh
  127049. * @param scene defines the hosting scene
  127050. * @returns the ground mesh
  127051. * @see https://doc.babylonjs.com/babylon101/height_map
  127052. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127053. */
  127054. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127055. width?: number;
  127056. height?: number;
  127057. subdivisions?: number;
  127058. minHeight?: number;
  127059. maxHeight?: number;
  127060. colorFilter?: Color3;
  127061. alphaFilter?: number;
  127062. updatable?: boolean;
  127063. onReady?: (mesh: GroundMesh) => void;
  127064. }, scene?: Nullable<Scene>): GroundMesh;
  127065. }
  127066. }
  127067. declare module BABYLON {
  127068. /**
  127069. * Class containing static functions to help procedurally build meshes
  127070. */
  127071. export class TorusBuilder {
  127072. /**
  127073. * Creates a torus mesh
  127074. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127075. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127076. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127077. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127078. * * 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
  127079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127080. * @param name defines the name of the mesh
  127081. * @param options defines the options used to create the mesh
  127082. * @param scene defines the hosting scene
  127083. * @returns the torus mesh
  127084. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127085. */
  127086. static CreateTorus(name: string, options: {
  127087. diameter?: number;
  127088. thickness?: number;
  127089. tessellation?: number;
  127090. updatable?: boolean;
  127091. sideOrientation?: number;
  127092. frontUVs?: Vector4;
  127093. backUVs?: Vector4;
  127094. }, scene: any): Mesh;
  127095. }
  127096. }
  127097. declare module BABYLON {
  127098. /**
  127099. * Class containing static functions to help procedurally build meshes
  127100. */
  127101. export class CylinderBuilder {
  127102. /**
  127103. * Creates a cylinder or a cone mesh
  127104. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127105. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127106. * * 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.
  127107. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127108. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127109. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127110. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127111. * * 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).
  127112. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127113. * * 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).
  127114. * * 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
  127115. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127116. * * 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
  127117. * * 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.
  127118. * * If `enclose` is false, a ring surface is one element.
  127119. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127120. * * 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
  127121. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127122. * * 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
  127123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127124. * @param name defines the name of the mesh
  127125. * @param options defines the options used to create the mesh
  127126. * @param scene defines the hosting scene
  127127. * @returns the cylinder mesh
  127128. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127129. */
  127130. static CreateCylinder(name: string, options: {
  127131. height?: number;
  127132. diameterTop?: number;
  127133. diameterBottom?: number;
  127134. diameter?: number;
  127135. tessellation?: number;
  127136. subdivisions?: number;
  127137. arc?: number;
  127138. faceColors?: Color4[];
  127139. faceUV?: Vector4[];
  127140. updatable?: boolean;
  127141. hasRings?: boolean;
  127142. enclose?: boolean;
  127143. cap?: number;
  127144. sideOrientation?: number;
  127145. frontUVs?: Vector4;
  127146. backUVs?: Vector4;
  127147. }, scene: any): Mesh;
  127148. }
  127149. }
  127150. declare module BABYLON {
  127151. /**
  127152. * States of the webXR experience
  127153. */
  127154. export enum WebXRState {
  127155. /**
  127156. * Transitioning to being in XR mode
  127157. */
  127158. ENTERING_XR = 0,
  127159. /**
  127160. * Transitioning to non XR mode
  127161. */
  127162. EXITING_XR = 1,
  127163. /**
  127164. * In XR mode and presenting
  127165. */
  127166. IN_XR = 2,
  127167. /**
  127168. * Not entered XR mode
  127169. */
  127170. NOT_IN_XR = 3
  127171. }
  127172. /**
  127173. * Abstraction of the XR render target
  127174. */
  127175. export interface WebXRRenderTarget extends IDisposable {
  127176. /**
  127177. * xrpresent context of the canvas which can be used to display/mirror xr content
  127178. */
  127179. canvasContext: WebGLRenderingContext;
  127180. /**
  127181. * xr layer for the canvas
  127182. */
  127183. xrLayer: Nullable<XRWebGLLayer>;
  127184. /**
  127185. * Initializes the xr layer for the session
  127186. * @param xrSession xr session
  127187. * @returns a promise that will resolve once the XR Layer has been created
  127188. */
  127189. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127190. }
  127191. }
  127192. declare module BABYLON {
  127193. /**
  127194. * COnfiguration object for WebXR output canvas
  127195. */
  127196. export class WebXRManagedOutputCanvasOptions {
  127197. /**
  127198. * An optional canvas in case you wish to create it yourself and provide it here.
  127199. * If not provided, a new canvas will be created
  127200. */
  127201. canvasElement?: HTMLCanvasElement;
  127202. /**
  127203. * Options for this XR Layer output
  127204. */
  127205. canvasOptions?: XRWebGLLayerOptions;
  127206. /**
  127207. * CSS styling for a newly created canvas (if not provided)
  127208. */
  127209. newCanvasCssStyle?: string;
  127210. /**
  127211. * Get the default values of the configuration object
  127212. * @param engine defines the engine to use (can be null)
  127213. * @returns default values of this configuration object
  127214. */
  127215. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127216. }
  127217. /**
  127218. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127219. */
  127220. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127221. private _options;
  127222. private _canvas;
  127223. private _engine;
  127224. private _originalCanvasSize;
  127225. /**
  127226. * Rendering context of the canvas which can be used to display/mirror xr content
  127227. */
  127228. canvasContext: WebGLRenderingContext;
  127229. /**
  127230. * xr layer for the canvas
  127231. */
  127232. xrLayer: Nullable<XRWebGLLayer>;
  127233. /**
  127234. * Obseervers registered here will be triggered when the xr layer was initialized
  127235. */
  127236. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127237. /**
  127238. * Initializes the canvas to be added/removed upon entering/exiting xr
  127239. * @param _xrSessionManager The XR Session manager
  127240. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127241. */
  127242. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127243. /**
  127244. * Disposes of the object
  127245. */
  127246. dispose(): void;
  127247. /**
  127248. * Initializes the xr layer for the session
  127249. * @param xrSession xr session
  127250. * @returns a promise that will resolve once the XR Layer has been created
  127251. */
  127252. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127253. private _addCanvas;
  127254. private _removeCanvas;
  127255. private _setCanvasSize;
  127256. private _setManagedOutputCanvas;
  127257. }
  127258. }
  127259. declare module BABYLON {
  127260. /**
  127261. * Manages an XRSession to work with Babylon's engine
  127262. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127263. */
  127264. export class WebXRSessionManager implements IDisposable {
  127265. /** The scene which the session should be created for */
  127266. scene: Scene;
  127267. private _referenceSpace;
  127268. private _rttProvider;
  127269. private _sessionEnded;
  127270. private _xrNavigator;
  127271. private baseLayer;
  127272. /**
  127273. * The base reference space from which the session started. good if you want to reset your
  127274. * reference space
  127275. */
  127276. baseReferenceSpace: XRReferenceSpace;
  127277. /**
  127278. * Current XR frame
  127279. */
  127280. currentFrame: Nullable<XRFrame>;
  127281. /** WebXR timestamp updated every frame */
  127282. currentTimestamp: number;
  127283. /**
  127284. * Used just in case of a failure to initialize an immersive session.
  127285. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127286. */
  127287. defaultHeightCompensation: number;
  127288. /**
  127289. * Fires every time a new xrFrame arrives which can be used to update the camera
  127290. */
  127291. onXRFrameObservable: Observable<XRFrame>;
  127292. /**
  127293. * Fires when the reference space changed
  127294. */
  127295. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127296. /**
  127297. * Fires when the xr session is ended either by the device or manually done
  127298. */
  127299. onXRSessionEnded: Observable<any>;
  127300. /**
  127301. * Fires when the xr session is ended either by the device or manually done
  127302. */
  127303. onXRSessionInit: Observable<XRSession>;
  127304. /**
  127305. * Underlying xr session
  127306. */
  127307. session: XRSession;
  127308. /**
  127309. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127310. * or get the offset the player is currently at.
  127311. */
  127312. viewerReferenceSpace: XRReferenceSpace;
  127313. /**
  127314. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127315. * @param scene The scene which the session should be created for
  127316. */
  127317. constructor(
  127318. /** The scene which the session should be created for */
  127319. scene: Scene);
  127320. /**
  127321. * The current reference space used in this session. This reference space can constantly change!
  127322. * It is mainly used to offset the camera's position.
  127323. */
  127324. get referenceSpace(): XRReferenceSpace;
  127325. /**
  127326. * Set a new reference space and triggers the observable
  127327. */
  127328. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127329. /**
  127330. * Disposes of the session manager
  127331. */
  127332. dispose(): void;
  127333. /**
  127334. * Stops the xrSession and restores the render loop
  127335. * @returns Promise which resolves after it exits XR
  127336. */
  127337. exitXRAsync(): Promise<void>;
  127338. /**
  127339. * Gets the correct render target texture to be rendered this frame for this eye
  127340. * @param eye the eye for which to get the render target
  127341. * @returns the render target for the specified eye
  127342. */
  127343. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127344. /**
  127345. * Creates a WebXRRenderTarget object for the XR session
  127346. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127347. * @param options optional options to provide when creating a new render target
  127348. * @returns a WebXR render target to which the session can render
  127349. */
  127350. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127351. /**
  127352. * Initializes the manager
  127353. * After initialization enterXR can be called to start an XR session
  127354. * @returns Promise which resolves after it is initialized
  127355. */
  127356. initializeAsync(): Promise<void>;
  127357. /**
  127358. * Initializes an xr session
  127359. * @param xrSessionMode mode to initialize
  127360. * @param xrSessionInit defines optional and required values to pass to the session builder
  127361. * @returns a promise which will resolve once the session has been initialized
  127362. */
  127363. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127364. /**
  127365. * Checks if a session would be supported for the creation options specified
  127366. * @param sessionMode session mode to check if supported eg. immersive-vr
  127367. * @returns A Promise that resolves to true if supported and false if not
  127368. */
  127369. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127370. /**
  127371. * Resets the reference space to the one started the session
  127372. */
  127373. resetReferenceSpace(): void;
  127374. /**
  127375. * Starts rendering to the xr layer
  127376. */
  127377. runXRRenderLoop(): void;
  127378. /**
  127379. * Sets the reference space on the xr session
  127380. * @param referenceSpaceType space to set
  127381. * @returns a promise that will resolve once the reference space has been set
  127382. */
  127383. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127384. /**
  127385. * Updates the render state of the session
  127386. * @param state state to set
  127387. * @returns a promise that resolves once the render state has been updated
  127388. */
  127389. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127390. /**
  127391. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127392. * @param sessionMode defines the session to test
  127393. * @returns a promise with boolean as final value
  127394. */
  127395. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127396. private _createRenderTargetTexture;
  127397. }
  127398. }
  127399. declare module BABYLON {
  127400. /**
  127401. * WebXR Camera which holds the views for the xrSession
  127402. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127403. */
  127404. export class WebXRCamera extends FreeCamera {
  127405. private _xrSessionManager;
  127406. private _firstFrame;
  127407. private _referenceQuaternion;
  127408. private _referencedPosition;
  127409. private _xrInvPositionCache;
  127410. private _xrInvQuaternionCache;
  127411. /**
  127412. * Observable raised before camera teleportation
  127413. */
  127414. onBeforeCameraTeleport: Observable<Vector3>;
  127415. /**
  127416. * Observable raised after camera teleportation
  127417. */
  127418. onAfterCameraTeleport: Observable<Vector3>;
  127419. /**
  127420. * Should position compensation execute on first frame.
  127421. * This is used when copying the position from a native (non XR) camera
  127422. */
  127423. compensateOnFirstFrame: boolean;
  127424. /**
  127425. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127426. * @param name the name of the camera
  127427. * @param scene the scene to add the camera to
  127428. * @param _xrSessionManager a constructed xr session manager
  127429. */
  127430. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127431. /**
  127432. * Return the user's height, unrelated to the current ground.
  127433. * This will be the y position of this camera, when ground level is 0.
  127434. */
  127435. get realWorldHeight(): number;
  127436. /** @hidden */
  127437. _updateForDualEyeDebugging(): void;
  127438. /**
  127439. * Sets this camera's transformation based on a non-vr camera
  127440. * @param otherCamera the non-vr camera to copy the transformation from
  127441. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127442. */
  127443. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127444. /**
  127445. * Gets the current instance class name ("WebXRCamera").
  127446. * @returns the class name
  127447. */
  127448. getClassName(): string;
  127449. private _rotate180;
  127450. private _updateFromXRSession;
  127451. private _updateNumberOfRigCameras;
  127452. private _updateReferenceSpace;
  127453. private _updateReferenceSpaceOffset;
  127454. }
  127455. }
  127456. declare module BABYLON {
  127457. /**
  127458. * Defining the interface required for a (webxr) feature
  127459. */
  127460. export interface IWebXRFeature extends IDisposable {
  127461. /**
  127462. * Is this feature attached
  127463. */
  127464. attached: boolean;
  127465. /**
  127466. * Should auto-attach be disabled?
  127467. */
  127468. disableAutoAttach: boolean;
  127469. /**
  127470. * Attach the feature to the session
  127471. * Will usually be called by the features manager
  127472. *
  127473. * @param force should attachment be forced (even when already attached)
  127474. * @returns true if successful.
  127475. */
  127476. attach(force?: boolean): boolean;
  127477. /**
  127478. * Detach the feature from the session
  127479. * Will usually be called by the features manager
  127480. *
  127481. * @returns true if successful.
  127482. */
  127483. detach(): boolean;
  127484. /**
  127485. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127486. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127487. *
  127488. * @returns whether or not the feature is compatible in this environment
  127489. */
  127490. isCompatible(): boolean;
  127491. /**
  127492. * Was this feature disposed;
  127493. */
  127494. isDisposed: boolean;
  127495. /**
  127496. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127497. */
  127498. xrNativeFeatureName?: string;
  127499. /**
  127500. * A list of (Babylon WebXR) features this feature depends on
  127501. */
  127502. dependsOn?: string[];
  127503. }
  127504. /**
  127505. * A list of the currently available features without referencing them
  127506. */
  127507. export class WebXRFeatureName {
  127508. /**
  127509. * The name of the anchor system feature
  127510. */
  127511. static readonly ANCHOR_SYSTEM: string;
  127512. /**
  127513. * The name of the background remover feature
  127514. */
  127515. static readonly BACKGROUND_REMOVER: string;
  127516. /**
  127517. * The name of the hit test feature
  127518. */
  127519. static readonly HIT_TEST: string;
  127520. /**
  127521. * physics impostors for xr controllers feature
  127522. */
  127523. static readonly PHYSICS_CONTROLLERS: string;
  127524. /**
  127525. * The name of the plane detection feature
  127526. */
  127527. static readonly PLANE_DETECTION: string;
  127528. /**
  127529. * The name of the pointer selection feature
  127530. */
  127531. static readonly POINTER_SELECTION: string;
  127532. /**
  127533. * The name of the teleportation feature
  127534. */
  127535. static readonly TELEPORTATION: string;
  127536. /**
  127537. * The name of the feature points feature.
  127538. */
  127539. static readonly FEATURE_POINTS: string;
  127540. /**
  127541. * The name of the hand tracking feature.
  127542. */
  127543. static readonly HAND_TRACKING: string;
  127544. }
  127545. /**
  127546. * Defining the constructor of a feature. Used to register the modules.
  127547. */
  127548. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127549. /**
  127550. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127551. * It is mainly used in AR sessions.
  127552. *
  127553. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127554. */
  127555. export class WebXRFeaturesManager implements IDisposable {
  127556. private _xrSessionManager;
  127557. private static readonly _AvailableFeatures;
  127558. private _features;
  127559. /**
  127560. * constructs a new features manages.
  127561. *
  127562. * @param _xrSessionManager an instance of WebXRSessionManager
  127563. */
  127564. constructor(_xrSessionManager: WebXRSessionManager);
  127565. /**
  127566. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127567. * Mainly used internally.
  127568. *
  127569. * @param featureName the name of the feature to register
  127570. * @param constructorFunction the function used to construct the module
  127571. * @param version the (babylon) version of the module
  127572. * @param stable is that a stable version of this module
  127573. */
  127574. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127575. /**
  127576. * Returns a constructor of a specific feature.
  127577. *
  127578. * @param featureName the name of the feature to construct
  127579. * @param version the version of the feature to load
  127580. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127581. * @param options optional options provided to the module.
  127582. * @returns a function that, when called, will return a new instance of this feature
  127583. */
  127584. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127585. /**
  127586. * Can be used to return the list of features currently registered
  127587. *
  127588. * @returns an Array of available features
  127589. */
  127590. static GetAvailableFeatures(): string[];
  127591. /**
  127592. * Gets the versions available for a specific feature
  127593. * @param featureName the name of the feature
  127594. * @returns an array with the available versions
  127595. */
  127596. static GetAvailableVersions(featureName: string): string[];
  127597. /**
  127598. * Return the latest unstable version of this feature
  127599. * @param featureName the name of the feature to search
  127600. * @returns the version number. if not found will return -1
  127601. */
  127602. static GetLatestVersionOfFeature(featureName: string): number;
  127603. /**
  127604. * Return the latest stable version of this feature
  127605. * @param featureName the name of the feature to search
  127606. * @returns the version number. if not found will return -1
  127607. */
  127608. static GetStableVersionOfFeature(featureName: string): number;
  127609. /**
  127610. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127611. * Can be used during a session to start a feature
  127612. * @param featureName the name of feature to attach
  127613. */
  127614. attachFeature(featureName: string): void;
  127615. /**
  127616. * Can be used inside a session or when the session ends to detach a specific feature
  127617. * @param featureName the name of the feature to detach
  127618. */
  127619. detachFeature(featureName: string): void;
  127620. /**
  127621. * Used to disable an already-enabled feature
  127622. * The feature will be disposed and will be recreated once enabled.
  127623. * @param featureName the feature to disable
  127624. * @returns true if disable was successful
  127625. */
  127626. disableFeature(featureName: string | {
  127627. Name: string;
  127628. }): boolean;
  127629. /**
  127630. * dispose this features manager
  127631. */
  127632. dispose(): void;
  127633. /**
  127634. * 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.
  127635. * 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.
  127636. *
  127637. * @param featureName the name of the feature to load or the class of the feature
  127638. * @param version optional version to load. if not provided the latest version will be enabled
  127639. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127640. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127641. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127642. * @returns a new constructed feature or throws an error if feature not found.
  127643. */
  127644. enableFeature(featureName: string | {
  127645. Name: string;
  127646. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127647. /**
  127648. * get the implementation of an enabled feature.
  127649. * @param featureName the name of the feature to load
  127650. * @returns the feature class, if found
  127651. */
  127652. getEnabledFeature(featureName: string): IWebXRFeature;
  127653. /**
  127654. * Get the list of enabled features
  127655. * @returns an array of enabled features
  127656. */
  127657. getEnabledFeatures(): string[];
  127658. /**
  127659. * This function will exten the session creation configuration object with enabled features.
  127660. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  127661. * according to the defined "required" variable, provided during enableFeature call
  127662. * @param xrSessionInit the xr Session init object to extend
  127663. *
  127664. * @returns an extended XRSessionInit object
  127665. */
  127666. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  127667. }
  127668. }
  127669. declare module BABYLON {
  127670. /**
  127671. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  127672. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  127673. */
  127674. export class WebXRExperienceHelper implements IDisposable {
  127675. private scene;
  127676. private _nonVRCamera;
  127677. private _originalSceneAutoClear;
  127678. private _supported;
  127679. /**
  127680. * Camera used to render xr content
  127681. */
  127682. camera: WebXRCamera;
  127683. /** A features manager for this xr session */
  127684. featuresManager: WebXRFeaturesManager;
  127685. /**
  127686. * Observers registered here will be triggered after the camera's initial transformation is set
  127687. * This can be used to set a different ground level or an extra rotation.
  127688. *
  127689. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  127690. * to the position set after this observable is done executing.
  127691. */
  127692. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  127693. /**
  127694. * Fires when the state of the experience helper has changed
  127695. */
  127696. onStateChangedObservable: Observable<WebXRState>;
  127697. /** Session manager used to keep track of xr session */
  127698. sessionManager: WebXRSessionManager;
  127699. /**
  127700. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  127701. */
  127702. state: WebXRState;
  127703. /**
  127704. * Creates a WebXRExperienceHelper
  127705. * @param scene The scene the helper should be created in
  127706. */
  127707. private constructor();
  127708. /**
  127709. * Creates the experience helper
  127710. * @param scene the scene to attach the experience helper to
  127711. * @returns a promise for the experience helper
  127712. */
  127713. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  127714. /**
  127715. * Disposes of the experience helper
  127716. */
  127717. dispose(): void;
  127718. /**
  127719. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  127720. * @param sessionMode options for the XR session
  127721. * @param referenceSpaceType frame of reference of the XR session
  127722. * @param renderTarget the output canvas that will be used to enter XR mode
  127723. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  127724. * @returns promise that resolves after xr mode has entered
  127725. */
  127726. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  127727. /**
  127728. * Exits XR mode and returns the scene to its original state
  127729. * @returns promise that resolves after xr mode has exited
  127730. */
  127731. exitXRAsync(): Promise<void>;
  127732. private _nonXRToXRCamera;
  127733. private _setState;
  127734. }
  127735. }
  127736. declare module BABYLON {
  127737. /**
  127738. * X-Y values for axes in WebXR
  127739. */
  127740. export interface IWebXRMotionControllerAxesValue {
  127741. /**
  127742. * The value of the x axis
  127743. */
  127744. x: number;
  127745. /**
  127746. * The value of the y-axis
  127747. */
  127748. y: number;
  127749. }
  127750. /**
  127751. * changed / previous values for the values of this component
  127752. */
  127753. export interface IWebXRMotionControllerComponentChangesValues<T> {
  127754. /**
  127755. * current (this frame) value
  127756. */
  127757. current: T;
  127758. /**
  127759. * previous (last change) value
  127760. */
  127761. previous: T;
  127762. }
  127763. /**
  127764. * Represents changes in the component between current frame and last values recorded
  127765. */
  127766. export interface IWebXRMotionControllerComponentChanges {
  127767. /**
  127768. * will be populated with previous and current values if axes changed
  127769. */
  127770. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  127771. /**
  127772. * will be populated with previous and current values if pressed changed
  127773. */
  127774. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127775. /**
  127776. * will be populated with previous and current values if touched changed
  127777. */
  127778. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  127779. /**
  127780. * will be populated with previous and current values if value changed
  127781. */
  127782. value?: IWebXRMotionControllerComponentChangesValues<number>;
  127783. }
  127784. /**
  127785. * This class represents a single component (for example button or thumbstick) of a motion controller
  127786. */
  127787. export class WebXRControllerComponent implements IDisposable {
  127788. /**
  127789. * the id of this component
  127790. */
  127791. id: string;
  127792. /**
  127793. * the type of the component
  127794. */
  127795. type: MotionControllerComponentType;
  127796. private _buttonIndex;
  127797. private _axesIndices;
  127798. private _axes;
  127799. private _changes;
  127800. private _currentValue;
  127801. private _hasChanges;
  127802. private _pressed;
  127803. private _touched;
  127804. /**
  127805. * button component type
  127806. */
  127807. static BUTTON_TYPE: MotionControllerComponentType;
  127808. /**
  127809. * squeeze component type
  127810. */
  127811. static SQUEEZE_TYPE: MotionControllerComponentType;
  127812. /**
  127813. * Thumbstick component type
  127814. */
  127815. static THUMBSTICK_TYPE: MotionControllerComponentType;
  127816. /**
  127817. * Touchpad component type
  127818. */
  127819. static TOUCHPAD_TYPE: MotionControllerComponentType;
  127820. /**
  127821. * trigger component type
  127822. */
  127823. static TRIGGER_TYPE: MotionControllerComponentType;
  127824. /**
  127825. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  127826. * the axes data changes
  127827. */
  127828. onAxisValueChangedObservable: Observable<{
  127829. x: number;
  127830. y: number;
  127831. }>;
  127832. /**
  127833. * Observers registered here will be triggered when the state of a button changes
  127834. * State change is either pressed / touched / value
  127835. */
  127836. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  127837. /**
  127838. * Creates a new component for a motion controller.
  127839. * It is created by the motion controller itself
  127840. *
  127841. * @param id the id of this component
  127842. * @param type the type of the component
  127843. * @param _buttonIndex index in the buttons array of the gamepad
  127844. * @param _axesIndices indices of the values in the axes array of the gamepad
  127845. */
  127846. constructor(
  127847. /**
  127848. * the id of this component
  127849. */
  127850. id: string,
  127851. /**
  127852. * the type of the component
  127853. */
  127854. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  127855. /**
  127856. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  127857. */
  127858. get axes(): IWebXRMotionControllerAxesValue;
  127859. /**
  127860. * Get the changes. Elements will be populated only if they changed with their previous and current value
  127861. */
  127862. get changes(): IWebXRMotionControllerComponentChanges;
  127863. /**
  127864. * Return whether or not the component changed the last frame
  127865. */
  127866. get hasChanges(): boolean;
  127867. /**
  127868. * is the button currently pressed
  127869. */
  127870. get pressed(): boolean;
  127871. /**
  127872. * is the button currently touched
  127873. */
  127874. get touched(): boolean;
  127875. /**
  127876. * Get the current value of this component
  127877. */
  127878. get value(): number;
  127879. /**
  127880. * Dispose this component
  127881. */
  127882. dispose(): void;
  127883. /**
  127884. * Are there axes correlating to this component
  127885. * @return true is axes data is available
  127886. */
  127887. isAxes(): boolean;
  127888. /**
  127889. * Is this component a button (hence - pressable)
  127890. * @returns true if can be pressed
  127891. */
  127892. isButton(): boolean;
  127893. /**
  127894. * update this component using the gamepad object it is in. Called on every frame
  127895. * @param nativeController the native gamepad controller object
  127896. */
  127897. update(nativeController: IMinimalMotionControllerObject): void;
  127898. }
  127899. }
  127900. declare module BABYLON {
  127901. /**
  127902. * Interface used to represent data loading progression
  127903. */
  127904. export interface ISceneLoaderProgressEvent {
  127905. /**
  127906. * Defines if data length to load can be evaluated
  127907. */
  127908. readonly lengthComputable: boolean;
  127909. /**
  127910. * Defines the loaded data length
  127911. */
  127912. readonly loaded: number;
  127913. /**
  127914. * Defines the data length to load
  127915. */
  127916. readonly total: number;
  127917. }
  127918. /**
  127919. * Interface used by SceneLoader plugins to define supported file extensions
  127920. */
  127921. export interface ISceneLoaderPluginExtensions {
  127922. /**
  127923. * Defines the list of supported extensions
  127924. */
  127925. [extension: string]: {
  127926. isBinary: boolean;
  127927. };
  127928. }
  127929. /**
  127930. * Interface used by SceneLoader plugin factory
  127931. */
  127932. export interface ISceneLoaderPluginFactory {
  127933. /**
  127934. * Defines the name of the factory
  127935. */
  127936. name: string;
  127937. /**
  127938. * Function called to create a new plugin
  127939. * @return the new plugin
  127940. */
  127941. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  127942. /**
  127943. * The callback that returns true if the data can be directly loaded.
  127944. * @param data string containing the file data
  127945. * @returns if the data can be loaded directly
  127946. */
  127947. canDirectLoad?(data: string): boolean;
  127948. }
  127949. /**
  127950. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  127951. */
  127952. export interface ISceneLoaderPluginBase {
  127953. /**
  127954. * The friendly name of this plugin.
  127955. */
  127956. name: string;
  127957. /**
  127958. * The file extensions supported by this plugin.
  127959. */
  127960. extensions: string | ISceneLoaderPluginExtensions;
  127961. /**
  127962. * The callback called when loading from a url.
  127963. * @param scene scene loading this url
  127964. * @param url url to load
  127965. * @param onSuccess callback called when the file successfully loads
  127966. * @param onProgress callback called while file is loading (if the server supports this mode)
  127967. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  127968. * @param onError callback called when the file fails to load
  127969. * @returns a file request object
  127970. */
  127971. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127972. /**
  127973. * The callback called when loading from a file object.
  127974. * @param scene scene loading this file
  127975. * @param file defines the file to load
  127976. * @param onSuccess defines the callback to call when data is loaded
  127977. * @param onProgress defines the callback to call during loading process
  127978. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  127979. * @param onError defines the callback to call when an error occurs
  127980. * @returns a file request object
  127981. */
  127982. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  127983. /**
  127984. * The callback that returns true if the data can be directly loaded.
  127985. * @param data string containing the file data
  127986. * @returns if the data can be loaded directly
  127987. */
  127988. canDirectLoad?(data: string): boolean;
  127989. /**
  127990. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  127991. * @param scene scene loading this data
  127992. * @param data string containing the data
  127993. * @returns data to pass to the plugin
  127994. */
  127995. directLoad?(scene: Scene, data: string): any;
  127996. /**
  127997. * The callback that allows custom handling of the root url based on the response url.
  127998. * @param rootUrl the original root url
  127999. * @param responseURL the response url if available
  128000. * @returns the new root url
  128001. */
  128002. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128003. }
  128004. /**
  128005. * Interface used to define a SceneLoader plugin
  128006. */
  128007. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128008. /**
  128009. * Import meshes into a scene.
  128010. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128011. * @param scene The scene to import into
  128012. * @param data The data to import
  128013. * @param rootUrl The root url for scene and resources
  128014. * @param meshes The meshes array to import into
  128015. * @param particleSystems The particle systems array to import into
  128016. * @param skeletons The skeletons array to import into
  128017. * @param onError The callback when import fails
  128018. * @returns True if successful or false otherwise
  128019. */
  128020. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128021. /**
  128022. * Load into a scene.
  128023. * @param scene The scene to load into
  128024. * @param data The data to import
  128025. * @param rootUrl The root url for scene and resources
  128026. * @param onError The callback when import fails
  128027. * @returns True if successful or false otherwise
  128028. */
  128029. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128030. /**
  128031. * Load into an asset container.
  128032. * @param scene The scene to load into
  128033. * @param data The data to import
  128034. * @param rootUrl The root url for scene and resources
  128035. * @param onError The callback when import fails
  128036. * @returns The loaded asset container
  128037. */
  128038. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128039. }
  128040. /**
  128041. * Interface used to define an async SceneLoader plugin
  128042. */
  128043. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128044. /**
  128045. * Import meshes into a scene.
  128046. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128047. * @param scene The scene to import into
  128048. * @param data The data to import
  128049. * @param rootUrl The root url for scene and resources
  128050. * @param onProgress The callback when the load progresses
  128051. * @param fileName Defines the name of the file to load
  128052. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128053. */
  128054. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128055. meshes: AbstractMesh[];
  128056. particleSystems: IParticleSystem[];
  128057. skeletons: Skeleton[];
  128058. animationGroups: AnimationGroup[];
  128059. }>;
  128060. /**
  128061. * Load into a scene.
  128062. * @param scene The scene to load into
  128063. * @param data The data to import
  128064. * @param rootUrl The root url for scene and resources
  128065. * @param onProgress The callback when the load progresses
  128066. * @param fileName Defines the name of the file to load
  128067. * @returns Nothing
  128068. */
  128069. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128070. /**
  128071. * Load into an asset container.
  128072. * @param scene The scene to load into
  128073. * @param data The data to import
  128074. * @param rootUrl The root url for scene and resources
  128075. * @param onProgress The callback when the load progresses
  128076. * @param fileName Defines the name of the file to load
  128077. * @returns The loaded asset container
  128078. */
  128079. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128080. }
  128081. /**
  128082. * Mode that determines how to handle old animation groups before loading new ones.
  128083. */
  128084. export enum SceneLoaderAnimationGroupLoadingMode {
  128085. /**
  128086. * Reset all old animations to initial state then dispose them.
  128087. */
  128088. Clean = 0,
  128089. /**
  128090. * Stop all old animations.
  128091. */
  128092. Stop = 1,
  128093. /**
  128094. * Restart old animations from first frame.
  128095. */
  128096. Sync = 2,
  128097. /**
  128098. * Old animations remains untouched.
  128099. */
  128100. NoSync = 3
  128101. }
  128102. /**
  128103. * Defines a plugin registered by the SceneLoader
  128104. */
  128105. interface IRegisteredPlugin {
  128106. /**
  128107. * Defines the plugin to use
  128108. */
  128109. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128110. /**
  128111. * Defines if the plugin supports binary data
  128112. */
  128113. isBinary: boolean;
  128114. }
  128115. /**
  128116. * Class used to load scene from various file formats using registered plugins
  128117. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128118. */
  128119. export class SceneLoader {
  128120. /**
  128121. * No logging while loading
  128122. */
  128123. static readonly NO_LOGGING: number;
  128124. /**
  128125. * Minimal logging while loading
  128126. */
  128127. static readonly MINIMAL_LOGGING: number;
  128128. /**
  128129. * Summary logging while loading
  128130. */
  128131. static readonly SUMMARY_LOGGING: number;
  128132. /**
  128133. * Detailled logging while loading
  128134. */
  128135. static readonly DETAILED_LOGGING: number;
  128136. /**
  128137. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128138. */
  128139. static get ForceFullSceneLoadingForIncremental(): boolean;
  128140. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128141. /**
  128142. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128143. */
  128144. static get ShowLoadingScreen(): boolean;
  128145. static set ShowLoadingScreen(value: boolean);
  128146. /**
  128147. * Defines the current logging level (while loading the scene)
  128148. * @ignorenaming
  128149. */
  128150. static get loggingLevel(): number;
  128151. static set loggingLevel(value: number);
  128152. /**
  128153. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128154. */
  128155. static get CleanBoneMatrixWeights(): boolean;
  128156. static set CleanBoneMatrixWeights(value: boolean);
  128157. /**
  128158. * Event raised when a plugin is used to load a scene
  128159. */
  128160. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128161. private static _registeredPlugins;
  128162. private static _showingLoadingScreen;
  128163. /**
  128164. * Gets the default plugin (used to load Babylon files)
  128165. * @returns the .babylon plugin
  128166. */
  128167. static GetDefaultPlugin(): IRegisteredPlugin;
  128168. private static _GetPluginForExtension;
  128169. private static _GetPluginForDirectLoad;
  128170. private static _GetPluginForFilename;
  128171. private static _GetDirectLoad;
  128172. private static _LoadData;
  128173. private static _GetFileInfo;
  128174. /**
  128175. * Gets a plugin that can load the given extension
  128176. * @param extension defines the extension to load
  128177. * @returns a plugin or null if none works
  128178. */
  128179. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128180. /**
  128181. * Gets a boolean indicating that the given extension can be loaded
  128182. * @param extension defines the extension to load
  128183. * @returns true if the extension is supported
  128184. */
  128185. static IsPluginForExtensionAvailable(extension: string): boolean;
  128186. /**
  128187. * Adds a new plugin to the list of registered plugins
  128188. * @param plugin defines the plugin to add
  128189. */
  128190. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128191. /**
  128192. * Import meshes into a scene
  128193. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128194. * @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)
  128195. * @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)
  128196. * @param scene the instance of BABYLON.Scene to append to
  128197. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128198. * @param onProgress a callback with a progress event for each file being loaded
  128199. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128200. * @param pluginExtension the extension used to determine the plugin
  128201. * @returns The loaded plugin
  128202. */
  128203. 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>;
  128204. /**
  128205. * Import meshes into a scene
  128206. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128207. * @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)
  128208. * @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)
  128209. * @param scene the instance of BABYLON.Scene to append to
  128210. * @param onProgress a callback with a progress event for each file being loaded
  128211. * @param pluginExtension the extension used to determine the plugin
  128212. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128213. */
  128214. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128215. meshes: AbstractMesh[];
  128216. particleSystems: IParticleSystem[];
  128217. skeletons: Skeleton[];
  128218. animationGroups: AnimationGroup[];
  128219. }>;
  128220. /**
  128221. * Load a scene
  128222. * @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)
  128223. * @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)
  128224. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128225. * @param onSuccess a callback with the scene when import succeeds
  128226. * @param onProgress a callback with a progress event for each file being loaded
  128227. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128228. * @param pluginExtension the extension used to determine the plugin
  128229. * @returns The loaded plugin
  128230. */
  128231. 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>;
  128232. /**
  128233. * Load a scene
  128234. * @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)
  128235. * @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)
  128236. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128237. * @param onProgress a callback with a progress event for each file being loaded
  128238. * @param pluginExtension the extension used to determine the plugin
  128239. * @returns The loaded scene
  128240. */
  128241. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128242. /**
  128243. * Append a scene
  128244. * @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)
  128245. * @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)
  128246. * @param scene is the instance of BABYLON.Scene to append to
  128247. * @param onSuccess a callback with the scene when import succeeds
  128248. * @param onProgress a callback with a progress event for each file being loaded
  128249. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128250. * @param pluginExtension the extension used to determine the plugin
  128251. * @returns The loaded plugin
  128252. */
  128253. 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>;
  128254. /**
  128255. * Append a scene
  128256. * @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)
  128257. * @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)
  128258. * @param scene is the instance of BABYLON.Scene to append to
  128259. * @param onProgress a callback with a progress event for each file being loaded
  128260. * @param pluginExtension the extension used to determine the plugin
  128261. * @returns The given scene
  128262. */
  128263. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128264. /**
  128265. * Load a scene into an asset container
  128266. * @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)
  128267. * @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)
  128268. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128269. * @param onSuccess a callback with the scene when import succeeds
  128270. * @param onProgress a callback with a progress event for each file being loaded
  128271. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128272. * @param pluginExtension the extension used to determine the plugin
  128273. * @returns The loaded plugin
  128274. */
  128275. 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>;
  128276. /**
  128277. * Load a scene into an asset container
  128278. * @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)
  128279. * @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)
  128280. * @param scene is the instance of Scene to append to
  128281. * @param onProgress a callback with a progress event for each file being loaded
  128282. * @param pluginExtension the extension used to determine the plugin
  128283. * @returns The loaded asset container
  128284. */
  128285. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128286. /**
  128287. * Import animations from a file into a scene
  128288. * @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)
  128289. * @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)
  128290. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128291. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128292. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128293. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128294. * @param onSuccess a callback with the scene when import succeeds
  128295. * @param onProgress a callback with a progress event for each file being loaded
  128296. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128297. * @param pluginExtension the extension used to determine the plugin
  128298. */
  128299. 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;
  128300. /**
  128301. * Import animations from a file into a scene
  128302. * @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)
  128303. * @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)
  128304. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128305. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128306. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128307. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128308. * @param onSuccess a callback with the scene when import succeeds
  128309. * @param onProgress a callback with a progress event for each file being loaded
  128310. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128311. * @param pluginExtension the extension used to determine the plugin
  128312. * @returns the updated scene with imported animations
  128313. */
  128314. 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>;
  128315. }
  128316. }
  128317. declare module BABYLON {
  128318. /**
  128319. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128320. */
  128321. export type MotionControllerHandedness = "none" | "left" | "right";
  128322. /**
  128323. * The type of components available in motion controllers.
  128324. * This is not the name of the component.
  128325. */
  128326. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128327. /**
  128328. * The state of a controller component
  128329. */
  128330. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128331. /**
  128332. * The schema of motion controller layout.
  128333. * No object will be initialized using this interface
  128334. * This is used just to define the profile.
  128335. */
  128336. export interface IMotionControllerLayout {
  128337. /**
  128338. * Path to load the assets. Usually relative to the base path
  128339. */
  128340. assetPath: string;
  128341. /**
  128342. * Available components (unsorted)
  128343. */
  128344. components: {
  128345. /**
  128346. * A map of component Ids
  128347. */
  128348. [componentId: string]: {
  128349. /**
  128350. * The type of input the component outputs
  128351. */
  128352. type: MotionControllerComponentType;
  128353. /**
  128354. * The indices of this component in the gamepad object
  128355. */
  128356. gamepadIndices: {
  128357. /**
  128358. * Index of button
  128359. */
  128360. button?: number;
  128361. /**
  128362. * If available, index of x-axis
  128363. */
  128364. xAxis?: number;
  128365. /**
  128366. * If available, index of y-axis
  128367. */
  128368. yAxis?: number;
  128369. };
  128370. /**
  128371. * The mesh's root node name
  128372. */
  128373. rootNodeName: string;
  128374. /**
  128375. * Animation definitions for this model
  128376. */
  128377. visualResponses: {
  128378. [stateKey: string]: {
  128379. /**
  128380. * What property will be animated
  128381. */
  128382. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128383. /**
  128384. * What states influence this visual response
  128385. */
  128386. states: MotionControllerComponentStateType[];
  128387. /**
  128388. * Type of animation - movement or visibility
  128389. */
  128390. valueNodeProperty: "transform" | "visibility";
  128391. /**
  128392. * Base node name to move. Its position will be calculated according to the min and max nodes
  128393. */
  128394. valueNodeName?: string;
  128395. /**
  128396. * Minimum movement node
  128397. */
  128398. minNodeName?: string;
  128399. /**
  128400. * Max movement node
  128401. */
  128402. maxNodeName?: string;
  128403. };
  128404. };
  128405. /**
  128406. * If touch enabled, what is the name of node to display user feedback
  128407. */
  128408. touchPointNodeName?: string;
  128409. };
  128410. };
  128411. /**
  128412. * Is it xr standard mapping or not
  128413. */
  128414. gamepadMapping: "" | "xr-standard";
  128415. /**
  128416. * Base root node of this entire model
  128417. */
  128418. rootNodeName: string;
  128419. /**
  128420. * Defines the main button component id
  128421. */
  128422. selectComponentId: string;
  128423. }
  128424. /**
  128425. * A definition for the layout map in the input profile
  128426. */
  128427. export interface IMotionControllerLayoutMap {
  128428. /**
  128429. * Layouts with handedness type as a key
  128430. */
  128431. [handedness: string]: IMotionControllerLayout;
  128432. }
  128433. /**
  128434. * The XR Input profile schema
  128435. * Profiles can be found here:
  128436. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128437. */
  128438. export interface IMotionControllerProfile {
  128439. /**
  128440. * fallback profiles for this profileId
  128441. */
  128442. fallbackProfileIds: string[];
  128443. /**
  128444. * The layout map, with handedness as key
  128445. */
  128446. layouts: IMotionControllerLayoutMap;
  128447. /**
  128448. * The id of this profile
  128449. * correlates to the profile(s) in the xrInput.profiles array
  128450. */
  128451. profileId: string;
  128452. }
  128453. /**
  128454. * A helper-interface for the 3 meshes needed for controller button animation
  128455. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128456. */
  128457. export interface IMotionControllerButtonMeshMap {
  128458. /**
  128459. * the mesh that defines the pressed value mesh position.
  128460. * This is used to find the max-position of this button
  128461. */
  128462. pressedMesh: AbstractMesh;
  128463. /**
  128464. * the mesh that defines the unpressed value mesh position.
  128465. * This is used to find the min (or initial) position of this button
  128466. */
  128467. unpressedMesh: AbstractMesh;
  128468. /**
  128469. * The mesh that will be changed when value changes
  128470. */
  128471. valueMesh: AbstractMesh;
  128472. }
  128473. /**
  128474. * A helper-interface for the 3 meshes needed for controller axis animation.
  128475. * This will be expanded when touchpad animations are fully supported
  128476. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128477. */
  128478. export interface IMotionControllerMeshMap {
  128479. /**
  128480. * the mesh that defines the maximum value mesh position.
  128481. */
  128482. maxMesh?: AbstractMesh;
  128483. /**
  128484. * the mesh that defines the minimum value mesh position.
  128485. */
  128486. minMesh?: AbstractMesh;
  128487. /**
  128488. * The mesh that will be changed when axis value changes
  128489. */
  128490. valueMesh?: AbstractMesh;
  128491. }
  128492. /**
  128493. * The elements needed for change-detection of the gamepad objects in motion controllers
  128494. */
  128495. export interface IMinimalMotionControllerObject {
  128496. /**
  128497. * Available axes of this controller
  128498. */
  128499. axes: number[];
  128500. /**
  128501. * An array of available buttons
  128502. */
  128503. buttons: Array<{
  128504. /**
  128505. * Value of the button/trigger
  128506. */
  128507. value: number;
  128508. /**
  128509. * If the button/trigger is currently touched
  128510. */
  128511. touched: boolean;
  128512. /**
  128513. * If the button/trigger is currently pressed
  128514. */
  128515. pressed: boolean;
  128516. }>;
  128517. /**
  128518. * EXPERIMENTAL haptic support.
  128519. */
  128520. hapticActuators?: Array<{
  128521. pulse: (value: number, duration: number) => Promise<boolean>;
  128522. }>;
  128523. }
  128524. /**
  128525. * An Abstract Motion controller
  128526. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128527. * Each component has an observable to check for changes in value and state
  128528. */
  128529. export abstract class WebXRAbstractMotionController implements IDisposable {
  128530. protected scene: Scene;
  128531. protected layout: IMotionControllerLayout;
  128532. /**
  128533. * The gamepad object correlating to this controller
  128534. */
  128535. gamepadObject: IMinimalMotionControllerObject;
  128536. /**
  128537. * handedness (left/right/none) of this controller
  128538. */
  128539. handedness: MotionControllerHandedness;
  128540. private _initComponent;
  128541. private _modelReady;
  128542. /**
  128543. * A map of components (WebXRControllerComponent) in this motion controller
  128544. * Components have a ComponentType and can also have both button and axis definitions
  128545. */
  128546. readonly components: {
  128547. [id: string]: WebXRControllerComponent;
  128548. };
  128549. /**
  128550. * Disable the model's animation. Can be set at any time.
  128551. */
  128552. disableAnimation: boolean;
  128553. /**
  128554. * Observers registered here will be triggered when the model of this controller is done loading
  128555. */
  128556. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128557. /**
  128558. * The profile id of this motion controller
  128559. */
  128560. abstract profileId: string;
  128561. /**
  128562. * The root mesh of the model. It is null if the model was not yet initialized
  128563. */
  128564. rootMesh: Nullable<AbstractMesh>;
  128565. /**
  128566. * constructs a new abstract motion controller
  128567. * @param scene the scene to which the model of the controller will be added
  128568. * @param layout The profile layout to load
  128569. * @param gamepadObject The gamepad object correlating to this controller
  128570. * @param handedness handedness (left/right/none) of this controller
  128571. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128572. */
  128573. constructor(scene: Scene, layout: IMotionControllerLayout,
  128574. /**
  128575. * The gamepad object correlating to this controller
  128576. */
  128577. gamepadObject: IMinimalMotionControllerObject,
  128578. /**
  128579. * handedness (left/right/none) of this controller
  128580. */
  128581. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128582. /**
  128583. * Dispose this controller, the model mesh and all its components
  128584. */
  128585. dispose(): void;
  128586. /**
  128587. * Returns all components of specific type
  128588. * @param type the type to search for
  128589. * @return an array of components with this type
  128590. */
  128591. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128592. /**
  128593. * get a component based an its component id as defined in layout.components
  128594. * @param id the id of the component
  128595. * @returns the component correlates to the id or undefined if not found
  128596. */
  128597. getComponent(id: string): WebXRControllerComponent;
  128598. /**
  128599. * Get the list of components available in this motion controller
  128600. * @returns an array of strings correlating to available components
  128601. */
  128602. getComponentIds(): string[];
  128603. /**
  128604. * Get the first component of specific type
  128605. * @param type type of component to find
  128606. * @return a controller component or null if not found
  128607. */
  128608. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128609. /**
  128610. * Get the main (Select) component of this controller as defined in the layout
  128611. * @returns the main component of this controller
  128612. */
  128613. getMainComponent(): WebXRControllerComponent;
  128614. /**
  128615. * Loads the model correlating to this controller
  128616. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128617. * @returns A promise fulfilled with the result of the model loading
  128618. */
  128619. loadModel(): Promise<boolean>;
  128620. /**
  128621. * Update this model using the current XRFrame
  128622. * @param xrFrame the current xr frame to use and update the model
  128623. */
  128624. updateFromXRFrame(xrFrame: XRFrame): void;
  128625. /**
  128626. * Backwards compatibility due to a deeply-integrated typo
  128627. */
  128628. get handness(): XREye;
  128629. /**
  128630. * Pulse (vibrate) this controller
  128631. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128632. * Consecutive calls to this function will cancel the last pulse call
  128633. *
  128634. * @param value the strength of the pulse in 0.0...1.0 range
  128635. * @param duration Duration of the pulse in milliseconds
  128636. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128637. * @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
  128638. */
  128639. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128640. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128641. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128642. /**
  128643. * Moves the axis on the controller mesh based on its current state
  128644. * @param axis the index of the axis
  128645. * @param axisValue the value of the axis which determines the meshes new position
  128646. * @hidden
  128647. */
  128648. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128649. /**
  128650. * Update the model itself with the current frame data
  128651. * @param xrFrame the frame to use for updating the model mesh
  128652. */
  128653. protected updateModel(xrFrame: XRFrame): void;
  128654. /**
  128655. * Get the filename and path for this controller's model
  128656. * @returns a map of filename and path
  128657. */
  128658. protected abstract _getFilenameAndPath(): {
  128659. filename: string;
  128660. path: string;
  128661. };
  128662. /**
  128663. * This function is called before the mesh is loaded. It checks for loading constraints.
  128664. * For example, this function can check if the GLB loader is available
  128665. * If this function returns false, the generic controller will be loaded instead
  128666. * @returns Is the client ready to load the mesh
  128667. */
  128668. protected abstract _getModelLoadingConstraints(): boolean;
  128669. /**
  128670. * This function will be called after the model was successfully loaded and can be used
  128671. * for mesh transformations before it is available for the user
  128672. * @param meshes the loaded meshes
  128673. */
  128674. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  128675. /**
  128676. * Set the root mesh for this controller. Important for the WebXR controller class
  128677. * @param meshes the loaded meshes
  128678. */
  128679. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  128680. /**
  128681. * A function executed each frame that updates the mesh (if needed)
  128682. * @param xrFrame the current xrFrame
  128683. */
  128684. protected abstract _updateModel(xrFrame: XRFrame): void;
  128685. private _getGenericFilenameAndPath;
  128686. private _getGenericParentMesh;
  128687. }
  128688. }
  128689. declare module BABYLON {
  128690. /**
  128691. * A generic trigger-only motion controller for WebXR
  128692. */
  128693. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  128694. /**
  128695. * Static version of the profile id of this controller
  128696. */
  128697. static ProfileId: string;
  128698. profileId: string;
  128699. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  128700. protected _getFilenameAndPath(): {
  128701. filename: string;
  128702. path: string;
  128703. };
  128704. protected _getModelLoadingConstraints(): boolean;
  128705. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  128706. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128707. protected _updateModel(): void;
  128708. }
  128709. }
  128710. declare module BABYLON {
  128711. /**
  128712. * Class containing static functions to help procedurally build meshes
  128713. */
  128714. export class SphereBuilder {
  128715. /**
  128716. * Creates a sphere mesh
  128717. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  128718. * * 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`)
  128719. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  128720. * * 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
  128721. * * 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)
  128722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128723. * * 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
  128724. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128725. * @param name defines the name of the mesh
  128726. * @param options defines the options used to create the mesh
  128727. * @param scene defines the hosting scene
  128728. * @returns the sphere mesh
  128729. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  128730. */
  128731. static CreateSphere(name: string, options: {
  128732. segments?: number;
  128733. diameter?: number;
  128734. diameterX?: number;
  128735. diameterY?: number;
  128736. diameterZ?: number;
  128737. arc?: number;
  128738. slice?: number;
  128739. sideOrientation?: number;
  128740. frontUVs?: Vector4;
  128741. backUVs?: Vector4;
  128742. updatable?: boolean;
  128743. }, scene?: Nullable<Scene>): Mesh;
  128744. }
  128745. }
  128746. declare module BABYLON {
  128747. /**
  128748. * A profiled motion controller has its profile loaded from an online repository.
  128749. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  128750. */
  128751. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  128752. private _repositoryUrl;
  128753. private _buttonMeshMapping;
  128754. private _touchDots;
  128755. /**
  128756. * The profile ID of this controller. Will be populated when the controller initializes.
  128757. */
  128758. profileId: string;
  128759. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  128760. dispose(): void;
  128761. protected _getFilenameAndPath(): {
  128762. filename: string;
  128763. path: string;
  128764. };
  128765. protected _getModelLoadingConstraints(): boolean;
  128766. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  128767. protected _setRootMesh(meshes: AbstractMesh[]): void;
  128768. protected _updateModel(_xrFrame: XRFrame): void;
  128769. }
  128770. }
  128771. declare module BABYLON {
  128772. /**
  128773. * A construction function type to create a new controller based on an xrInput object
  128774. */
  128775. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  128776. /**
  128777. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  128778. *
  128779. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  128780. * it should be replaced with auto-loaded controllers.
  128781. *
  128782. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  128783. */
  128784. export class WebXRMotionControllerManager {
  128785. private static _AvailableControllers;
  128786. private static _Fallbacks;
  128787. private static _ProfileLoadingPromises;
  128788. private static _ProfilesList;
  128789. /**
  128790. * The base URL of the online controller repository. Can be changed at any time.
  128791. */
  128792. static BaseRepositoryUrl: string;
  128793. /**
  128794. * Which repository gets priority - local or online
  128795. */
  128796. static PrioritizeOnlineRepository: boolean;
  128797. /**
  128798. * Use the online repository, or use only locally-defined controllers
  128799. */
  128800. static UseOnlineRepository: boolean;
  128801. /**
  128802. * Clear the cache used for profile loading and reload when requested again
  128803. */
  128804. static ClearProfilesCache(): void;
  128805. /**
  128806. * Register the default fallbacks.
  128807. * This function is called automatically when this file is imported.
  128808. */
  128809. static DefaultFallbacks(): void;
  128810. /**
  128811. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  128812. * @param profileId the profile to which a fallback needs to be found
  128813. * @return an array with corresponding fallback profiles
  128814. */
  128815. static FindFallbackWithProfileId(profileId: string): string[];
  128816. /**
  128817. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  128818. * The order of search:
  128819. *
  128820. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  128821. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  128822. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  128823. * 4) return the generic trigger controller if none were found
  128824. *
  128825. * @param xrInput the xrInput to which a new controller is initialized
  128826. * @param scene the scene to which the model will be added
  128827. * @param forceProfile force a certain profile for this controller
  128828. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  128829. */
  128830. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  128831. /**
  128832. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  128833. *
  128834. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  128835. *
  128836. * @param type the profile type to register
  128837. * @param constructFunction the function to be called when loading this profile
  128838. */
  128839. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  128840. /**
  128841. * Register a fallback to a specific profile.
  128842. * @param profileId the profileId that will receive the fallbacks
  128843. * @param fallbacks A list of fallback profiles
  128844. */
  128845. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  128846. /**
  128847. * Will update the list of profiles available in the repository
  128848. * @return a promise that resolves to a map of profiles available online
  128849. */
  128850. static UpdateProfilesList(): Promise<{
  128851. [profile: string]: string;
  128852. }>;
  128853. private static _LoadProfileFromRepository;
  128854. private static _LoadProfilesFromAvailableControllers;
  128855. }
  128856. }
  128857. declare module BABYLON {
  128858. /**
  128859. * Configuration options for the WebXR controller creation
  128860. */
  128861. export interface IWebXRControllerOptions {
  128862. /**
  128863. * Should the controller mesh be animated when a user interacts with it
  128864. * The pressed buttons / thumbstick and touchpad animations will be disabled
  128865. */
  128866. disableMotionControllerAnimation?: boolean;
  128867. /**
  128868. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  128869. */
  128870. doNotLoadControllerMesh?: boolean;
  128871. /**
  128872. * Force a specific controller type for this controller.
  128873. * This can be used when creating your own profile or when testing different controllers
  128874. */
  128875. forceControllerProfile?: string;
  128876. /**
  128877. * Defines a rendering group ID for meshes that will be loaded.
  128878. * This is for the default controllers only.
  128879. */
  128880. renderingGroupId?: number;
  128881. }
  128882. /**
  128883. * Represents an XR controller
  128884. */
  128885. export class WebXRInputSource {
  128886. private _scene;
  128887. /** The underlying input source for the controller */
  128888. inputSource: XRInputSource;
  128889. private _options;
  128890. private _tmpVector;
  128891. private _uniqueId;
  128892. private _disposed;
  128893. /**
  128894. * 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
  128895. */
  128896. grip?: AbstractMesh;
  128897. /**
  128898. * If available, this is the gamepad object related to this controller.
  128899. * Using this object it is possible to get click events and trackpad changes of the
  128900. * webxr controller that is currently being used.
  128901. */
  128902. motionController?: WebXRAbstractMotionController;
  128903. /**
  128904. * Event that fires when the controller is removed/disposed.
  128905. * The object provided as event data is this controller, after associated assets were disposed.
  128906. * uniqueId is still available.
  128907. */
  128908. onDisposeObservable: Observable<WebXRInputSource>;
  128909. /**
  128910. * Will be triggered when the mesh associated with the motion controller is done loading.
  128911. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  128912. * A shortened version of controller -> motion controller -> on mesh loaded.
  128913. */
  128914. onMeshLoadedObservable: Observable<AbstractMesh>;
  128915. /**
  128916. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  128917. */
  128918. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  128919. /**
  128920. * Pointer which can be used to select objects or attach a visible laser to
  128921. */
  128922. pointer: AbstractMesh;
  128923. /**
  128924. * Creates the input source object
  128925. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  128926. * @param _scene the scene which the controller should be associated to
  128927. * @param inputSource the underlying input source for the controller
  128928. * @param _options options for this controller creation
  128929. */
  128930. constructor(_scene: Scene,
  128931. /** The underlying input source for the controller */
  128932. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  128933. /**
  128934. * Get this controllers unique id
  128935. */
  128936. get uniqueId(): string;
  128937. /**
  128938. * Disposes of the object
  128939. */
  128940. dispose(): void;
  128941. /**
  128942. * Gets a world space ray coming from the pointer or grip
  128943. * @param result the resulting ray
  128944. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  128945. */
  128946. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  128947. /**
  128948. * Updates the controller pose based on the given XRFrame
  128949. * @param xrFrame xr frame to update the pose with
  128950. * @param referenceSpace reference space to use
  128951. */
  128952. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  128953. }
  128954. }
  128955. declare module BABYLON {
  128956. /**
  128957. * The schema for initialization options of the XR Input class
  128958. */
  128959. export interface IWebXRInputOptions {
  128960. /**
  128961. * If set to true no model will be automatically loaded
  128962. */
  128963. doNotLoadControllerMeshes?: boolean;
  128964. /**
  128965. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  128966. * If not found, the xr input profile data will be used.
  128967. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  128968. */
  128969. forceInputProfile?: string;
  128970. /**
  128971. * Do not send a request to the controller repository to load the profile.
  128972. *
  128973. * Instead, use the controllers available in babylon itself.
  128974. */
  128975. disableOnlineControllerRepository?: boolean;
  128976. /**
  128977. * A custom URL for the controllers repository
  128978. */
  128979. customControllersRepositoryURL?: string;
  128980. /**
  128981. * Should the controller model's components not move according to the user input
  128982. */
  128983. disableControllerAnimation?: boolean;
  128984. /**
  128985. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  128986. */
  128987. controllerOptions?: IWebXRControllerOptions;
  128988. }
  128989. /**
  128990. * XR input used to track XR inputs such as controllers/rays
  128991. */
  128992. export class WebXRInput implements IDisposable {
  128993. /**
  128994. * the xr session manager for this session
  128995. */
  128996. xrSessionManager: WebXRSessionManager;
  128997. /**
  128998. * the WebXR camera for this session. Mainly used for teleportation
  128999. */
  129000. xrCamera: WebXRCamera;
  129001. private readonly options;
  129002. /**
  129003. * XR controllers being tracked
  129004. */
  129005. controllers: Array<WebXRInputSource>;
  129006. private _frameObserver;
  129007. private _sessionEndedObserver;
  129008. private _sessionInitObserver;
  129009. /**
  129010. * Event when a controller has been connected/added
  129011. */
  129012. onControllerAddedObservable: Observable<WebXRInputSource>;
  129013. /**
  129014. * Event when a controller has been removed/disconnected
  129015. */
  129016. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129017. /**
  129018. * Initializes the WebXRInput
  129019. * @param xrSessionManager the xr session manager for this session
  129020. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129021. * @param options = initialization options for this xr input
  129022. */
  129023. constructor(
  129024. /**
  129025. * the xr session manager for this session
  129026. */
  129027. xrSessionManager: WebXRSessionManager,
  129028. /**
  129029. * the WebXR camera for this session. Mainly used for teleportation
  129030. */
  129031. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129032. private _onInputSourcesChange;
  129033. private _addAndRemoveControllers;
  129034. /**
  129035. * Disposes of the object
  129036. */
  129037. dispose(): void;
  129038. }
  129039. }
  129040. declare module BABYLON {
  129041. /**
  129042. * This is the base class for all WebXR features.
  129043. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129044. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129045. */
  129046. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129047. protected _xrSessionManager: WebXRSessionManager;
  129048. private _attached;
  129049. private _removeOnDetach;
  129050. /**
  129051. * Is this feature disposed?
  129052. */
  129053. isDisposed: boolean;
  129054. /**
  129055. * Should auto-attach be disabled?
  129056. */
  129057. disableAutoAttach: boolean;
  129058. /**
  129059. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129060. */
  129061. xrNativeFeatureName: string;
  129062. /**
  129063. * Construct a new (abstract) WebXR feature
  129064. * @param _xrSessionManager the xr session manager for this feature
  129065. */
  129066. constructor(_xrSessionManager: WebXRSessionManager);
  129067. /**
  129068. * Is this feature attached
  129069. */
  129070. get attached(): boolean;
  129071. /**
  129072. * attach this feature
  129073. *
  129074. * @param force should attachment be forced (even when already attached)
  129075. * @returns true if successful, false is failed or already attached
  129076. */
  129077. attach(force?: boolean): boolean;
  129078. /**
  129079. * detach this feature.
  129080. *
  129081. * @returns true if successful, false if failed or already detached
  129082. */
  129083. detach(): boolean;
  129084. /**
  129085. * Dispose this feature and all of the resources attached
  129086. */
  129087. dispose(): void;
  129088. /**
  129089. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129090. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129091. *
  129092. * @returns whether or not the feature is compatible in this environment
  129093. */
  129094. isCompatible(): boolean;
  129095. /**
  129096. * This is used to register callbacks that will automatically be removed when detach is called.
  129097. * @param observable the observable to which the observer will be attached
  129098. * @param callback the callback to register
  129099. */
  129100. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129101. /**
  129102. * Code in this function will be executed on each xrFrame received from the browser.
  129103. * This function will not execute after the feature is detached.
  129104. * @param _xrFrame the current frame
  129105. */
  129106. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129107. }
  129108. }
  129109. declare module BABYLON {
  129110. /**
  129111. * Renders a layer on top of an existing scene
  129112. */
  129113. export class UtilityLayerRenderer implements IDisposable {
  129114. /** the original scene that will be rendered on top of */
  129115. originalScene: Scene;
  129116. private _pointerCaptures;
  129117. private _lastPointerEvents;
  129118. private static _DefaultUtilityLayer;
  129119. private static _DefaultKeepDepthUtilityLayer;
  129120. private _sharedGizmoLight;
  129121. private _renderCamera;
  129122. /**
  129123. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129124. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129125. * @returns the camera that is used when rendering the utility layer
  129126. */
  129127. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129128. /**
  129129. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129130. * @param cam the camera that should be used when rendering the utility layer
  129131. */
  129132. setRenderCamera(cam: Nullable<Camera>): void;
  129133. /**
  129134. * @hidden
  129135. * Light which used by gizmos to get light shading
  129136. */
  129137. _getSharedGizmoLight(): HemisphericLight;
  129138. /**
  129139. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129140. */
  129141. pickUtilitySceneFirst: boolean;
  129142. /**
  129143. * 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)
  129144. */
  129145. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129146. /**
  129147. * 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)
  129148. */
  129149. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129150. /**
  129151. * The scene that is rendered on top of the original scene
  129152. */
  129153. utilityLayerScene: Scene;
  129154. /**
  129155. * If the utility layer should automatically be rendered on top of existing scene
  129156. */
  129157. shouldRender: boolean;
  129158. /**
  129159. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129160. */
  129161. onlyCheckPointerDownEvents: boolean;
  129162. /**
  129163. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129164. */
  129165. processAllEvents: boolean;
  129166. /**
  129167. * Observable raised when the pointer move from the utility layer scene to the main scene
  129168. */
  129169. onPointerOutObservable: Observable<number>;
  129170. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129171. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129172. private _afterRenderObserver;
  129173. private _sceneDisposeObserver;
  129174. private _originalPointerObserver;
  129175. /**
  129176. * Instantiates a UtilityLayerRenderer
  129177. * @param originalScene the original scene that will be rendered on top of
  129178. * @param handleEvents boolean indicating if the utility layer should handle events
  129179. */
  129180. constructor(
  129181. /** the original scene that will be rendered on top of */
  129182. originalScene: Scene, handleEvents?: boolean);
  129183. private _notifyObservers;
  129184. /**
  129185. * Renders the utility layers scene on top of the original scene
  129186. */
  129187. render(): void;
  129188. /**
  129189. * Disposes of the renderer
  129190. */
  129191. dispose(): void;
  129192. private _updateCamera;
  129193. }
  129194. }
  129195. declare module BABYLON {
  129196. /**
  129197. * Options interface for the pointer selection module
  129198. */
  129199. export interface IWebXRControllerPointerSelectionOptions {
  129200. /**
  129201. * if provided, this scene will be used to render meshes.
  129202. */
  129203. customUtilityLayerScene?: Scene;
  129204. /**
  129205. * 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)
  129206. * If not disabled, the last picked point will be used to execute a pointer up event
  129207. * If disabled, pointer up event will be triggered right after the pointer down event.
  129208. * Used in screen and gaze target ray mode only
  129209. */
  129210. disablePointerUpOnTouchOut: boolean;
  129211. /**
  129212. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129213. */
  129214. forceGazeMode: boolean;
  129215. /**
  129216. * 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
  129217. * to start a new countdown to the pointer down event.
  129218. * Defaults to 1.
  129219. */
  129220. gazeModePointerMovedFactor?: number;
  129221. /**
  129222. * Different button type to use instead of the main component
  129223. */
  129224. overrideButtonId?: string;
  129225. /**
  129226. * use this rendering group id for the meshes (optional)
  129227. */
  129228. renderingGroupId?: number;
  129229. /**
  129230. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129231. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129232. * 3000 means 3 seconds between pointing at something and selecting it
  129233. */
  129234. timeToSelect?: number;
  129235. /**
  129236. * Should meshes created here be added to a utility layer or the main scene
  129237. */
  129238. useUtilityLayer?: boolean;
  129239. /**
  129240. * Optional WebXR camera to be used for gaze selection
  129241. */
  129242. gazeCamera?: WebXRCamera;
  129243. /**
  129244. * the xr input to use with this pointer selection
  129245. */
  129246. xrInput: WebXRInput;
  129247. }
  129248. /**
  129249. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129250. */
  129251. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129252. private readonly _options;
  129253. private static _idCounter;
  129254. private _attachController;
  129255. private _controllers;
  129256. private _scene;
  129257. private _tmpVectorForPickCompare;
  129258. /**
  129259. * The module's name
  129260. */
  129261. static readonly Name: string;
  129262. /**
  129263. * The (Babylon) version of this module.
  129264. * This is an integer representing the implementation version.
  129265. * This number does not correspond to the WebXR specs version
  129266. */
  129267. static readonly Version: number;
  129268. /**
  129269. * Disable lighting on the laser pointer (so it will always be visible)
  129270. */
  129271. disablePointerLighting: boolean;
  129272. /**
  129273. * Disable lighting on the selection mesh (so it will always be visible)
  129274. */
  129275. disableSelectionMeshLighting: boolean;
  129276. /**
  129277. * Should the laser pointer be displayed
  129278. */
  129279. displayLaserPointer: boolean;
  129280. /**
  129281. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129282. */
  129283. displaySelectionMesh: boolean;
  129284. /**
  129285. * This color will be set to the laser pointer when selection is triggered
  129286. */
  129287. laserPointerPickedColor: Color3;
  129288. /**
  129289. * Default color of the laser pointer
  129290. */
  129291. laserPointerDefaultColor: Color3;
  129292. /**
  129293. * default color of the selection ring
  129294. */
  129295. selectionMeshDefaultColor: Color3;
  129296. /**
  129297. * This color will be applied to the selection ring when selection is triggered
  129298. */
  129299. selectionMeshPickedColor: Color3;
  129300. /**
  129301. * Optional filter to be used for ray selection. This predicate shares behavior with
  129302. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129303. */
  129304. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129305. /**
  129306. * constructs a new background remover module
  129307. * @param _xrSessionManager the session manager for this module
  129308. * @param _options read-only options to be used in this module
  129309. */
  129310. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129311. /**
  129312. * attach this feature
  129313. * Will usually be called by the features manager
  129314. *
  129315. * @returns true if successful.
  129316. */
  129317. attach(): boolean;
  129318. /**
  129319. * detach this feature.
  129320. * Will usually be called by the features manager
  129321. *
  129322. * @returns true if successful.
  129323. */
  129324. detach(): boolean;
  129325. /**
  129326. * Will get the mesh under a specific pointer.
  129327. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129328. * @param controllerId the controllerId to check
  129329. * @returns The mesh under pointer or null if no mesh is under the pointer
  129330. */
  129331. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129332. /**
  129333. * Get the xr controller that correlates to the pointer id in the pointer event
  129334. *
  129335. * @param id the pointer id to search for
  129336. * @returns the controller that correlates to this id or null if not found
  129337. */
  129338. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129339. protected _onXRFrame(_xrFrame: XRFrame): void;
  129340. private _attachGazeMode;
  129341. private _attachScreenRayMode;
  129342. private _attachTrackedPointerRayMode;
  129343. private _convertNormalToDirectionOfRay;
  129344. private _detachController;
  129345. private _generateNewMeshPair;
  129346. private _pickingMoved;
  129347. private _updatePointerDistance;
  129348. /** @hidden */
  129349. get lasterPointerDefaultColor(): Color3;
  129350. }
  129351. }
  129352. declare module BABYLON {
  129353. /**
  129354. * Button which can be used to enter a different mode of XR
  129355. */
  129356. export class WebXREnterExitUIButton {
  129357. /** button element */
  129358. element: HTMLElement;
  129359. /** XR initialization options for the button */
  129360. sessionMode: XRSessionMode;
  129361. /** Reference space type */
  129362. referenceSpaceType: XRReferenceSpaceType;
  129363. /**
  129364. * Creates a WebXREnterExitUIButton
  129365. * @param element button element
  129366. * @param sessionMode XR initialization session mode
  129367. * @param referenceSpaceType the type of reference space to be used
  129368. */
  129369. constructor(
  129370. /** button element */
  129371. element: HTMLElement,
  129372. /** XR initialization options for the button */
  129373. sessionMode: XRSessionMode,
  129374. /** Reference space type */
  129375. referenceSpaceType: XRReferenceSpaceType);
  129376. /**
  129377. * Extendable function which can be used to update the button's visuals when the state changes
  129378. * @param activeButton the current active button in the UI
  129379. */
  129380. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129381. }
  129382. /**
  129383. * Options to create the webXR UI
  129384. */
  129385. export class WebXREnterExitUIOptions {
  129386. /**
  129387. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129388. */
  129389. customButtons?: Array<WebXREnterExitUIButton>;
  129390. /**
  129391. * A reference space type to use when creating the default button.
  129392. * Default is local-floor
  129393. */
  129394. referenceSpaceType?: XRReferenceSpaceType;
  129395. /**
  129396. * Context to enter xr with
  129397. */
  129398. renderTarget?: Nullable<WebXRRenderTarget>;
  129399. /**
  129400. * A session mode to use when creating the default button.
  129401. * Default is immersive-vr
  129402. */
  129403. sessionMode?: XRSessionMode;
  129404. /**
  129405. * A list of optional features to init the session with
  129406. */
  129407. optionalFeatures?: string[];
  129408. /**
  129409. * A list of optional features to init the session with
  129410. */
  129411. requiredFeatures?: string[];
  129412. }
  129413. /**
  129414. * UI to allow the user to enter/exit XR mode
  129415. */
  129416. export class WebXREnterExitUI implements IDisposable {
  129417. private scene;
  129418. /** version of the options passed to this UI */
  129419. options: WebXREnterExitUIOptions;
  129420. private _activeButton;
  129421. private _buttons;
  129422. /**
  129423. * The HTML Div Element to which buttons are added.
  129424. */
  129425. readonly overlay: HTMLDivElement;
  129426. /**
  129427. * Fired every time the active button is changed.
  129428. *
  129429. * When xr is entered via a button that launches xr that button will be the callback parameter
  129430. *
  129431. * When exiting xr the callback parameter will be null)
  129432. */
  129433. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129434. /**
  129435. *
  129436. * @param scene babylon scene object to use
  129437. * @param options (read-only) version of the options passed to this UI
  129438. */
  129439. private constructor();
  129440. /**
  129441. * Creates UI to allow the user to enter/exit XR mode
  129442. * @param scene the scene to add the ui to
  129443. * @param helper the xr experience helper to enter/exit xr with
  129444. * @param options options to configure the UI
  129445. * @returns the created ui
  129446. */
  129447. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129448. /**
  129449. * Disposes of the XR UI component
  129450. */
  129451. dispose(): void;
  129452. private _updateButtons;
  129453. }
  129454. }
  129455. declare module BABYLON {
  129456. /**
  129457. * Class containing static functions to help procedurally build meshes
  129458. */
  129459. export class LinesBuilder {
  129460. /**
  129461. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129462. * * 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
  129463. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129464. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129465. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129466. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129467. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129468. * * 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
  129469. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129470. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129471. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129472. * @param name defines the name of the new line system
  129473. * @param options defines the options used to create the line system
  129474. * @param scene defines the hosting scene
  129475. * @returns a new line system mesh
  129476. */
  129477. static CreateLineSystem(name: string, options: {
  129478. lines: Vector3[][];
  129479. updatable?: boolean;
  129480. instance?: Nullable<LinesMesh>;
  129481. colors?: Nullable<Color4[][]>;
  129482. useVertexAlpha?: boolean;
  129483. }, scene: Nullable<Scene>): LinesMesh;
  129484. /**
  129485. * Creates a line mesh
  129486. * 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
  129487. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129488. * * The parameter `points` is an array successive Vector3
  129489. * * 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
  129490. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129491. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129492. * * When updating an instance, remember that only point positions can change, not the number of points
  129493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129494. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129495. * @param name defines the name of the new line system
  129496. * @param options defines the options used to create the line system
  129497. * @param scene defines the hosting scene
  129498. * @returns a new line mesh
  129499. */
  129500. static CreateLines(name: string, options: {
  129501. points: Vector3[];
  129502. updatable?: boolean;
  129503. instance?: Nullable<LinesMesh>;
  129504. colors?: Color4[];
  129505. useVertexAlpha?: boolean;
  129506. }, scene?: Nullable<Scene>): LinesMesh;
  129507. /**
  129508. * Creates a dashed line mesh
  129509. * * 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
  129510. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129511. * * The parameter `points` is an array successive Vector3
  129512. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129513. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129514. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129515. * * 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
  129516. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129517. * * When updating an instance, remember that only point positions can change, not the number of points
  129518. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129519. * @param name defines the name of the mesh
  129520. * @param options defines the options used to create the mesh
  129521. * @param scene defines the hosting scene
  129522. * @returns the dashed line mesh
  129523. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129524. */
  129525. static CreateDashedLines(name: string, options: {
  129526. points: Vector3[];
  129527. dashSize?: number;
  129528. gapSize?: number;
  129529. dashNb?: number;
  129530. updatable?: boolean;
  129531. instance?: LinesMesh;
  129532. useVertexAlpha?: boolean;
  129533. }, scene?: Nullable<Scene>): LinesMesh;
  129534. }
  129535. }
  129536. declare module BABYLON {
  129537. /**
  129538. * Construction options for a timer
  129539. */
  129540. export interface ITimerOptions<T> {
  129541. /**
  129542. * Time-to-end
  129543. */
  129544. timeout: number;
  129545. /**
  129546. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129547. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129548. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129549. */
  129550. contextObservable: Observable<T>;
  129551. /**
  129552. * Optional parameters when adding an observer to the observable
  129553. */
  129554. observableParameters?: {
  129555. mask?: number;
  129556. insertFirst?: boolean;
  129557. scope?: any;
  129558. };
  129559. /**
  129560. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129561. */
  129562. breakCondition?: (data?: ITimerData<T>) => boolean;
  129563. /**
  129564. * Will be triggered when the time condition has met
  129565. */
  129566. onEnded?: (data: ITimerData<any>) => void;
  129567. /**
  129568. * Will be triggered when the break condition has met (prematurely ended)
  129569. */
  129570. onAborted?: (data: ITimerData<any>) => void;
  129571. /**
  129572. * Optional function to execute on each tick (or count)
  129573. */
  129574. onTick?: (data: ITimerData<any>) => void;
  129575. }
  129576. /**
  129577. * An interface defining the data sent by the timer
  129578. */
  129579. export interface ITimerData<T> {
  129580. /**
  129581. * When did it start
  129582. */
  129583. startTime: number;
  129584. /**
  129585. * Time now
  129586. */
  129587. currentTime: number;
  129588. /**
  129589. * Time passed since started
  129590. */
  129591. deltaTime: number;
  129592. /**
  129593. * How much is completed, in [0.0...1.0].
  129594. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129595. */
  129596. completeRate: number;
  129597. /**
  129598. * What the registered observable sent in the last count
  129599. */
  129600. payload: T;
  129601. }
  129602. /**
  129603. * The current state of the timer
  129604. */
  129605. export enum TimerState {
  129606. /**
  129607. * Timer initialized, not yet started
  129608. */
  129609. INIT = 0,
  129610. /**
  129611. * Timer started and counting
  129612. */
  129613. STARTED = 1,
  129614. /**
  129615. * Timer ended (whether aborted or time reached)
  129616. */
  129617. ENDED = 2
  129618. }
  129619. /**
  129620. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129621. *
  129622. * @param options options with which to initialize this timer
  129623. */
  129624. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129625. /**
  129626. * An advanced implementation of a timer class
  129627. */
  129628. export class AdvancedTimer<T = any> implements IDisposable {
  129629. /**
  129630. * Will notify each time the timer calculates the remaining time
  129631. */
  129632. onEachCountObservable: Observable<ITimerData<T>>;
  129633. /**
  129634. * Will trigger when the timer was aborted due to the break condition
  129635. */
  129636. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129637. /**
  129638. * Will trigger when the timer ended successfully
  129639. */
  129640. onTimerEndedObservable: Observable<ITimerData<T>>;
  129641. /**
  129642. * Will trigger when the timer state has changed
  129643. */
  129644. onStateChangedObservable: Observable<TimerState>;
  129645. private _observer;
  129646. private _contextObservable;
  129647. private _observableParameters;
  129648. private _startTime;
  129649. private _timer;
  129650. private _state;
  129651. private _breakCondition;
  129652. private _timeToEnd;
  129653. private _breakOnNextTick;
  129654. /**
  129655. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  129656. * @param options construction options for this advanced timer
  129657. */
  129658. constructor(options: ITimerOptions<T>);
  129659. /**
  129660. * set a breaking condition for this timer. Default is to never break during count
  129661. * @param predicate the new break condition. Returns true to break, false otherwise
  129662. */
  129663. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  129664. /**
  129665. * Reset ALL associated observables in this advanced timer
  129666. */
  129667. clearObservables(): void;
  129668. /**
  129669. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  129670. *
  129671. * @param timeToEnd how much time to measure until timer ended
  129672. */
  129673. start(timeToEnd?: number): void;
  129674. /**
  129675. * Will force a stop on the next tick.
  129676. */
  129677. stop(): void;
  129678. /**
  129679. * Dispose this timer, clearing all resources
  129680. */
  129681. dispose(): void;
  129682. private _setState;
  129683. private _tick;
  129684. private _stop;
  129685. }
  129686. }
  129687. declare module BABYLON {
  129688. /**
  129689. * The options container for the teleportation module
  129690. */
  129691. export interface IWebXRTeleportationOptions {
  129692. /**
  129693. * if provided, this scene will be used to render meshes.
  129694. */
  129695. customUtilityLayerScene?: Scene;
  129696. /**
  129697. * Values to configure the default target mesh
  129698. */
  129699. defaultTargetMeshOptions?: {
  129700. /**
  129701. * Fill color of the teleportation area
  129702. */
  129703. teleportationFillColor?: string;
  129704. /**
  129705. * Border color for the teleportation area
  129706. */
  129707. teleportationBorderColor?: string;
  129708. /**
  129709. * Disable the mesh's animation sequence
  129710. */
  129711. disableAnimation?: boolean;
  129712. /**
  129713. * Disable lighting on the material or the ring and arrow
  129714. */
  129715. disableLighting?: boolean;
  129716. /**
  129717. * Override the default material of the torus and arrow
  129718. */
  129719. torusArrowMaterial?: Material;
  129720. };
  129721. /**
  129722. * A list of meshes to use as floor meshes.
  129723. * Meshes can be added and removed after initializing the feature using the
  129724. * addFloorMesh and removeFloorMesh functions
  129725. * If empty, rotation will still work
  129726. */
  129727. floorMeshes?: AbstractMesh[];
  129728. /**
  129729. * use this rendering group id for the meshes (optional)
  129730. */
  129731. renderingGroupId?: number;
  129732. /**
  129733. * Should teleportation move only to snap points
  129734. */
  129735. snapPointsOnly?: boolean;
  129736. /**
  129737. * An array of points to which the teleportation will snap to.
  129738. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  129739. */
  129740. snapPositions?: Vector3[];
  129741. /**
  129742. * How close should the teleportation ray be in order to snap to position.
  129743. * Default to 0.8 units (meters)
  129744. */
  129745. snapToPositionRadius?: number;
  129746. /**
  129747. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  129748. * If you want to support rotation, make sure your mesh has a direction indicator.
  129749. *
  129750. * When left untouched, the default mesh will be initialized.
  129751. */
  129752. teleportationTargetMesh?: AbstractMesh;
  129753. /**
  129754. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  129755. */
  129756. timeToTeleport?: number;
  129757. /**
  129758. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  129759. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  129760. */
  129761. useMainComponentOnly?: boolean;
  129762. /**
  129763. * Should meshes created here be added to a utility layer or the main scene
  129764. */
  129765. useUtilityLayer?: boolean;
  129766. /**
  129767. * Babylon XR Input class for controller
  129768. */
  129769. xrInput: WebXRInput;
  129770. /**
  129771. * Meshes that the teleportation ray cannot go through
  129772. */
  129773. pickBlockerMeshes?: AbstractMesh[];
  129774. }
  129775. /**
  129776. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  129777. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  129778. * the input of the attached controllers.
  129779. */
  129780. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  129781. private _options;
  129782. private _controllers;
  129783. private _currentTeleportationControllerId;
  129784. private _floorMeshes;
  129785. private _quadraticBezierCurve;
  129786. private _selectionFeature;
  129787. private _snapToPositions;
  129788. private _snappedToPoint;
  129789. private _teleportationRingMaterial?;
  129790. private _tmpRay;
  129791. private _tmpVector;
  129792. private _tmpQuaternion;
  129793. /**
  129794. * The module's name
  129795. */
  129796. static readonly Name: string;
  129797. /**
  129798. * The (Babylon) version of this module.
  129799. * This is an integer representing the implementation version.
  129800. * This number does not correspond to the webxr specs version
  129801. */
  129802. static readonly Version: number;
  129803. /**
  129804. * Is movement backwards enabled
  129805. */
  129806. backwardsMovementEnabled: boolean;
  129807. /**
  129808. * Distance to travel when moving backwards
  129809. */
  129810. backwardsTeleportationDistance: number;
  129811. /**
  129812. * The distance from the user to the inspection point in the direction of the controller
  129813. * A higher number will allow the user to move further
  129814. * defaults to 5 (meters, in xr units)
  129815. */
  129816. parabolicCheckRadius: number;
  129817. /**
  129818. * Should the module support parabolic ray on top of direct ray
  129819. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  129820. * Very helpful when moving between floors / different heights
  129821. */
  129822. parabolicRayEnabled: boolean;
  129823. /**
  129824. * How much rotation should be applied when rotating right and left
  129825. */
  129826. rotationAngle: number;
  129827. /**
  129828. * Is rotation enabled when moving forward?
  129829. * Disabling this feature will prevent the user from deciding the direction when teleporting
  129830. */
  129831. rotationEnabled: boolean;
  129832. /**
  129833. * constructs a new anchor system
  129834. * @param _xrSessionManager an instance of WebXRSessionManager
  129835. * @param _options configuration object for this feature
  129836. */
  129837. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  129838. /**
  129839. * Get the snapPointsOnly flag
  129840. */
  129841. get snapPointsOnly(): boolean;
  129842. /**
  129843. * Sets the snapPointsOnly flag
  129844. * @param snapToPoints should teleportation be exclusively to snap points
  129845. */
  129846. set snapPointsOnly(snapToPoints: boolean);
  129847. /**
  129848. * Add a new mesh to the floor meshes array
  129849. * @param mesh the mesh to use as floor mesh
  129850. */
  129851. addFloorMesh(mesh: AbstractMesh): void;
  129852. /**
  129853. * Add a new snap-to point to fix teleportation to this position
  129854. * @param newSnapPoint The new Snap-To point
  129855. */
  129856. addSnapPoint(newSnapPoint: Vector3): void;
  129857. attach(): boolean;
  129858. detach(): boolean;
  129859. dispose(): void;
  129860. /**
  129861. * Remove a mesh from the floor meshes array
  129862. * @param mesh the mesh to remove
  129863. */
  129864. removeFloorMesh(mesh: AbstractMesh): void;
  129865. /**
  129866. * Remove a mesh from the floor meshes array using its name
  129867. * @param name the mesh name to remove
  129868. */
  129869. removeFloorMeshByName(name: string): void;
  129870. /**
  129871. * 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
  129872. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  129873. * @returns was the point found and removed or not
  129874. */
  129875. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  129876. /**
  129877. * This function sets a selection feature that will be disabled when
  129878. * the forward ray is shown and will be reattached when hidden.
  129879. * This is used to remove the selection rays when moving.
  129880. * @param selectionFeature the feature to disable when forward movement is enabled
  129881. */
  129882. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  129883. protected _onXRFrame(_xrFrame: XRFrame): void;
  129884. private _attachController;
  129885. private _createDefaultTargetMesh;
  129886. private _detachController;
  129887. private _findClosestSnapPointWithRadius;
  129888. private _setTargetMeshPosition;
  129889. private _setTargetMeshVisibility;
  129890. private _showParabolicPath;
  129891. private _teleportForward;
  129892. }
  129893. }
  129894. declare module BABYLON {
  129895. /**
  129896. * Options for the default xr helper
  129897. */
  129898. export class WebXRDefaultExperienceOptions {
  129899. /**
  129900. * Enable or disable default UI to enter XR
  129901. */
  129902. disableDefaultUI?: boolean;
  129903. /**
  129904. * Should teleportation not initialize. defaults to false.
  129905. */
  129906. disableTeleportation?: boolean;
  129907. /**
  129908. * Floor meshes that will be used for teleport
  129909. */
  129910. floorMeshes?: Array<AbstractMesh>;
  129911. /**
  129912. * If set to true, the first frame will not be used to reset position
  129913. * The first frame is mainly used when copying transformation from the old camera
  129914. * Mainly used in AR
  129915. */
  129916. ignoreNativeCameraTransformation?: boolean;
  129917. /**
  129918. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  129919. */
  129920. inputOptions?: IWebXRInputOptions;
  129921. /**
  129922. * optional configuration for the output canvas
  129923. */
  129924. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  129925. /**
  129926. * optional UI options. This can be used among other to change session mode and reference space type
  129927. */
  129928. uiOptions?: WebXREnterExitUIOptions;
  129929. /**
  129930. * When loading teleportation and pointer select, use stable versions instead of latest.
  129931. */
  129932. useStablePlugins?: boolean;
  129933. /**
  129934. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  129935. */
  129936. renderingGroupId?: number;
  129937. /**
  129938. * A list of optional features to init the session with
  129939. * If set to true, all features we support will be added
  129940. */
  129941. optionalFeatures?: boolean | string[];
  129942. }
  129943. /**
  129944. * Default experience which provides a similar setup to the previous webVRExperience
  129945. */
  129946. export class WebXRDefaultExperience {
  129947. /**
  129948. * Base experience
  129949. */
  129950. baseExperience: WebXRExperienceHelper;
  129951. /**
  129952. * Enables ui for entering/exiting xr
  129953. */
  129954. enterExitUI: WebXREnterExitUI;
  129955. /**
  129956. * Input experience extension
  129957. */
  129958. input: WebXRInput;
  129959. /**
  129960. * Enables laser pointer and selection
  129961. */
  129962. pointerSelection: WebXRControllerPointerSelection;
  129963. /**
  129964. * Default target xr should render to
  129965. */
  129966. renderTarget: WebXRRenderTarget;
  129967. /**
  129968. * Enables teleportation
  129969. */
  129970. teleportation: WebXRMotionControllerTeleportation;
  129971. private constructor();
  129972. /**
  129973. * Creates the default xr experience
  129974. * @param scene scene
  129975. * @param options options for basic configuration
  129976. * @returns resulting WebXRDefaultExperience
  129977. */
  129978. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  129979. /**
  129980. * DIsposes of the experience helper
  129981. */
  129982. dispose(): void;
  129983. }
  129984. }
  129985. declare module BABYLON {
  129986. /**
  129987. * Options to modify the vr teleportation behavior.
  129988. */
  129989. export interface VRTeleportationOptions {
  129990. /**
  129991. * The name of the mesh which should be used as the teleportation floor. (default: null)
  129992. */
  129993. floorMeshName?: string;
  129994. /**
  129995. * A list of meshes to be used as the teleportation floor. (default: empty)
  129996. */
  129997. floorMeshes?: Mesh[];
  129998. /**
  129999. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130000. */
  130001. teleportationMode?: number;
  130002. /**
  130003. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130004. */
  130005. teleportationTime?: number;
  130006. /**
  130007. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130008. */
  130009. teleportationSpeed?: number;
  130010. /**
  130011. * The easing function used in the animation or null for Linear. (default CircleEase)
  130012. */
  130013. easingFunction?: EasingFunction;
  130014. }
  130015. /**
  130016. * Options to modify the vr experience helper's behavior.
  130017. */
  130018. export interface VRExperienceHelperOptions extends WebVROptions {
  130019. /**
  130020. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130021. */
  130022. createDeviceOrientationCamera?: boolean;
  130023. /**
  130024. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130025. */
  130026. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130027. /**
  130028. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130029. */
  130030. laserToggle?: boolean;
  130031. /**
  130032. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130033. */
  130034. floorMeshes?: Mesh[];
  130035. /**
  130036. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130037. */
  130038. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130039. /**
  130040. * Defines if WebXR should be used instead of WebVR (if available)
  130041. */
  130042. useXR?: boolean;
  130043. }
  130044. /**
  130045. * Event containing information after VR has been entered
  130046. */
  130047. export class OnAfterEnteringVRObservableEvent {
  130048. /**
  130049. * If entering vr was successful
  130050. */
  130051. success: boolean;
  130052. }
  130053. /**
  130054. * Helps to quickly add VR support to an existing scene.
  130055. * See https://doc.babylonjs.com/how_to/webvr_helper
  130056. */
  130057. export class VRExperienceHelper {
  130058. /** Options to modify the vr experience helper's behavior. */
  130059. webVROptions: VRExperienceHelperOptions;
  130060. private _scene;
  130061. private _position;
  130062. private _btnVR;
  130063. private _btnVRDisplayed;
  130064. private _webVRsupported;
  130065. private _webVRready;
  130066. private _webVRrequesting;
  130067. private _webVRpresenting;
  130068. private _hasEnteredVR;
  130069. private _fullscreenVRpresenting;
  130070. private _inputElement;
  130071. private _webVRCamera;
  130072. private _vrDeviceOrientationCamera;
  130073. private _deviceOrientationCamera;
  130074. private _existingCamera;
  130075. private _onKeyDown;
  130076. private _onVrDisplayPresentChange;
  130077. private _onVRDisplayChanged;
  130078. private _onVRRequestPresentStart;
  130079. private _onVRRequestPresentComplete;
  130080. /**
  130081. * 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)
  130082. */
  130083. enableGazeEvenWhenNoPointerLock: boolean;
  130084. /**
  130085. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130086. */
  130087. exitVROnDoubleTap: boolean;
  130088. /**
  130089. * Observable raised right before entering VR.
  130090. */
  130091. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130092. /**
  130093. * Observable raised when entering VR has completed.
  130094. */
  130095. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130096. /**
  130097. * Observable raised when exiting VR.
  130098. */
  130099. onExitingVRObservable: Observable<VRExperienceHelper>;
  130100. /**
  130101. * Observable raised when controller mesh is loaded.
  130102. */
  130103. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130104. /** Return this.onEnteringVRObservable
  130105. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130106. */
  130107. get onEnteringVR(): Observable<VRExperienceHelper>;
  130108. /** Return this.onExitingVRObservable
  130109. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130110. */
  130111. get onExitingVR(): Observable<VRExperienceHelper>;
  130112. /** Return this.onControllerMeshLoadedObservable
  130113. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130114. */
  130115. get onControllerMeshLoaded(): Observable<WebVRController>;
  130116. private _rayLength;
  130117. private _useCustomVRButton;
  130118. private _teleportationRequested;
  130119. private _teleportActive;
  130120. private _floorMeshName;
  130121. private _floorMeshesCollection;
  130122. private _teleportationMode;
  130123. private _teleportationTime;
  130124. private _teleportationSpeed;
  130125. private _teleportationEasing;
  130126. private _rotationAllowed;
  130127. private _teleportBackwardsVector;
  130128. private _teleportationTarget;
  130129. private _isDefaultTeleportationTarget;
  130130. private _postProcessMove;
  130131. private _teleportationFillColor;
  130132. private _teleportationBorderColor;
  130133. private _rotationAngle;
  130134. private _haloCenter;
  130135. private _cameraGazer;
  130136. private _padSensibilityUp;
  130137. private _padSensibilityDown;
  130138. private _leftController;
  130139. private _rightController;
  130140. private _gazeColor;
  130141. private _laserColor;
  130142. private _pickedLaserColor;
  130143. private _pickedGazeColor;
  130144. /**
  130145. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130146. */
  130147. onNewMeshSelected: Observable<AbstractMesh>;
  130148. /**
  130149. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130150. * This observable will provide the mesh and the controller used to select the mesh
  130151. */
  130152. onMeshSelectedWithController: Observable<{
  130153. mesh: AbstractMesh;
  130154. controller: WebVRController;
  130155. }>;
  130156. /**
  130157. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130158. */
  130159. onNewMeshPicked: Observable<PickingInfo>;
  130160. private _circleEase;
  130161. /**
  130162. * Observable raised before camera teleportation
  130163. */
  130164. onBeforeCameraTeleport: Observable<Vector3>;
  130165. /**
  130166. * Observable raised after camera teleportation
  130167. */
  130168. onAfterCameraTeleport: Observable<Vector3>;
  130169. /**
  130170. * Observable raised when current selected mesh gets unselected
  130171. */
  130172. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130173. private _raySelectionPredicate;
  130174. /**
  130175. * To be optionaly changed by user to define custom ray selection
  130176. */
  130177. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130178. /**
  130179. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130180. */
  130181. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130182. /**
  130183. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130184. */
  130185. teleportationEnabled: boolean;
  130186. private _defaultHeight;
  130187. private _teleportationInitialized;
  130188. private _interactionsEnabled;
  130189. private _interactionsRequested;
  130190. private _displayGaze;
  130191. private _displayLaserPointer;
  130192. /**
  130193. * The mesh used to display where the user is going to teleport.
  130194. */
  130195. get teleportationTarget(): Mesh;
  130196. /**
  130197. * Sets the mesh to be used to display where the user is going to teleport.
  130198. */
  130199. set teleportationTarget(value: Mesh);
  130200. /**
  130201. * 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
  130202. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130203. * See https://doc.babylonjs.com/resources/baking_transformations
  130204. */
  130205. get gazeTrackerMesh(): Mesh;
  130206. set gazeTrackerMesh(value: Mesh);
  130207. /**
  130208. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130209. */
  130210. updateGazeTrackerScale: boolean;
  130211. /**
  130212. * If the gaze trackers color should be updated when selecting meshes
  130213. */
  130214. updateGazeTrackerColor: boolean;
  130215. /**
  130216. * If the controller laser color should be updated when selecting meshes
  130217. */
  130218. updateControllerLaserColor: boolean;
  130219. /**
  130220. * The gaze tracking mesh corresponding to the left controller
  130221. */
  130222. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130223. /**
  130224. * The gaze tracking mesh corresponding to the right controller
  130225. */
  130226. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130227. /**
  130228. * If the ray of the gaze should be displayed.
  130229. */
  130230. get displayGaze(): boolean;
  130231. /**
  130232. * Sets if the ray of the gaze should be displayed.
  130233. */
  130234. set displayGaze(value: boolean);
  130235. /**
  130236. * If the ray of the LaserPointer should be displayed.
  130237. */
  130238. get displayLaserPointer(): boolean;
  130239. /**
  130240. * Sets if the ray of the LaserPointer should be displayed.
  130241. */
  130242. set displayLaserPointer(value: boolean);
  130243. /**
  130244. * The deviceOrientationCamera used as the camera when not in VR.
  130245. */
  130246. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130247. /**
  130248. * Based on the current WebVR support, returns the current VR camera used.
  130249. */
  130250. get currentVRCamera(): Nullable<Camera>;
  130251. /**
  130252. * The webVRCamera which is used when in VR.
  130253. */
  130254. get webVRCamera(): WebVRFreeCamera;
  130255. /**
  130256. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130257. */
  130258. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130259. /**
  130260. * The html button that is used to trigger entering into VR.
  130261. */
  130262. get vrButton(): Nullable<HTMLButtonElement>;
  130263. private get _teleportationRequestInitiated();
  130264. /**
  130265. * Defines whether or not Pointer lock should be requested when switching to
  130266. * full screen.
  130267. */
  130268. requestPointerLockOnFullScreen: boolean;
  130269. /**
  130270. * If asking to force XR, this will be populated with the default xr experience
  130271. */
  130272. xr: WebXRDefaultExperience;
  130273. /**
  130274. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130275. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130276. */
  130277. xrTestDone: boolean;
  130278. /**
  130279. * Instantiates a VRExperienceHelper.
  130280. * Helps to quickly add VR support to an existing scene.
  130281. * @param scene The scene the VRExperienceHelper belongs to.
  130282. * @param webVROptions Options to modify the vr experience helper's behavior.
  130283. */
  130284. constructor(scene: Scene,
  130285. /** Options to modify the vr experience helper's behavior. */
  130286. webVROptions?: VRExperienceHelperOptions);
  130287. private completeVRInit;
  130288. private _onDefaultMeshLoaded;
  130289. private _onResize;
  130290. private _onFullscreenChange;
  130291. /**
  130292. * Gets a value indicating if we are currently in VR mode.
  130293. */
  130294. get isInVRMode(): boolean;
  130295. private onVrDisplayPresentChange;
  130296. private onVRDisplayChanged;
  130297. private moveButtonToBottomRight;
  130298. private displayVRButton;
  130299. private updateButtonVisibility;
  130300. private _cachedAngularSensibility;
  130301. /**
  130302. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130303. * Otherwise, will use the fullscreen API.
  130304. */
  130305. enterVR(): void;
  130306. /**
  130307. * Attempt to exit VR, or fullscreen.
  130308. */
  130309. exitVR(): void;
  130310. /**
  130311. * The position of the vr experience helper.
  130312. */
  130313. get position(): Vector3;
  130314. /**
  130315. * Sets the position of the vr experience helper.
  130316. */
  130317. set position(value: Vector3);
  130318. /**
  130319. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130320. */
  130321. enableInteractions(): void;
  130322. private get _noControllerIsActive();
  130323. private beforeRender;
  130324. private _isTeleportationFloor;
  130325. /**
  130326. * Adds a floor mesh to be used for teleportation.
  130327. * @param floorMesh the mesh to be used for teleportation.
  130328. */
  130329. addFloorMesh(floorMesh: Mesh): void;
  130330. /**
  130331. * Removes a floor mesh from being used for teleportation.
  130332. * @param floorMesh the mesh to be removed.
  130333. */
  130334. removeFloorMesh(floorMesh: Mesh): void;
  130335. /**
  130336. * Enables interactions and teleportation using the VR controllers and gaze.
  130337. * @param vrTeleportationOptions options to modify teleportation behavior.
  130338. */
  130339. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130340. private _onNewGamepadConnected;
  130341. private _tryEnableInteractionOnController;
  130342. private _onNewGamepadDisconnected;
  130343. private _enableInteractionOnController;
  130344. private _checkTeleportWithRay;
  130345. private _checkRotate;
  130346. private _checkTeleportBackwards;
  130347. private _enableTeleportationOnController;
  130348. private _createTeleportationCircles;
  130349. private _displayTeleportationTarget;
  130350. private _hideTeleportationTarget;
  130351. private _rotateCamera;
  130352. private _moveTeleportationSelectorTo;
  130353. private _workingVector;
  130354. private _workingQuaternion;
  130355. private _workingMatrix;
  130356. /**
  130357. * Time Constant Teleportation Mode
  130358. */
  130359. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130360. /**
  130361. * Speed Constant Teleportation Mode
  130362. */
  130363. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130364. /**
  130365. * Teleports the users feet to the desired location
  130366. * @param location The location where the user's feet should be placed
  130367. */
  130368. teleportCamera(location: Vector3): void;
  130369. private _convertNormalToDirectionOfRay;
  130370. private _castRayAndSelectObject;
  130371. private _notifySelectedMeshUnselected;
  130372. /**
  130373. * Permanently set new colors for the laser pointer
  130374. * @param color the new laser color
  130375. * @param pickedColor the new laser color when picked mesh detected
  130376. */
  130377. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130378. /**
  130379. * Set lighting enabled / disabled on the laser pointer of both controllers
  130380. * @param enabled should the lighting be enabled on the laser pointer
  130381. */
  130382. setLaserLightingState(enabled?: boolean): void;
  130383. /**
  130384. * Permanently set new colors for the gaze pointer
  130385. * @param color the new gaze color
  130386. * @param pickedColor the new gaze color when picked mesh detected
  130387. */
  130388. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130389. /**
  130390. * Sets the color of the laser ray from the vr controllers.
  130391. * @param color new color for the ray.
  130392. */
  130393. changeLaserColor(color: Color3): void;
  130394. /**
  130395. * Sets the color of the ray from the vr headsets gaze.
  130396. * @param color new color for the ray.
  130397. */
  130398. changeGazeColor(color: Color3): void;
  130399. /**
  130400. * Exits VR and disposes of the vr experience helper
  130401. */
  130402. dispose(): void;
  130403. /**
  130404. * Gets the name of the VRExperienceHelper class
  130405. * @returns "VRExperienceHelper"
  130406. */
  130407. getClassName(): string;
  130408. }
  130409. }
  130410. declare module BABYLON {
  130411. /**
  130412. * Contains an array of blocks representing the octree
  130413. */
  130414. export interface IOctreeContainer<T> {
  130415. /**
  130416. * Blocks within the octree
  130417. */
  130418. blocks: Array<OctreeBlock<T>>;
  130419. }
  130420. /**
  130421. * Class used to store a cell in an octree
  130422. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130423. */
  130424. export class OctreeBlock<T> {
  130425. /**
  130426. * Gets the content of the current block
  130427. */
  130428. entries: T[];
  130429. /**
  130430. * Gets the list of block children
  130431. */
  130432. blocks: Array<OctreeBlock<T>>;
  130433. private _depth;
  130434. private _maxDepth;
  130435. private _capacity;
  130436. private _minPoint;
  130437. private _maxPoint;
  130438. private _boundingVectors;
  130439. private _creationFunc;
  130440. /**
  130441. * Creates a new block
  130442. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130443. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130444. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130445. * @param depth defines the current depth of this block in the octree
  130446. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130447. * @param creationFunc defines a callback to call when an element is added to the block
  130448. */
  130449. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130450. /**
  130451. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130452. */
  130453. get capacity(): number;
  130454. /**
  130455. * Gets the minimum vector (in world space) of the block's bounding box
  130456. */
  130457. get minPoint(): Vector3;
  130458. /**
  130459. * Gets the maximum vector (in world space) of the block's bounding box
  130460. */
  130461. get maxPoint(): Vector3;
  130462. /**
  130463. * Add a new element to this block
  130464. * @param entry defines the element to add
  130465. */
  130466. addEntry(entry: T): void;
  130467. /**
  130468. * Remove an element from this block
  130469. * @param entry defines the element to remove
  130470. */
  130471. removeEntry(entry: T): void;
  130472. /**
  130473. * Add an array of elements to this block
  130474. * @param entries defines the array of elements to add
  130475. */
  130476. addEntries(entries: T[]): void;
  130477. /**
  130478. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130479. * @param frustumPlanes defines the frustum planes to test
  130480. * @param selection defines the array to store current content if selection is positive
  130481. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130482. */
  130483. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130484. /**
  130485. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130486. * @param sphereCenter defines the bounding sphere center
  130487. * @param sphereRadius defines the bounding sphere radius
  130488. * @param selection defines the array to store current content if selection is positive
  130489. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130490. */
  130491. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130492. /**
  130493. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130494. * @param ray defines the ray to test with
  130495. * @param selection defines the array to store current content if selection is positive
  130496. */
  130497. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130498. /**
  130499. * Subdivide the content into child blocks (this block will then be empty)
  130500. */
  130501. createInnerBlocks(): void;
  130502. /**
  130503. * @hidden
  130504. */
  130505. 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;
  130506. }
  130507. }
  130508. declare module BABYLON {
  130509. /**
  130510. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130511. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130512. */
  130513. export class Octree<T> {
  130514. /** 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.) */
  130515. maxDepth: number;
  130516. /**
  130517. * Blocks within the octree containing objects
  130518. */
  130519. blocks: Array<OctreeBlock<T>>;
  130520. /**
  130521. * Content stored in the octree
  130522. */
  130523. dynamicContent: T[];
  130524. private _maxBlockCapacity;
  130525. private _selectionContent;
  130526. private _creationFunc;
  130527. /**
  130528. * Creates a octree
  130529. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130530. * @param creationFunc function to be used to instatiate the octree
  130531. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130532. * @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.)
  130533. */
  130534. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130535. /** 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.) */
  130536. maxDepth?: number);
  130537. /**
  130538. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130539. * @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);
  130540. * @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);
  130541. * @param entries meshes to be added to the octree blocks
  130542. */
  130543. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130544. /**
  130545. * Adds a mesh to the octree
  130546. * @param entry Mesh to add to the octree
  130547. */
  130548. addMesh(entry: T): void;
  130549. /**
  130550. * Remove an element from the octree
  130551. * @param entry defines the element to remove
  130552. */
  130553. removeMesh(entry: T): void;
  130554. /**
  130555. * Selects an array of meshes within the frustum
  130556. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130557. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130558. * @returns array of meshes within the frustum
  130559. */
  130560. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130561. /**
  130562. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130563. * @param sphereCenter defines the bounding sphere center
  130564. * @param sphereRadius defines the bounding sphere radius
  130565. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130566. * @returns an array of objects that intersect the sphere
  130567. */
  130568. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130569. /**
  130570. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130571. * @param ray defines the ray to test with
  130572. * @returns array of intersected objects
  130573. */
  130574. intersectsRay(ray: Ray): SmartArray<T>;
  130575. /**
  130576. * Adds a mesh into the octree block if it intersects the block
  130577. */
  130578. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130579. /**
  130580. * Adds a submesh into the octree block if it intersects the block
  130581. */
  130582. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130583. }
  130584. }
  130585. declare module BABYLON {
  130586. interface Scene {
  130587. /**
  130588. * @hidden
  130589. * Backing Filed
  130590. */
  130591. _selectionOctree: Octree<AbstractMesh>;
  130592. /**
  130593. * Gets the octree used to boost mesh selection (picking)
  130594. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130595. */
  130596. selectionOctree: Octree<AbstractMesh>;
  130597. /**
  130598. * Creates or updates the octree used to boost selection (picking)
  130599. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130600. * @param maxCapacity defines the maximum capacity per leaf
  130601. * @param maxDepth defines the maximum depth of the octree
  130602. * @returns an octree of AbstractMesh
  130603. */
  130604. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130605. }
  130606. interface AbstractMesh {
  130607. /**
  130608. * @hidden
  130609. * Backing Field
  130610. */
  130611. _submeshesOctree: Octree<SubMesh>;
  130612. /**
  130613. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130614. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130615. * @param maxCapacity defines the maximum size of each block (64 by default)
  130616. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130617. * @returns the new octree
  130618. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130619. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130620. */
  130621. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130622. }
  130623. /**
  130624. * Defines the octree scene component responsible to manage any octrees
  130625. * in a given scene.
  130626. */
  130627. export class OctreeSceneComponent {
  130628. /**
  130629. * The component name help to identify the component in the list of scene components.
  130630. */
  130631. readonly name: string;
  130632. /**
  130633. * The scene the component belongs to.
  130634. */
  130635. scene: Scene;
  130636. /**
  130637. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130638. */
  130639. readonly checksIsEnabled: boolean;
  130640. /**
  130641. * Creates a new instance of the component for the given scene
  130642. * @param scene Defines the scene to register the component in
  130643. */
  130644. constructor(scene: Scene);
  130645. /**
  130646. * Registers the component in a given scene
  130647. */
  130648. register(): void;
  130649. /**
  130650. * Return the list of active meshes
  130651. * @returns the list of active meshes
  130652. */
  130653. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  130654. /**
  130655. * Return the list of active sub meshes
  130656. * @param mesh The mesh to get the candidates sub meshes from
  130657. * @returns the list of active sub meshes
  130658. */
  130659. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  130660. private _tempRay;
  130661. /**
  130662. * Return the list of sub meshes intersecting with a given local ray
  130663. * @param mesh defines the mesh to find the submesh for
  130664. * @param localRay defines the ray in local space
  130665. * @returns the list of intersecting sub meshes
  130666. */
  130667. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  130668. /**
  130669. * Return the list of sub meshes colliding with a collider
  130670. * @param mesh defines the mesh to find the submesh for
  130671. * @param collider defines the collider to evaluate the collision against
  130672. * @returns the list of colliding sub meshes
  130673. */
  130674. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  130675. /**
  130676. * Rebuilds the elements related to this component in case of
  130677. * context lost for instance.
  130678. */
  130679. rebuild(): void;
  130680. /**
  130681. * Disposes the component and the associated ressources.
  130682. */
  130683. dispose(): void;
  130684. }
  130685. }
  130686. declare module BABYLON {
  130687. /**
  130688. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  130689. */
  130690. export class Gizmo implements IDisposable {
  130691. /** The utility layer the gizmo will be added to */
  130692. gizmoLayer: UtilityLayerRenderer;
  130693. /**
  130694. * The root mesh of the gizmo
  130695. */
  130696. _rootMesh: Mesh;
  130697. private _attachedMesh;
  130698. private _attachedNode;
  130699. /**
  130700. * Ratio for the scale of the gizmo (Default: 1)
  130701. */
  130702. protected _scaleRatio: number;
  130703. /**
  130704. * Ratio for the scale of the gizmo (Default: 1)
  130705. */
  130706. set scaleRatio(value: number);
  130707. get scaleRatio(): number;
  130708. /**
  130709. * If a custom mesh has been set (Default: false)
  130710. */
  130711. protected _customMeshSet: boolean;
  130712. /**
  130713. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  130714. * * When set, interactions will be enabled
  130715. */
  130716. get attachedMesh(): Nullable<AbstractMesh>;
  130717. set attachedMesh(value: Nullable<AbstractMesh>);
  130718. /**
  130719. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  130720. * * When set, interactions will be enabled
  130721. */
  130722. get attachedNode(): Nullable<Node>;
  130723. set attachedNode(value: Nullable<Node>);
  130724. /**
  130725. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  130726. * @param mesh The mesh to replace the default mesh of the gizmo
  130727. */
  130728. setCustomMesh(mesh: Mesh): void;
  130729. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  130730. /**
  130731. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  130732. */
  130733. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130734. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130735. /**
  130736. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  130737. */
  130738. updateGizmoPositionToMatchAttachedMesh: boolean;
  130739. /**
  130740. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  130741. */
  130742. updateScale: boolean;
  130743. protected _interactionsEnabled: boolean;
  130744. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130745. private _beforeRenderObserver;
  130746. private _tempQuaternion;
  130747. private _tempVector;
  130748. private _tempVector2;
  130749. private _tempMatrix1;
  130750. private _tempMatrix2;
  130751. private _rightHandtoLeftHandMatrix;
  130752. /**
  130753. * Creates a gizmo
  130754. * @param gizmoLayer The utility layer the gizmo will be added to
  130755. */
  130756. constructor(
  130757. /** The utility layer the gizmo will be added to */
  130758. gizmoLayer?: UtilityLayerRenderer);
  130759. /**
  130760. * Updates the gizmo to match the attached mesh's position/rotation
  130761. */
  130762. protected _update(): void;
  130763. /**
  130764. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  130765. * @param value Node, TransformNode or mesh
  130766. */
  130767. protected _matrixChanged(): void;
  130768. /**
  130769. * Disposes of the gizmo
  130770. */
  130771. dispose(): void;
  130772. }
  130773. }
  130774. declare module BABYLON {
  130775. /**
  130776. * Single plane drag gizmo
  130777. */
  130778. export class PlaneDragGizmo extends Gizmo {
  130779. /**
  130780. * Drag behavior responsible for the gizmos dragging interactions
  130781. */
  130782. dragBehavior: PointerDragBehavior;
  130783. private _pointerObserver;
  130784. /**
  130785. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130786. */
  130787. snapDistance: number;
  130788. /**
  130789. * Event that fires each time the gizmo snaps to a new location.
  130790. * * snapDistance is the the change in distance
  130791. */
  130792. onSnapObservable: Observable<{
  130793. snapDistance: number;
  130794. }>;
  130795. private _plane;
  130796. private _coloredMaterial;
  130797. private _hoverMaterial;
  130798. private _isEnabled;
  130799. private _parent;
  130800. /** @hidden */
  130801. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  130802. /** @hidden */
  130803. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130804. /**
  130805. * Creates a PlaneDragGizmo
  130806. * @param gizmoLayer The utility layer the gizmo will be added to
  130807. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  130808. * @param color The color of the gizmo
  130809. */
  130810. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  130811. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130812. /**
  130813. * If the gizmo is enabled
  130814. */
  130815. set isEnabled(value: boolean);
  130816. get isEnabled(): boolean;
  130817. /**
  130818. * Disposes of the gizmo
  130819. */
  130820. dispose(): void;
  130821. }
  130822. }
  130823. declare module BABYLON {
  130824. /**
  130825. * Gizmo that enables dragging a mesh along 3 axis
  130826. */
  130827. export class PositionGizmo extends Gizmo {
  130828. /**
  130829. * Internal gizmo used for interactions on the x axis
  130830. */
  130831. xGizmo: AxisDragGizmo;
  130832. /**
  130833. * Internal gizmo used for interactions on the y axis
  130834. */
  130835. yGizmo: AxisDragGizmo;
  130836. /**
  130837. * Internal gizmo used for interactions on the z axis
  130838. */
  130839. zGizmo: AxisDragGizmo;
  130840. /**
  130841. * Internal gizmo used for interactions on the yz plane
  130842. */
  130843. xPlaneGizmo: PlaneDragGizmo;
  130844. /**
  130845. * Internal gizmo used for interactions on the xz plane
  130846. */
  130847. yPlaneGizmo: PlaneDragGizmo;
  130848. /**
  130849. * Internal gizmo used for interactions on the xy plane
  130850. */
  130851. zPlaneGizmo: PlaneDragGizmo;
  130852. /**
  130853. * private variables
  130854. */
  130855. private _meshAttached;
  130856. private _nodeAttached;
  130857. private _snapDistance;
  130858. /** Fires an event when any of it's sub gizmos are dragged */
  130859. onDragStartObservable: Observable<unknown>;
  130860. /** Fires an event when any of it's sub gizmos are released from dragging */
  130861. onDragEndObservable: Observable<unknown>;
  130862. /**
  130863. * If set to true, planar drag is enabled
  130864. */
  130865. private _planarGizmoEnabled;
  130866. get attachedMesh(): Nullable<AbstractMesh>;
  130867. set attachedMesh(mesh: Nullable<AbstractMesh>);
  130868. get attachedNode(): Nullable<Node>;
  130869. set attachedNode(node: Nullable<Node>);
  130870. /**
  130871. * Creates a PositionGizmo
  130872. * @param gizmoLayer The utility layer the gizmo will be added to
  130873. @param thickness display gizmo axis thickness
  130874. */
  130875. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  130876. /**
  130877. * If the planar drag gizmo is enabled
  130878. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  130879. */
  130880. set planarGizmoEnabled(value: boolean);
  130881. get planarGizmoEnabled(): boolean;
  130882. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  130883. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  130884. /**
  130885. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130886. */
  130887. set snapDistance(value: number);
  130888. get snapDistance(): number;
  130889. /**
  130890. * Ratio for the scale of the gizmo (Default: 1)
  130891. */
  130892. set scaleRatio(value: number);
  130893. get scaleRatio(): number;
  130894. /**
  130895. * Disposes of the gizmo
  130896. */
  130897. dispose(): void;
  130898. /**
  130899. * CustomMeshes are not supported by this gizmo
  130900. * @param mesh The mesh to replace the default mesh of the gizmo
  130901. */
  130902. setCustomMesh(mesh: Mesh): void;
  130903. }
  130904. }
  130905. declare module BABYLON {
  130906. /**
  130907. * Single axis drag gizmo
  130908. */
  130909. export class AxisDragGizmo extends Gizmo {
  130910. /**
  130911. * Drag behavior responsible for the gizmos dragging interactions
  130912. */
  130913. dragBehavior: PointerDragBehavior;
  130914. private _pointerObserver;
  130915. /**
  130916. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  130917. */
  130918. snapDistance: number;
  130919. /**
  130920. * Event that fires each time the gizmo snaps to a new location.
  130921. * * snapDistance is the the change in distance
  130922. */
  130923. onSnapObservable: Observable<{
  130924. snapDistance: number;
  130925. }>;
  130926. private _isEnabled;
  130927. private _parent;
  130928. private _arrow;
  130929. private _coloredMaterial;
  130930. private _hoverMaterial;
  130931. /** @hidden */
  130932. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  130933. /** @hidden */
  130934. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  130935. /**
  130936. * Creates an AxisDragGizmo
  130937. * @param gizmoLayer The utility layer the gizmo will be added to
  130938. * @param dragAxis The axis which the gizmo will be able to drag on
  130939. * @param color The color of the gizmo
  130940. * @param thickness display gizmo axis thickness
  130941. */
  130942. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  130943. protected _attachedNodeChanged(value: Nullable<Node>): void;
  130944. /**
  130945. * If the gizmo is enabled
  130946. */
  130947. set isEnabled(value: boolean);
  130948. get isEnabled(): boolean;
  130949. /**
  130950. * Disposes of the gizmo
  130951. */
  130952. dispose(): void;
  130953. }
  130954. }
  130955. declare module BABYLON.Debug {
  130956. /**
  130957. * The Axes viewer will show 3 axes in a specific point in space
  130958. */
  130959. export class AxesViewer {
  130960. private _xAxis;
  130961. private _yAxis;
  130962. private _zAxis;
  130963. private _scaleLinesFactor;
  130964. private _instanced;
  130965. /**
  130966. * Gets the hosting scene
  130967. */
  130968. scene: Nullable<Scene>;
  130969. /**
  130970. * Gets or sets a number used to scale line length
  130971. */
  130972. scaleLines: number;
  130973. /** Gets the node hierarchy used to render x-axis */
  130974. get xAxis(): TransformNode;
  130975. /** Gets the node hierarchy used to render y-axis */
  130976. get yAxis(): TransformNode;
  130977. /** Gets the node hierarchy used to render z-axis */
  130978. get zAxis(): TransformNode;
  130979. /**
  130980. * Creates a new AxesViewer
  130981. * @param scene defines the hosting scene
  130982. * @param scaleLines defines a number used to scale line length (1 by default)
  130983. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  130984. * @param xAxis defines the node hierarchy used to render the x-axis
  130985. * @param yAxis defines the node hierarchy used to render the y-axis
  130986. * @param zAxis defines the node hierarchy used to render the z-axis
  130987. */
  130988. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  130989. /**
  130990. * Force the viewer to update
  130991. * @param position defines the position of the viewer
  130992. * @param xaxis defines the x axis of the viewer
  130993. * @param yaxis defines the y axis of the viewer
  130994. * @param zaxis defines the z axis of the viewer
  130995. */
  130996. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  130997. /**
  130998. * Creates an instance of this axes viewer.
  130999. * @returns a new axes viewer with instanced meshes
  131000. */
  131001. createInstance(): AxesViewer;
  131002. /** Releases resources */
  131003. dispose(): void;
  131004. private static _SetRenderingGroupId;
  131005. }
  131006. }
  131007. declare module BABYLON.Debug {
  131008. /**
  131009. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131010. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131011. */
  131012. export class BoneAxesViewer extends AxesViewer {
  131013. /**
  131014. * Gets or sets the target mesh where to display the axes viewer
  131015. */
  131016. mesh: Nullable<Mesh>;
  131017. /**
  131018. * Gets or sets the target bone where to display the axes viewer
  131019. */
  131020. bone: Nullable<Bone>;
  131021. /** Gets current position */
  131022. pos: Vector3;
  131023. /** Gets direction of X axis */
  131024. xaxis: Vector3;
  131025. /** Gets direction of Y axis */
  131026. yaxis: Vector3;
  131027. /** Gets direction of Z axis */
  131028. zaxis: Vector3;
  131029. /**
  131030. * Creates a new BoneAxesViewer
  131031. * @param scene defines the hosting scene
  131032. * @param bone defines the target bone
  131033. * @param mesh defines the target mesh
  131034. * @param scaleLines defines a scaling factor for line length (1 by default)
  131035. */
  131036. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131037. /**
  131038. * Force the viewer to update
  131039. */
  131040. update(): void;
  131041. /** Releases resources */
  131042. dispose(): void;
  131043. }
  131044. }
  131045. declare module BABYLON {
  131046. /**
  131047. * Interface used to define scene explorer extensibility option
  131048. */
  131049. export interface IExplorerExtensibilityOption {
  131050. /**
  131051. * Define the option label
  131052. */
  131053. label: string;
  131054. /**
  131055. * Defines the action to execute on click
  131056. */
  131057. action: (entity: any) => void;
  131058. }
  131059. /**
  131060. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131061. */
  131062. export interface IExplorerExtensibilityGroup {
  131063. /**
  131064. * Defines a predicate to test if a given type mut be extended
  131065. */
  131066. predicate: (entity: any) => boolean;
  131067. /**
  131068. * Gets the list of options added to a type
  131069. */
  131070. entries: IExplorerExtensibilityOption[];
  131071. }
  131072. /**
  131073. * Interface used to define the options to use to create the Inspector
  131074. */
  131075. export interface IInspectorOptions {
  131076. /**
  131077. * Display in overlay mode (default: false)
  131078. */
  131079. overlay?: boolean;
  131080. /**
  131081. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131082. */
  131083. globalRoot?: HTMLElement;
  131084. /**
  131085. * Display the Scene explorer
  131086. */
  131087. showExplorer?: boolean;
  131088. /**
  131089. * Display the property inspector
  131090. */
  131091. showInspector?: boolean;
  131092. /**
  131093. * Display in embed mode (both panes on the right)
  131094. */
  131095. embedMode?: boolean;
  131096. /**
  131097. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131098. */
  131099. handleResize?: boolean;
  131100. /**
  131101. * Allow the panes to popup (default: true)
  131102. */
  131103. enablePopup?: boolean;
  131104. /**
  131105. * Allow the panes to be closed by users (default: true)
  131106. */
  131107. enableClose?: boolean;
  131108. /**
  131109. * Optional list of extensibility entries
  131110. */
  131111. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131112. /**
  131113. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131114. */
  131115. inspectorURL?: string;
  131116. /**
  131117. * Optional initial tab (default to DebugLayerTab.Properties)
  131118. */
  131119. initialTab?: DebugLayerTab;
  131120. }
  131121. interface Scene {
  131122. /**
  131123. * @hidden
  131124. * Backing field
  131125. */
  131126. _debugLayer: DebugLayer;
  131127. /**
  131128. * Gets the debug layer (aka Inspector) associated with the scene
  131129. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131130. */
  131131. debugLayer: DebugLayer;
  131132. }
  131133. /**
  131134. * Enum of inspector action tab
  131135. */
  131136. export enum DebugLayerTab {
  131137. /**
  131138. * Properties tag (default)
  131139. */
  131140. Properties = 0,
  131141. /**
  131142. * Debug tab
  131143. */
  131144. Debug = 1,
  131145. /**
  131146. * Statistics tab
  131147. */
  131148. Statistics = 2,
  131149. /**
  131150. * Tools tab
  131151. */
  131152. Tools = 3,
  131153. /**
  131154. * Settings tab
  131155. */
  131156. Settings = 4
  131157. }
  131158. /**
  131159. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131160. * what is happening in your scene
  131161. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131162. */
  131163. export class DebugLayer {
  131164. /**
  131165. * Define the url to get the inspector script from.
  131166. * By default it uses the babylonjs CDN.
  131167. * @ignoreNaming
  131168. */
  131169. static InspectorURL: string;
  131170. private _scene;
  131171. private BJSINSPECTOR;
  131172. private _onPropertyChangedObservable?;
  131173. /**
  131174. * Observable triggered when a property is changed through the inspector.
  131175. */
  131176. get onPropertyChangedObservable(): any;
  131177. /**
  131178. * Instantiates a new debug layer.
  131179. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131180. * what is happening in your scene
  131181. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131182. * @param scene Defines the scene to inspect
  131183. */
  131184. constructor(scene: Scene);
  131185. /** Creates the inspector window. */
  131186. private _createInspector;
  131187. /**
  131188. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131189. * @param entity defines the entity to select
  131190. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131191. */
  131192. select(entity: any, lineContainerTitles?: string | string[]): void;
  131193. /** Get the inspector from bundle or global */
  131194. private _getGlobalInspector;
  131195. /**
  131196. * Get if the inspector is visible or not.
  131197. * @returns true if visible otherwise, false
  131198. */
  131199. isVisible(): boolean;
  131200. /**
  131201. * Hide the inspector and close its window.
  131202. */
  131203. hide(): void;
  131204. /**
  131205. * Update the scene in the inspector
  131206. */
  131207. setAsActiveScene(): void;
  131208. /**
  131209. * Launch the debugLayer.
  131210. * @param config Define the configuration of the inspector
  131211. * @return a promise fulfilled when the debug layer is visible
  131212. */
  131213. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131214. }
  131215. }
  131216. declare module BABYLON {
  131217. /**
  131218. * Class containing static functions to help procedurally build meshes
  131219. */
  131220. export class BoxBuilder {
  131221. /**
  131222. * Creates a box mesh
  131223. * * The parameter `size` sets the size (float) of each box side (default 1)
  131224. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131225. * * 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)
  131226. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131227. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131228. * * 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
  131229. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131230. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131231. * @param name defines the name of the mesh
  131232. * @param options defines the options used to create the mesh
  131233. * @param scene defines the hosting scene
  131234. * @returns the box mesh
  131235. */
  131236. static CreateBox(name: string, options: {
  131237. size?: number;
  131238. width?: number;
  131239. height?: number;
  131240. depth?: number;
  131241. faceUV?: Vector4[];
  131242. faceColors?: Color4[];
  131243. sideOrientation?: number;
  131244. frontUVs?: Vector4;
  131245. backUVs?: Vector4;
  131246. wrap?: boolean;
  131247. topBaseAt?: number;
  131248. bottomBaseAt?: number;
  131249. updatable?: boolean;
  131250. }, scene?: Nullable<Scene>): Mesh;
  131251. }
  131252. }
  131253. declare module BABYLON.Debug {
  131254. /**
  131255. * Used to show the physics impostor around the specific mesh
  131256. */
  131257. export class PhysicsViewer {
  131258. /** @hidden */
  131259. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131260. /** @hidden */
  131261. protected _meshes: Array<Nullable<AbstractMesh>>;
  131262. /** @hidden */
  131263. protected _scene: Nullable<Scene>;
  131264. /** @hidden */
  131265. protected _numMeshes: number;
  131266. /** @hidden */
  131267. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131268. private _renderFunction;
  131269. private _utilityLayer;
  131270. private _debugBoxMesh;
  131271. private _debugSphereMesh;
  131272. private _debugCylinderMesh;
  131273. private _debugMaterial;
  131274. private _debugMeshMeshes;
  131275. /**
  131276. * Creates a new PhysicsViewer
  131277. * @param scene defines the hosting scene
  131278. */
  131279. constructor(scene: Scene);
  131280. /** @hidden */
  131281. protected _updateDebugMeshes(): void;
  131282. /**
  131283. * Renders a specified physic impostor
  131284. * @param impostor defines the impostor to render
  131285. * @param targetMesh defines the mesh represented by the impostor
  131286. * @returns the new debug mesh used to render the impostor
  131287. */
  131288. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131289. /**
  131290. * Hides a specified physic impostor
  131291. * @param impostor defines the impostor to hide
  131292. */
  131293. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131294. private _getDebugMaterial;
  131295. private _getDebugBoxMesh;
  131296. private _getDebugSphereMesh;
  131297. private _getDebugCylinderMesh;
  131298. private _getDebugMeshMesh;
  131299. private _getDebugMesh;
  131300. /** Releases all resources */
  131301. dispose(): void;
  131302. }
  131303. }
  131304. declare module BABYLON {
  131305. /**
  131306. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131307. * in order to better appreciate the issue one might have.
  131308. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131309. */
  131310. export class RayHelper {
  131311. /**
  131312. * Defines the ray we are currently tryin to visualize.
  131313. */
  131314. ray: Nullable<Ray>;
  131315. private _renderPoints;
  131316. private _renderLine;
  131317. private _renderFunction;
  131318. private _scene;
  131319. private _onAfterRenderObserver;
  131320. private _onAfterStepObserver;
  131321. private _attachedToMesh;
  131322. private _meshSpaceDirection;
  131323. private _meshSpaceOrigin;
  131324. /**
  131325. * Helper function to create a colored helper in a scene in one line.
  131326. * @param ray Defines the ray we are currently tryin to visualize
  131327. * @param scene Defines the scene the ray is used in
  131328. * @param color Defines the color we want to see the ray in
  131329. * @returns The newly created ray helper.
  131330. */
  131331. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131332. /**
  131333. * Instantiate a new ray helper.
  131334. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131335. * in order to better appreciate the issue one might have.
  131336. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131337. * @param ray Defines the ray we are currently tryin to visualize
  131338. */
  131339. constructor(ray: Ray);
  131340. /**
  131341. * Shows the ray we are willing to debug.
  131342. * @param scene Defines the scene the ray needs to be rendered in
  131343. * @param color Defines the color the ray needs to be rendered in
  131344. */
  131345. show(scene: Scene, color?: Color3): void;
  131346. /**
  131347. * Hides the ray we are debugging.
  131348. */
  131349. hide(): void;
  131350. private _render;
  131351. /**
  131352. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131353. * @param mesh Defines the mesh we want the helper attached to
  131354. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131355. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131356. * @param length Defines the length of the ray
  131357. */
  131358. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131359. /**
  131360. * Detach the ray helper from the mesh it has previously been attached to.
  131361. */
  131362. detachFromMesh(): void;
  131363. private _updateToMesh;
  131364. /**
  131365. * Dispose the helper and release its associated resources.
  131366. */
  131367. dispose(): void;
  131368. }
  131369. }
  131370. declare module BABYLON {
  131371. /**
  131372. * Defines the options associated with the creation of a SkeletonViewer.
  131373. */
  131374. export interface ISkeletonViewerOptions {
  131375. /** Should the system pause animations before building the Viewer? */
  131376. pauseAnimations: boolean;
  131377. /** Should the system return the skeleton to rest before building? */
  131378. returnToRest: boolean;
  131379. /** public Display Mode of the Viewer */
  131380. displayMode: number;
  131381. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131382. displayOptions: ISkeletonViewerDisplayOptions;
  131383. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131384. computeBonesUsingShaders: boolean;
  131385. /** Flag ignore non weighted bones */
  131386. useAllBones: boolean;
  131387. }
  131388. /**
  131389. * Defines how to display the various bone meshes for the viewer.
  131390. */
  131391. export interface ISkeletonViewerDisplayOptions {
  131392. /** How far down to start tapering the bone spurs */
  131393. midStep?: number;
  131394. /** How big is the midStep? */
  131395. midStepFactor?: number;
  131396. /** Base for the Sphere Size */
  131397. sphereBaseSize?: number;
  131398. /** The ratio of the sphere to the longest bone in units */
  131399. sphereScaleUnit?: number;
  131400. /** Ratio for the Sphere Size */
  131401. sphereFactor?: number;
  131402. /** Whether to show local axes or not */
  131403. showLocalAxes?: boolean;
  131404. /** Length of each local axis */
  131405. localAxesSize?: number;
  131406. }
  131407. /**
  131408. * Defines the constructor options for the BoneWeight Shader.
  131409. */
  131410. export interface IBoneWeightShaderOptions {
  131411. /** Skeleton to Map */
  131412. skeleton: Skeleton;
  131413. /** Colors for Uninfluenced bones */
  131414. colorBase?: Color3;
  131415. /** Colors for 0.0-0.25 Weight bones */
  131416. colorZero?: Color3;
  131417. /** Color for 0.25-0.5 Weight Influence */
  131418. colorQuarter?: Color3;
  131419. /** Color for 0.5-0.75 Weight Influence */
  131420. colorHalf?: Color3;
  131421. /** Color for 0.75-1 Weight Influence */
  131422. colorFull?: Color3;
  131423. /** Color for Zero Weight Influence */
  131424. targetBoneIndex?: number;
  131425. }
  131426. /**
  131427. * Simple structure of the gradient steps for the Color Map.
  131428. */
  131429. export interface ISkeletonMapShaderColorMapKnot {
  131430. /** Color of the Knot */
  131431. color: Color3;
  131432. /** Location of the Knot */
  131433. location: number;
  131434. }
  131435. /**
  131436. * Defines the constructor options for the SkeletonMap Shader.
  131437. */
  131438. export interface ISkeletonMapShaderOptions {
  131439. /** Skeleton to Map */
  131440. skeleton: Skeleton;
  131441. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131442. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131443. }
  131444. }
  131445. declare module BABYLON {
  131446. /**
  131447. * Class containing static functions to help procedurally build meshes
  131448. */
  131449. export class RibbonBuilder {
  131450. /**
  131451. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131452. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131453. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131454. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131455. * * 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
  131456. * * 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
  131457. * * 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
  131458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131459. * * 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
  131460. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131461. * * 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
  131462. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131463. * * 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
  131464. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131466. * @param name defines the name of the mesh
  131467. * @param options defines the options used to create the mesh
  131468. * @param scene defines the hosting scene
  131469. * @returns the ribbon mesh
  131470. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131471. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131472. */
  131473. static CreateRibbon(name: string, options: {
  131474. pathArray: Vector3[][];
  131475. closeArray?: boolean;
  131476. closePath?: boolean;
  131477. offset?: number;
  131478. updatable?: boolean;
  131479. sideOrientation?: number;
  131480. frontUVs?: Vector4;
  131481. backUVs?: Vector4;
  131482. instance?: Mesh;
  131483. invertUV?: boolean;
  131484. uvs?: Vector2[];
  131485. colors?: Color4[];
  131486. }, scene?: Nullable<Scene>): Mesh;
  131487. }
  131488. }
  131489. declare module BABYLON {
  131490. /**
  131491. * Class containing static functions to help procedurally build meshes
  131492. */
  131493. export class ShapeBuilder {
  131494. /**
  131495. * 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.
  131496. * * 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.
  131497. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131498. * * 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.
  131499. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131500. * * 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
  131501. * * 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
  131502. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131503. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131504. * * 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
  131505. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131507. * @param name defines the name of the mesh
  131508. * @param options defines the options used to create the mesh
  131509. * @param scene defines the hosting scene
  131510. * @returns the extruded shape mesh
  131511. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131512. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131513. */
  131514. static ExtrudeShape(name: string, options: {
  131515. shape: Vector3[];
  131516. path: Vector3[];
  131517. scale?: number;
  131518. rotation?: number;
  131519. cap?: number;
  131520. updatable?: boolean;
  131521. sideOrientation?: number;
  131522. frontUVs?: Vector4;
  131523. backUVs?: Vector4;
  131524. instance?: Mesh;
  131525. invertUV?: boolean;
  131526. }, scene?: Nullable<Scene>): Mesh;
  131527. /**
  131528. * Creates an custom extruded shape mesh.
  131529. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131530. * * 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.
  131531. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131532. * * 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
  131533. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131534. * * 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
  131535. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131536. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131537. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131538. * * 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
  131539. * * 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
  131540. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131542. * * 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
  131543. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131544. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131545. * @param name defines the name of the mesh
  131546. * @param options defines the options used to create the mesh
  131547. * @param scene defines the hosting scene
  131548. * @returns the custom extruded shape mesh
  131549. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131550. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131551. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131552. */
  131553. static ExtrudeShapeCustom(name: string, options: {
  131554. shape: Vector3[];
  131555. path: Vector3[];
  131556. scaleFunction?: any;
  131557. rotationFunction?: any;
  131558. ribbonCloseArray?: boolean;
  131559. ribbonClosePath?: boolean;
  131560. cap?: number;
  131561. updatable?: boolean;
  131562. sideOrientation?: number;
  131563. frontUVs?: Vector4;
  131564. backUVs?: Vector4;
  131565. instance?: Mesh;
  131566. invertUV?: boolean;
  131567. }, scene?: Nullable<Scene>): Mesh;
  131568. private static _ExtrudeShapeGeneric;
  131569. }
  131570. }
  131571. declare module BABYLON.Debug {
  131572. /**
  131573. * Class used to render a debug view of a given skeleton
  131574. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131575. */
  131576. export class SkeletonViewer {
  131577. /** defines the skeleton to render */
  131578. skeleton: Skeleton;
  131579. /** defines the mesh attached to the skeleton */
  131580. mesh: AbstractMesh;
  131581. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131582. autoUpdateBonesMatrices: boolean;
  131583. /** defines the rendering group id to use with the viewer */
  131584. renderingGroupId: number;
  131585. /** is the options for the viewer */
  131586. options: Partial<ISkeletonViewerOptions>;
  131587. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131588. static readonly DISPLAY_LINES: number;
  131589. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131590. static readonly DISPLAY_SPHERES: number;
  131591. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131592. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131593. /** public static method to create a BoneWeight Shader
  131594. * @param options The constructor options
  131595. * @param scene The scene that the shader is scoped to
  131596. * @returns The created ShaderMaterial
  131597. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131598. */
  131599. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131600. /** public static method to create a BoneWeight Shader
  131601. * @param options The constructor options
  131602. * @param scene The scene that the shader is scoped to
  131603. * @returns The created ShaderMaterial
  131604. */
  131605. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131606. /** private static method to create a BoneWeight Shader
  131607. * @param size The size of the buffer to create (usually the bone count)
  131608. * @param colorMap The gradient data to generate
  131609. * @param scene The scene that the shader is scoped to
  131610. * @returns an Array of floats from the color gradient values
  131611. */
  131612. private static _CreateBoneMapColorBuffer;
  131613. /** If SkeletonViewer scene scope. */
  131614. private _scene;
  131615. /** Gets or sets the color used to render the skeleton */
  131616. color: Color3;
  131617. /** Array of the points of the skeleton fo the line view. */
  131618. private _debugLines;
  131619. /** The SkeletonViewers Mesh. */
  131620. private _debugMesh;
  131621. /** The local axes Meshes. */
  131622. private _localAxes;
  131623. /** If SkeletonViewer is enabled. */
  131624. private _isEnabled;
  131625. /** If SkeletonViewer is ready. */
  131626. private _ready;
  131627. /** SkeletonViewer render observable. */
  131628. private _obs;
  131629. /** The Utility Layer to render the gizmos in. */
  131630. private _utilityLayer;
  131631. private _boneIndices;
  131632. /** Gets the Scene. */
  131633. get scene(): Scene;
  131634. /** Gets the utilityLayer. */
  131635. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131636. /** Checks Ready Status. */
  131637. get isReady(): Boolean;
  131638. /** Sets Ready Status. */
  131639. set ready(value: boolean);
  131640. /** Gets the debugMesh */
  131641. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  131642. /** Sets the debugMesh */
  131643. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  131644. /** Gets the displayMode */
  131645. get displayMode(): number;
  131646. /** Sets the displayMode */
  131647. set displayMode(value: number);
  131648. /**
  131649. * Creates a new SkeletonViewer
  131650. * @param skeleton defines the skeleton to render
  131651. * @param mesh defines the mesh attached to the skeleton
  131652. * @param scene defines the hosting scene
  131653. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  131654. * @param renderingGroupId defines the rendering group id to use with the viewer
  131655. * @param options All of the extra constructor options for the SkeletonViewer
  131656. */
  131657. constructor(
  131658. /** defines the skeleton to render */
  131659. skeleton: Skeleton,
  131660. /** defines the mesh attached to the skeleton */
  131661. mesh: AbstractMesh,
  131662. /** The Scene scope*/
  131663. scene: Scene,
  131664. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131665. autoUpdateBonesMatrices?: boolean,
  131666. /** defines the rendering group id to use with the viewer */
  131667. renderingGroupId?: number,
  131668. /** is the options for the viewer */
  131669. options?: Partial<ISkeletonViewerOptions>);
  131670. /** The Dynamic bindings for the update functions */
  131671. private _bindObs;
  131672. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  131673. update(): void;
  131674. /** Gets or sets a boolean indicating if the viewer is enabled */
  131675. set isEnabled(value: boolean);
  131676. get isEnabled(): boolean;
  131677. private _getBonePosition;
  131678. private _getLinesForBonesWithLength;
  131679. private _getLinesForBonesNoLength;
  131680. /** function to revert the mesh and scene back to the initial state. */
  131681. private _revert;
  131682. private getAbsoluteRestPose;
  131683. /** function to build and bind sphere joint points and spur bone representations. */
  131684. private _buildSpheresAndSpurs;
  131685. private _buildLocalAxes;
  131686. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  131687. private _displayLinesUpdate;
  131688. /** Changes the displayMode of the skeleton viewer
  131689. * @param mode The displayMode numerical value
  131690. */
  131691. changeDisplayMode(mode: number): void;
  131692. /** Sets a display option of the skeleton viewer
  131693. *
  131694. * | Option | Type | Default | Description |
  131695. * | --------------- | ------- | ------- | ----------- |
  131696. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  131697. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  131698. *
  131699. * @param option String of the option name
  131700. * @param value The numerical option value
  131701. */
  131702. changeDisplayOptions(option: string, value: number): void;
  131703. /** Release associated resources */
  131704. dispose(): void;
  131705. }
  131706. }
  131707. declare module BABYLON {
  131708. /**
  131709. * Enum for Device Types
  131710. */
  131711. export enum DeviceType {
  131712. /** Generic */
  131713. Generic = 0,
  131714. /** Keyboard */
  131715. Keyboard = 1,
  131716. /** Mouse */
  131717. Mouse = 2,
  131718. /** Touch Pointers */
  131719. Touch = 3,
  131720. /** PS4 Dual Shock */
  131721. DualShock = 4,
  131722. /** Xbox */
  131723. Xbox = 5,
  131724. /** Switch Controller */
  131725. Switch = 6
  131726. }
  131727. /**
  131728. * Enum for All Pointers (Touch/Mouse)
  131729. */
  131730. export enum PointerInput {
  131731. /** Horizontal Axis */
  131732. Horizontal = 0,
  131733. /** Vertical Axis */
  131734. Vertical = 1,
  131735. /** Left Click or Touch */
  131736. LeftClick = 2,
  131737. /** Middle Click */
  131738. MiddleClick = 3,
  131739. /** Right Click */
  131740. RightClick = 4,
  131741. /** Browser Back */
  131742. BrowserBack = 5,
  131743. /** Browser Forward */
  131744. BrowserForward = 6
  131745. }
  131746. /**
  131747. * Enum for Dual Shock Gamepad
  131748. */
  131749. export enum DualShockInput {
  131750. /** Cross */
  131751. Cross = 0,
  131752. /** Circle */
  131753. Circle = 1,
  131754. /** Square */
  131755. Square = 2,
  131756. /** Triangle */
  131757. Triangle = 3,
  131758. /** L1 */
  131759. L1 = 4,
  131760. /** R1 */
  131761. R1 = 5,
  131762. /** L2 */
  131763. L2 = 6,
  131764. /** R2 */
  131765. R2 = 7,
  131766. /** Share */
  131767. Share = 8,
  131768. /** Options */
  131769. Options = 9,
  131770. /** L3 */
  131771. L3 = 10,
  131772. /** R3 */
  131773. R3 = 11,
  131774. /** DPadUp */
  131775. DPadUp = 12,
  131776. /** DPadDown */
  131777. DPadDown = 13,
  131778. /** DPadLeft */
  131779. DPadLeft = 14,
  131780. /** DRight */
  131781. DPadRight = 15,
  131782. /** Home */
  131783. Home = 16,
  131784. /** TouchPad */
  131785. TouchPad = 17,
  131786. /** LStickXAxis */
  131787. LStickXAxis = 18,
  131788. /** LStickYAxis */
  131789. LStickYAxis = 19,
  131790. /** RStickXAxis */
  131791. RStickXAxis = 20,
  131792. /** RStickYAxis */
  131793. RStickYAxis = 21
  131794. }
  131795. /**
  131796. * Enum for Xbox Gamepad
  131797. */
  131798. export enum XboxInput {
  131799. /** A */
  131800. A = 0,
  131801. /** B */
  131802. B = 1,
  131803. /** X */
  131804. X = 2,
  131805. /** Y */
  131806. Y = 3,
  131807. /** LB */
  131808. LB = 4,
  131809. /** RB */
  131810. RB = 5,
  131811. /** LT */
  131812. LT = 6,
  131813. /** RT */
  131814. RT = 7,
  131815. /** Back */
  131816. Back = 8,
  131817. /** Start */
  131818. Start = 9,
  131819. /** LS */
  131820. LS = 10,
  131821. /** RS */
  131822. RS = 11,
  131823. /** DPadUp */
  131824. DPadUp = 12,
  131825. /** DPadDown */
  131826. DPadDown = 13,
  131827. /** DPadLeft */
  131828. DPadLeft = 14,
  131829. /** DRight */
  131830. DPadRight = 15,
  131831. /** Home */
  131832. Home = 16,
  131833. /** LStickXAxis */
  131834. LStickXAxis = 17,
  131835. /** LStickYAxis */
  131836. LStickYAxis = 18,
  131837. /** RStickXAxis */
  131838. RStickXAxis = 19,
  131839. /** RStickYAxis */
  131840. RStickYAxis = 20
  131841. }
  131842. /**
  131843. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  131844. */
  131845. export enum SwitchInput {
  131846. /** B */
  131847. B = 0,
  131848. /** A */
  131849. A = 1,
  131850. /** Y */
  131851. Y = 2,
  131852. /** X */
  131853. X = 3,
  131854. /** L */
  131855. L = 4,
  131856. /** R */
  131857. R = 5,
  131858. /** ZL */
  131859. ZL = 6,
  131860. /** ZR */
  131861. ZR = 7,
  131862. /** Minus */
  131863. Minus = 8,
  131864. /** Plus */
  131865. Plus = 9,
  131866. /** LS */
  131867. LS = 10,
  131868. /** RS */
  131869. RS = 11,
  131870. /** DPadUp */
  131871. DPadUp = 12,
  131872. /** DPadDown */
  131873. DPadDown = 13,
  131874. /** DPadLeft */
  131875. DPadLeft = 14,
  131876. /** DRight */
  131877. DPadRight = 15,
  131878. /** Home */
  131879. Home = 16,
  131880. /** Capture */
  131881. Capture = 17,
  131882. /** LStickXAxis */
  131883. LStickXAxis = 18,
  131884. /** LStickYAxis */
  131885. LStickYAxis = 19,
  131886. /** RStickXAxis */
  131887. RStickXAxis = 20,
  131888. /** RStickYAxis */
  131889. RStickYAxis = 21
  131890. }
  131891. }
  131892. declare module BABYLON {
  131893. /**
  131894. * This class will take all inputs from Keyboard, Pointer, and
  131895. * any Gamepads and provide a polling system that all devices
  131896. * will use. This class assumes that there will only be one
  131897. * pointer device and one keyboard.
  131898. */
  131899. export class DeviceInputSystem implements IDisposable {
  131900. /**
  131901. * Callback to be triggered when a device is connected
  131902. */
  131903. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131904. /**
  131905. * Callback to be triggered when a device is disconnected
  131906. */
  131907. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  131908. /**
  131909. * Callback to be triggered when event driven input is updated
  131910. */
  131911. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  131912. private _inputs;
  131913. private _gamepads;
  131914. private _keyboardActive;
  131915. private _pointerActive;
  131916. private _elementToAttachTo;
  131917. private _keyboardDownEvent;
  131918. private _keyboardUpEvent;
  131919. private _pointerMoveEvent;
  131920. private _pointerDownEvent;
  131921. private _pointerUpEvent;
  131922. private _gamepadConnectedEvent;
  131923. private _gamepadDisconnectedEvent;
  131924. private static _MAX_KEYCODES;
  131925. private static _MAX_POINTER_INPUTS;
  131926. private constructor();
  131927. /**
  131928. * Creates a new DeviceInputSystem instance
  131929. * @param engine Engine to pull input element from
  131930. * @returns The new instance
  131931. */
  131932. static Create(engine: Engine): DeviceInputSystem;
  131933. /**
  131934. * Checks for current device input value, given an id and input index
  131935. * @param deviceName Id of connected device
  131936. * @param inputIndex Index of device input
  131937. * @returns Current value of input
  131938. */
  131939. /**
  131940. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  131941. * @param deviceType Enum specifiying device type
  131942. * @param deviceSlot "Slot" or index that device is referenced in
  131943. * @param inputIndex Id of input to be checked
  131944. * @returns Current value of input
  131945. */
  131946. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  131947. /**
  131948. * Dispose of all the eventlisteners
  131949. */
  131950. dispose(): void;
  131951. /**
  131952. * Add device and inputs to device array
  131953. * @param deviceType Enum specifiying device type
  131954. * @param deviceSlot "Slot" or index that device is referenced in
  131955. * @param numberOfInputs Number of input entries to create for given device
  131956. */
  131957. private _registerDevice;
  131958. /**
  131959. * Given a specific device name, remove that device from the device map
  131960. * @param deviceType Enum specifiying device type
  131961. * @param deviceSlot "Slot" or index that device is referenced in
  131962. */
  131963. private _unregisterDevice;
  131964. /**
  131965. * Handle all actions that come from keyboard interaction
  131966. */
  131967. private _handleKeyActions;
  131968. /**
  131969. * Handle all actions that come from pointer interaction
  131970. */
  131971. private _handlePointerActions;
  131972. /**
  131973. * Handle all actions that come from gamepad interaction
  131974. */
  131975. private _handleGamepadActions;
  131976. /**
  131977. * Update all non-event based devices with each frame
  131978. * @param deviceType Enum specifiying device type
  131979. * @param deviceSlot "Slot" or index that device is referenced in
  131980. * @param inputIndex Id of input to be checked
  131981. */
  131982. private _updateDevice;
  131983. /**
  131984. * Gets DeviceType from the device name
  131985. * @param deviceName Name of Device from DeviceInputSystem
  131986. * @returns DeviceType enum value
  131987. */
  131988. private _getGamepadDeviceType;
  131989. }
  131990. }
  131991. declare module BABYLON {
  131992. /**
  131993. * Type to handle enforcement of inputs
  131994. */
  131995. 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;
  131996. }
  131997. declare module BABYLON {
  131998. /**
  131999. * Class that handles all input for a specific device
  132000. */
  132001. export class DeviceSource<T extends DeviceType> {
  132002. /** Type of device */
  132003. readonly deviceType: DeviceType;
  132004. /** "Slot" or index that device is referenced in */
  132005. readonly deviceSlot: number;
  132006. /**
  132007. * Observable to handle device input changes per device
  132008. */
  132009. readonly onInputChangedObservable: Observable<{
  132010. inputIndex: DeviceInput<T>;
  132011. previousState: Nullable<number>;
  132012. currentState: Nullable<number>;
  132013. }>;
  132014. private readonly _deviceInputSystem;
  132015. /**
  132016. * Default Constructor
  132017. * @param deviceInputSystem Reference to DeviceInputSystem
  132018. * @param deviceType Type of device
  132019. * @param deviceSlot "Slot" or index that device is referenced in
  132020. */
  132021. constructor(deviceInputSystem: DeviceInputSystem,
  132022. /** Type of device */
  132023. deviceType: DeviceType,
  132024. /** "Slot" or index that device is referenced in */
  132025. deviceSlot?: number);
  132026. /**
  132027. * Get input for specific input
  132028. * @param inputIndex index of specific input on device
  132029. * @returns Input value from DeviceInputSystem
  132030. */
  132031. getInput(inputIndex: DeviceInput<T>): number;
  132032. }
  132033. /**
  132034. * Class to keep track of devices
  132035. */
  132036. export class DeviceSourceManager implements IDisposable {
  132037. /**
  132038. * Observable to be triggered when before a device is connected
  132039. */
  132040. readonly onBeforeDeviceConnectedObservable: Observable<{
  132041. deviceType: DeviceType;
  132042. deviceSlot: number;
  132043. }>;
  132044. /**
  132045. * Observable to be triggered when before a device is disconnected
  132046. */
  132047. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132048. deviceType: DeviceType;
  132049. deviceSlot: number;
  132050. }>;
  132051. /**
  132052. * Observable to be triggered when after a device is connected
  132053. */
  132054. readonly onAfterDeviceConnectedObservable: Observable<{
  132055. deviceType: DeviceType;
  132056. deviceSlot: number;
  132057. }>;
  132058. /**
  132059. * Observable to be triggered when after a device is disconnected
  132060. */
  132061. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132062. deviceType: DeviceType;
  132063. deviceSlot: number;
  132064. }>;
  132065. private readonly _devices;
  132066. private readonly _firstDevice;
  132067. private readonly _deviceInputSystem;
  132068. /**
  132069. * Default Constructor
  132070. * @param engine engine to pull input element from
  132071. */
  132072. constructor(engine: Engine);
  132073. /**
  132074. * Gets a DeviceSource, given a type and slot
  132075. * @param deviceType Enum specifying device type
  132076. * @param deviceSlot "Slot" or index that device is referenced in
  132077. * @returns DeviceSource object
  132078. */
  132079. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132080. /**
  132081. * Gets an array of DeviceSource objects for a given device type
  132082. * @param deviceType Enum specifying device type
  132083. * @returns Array of DeviceSource objects
  132084. */
  132085. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132086. /**
  132087. * Dispose of DeviceInputSystem and other parts
  132088. */
  132089. dispose(): void;
  132090. /**
  132091. * Function to add device name to device list
  132092. * @param deviceType Enum specifying device type
  132093. * @param deviceSlot "Slot" or index that device is referenced in
  132094. */
  132095. private _addDevice;
  132096. /**
  132097. * Function to remove device name to device list
  132098. * @param deviceType Enum specifying device type
  132099. * @param deviceSlot "Slot" or index that device is referenced in
  132100. */
  132101. private _removeDevice;
  132102. /**
  132103. * Updates array storing first connected device of each type
  132104. * @param type Type of Device
  132105. */
  132106. private _updateFirstDevices;
  132107. }
  132108. }
  132109. declare module BABYLON {
  132110. /**
  132111. * Options to create the null engine
  132112. */
  132113. export class NullEngineOptions {
  132114. /**
  132115. * Render width (Default: 512)
  132116. */
  132117. renderWidth: number;
  132118. /**
  132119. * Render height (Default: 256)
  132120. */
  132121. renderHeight: number;
  132122. /**
  132123. * Texture size (Default: 512)
  132124. */
  132125. textureSize: number;
  132126. /**
  132127. * If delta time between frames should be constant
  132128. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132129. */
  132130. deterministicLockstep: boolean;
  132131. /**
  132132. * Maximum about of steps between frames (Default: 4)
  132133. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132134. */
  132135. lockstepMaxSteps: number;
  132136. /**
  132137. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132138. */
  132139. useHighPrecisionMatrix?: boolean;
  132140. }
  132141. /**
  132142. * The null engine class provides support for headless version of babylon.js.
  132143. * This can be used in server side scenario or for testing purposes
  132144. */
  132145. export class NullEngine extends Engine {
  132146. private _options;
  132147. /**
  132148. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132149. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132150. * @returns true if engine is in deterministic lock step mode
  132151. */
  132152. isDeterministicLockStep(): boolean;
  132153. /**
  132154. * Gets the max steps when engine is running in deterministic lock step
  132155. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132156. * @returns the max steps
  132157. */
  132158. getLockstepMaxSteps(): number;
  132159. /**
  132160. * Gets the current hardware scaling level.
  132161. * By default the hardware scaling level is computed from the window device ratio.
  132162. * 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.
  132163. * @returns a number indicating the current hardware scaling level
  132164. */
  132165. getHardwareScalingLevel(): number;
  132166. constructor(options?: NullEngineOptions);
  132167. /**
  132168. * Creates a vertex buffer
  132169. * @param vertices the data for the vertex buffer
  132170. * @returns the new WebGL static buffer
  132171. */
  132172. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132173. /**
  132174. * Creates a new index buffer
  132175. * @param indices defines the content of the index buffer
  132176. * @param updatable defines if the index buffer must be updatable
  132177. * @returns a new webGL buffer
  132178. */
  132179. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132180. /**
  132181. * Clear the current render buffer or the current render target (if any is set up)
  132182. * @param color defines the color to use
  132183. * @param backBuffer defines if the back buffer must be cleared
  132184. * @param depth defines if the depth buffer must be cleared
  132185. * @param stencil defines if the stencil buffer must be cleared
  132186. */
  132187. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132188. /**
  132189. * Gets the current render width
  132190. * @param useScreen defines if screen size must be used (or the current render target if any)
  132191. * @returns a number defining the current render width
  132192. */
  132193. getRenderWidth(useScreen?: boolean): number;
  132194. /**
  132195. * Gets the current render height
  132196. * @param useScreen defines if screen size must be used (or the current render target if any)
  132197. * @returns a number defining the current render height
  132198. */
  132199. getRenderHeight(useScreen?: boolean): number;
  132200. /**
  132201. * Set the WebGL's viewport
  132202. * @param viewport defines the viewport element to be used
  132203. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132204. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132205. */
  132206. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132207. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132208. /**
  132209. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132210. * @param pipelineContext defines the pipeline context to use
  132211. * @param uniformsNames defines the list of uniform names
  132212. * @returns an array of webGL uniform locations
  132213. */
  132214. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132215. /**
  132216. * Gets the lsit of active attributes for a given webGL program
  132217. * @param pipelineContext defines the pipeline context to use
  132218. * @param attributesNames defines the list of attribute names to get
  132219. * @returns an array of indices indicating the offset of each attribute
  132220. */
  132221. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132222. /**
  132223. * Binds an effect to the webGL context
  132224. * @param effect defines the effect to bind
  132225. */
  132226. bindSamplers(effect: Effect): void;
  132227. /**
  132228. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132229. * @param effect defines the effect to activate
  132230. */
  132231. enableEffect(effect: Effect): void;
  132232. /**
  132233. * Set various states to the webGL context
  132234. * @param culling defines backface culling state
  132235. * @param zOffset defines the value to apply to zOffset (0 by default)
  132236. * @param force defines if states must be applied even if cache is up to date
  132237. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132238. */
  132239. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132240. /**
  132241. * Set the value of an uniform to an array of int32
  132242. * @param uniform defines the webGL uniform location where to store the value
  132243. * @param array defines the array of int32 to store
  132244. * @returns true if value was set
  132245. */
  132246. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132247. /**
  132248. * Set the value of an uniform to an array of int32 (stored as vec2)
  132249. * @param uniform defines the webGL uniform location where to store the value
  132250. * @param array defines the array of int32 to store
  132251. * @returns true if value was set
  132252. */
  132253. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132254. /**
  132255. * Set the value of an uniform to an array of int32 (stored as vec3)
  132256. * @param uniform defines the webGL uniform location where to store the value
  132257. * @param array defines the array of int32 to store
  132258. * @returns true if value was set
  132259. */
  132260. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132261. /**
  132262. * Set the value of an uniform to an array of int32 (stored as vec4)
  132263. * @param uniform defines the webGL uniform location where to store the value
  132264. * @param array defines the array of int32 to store
  132265. * @returns true if value was set
  132266. */
  132267. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132268. /**
  132269. * Set the value of an uniform to an array of float32
  132270. * @param uniform defines the webGL uniform location where to store the value
  132271. * @param array defines the array of float32 to store
  132272. * @returns true if value was set
  132273. */
  132274. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132275. /**
  132276. * Set the value of an uniform to an array of float32 (stored as vec2)
  132277. * @param uniform defines the webGL uniform location where to store the value
  132278. * @param array defines the array of float32 to store
  132279. * @returns true if value was set
  132280. */
  132281. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132282. /**
  132283. * Set the value of an uniform to an array of float32 (stored as vec3)
  132284. * @param uniform defines the webGL uniform location where to store the value
  132285. * @param array defines the array of float32 to store
  132286. * @returns true if value was set
  132287. */
  132288. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132289. /**
  132290. * Set the value of an uniform to an array of float32 (stored as vec4)
  132291. * @param uniform defines the webGL uniform location where to store the value
  132292. * @param array defines the array of float32 to store
  132293. * @returns true if value was set
  132294. */
  132295. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132296. /**
  132297. * Set the value of an uniform to an array of number
  132298. * @param uniform defines the webGL uniform location where to store the value
  132299. * @param array defines the array of number to store
  132300. * @returns true if value was set
  132301. */
  132302. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132303. /**
  132304. * Set the value of an uniform to an array of number (stored as vec2)
  132305. * @param uniform defines the webGL uniform location where to store the value
  132306. * @param array defines the array of number to store
  132307. * @returns true if value was set
  132308. */
  132309. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132310. /**
  132311. * Set the value of an uniform to an array of number (stored as vec3)
  132312. * @param uniform defines the webGL uniform location where to store the value
  132313. * @param array defines the array of number to store
  132314. * @returns true if value was set
  132315. */
  132316. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132317. /**
  132318. * Set the value of an uniform to an array of number (stored as vec4)
  132319. * @param uniform defines the webGL uniform location where to store the value
  132320. * @param array defines the array of number to store
  132321. * @returns true if value was set
  132322. */
  132323. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132324. /**
  132325. * Set the value of an uniform to an array of float32 (stored as matrices)
  132326. * @param uniform defines the webGL uniform location where to store the value
  132327. * @param matrices defines the array of float32 to store
  132328. * @returns true if value was set
  132329. */
  132330. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132331. /**
  132332. * Set the value of an uniform to a matrix (3x3)
  132333. * @param uniform defines the webGL uniform location where to store the value
  132334. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132335. * @returns true if value was set
  132336. */
  132337. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132338. /**
  132339. * Set the value of an uniform to a matrix (2x2)
  132340. * @param uniform defines the webGL uniform location where to store the value
  132341. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132342. * @returns true if value was set
  132343. */
  132344. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132345. /**
  132346. * Set the value of an uniform to a number (float)
  132347. * @param uniform defines the webGL uniform location where to store the value
  132348. * @param value defines the float number to store
  132349. * @returns true if value was set
  132350. */
  132351. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132352. /**
  132353. * Set the value of an uniform to a vec2
  132354. * @param uniform defines the webGL uniform location where to store the value
  132355. * @param x defines the 1st component of the value
  132356. * @param y defines the 2nd component of the value
  132357. * @returns true if value was set
  132358. */
  132359. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132360. /**
  132361. * Set the value of an uniform to a vec3
  132362. * @param uniform defines the webGL uniform location where to store the value
  132363. * @param x defines the 1st component of the value
  132364. * @param y defines the 2nd component of the value
  132365. * @param z defines the 3rd component of the value
  132366. * @returns true if value was set
  132367. */
  132368. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132369. /**
  132370. * Set the value of an uniform to a boolean
  132371. * @param uniform defines the webGL uniform location where to store the value
  132372. * @param bool defines the boolean to store
  132373. * @returns true if value was set
  132374. */
  132375. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132376. /**
  132377. * Set the value of an uniform to a vec4
  132378. * @param uniform defines the webGL uniform location where to store the value
  132379. * @param x defines the 1st component of the value
  132380. * @param y defines the 2nd component of the value
  132381. * @param z defines the 3rd component of the value
  132382. * @param w defines the 4th component of the value
  132383. * @returns true if value was set
  132384. */
  132385. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132386. /**
  132387. * Sets the current alpha mode
  132388. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132389. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132390. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132391. */
  132392. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132393. /**
  132394. * Bind webGl buffers directly to the webGL context
  132395. * @param vertexBuffers defines the vertex buffer to bind
  132396. * @param indexBuffer defines the index buffer to bind
  132397. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132398. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132399. * @param effect defines the effect associated with the vertex buffer
  132400. */
  132401. bindBuffers(vertexBuffers: {
  132402. [key: string]: VertexBuffer;
  132403. }, indexBuffer: DataBuffer, effect: Effect): void;
  132404. /**
  132405. * Force the entire cache to be cleared
  132406. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132407. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132408. */
  132409. wipeCaches(bruteForce?: boolean): void;
  132410. /**
  132411. * Send a draw order
  132412. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132413. * @param indexStart defines the starting index
  132414. * @param indexCount defines the number of index to draw
  132415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132416. */
  132417. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132418. /**
  132419. * Draw a list of indexed primitives
  132420. * @param fillMode defines the primitive to use
  132421. * @param indexStart defines the starting index
  132422. * @param indexCount defines the number of index to draw
  132423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132424. */
  132425. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132426. /**
  132427. * Draw a list of unindexed primitives
  132428. * @param fillMode defines the primitive to use
  132429. * @param verticesStart defines the index of first vertex to draw
  132430. * @param verticesCount defines the count of vertices to draw
  132431. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132432. */
  132433. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132434. /** @hidden */
  132435. _createTexture(): WebGLTexture;
  132436. /** @hidden */
  132437. _releaseTexture(texture: InternalTexture): void;
  132438. /**
  132439. * Usually called from Texture.ts.
  132440. * Passed information to create a WebGLTexture
  132441. * @param urlArg defines a value which contains one of the following:
  132442. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132443. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132444. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132445. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132446. * @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)
  132447. * @param scene needed for loading to the correct scene
  132448. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132449. * @param onLoad optional callback to be called upon successful completion
  132450. * @param onError optional callback to be called upon failure
  132451. * @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
  132452. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132453. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132454. * @param forcedExtension defines the extension to use to pick the right loader
  132455. * @param mimeType defines an optional mime type
  132456. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132457. */
  132458. 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;
  132459. /**
  132460. * Creates a new render target texture
  132461. * @param size defines the size of the texture
  132462. * @param options defines the options used to create the texture
  132463. * @returns a new render target texture stored in an InternalTexture
  132464. */
  132465. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132466. /**
  132467. * Update the sampling mode of a given texture
  132468. * @param samplingMode defines the required sampling mode
  132469. * @param texture defines the texture to update
  132470. */
  132471. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132472. /**
  132473. * Binds the frame buffer to the specified texture.
  132474. * @param texture The texture to render to or null for the default canvas
  132475. * @param faceIndex The face of the texture to render to in case of cube texture
  132476. * @param requiredWidth The width of the target to render to
  132477. * @param requiredHeight The height of the target to render to
  132478. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132479. * @param lodLevel defines le lod level to bind to the frame buffer
  132480. */
  132481. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132482. /**
  132483. * Unbind the current render target texture from the webGL context
  132484. * @param texture defines the render target texture to unbind
  132485. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132486. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132487. */
  132488. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132489. /**
  132490. * Creates a dynamic vertex buffer
  132491. * @param vertices the data for the dynamic vertex buffer
  132492. * @returns the new WebGL dynamic buffer
  132493. */
  132494. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132495. /**
  132496. * Update the content of a dynamic texture
  132497. * @param texture defines the texture to update
  132498. * @param canvas defines the canvas containing the source
  132499. * @param invertY defines if data must be stored with Y axis inverted
  132500. * @param premulAlpha defines if alpha is stored as premultiplied
  132501. * @param format defines the format of the data
  132502. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132503. */
  132504. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132505. /**
  132506. * Gets a boolean indicating if all created effects are ready
  132507. * @returns true if all effects are ready
  132508. */
  132509. areAllEffectsReady(): boolean;
  132510. /**
  132511. * @hidden
  132512. * Get the current error code of the webGL context
  132513. * @returns the error code
  132514. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132515. */
  132516. getError(): number;
  132517. /** @hidden */
  132518. _getUnpackAlignement(): number;
  132519. /** @hidden */
  132520. _unpackFlipY(value: boolean): void;
  132521. /**
  132522. * Update a dynamic index buffer
  132523. * @param indexBuffer defines the target index buffer
  132524. * @param indices defines the data to update
  132525. * @param offset defines the offset in the target index buffer where update should start
  132526. */
  132527. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132528. /**
  132529. * Updates a dynamic vertex buffer.
  132530. * @param vertexBuffer the vertex buffer to update
  132531. * @param vertices the data used to update the vertex buffer
  132532. * @param byteOffset the byte offset of the data (optional)
  132533. * @param byteLength the byte length of the data (optional)
  132534. */
  132535. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132536. /** @hidden */
  132537. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132538. /** @hidden */
  132539. _bindTexture(channel: number, texture: InternalTexture): void;
  132540. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132541. /**
  132542. * 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
  132543. */
  132544. releaseEffects(): void;
  132545. displayLoadingUI(): void;
  132546. hideLoadingUI(): void;
  132547. /** @hidden */
  132548. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132549. /** @hidden */
  132550. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132551. /** @hidden */
  132552. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132553. /** @hidden */
  132554. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132555. }
  132556. }
  132557. declare module BABYLON {
  132558. /**
  132559. * @hidden
  132560. **/
  132561. export class _TimeToken {
  132562. _startTimeQuery: Nullable<WebGLQuery>;
  132563. _endTimeQuery: Nullable<WebGLQuery>;
  132564. _timeElapsedQuery: Nullable<WebGLQuery>;
  132565. _timeElapsedQueryEnded: boolean;
  132566. }
  132567. }
  132568. declare module BABYLON {
  132569. /** @hidden */
  132570. export class _OcclusionDataStorage {
  132571. /** @hidden */
  132572. occlusionInternalRetryCounter: number;
  132573. /** @hidden */
  132574. isOcclusionQueryInProgress: boolean;
  132575. /** @hidden */
  132576. isOccluded: boolean;
  132577. /** @hidden */
  132578. occlusionRetryCount: number;
  132579. /** @hidden */
  132580. occlusionType: number;
  132581. /** @hidden */
  132582. occlusionQueryAlgorithmType: number;
  132583. }
  132584. interface Engine {
  132585. /**
  132586. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132587. * @return the new query
  132588. */
  132589. createQuery(): WebGLQuery;
  132590. /**
  132591. * Delete and release a webGL query
  132592. * @param query defines the query to delete
  132593. * @return the current engine
  132594. */
  132595. deleteQuery(query: WebGLQuery): Engine;
  132596. /**
  132597. * Check if a given query has resolved and got its value
  132598. * @param query defines the query to check
  132599. * @returns true if the query got its value
  132600. */
  132601. isQueryResultAvailable(query: WebGLQuery): boolean;
  132602. /**
  132603. * Gets the value of a given query
  132604. * @param query defines the query to check
  132605. * @returns the value of the query
  132606. */
  132607. getQueryResult(query: WebGLQuery): number;
  132608. /**
  132609. * Initiates an occlusion query
  132610. * @param algorithmType defines the algorithm to use
  132611. * @param query defines the query to use
  132612. * @returns the current engine
  132613. * @see https://doc.babylonjs.com/features/occlusionquery
  132614. */
  132615. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132616. /**
  132617. * Ends an occlusion query
  132618. * @see https://doc.babylonjs.com/features/occlusionquery
  132619. * @param algorithmType defines the algorithm to use
  132620. * @returns the current engine
  132621. */
  132622. endOcclusionQuery(algorithmType: number): Engine;
  132623. /**
  132624. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132625. * Please note that only one query can be issued at a time
  132626. * @returns a time token used to track the time span
  132627. */
  132628. startTimeQuery(): Nullable<_TimeToken>;
  132629. /**
  132630. * Ends a time query
  132631. * @param token defines the token used to measure the time span
  132632. * @returns the time spent (in ns)
  132633. */
  132634. endTimeQuery(token: _TimeToken): int;
  132635. /** @hidden */
  132636. _currentNonTimestampToken: Nullable<_TimeToken>;
  132637. /** @hidden */
  132638. _createTimeQuery(): WebGLQuery;
  132639. /** @hidden */
  132640. _deleteTimeQuery(query: WebGLQuery): void;
  132641. /** @hidden */
  132642. _getGlAlgorithmType(algorithmType: number): number;
  132643. /** @hidden */
  132644. _getTimeQueryResult(query: WebGLQuery): any;
  132645. /** @hidden */
  132646. _getTimeQueryAvailability(query: WebGLQuery): any;
  132647. }
  132648. interface AbstractMesh {
  132649. /**
  132650. * Backing filed
  132651. * @hidden
  132652. */
  132653. __occlusionDataStorage: _OcclusionDataStorage;
  132654. /**
  132655. * Access property
  132656. * @hidden
  132657. */
  132658. _occlusionDataStorage: _OcclusionDataStorage;
  132659. /**
  132660. * 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.
  132661. * The default value is -1 which means don't break the query and wait till the result
  132662. * @see https://doc.babylonjs.com/features/occlusionquery
  132663. */
  132664. occlusionRetryCount: number;
  132665. /**
  132666. * 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:
  132667. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  132668. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  132669. * * 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.
  132670. * @see https://doc.babylonjs.com/features/occlusionquery
  132671. */
  132672. occlusionType: number;
  132673. /**
  132674. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  132675. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  132676. * * 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.
  132677. * @see https://doc.babylonjs.com/features/occlusionquery
  132678. */
  132679. occlusionQueryAlgorithmType: number;
  132680. /**
  132681. * 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
  132682. * @see https://doc.babylonjs.com/features/occlusionquery
  132683. */
  132684. isOccluded: boolean;
  132685. /**
  132686. * Flag to check the progress status of the query
  132687. * @see https://doc.babylonjs.com/features/occlusionquery
  132688. */
  132689. isOcclusionQueryInProgress: boolean;
  132690. }
  132691. }
  132692. declare module BABYLON {
  132693. /** @hidden */
  132694. export var _forceTransformFeedbackToBundle: boolean;
  132695. interface Engine {
  132696. /**
  132697. * Creates a webGL transform feedback object
  132698. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  132699. * @returns the webGL transform feedback object
  132700. */
  132701. createTransformFeedback(): WebGLTransformFeedback;
  132702. /**
  132703. * Delete a webGL transform feedback object
  132704. * @param value defines the webGL transform feedback object to delete
  132705. */
  132706. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  132707. /**
  132708. * Bind a webGL transform feedback object to the webgl context
  132709. * @param value defines the webGL transform feedback object to bind
  132710. */
  132711. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  132712. /**
  132713. * Begins a transform feedback operation
  132714. * @param usePoints defines if points or triangles must be used
  132715. */
  132716. beginTransformFeedback(usePoints: boolean): void;
  132717. /**
  132718. * Ends a transform feedback operation
  132719. */
  132720. endTransformFeedback(): void;
  132721. /**
  132722. * Specify the varyings to use with transform feedback
  132723. * @param program defines the associated webGL program
  132724. * @param value defines the list of strings representing the varying names
  132725. */
  132726. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  132727. /**
  132728. * Bind a webGL buffer for a transform feedback operation
  132729. * @param value defines the webGL buffer to bind
  132730. */
  132731. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  132732. }
  132733. }
  132734. declare module BABYLON {
  132735. /**
  132736. * Class used to define an additional view for the engine
  132737. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132738. */
  132739. export class EngineView {
  132740. /** Defines the canvas where to render the view */
  132741. target: HTMLCanvasElement;
  132742. /** Defines an optional camera used to render the view (will use active camera else) */
  132743. camera?: Camera;
  132744. }
  132745. interface Engine {
  132746. /**
  132747. * Gets or sets the HTML element to use for attaching events
  132748. */
  132749. inputElement: Nullable<HTMLElement>;
  132750. /**
  132751. * Gets the current engine view
  132752. * @see https://doc.babylonjs.com/how_to/multi_canvases
  132753. */
  132754. activeView: Nullable<EngineView>;
  132755. /** Gets or sets the list of views */
  132756. views: EngineView[];
  132757. /**
  132758. * Register a new child canvas
  132759. * @param canvas defines the canvas to register
  132760. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  132761. * @returns the associated view
  132762. */
  132763. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  132764. /**
  132765. * Remove a registered child canvas
  132766. * @param canvas defines the canvas to remove
  132767. * @returns the current engine
  132768. */
  132769. unRegisterView(canvas: HTMLCanvasElement): Engine;
  132770. }
  132771. }
  132772. declare module BABYLON {
  132773. interface Engine {
  132774. /** @hidden */
  132775. _excludedCompressedTextures: string[];
  132776. /** @hidden */
  132777. _textureFormatInUse: string;
  132778. /**
  132779. * Gets the list of texture formats supported
  132780. */
  132781. readonly texturesSupported: Array<string>;
  132782. /**
  132783. * Gets the texture format in use
  132784. */
  132785. readonly textureFormatInUse: Nullable<string>;
  132786. /**
  132787. * Set the compressed texture extensions or file names to skip.
  132788. *
  132789. * @param skippedFiles defines the list of those texture files you want to skip
  132790. * Example: [".dds", ".env", "myfile.png"]
  132791. */
  132792. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  132793. /**
  132794. * Set the compressed texture format to use, based on the formats you have, and the formats
  132795. * supported by the hardware / browser.
  132796. *
  132797. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  132798. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  132799. * to API arguments needed to compressed textures. This puts the burden on the container
  132800. * generator to house the arcane code for determining these for current & future formats.
  132801. *
  132802. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  132803. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  132804. *
  132805. * Note: The result of this call is not taken into account when a texture is base64.
  132806. *
  132807. * @param formatsAvailable defines the list of those format families you have created
  132808. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  132809. *
  132810. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  132811. * @returns The extension selected.
  132812. */
  132813. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  132814. }
  132815. }
  132816. declare module BABYLON {
  132817. /**
  132818. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  132819. */
  132820. export interface CubeMapInfo {
  132821. /**
  132822. * The pixel array for the front face.
  132823. * This is stored in format, left to right, up to down format.
  132824. */
  132825. front: Nullable<ArrayBufferView>;
  132826. /**
  132827. * The pixel array for the back face.
  132828. * This is stored in format, left to right, up to down format.
  132829. */
  132830. back: Nullable<ArrayBufferView>;
  132831. /**
  132832. * The pixel array for the left face.
  132833. * This is stored in format, left to right, up to down format.
  132834. */
  132835. left: Nullable<ArrayBufferView>;
  132836. /**
  132837. * The pixel array for the right face.
  132838. * This is stored in format, left to right, up to down format.
  132839. */
  132840. right: Nullable<ArrayBufferView>;
  132841. /**
  132842. * The pixel array for the up face.
  132843. * This is stored in format, left to right, up to down format.
  132844. */
  132845. up: Nullable<ArrayBufferView>;
  132846. /**
  132847. * The pixel array for the down face.
  132848. * This is stored in format, left to right, up to down format.
  132849. */
  132850. down: Nullable<ArrayBufferView>;
  132851. /**
  132852. * The size of the cubemap stored.
  132853. *
  132854. * Each faces will be size * size pixels.
  132855. */
  132856. size: number;
  132857. /**
  132858. * The format of the texture.
  132859. *
  132860. * RGBA, RGB.
  132861. */
  132862. format: number;
  132863. /**
  132864. * The type of the texture data.
  132865. *
  132866. * UNSIGNED_INT, FLOAT.
  132867. */
  132868. type: number;
  132869. /**
  132870. * Specifies whether the texture is in gamma space.
  132871. */
  132872. gammaSpace: boolean;
  132873. }
  132874. /**
  132875. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  132876. */
  132877. export class PanoramaToCubeMapTools {
  132878. private static FACE_LEFT;
  132879. private static FACE_RIGHT;
  132880. private static FACE_FRONT;
  132881. private static FACE_BACK;
  132882. private static FACE_DOWN;
  132883. private static FACE_UP;
  132884. /**
  132885. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  132886. *
  132887. * @param float32Array The source data.
  132888. * @param inputWidth The width of the input panorama.
  132889. * @param inputHeight The height of the input panorama.
  132890. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  132891. * @return The cubemap data
  132892. */
  132893. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  132894. private static CreateCubemapTexture;
  132895. private static CalcProjectionSpherical;
  132896. }
  132897. }
  132898. declare module BABYLON {
  132899. /**
  132900. * Helper class dealing with the extraction of spherical polynomial dataArray
  132901. * from a cube map.
  132902. */
  132903. export class CubeMapToSphericalPolynomialTools {
  132904. private static FileFaces;
  132905. /**
  132906. * Converts a texture to the according Spherical Polynomial data.
  132907. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132908. *
  132909. * @param texture The texture to extract the information from.
  132910. * @return The Spherical Polynomial data.
  132911. */
  132912. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  132913. /**
  132914. * Converts a cubemap to the according Spherical Polynomial data.
  132915. * This extracts the first 3 orders only as they are the only one used in the lighting.
  132916. *
  132917. * @param cubeInfo The Cube map to extract the information from.
  132918. * @return The Spherical Polynomial data.
  132919. */
  132920. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  132921. }
  132922. }
  132923. declare module BABYLON {
  132924. interface BaseTexture {
  132925. /**
  132926. * Get the polynomial representation of the texture data.
  132927. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  132928. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  132929. */
  132930. sphericalPolynomial: Nullable<SphericalPolynomial>;
  132931. }
  132932. }
  132933. declare module BABYLON {
  132934. /** @hidden */
  132935. export var rgbdEncodePixelShader: {
  132936. name: string;
  132937. shader: string;
  132938. };
  132939. }
  132940. declare module BABYLON {
  132941. /** @hidden */
  132942. export var rgbdDecodePixelShader: {
  132943. name: string;
  132944. shader: string;
  132945. };
  132946. }
  132947. declare module BABYLON {
  132948. /**
  132949. * Raw texture data and descriptor sufficient for WebGL texture upload
  132950. */
  132951. export interface EnvironmentTextureInfo {
  132952. /**
  132953. * Version of the environment map
  132954. */
  132955. version: number;
  132956. /**
  132957. * Width of image
  132958. */
  132959. width: number;
  132960. /**
  132961. * Irradiance information stored in the file.
  132962. */
  132963. irradiance: any;
  132964. /**
  132965. * Specular information stored in the file.
  132966. */
  132967. specular: any;
  132968. }
  132969. /**
  132970. * Defines One Image in the file. It requires only the position in the file
  132971. * as well as the length.
  132972. */
  132973. interface BufferImageData {
  132974. /**
  132975. * Length of the image data.
  132976. */
  132977. length: number;
  132978. /**
  132979. * Position of the data from the null terminator delimiting the end of the JSON.
  132980. */
  132981. position: number;
  132982. }
  132983. /**
  132984. * Defines the specular data enclosed in the file.
  132985. * This corresponds to the version 1 of the data.
  132986. */
  132987. export interface EnvironmentTextureSpecularInfoV1 {
  132988. /**
  132989. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  132990. */
  132991. specularDataPosition?: number;
  132992. /**
  132993. * This contains all the images data needed to reconstruct the cubemap.
  132994. */
  132995. mipmaps: Array<BufferImageData>;
  132996. /**
  132997. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  132998. */
  132999. lodGenerationScale: number;
  133000. }
  133001. /**
  133002. * Sets of helpers addressing the serialization and deserialization of environment texture
  133003. * stored in a BabylonJS env file.
  133004. * Those files are usually stored as .env files.
  133005. */
  133006. export class EnvironmentTextureTools {
  133007. /**
  133008. * Magic number identifying the env file.
  133009. */
  133010. private static _MagicBytes;
  133011. /**
  133012. * Gets the environment info from an env file.
  133013. * @param data The array buffer containing the .env bytes.
  133014. * @returns the environment file info (the json header) if successfully parsed.
  133015. */
  133016. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133017. /**
  133018. * Creates an environment texture from a loaded cube texture.
  133019. * @param texture defines the cube texture to convert in env file
  133020. * @return a promise containing the environment data if succesfull.
  133021. */
  133022. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133023. /**
  133024. * Creates a JSON representation of the spherical data.
  133025. * @param texture defines the texture containing the polynomials
  133026. * @return the JSON representation of the spherical info
  133027. */
  133028. private static _CreateEnvTextureIrradiance;
  133029. /**
  133030. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133031. * @param data the image data
  133032. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133033. * @return the views described by info providing access to the underlying buffer
  133034. */
  133035. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133036. /**
  133037. * Uploads the texture info contained in the env file to the GPU.
  133038. * @param texture defines the internal texture to upload to
  133039. * @param data defines the data to load
  133040. * @param info defines the texture info retrieved through the GetEnvInfo method
  133041. * @returns a promise
  133042. */
  133043. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133044. private static _OnImageReadyAsync;
  133045. /**
  133046. * Uploads the levels of image data to the GPU.
  133047. * @param texture defines the internal texture to upload to
  133048. * @param imageData defines the array buffer views of image data [mipmap][face]
  133049. * @returns a promise
  133050. */
  133051. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133052. /**
  133053. * Uploads spherical polynomials information to the texture.
  133054. * @param texture defines the texture we are trying to upload the information to
  133055. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133056. */
  133057. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133058. /** @hidden */
  133059. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133060. }
  133061. }
  133062. declare module BABYLON {
  133063. /**
  133064. * Class used to inline functions in shader code
  133065. */
  133066. export class ShaderCodeInliner {
  133067. private static readonly _RegexpFindFunctionNameAndType;
  133068. private _sourceCode;
  133069. private _functionDescr;
  133070. private _numMaxIterations;
  133071. /** Gets or sets the token used to mark the functions to inline */
  133072. inlineToken: string;
  133073. /** Gets or sets the debug mode */
  133074. debug: boolean;
  133075. /** Gets the code after the inlining process */
  133076. get code(): string;
  133077. /**
  133078. * Initializes the inliner
  133079. * @param sourceCode shader code source to inline
  133080. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133081. */
  133082. constructor(sourceCode: string, numMaxIterations?: number);
  133083. /**
  133084. * Start the processing of the shader code
  133085. */
  133086. processCode(): void;
  133087. private _collectFunctions;
  133088. private _processInlining;
  133089. private _extractBetweenMarkers;
  133090. private _skipWhitespaces;
  133091. private _removeComments;
  133092. private _replaceFunctionCallsByCode;
  133093. private _findBackward;
  133094. private _escapeRegExp;
  133095. private _replaceNames;
  133096. }
  133097. }
  133098. declare module BABYLON {
  133099. /**
  133100. * Container for accessors for natively-stored mesh data buffers.
  133101. */
  133102. class NativeDataBuffer extends DataBuffer {
  133103. /**
  133104. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133105. */
  133106. nativeIndexBuffer?: any;
  133107. /**
  133108. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133109. */
  133110. nativeVertexBuffer?: any;
  133111. }
  133112. /** @hidden */
  133113. class NativeTexture extends InternalTexture {
  133114. getInternalTexture(): InternalTexture;
  133115. getViewCount(): number;
  133116. }
  133117. /** @hidden */
  133118. export class NativeEngine extends Engine {
  133119. private readonly _native;
  133120. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133121. private readonly INVALID_HANDLE;
  133122. private _boundBuffersVertexArray;
  133123. getHardwareScalingLevel(): number;
  133124. constructor();
  133125. dispose(): void;
  133126. /**
  133127. * Can be used to override the current requestAnimationFrame requester.
  133128. * @hidden
  133129. */
  133130. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133131. /**
  133132. * Override default engine behavior.
  133133. * @param color
  133134. * @param backBuffer
  133135. * @param depth
  133136. * @param stencil
  133137. */
  133138. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133139. /**
  133140. * Gets host document
  133141. * @returns the host document object
  133142. */
  133143. getHostDocument(): Nullable<Document>;
  133144. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133145. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133146. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133147. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133148. [key: string]: VertexBuffer;
  133149. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133150. bindBuffers(vertexBuffers: {
  133151. [key: string]: VertexBuffer;
  133152. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133153. recordVertexArrayObject(vertexBuffers: {
  133154. [key: string]: VertexBuffer;
  133155. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133156. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133157. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133158. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133159. /**
  133160. * Draw a list of indexed primitives
  133161. * @param fillMode defines the primitive to use
  133162. * @param indexStart defines the starting index
  133163. * @param indexCount defines the number of index to draw
  133164. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133165. */
  133166. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133167. /**
  133168. * Draw a list of unindexed primitives
  133169. * @param fillMode defines the primitive to use
  133170. * @param verticesStart defines the index of first vertex to draw
  133171. * @param verticesCount defines the count of vertices to draw
  133172. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133173. */
  133174. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133175. createPipelineContext(): IPipelineContext;
  133176. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133177. /** @hidden */
  133178. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133179. /** @hidden */
  133180. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133181. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133182. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133183. protected _setProgram(program: WebGLProgram): void;
  133184. _releaseEffect(effect: Effect): void;
  133185. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133186. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133187. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133188. bindSamplers(effect: Effect): void;
  133189. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133190. getRenderWidth(useScreen?: boolean): number;
  133191. getRenderHeight(useScreen?: boolean): number;
  133192. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133193. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133194. /**
  133195. * Set the z offset to apply to current rendering
  133196. * @param value defines the offset to apply
  133197. */
  133198. setZOffset(value: number): void;
  133199. /**
  133200. * Gets the current value of the zOffset
  133201. * @returns the current zOffset state
  133202. */
  133203. getZOffset(): number;
  133204. /**
  133205. * Enable or disable depth buffering
  133206. * @param enable defines the state to set
  133207. */
  133208. setDepthBuffer(enable: boolean): void;
  133209. /**
  133210. * Gets a boolean indicating if depth writing is enabled
  133211. * @returns the current depth writing state
  133212. */
  133213. getDepthWrite(): boolean;
  133214. /**
  133215. * Enable or disable depth writing
  133216. * @param enable defines the state to set
  133217. */
  133218. setDepthWrite(enable: boolean): void;
  133219. /**
  133220. * Enable or disable color writing
  133221. * @param enable defines the state to set
  133222. */
  133223. setColorWrite(enable: boolean): void;
  133224. /**
  133225. * Gets a boolean indicating if color writing is enabled
  133226. * @returns the current color writing state
  133227. */
  133228. getColorWrite(): boolean;
  133229. /**
  133230. * Sets alpha constants used by some alpha blending modes
  133231. * @param r defines the red component
  133232. * @param g defines the green component
  133233. * @param b defines the blue component
  133234. * @param a defines the alpha component
  133235. */
  133236. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133237. /**
  133238. * Sets the current alpha mode
  133239. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133240. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133241. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133242. */
  133243. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133244. /**
  133245. * Gets the current alpha mode
  133246. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133247. * @returns the current alpha mode
  133248. */
  133249. getAlphaMode(): number;
  133250. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133251. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133252. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133253. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133254. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133255. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133256. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133257. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133258. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133259. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133260. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133261. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133262. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133263. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133264. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133265. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133266. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133267. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133268. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133269. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133270. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133271. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133272. wipeCaches(bruteForce?: boolean): void;
  133273. _createTexture(): WebGLTexture;
  133274. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133275. /**
  133276. * Usually called from Texture.ts.
  133277. * Passed information to create a WebGLTexture
  133278. * @param url defines a value which contains one of the following:
  133279. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133280. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133281. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133282. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133283. * @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)
  133284. * @param scene needed for loading to the correct scene
  133285. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133286. * @param onLoad optional callback to be called upon successful completion
  133287. * @param onError optional callback to be called upon failure
  133288. * @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
  133289. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133290. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133291. * @param forcedExtension defines the extension to use to pick the right loader
  133292. * @param mimeType defines an optional mime type
  133293. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133294. */
  133295. 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;
  133296. /**
  133297. * Creates a cube texture
  133298. * @param rootUrl defines the url where the files to load is located
  133299. * @param scene defines the current scene
  133300. * @param files defines the list of files to load (1 per face)
  133301. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133302. * @param onLoad defines an optional callback raised when the texture is loaded
  133303. * @param onError defines an optional callback raised if there is an issue to load the texture
  133304. * @param format defines the format of the data
  133305. * @param forcedExtension defines the extension to use to pick the right loader
  133306. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133307. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133308. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133309. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133310. * @returns the cube texture as an InternalTexture
  133311. */
  133312. 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;
  133313. private _getSamplingFilter;
  133314. private static _GetNativeTextureFormat;
  133315. createRenderTargetTexture(size: number | {
  133316. width: number;
  133317. height: number;
  133318. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133319. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133320. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133321. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133322. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133323. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133324. /**
  133325. * Updates a dynamic vertex buffer.
  133326. * @param vertexBuffer the vertex buffer to update
  133327. * @param data the data used to update the vertex buffer
  133328. * @param byteOffset the byte offset of the data (optional)
  133329. * @param byteLength the byte length of the data (optional)
  133330. */
  133331. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133332. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133333. private _updateAnisotropicLevel;
  133334. private _getAddressMode;
  133335. /** @hidden */
  133336. _bindTexture(channel: number, texture: InternalTexture): void;
  133337. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133338. releaseEffects(): void;
  133339. /** @hidden */
  133340. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133341. /** @hidden */
  133342. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133343. /** @hidden */
  133344. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133345. /** @hidden */
  133346. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133347. }
  133348. }
  133349. declare module BABYLON {
  133350. /**
  133351. * Gather the list of clipboard event types as constants.
  133352. */
  133353. export class ClipboardEventTypes {
  133354. /**
  133355. * The clipboard event is fired when a copy command is active (pressed).
  133356. */
  133357. static readonly COPY: number;
  133358. /**
  133359. * The clipboard event is fired when a cut command is active (pressed).
  133360. */
  133361. static readonly CUT: number;
  133362. /**
  133363. * The clipboard event is fired when a paste command is active (pressed).
  133364. */
  133365. static readonly PASTE: number;
  133366. }
  133367. /**
  133368. * This class is used to store clipboard related info for the onClipboardObservable event.
  133369. */
  133370. export class ClipboardInfo {
  133371. /**
  133372. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133373. */
  133374. type: number;
  133375. /**
  133376. * Defines the related dom event
  133377. */
  133378. event: ClipboardEvent;
  133379. /**
  133380. *Creates an instance of ClipboardInfo.
  133381. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133382. * @param event Defines the related dom event
  133383. */
  133384. constructor(
  133385. /**
  133386. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133387. */
  133388. type: number,
  133389. /**
  133390. * Defines the related dom event
  133391. */
  133392. event: ClipboardEvent);
  133393. /**
  133394. * Get the clipboard event's type from the keycode.
  133395. * @param keyCode Defines the keyCode for the current keyboard event.
  133396. * @return {number}
  133397. */
  133398. static GetTypeFromCharacter(keyCode: number): number;
  133399. }
  133400. }
  133401. declare module BABYLON {
  133402. /**
  133403. * Google Daydream controller
  133404. */
  133405. export class DaydreamController extends WebVRController {
  133406. /**
  133407. * Base Url for the controller model.
  133408. */
  133409. static MODEL_BASE_URL: string;
  133410. /**
  133411. * File name for the controller model.
  133412. */
  133413. static MODEL_FILENAME: string;
  133414. /**
  133415. * Gamepad Id prefix used to identify Daydream Controller.
  133416. */
  133417. static readonly GAMEPAD_ID_PREFIX: string;
  133418. /**
  133419. * Creates a new DaydreamController from a gamepad
  133420. * @param vrGamepad the gamepad that the controller should be created from
  133421. */
  133422. constructor(vrGamepad: any);
  133423. /**
  133424. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133425. * @param scene scene in which to add meshes
  133426. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133427. */
  133428. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133429. /**
  133430. * Called once for each button that changed state since the last frame
  133431. * @param buttonIdx Which button index changed
  133432. * @param state New state of the button
  133433. * @param changes Which properties on the state changed since last frame
  133434. */
  133435. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133436. }
  133437. }
  133438. declare module BABYLON {
  133439. /**
  133440. * Gear VR Controller
  133441. */
  133442. export class GearVRController extends WebVRController {
  133443. /**
  133444. * Base Url for the controller model.
  133445. */
  133446. static MODEL_BASE_URL: string;
  133447. /**
  133448. * File name for the controller model.
  133449. */
  133450. static MODEL_FILENAME: string;
  133451. /**
  133452. * Gamepad Id prefix used to identify this controller.
  133453. */
  133454. static readonly GAMEPAD_ID_PREFIX: string;
  133455. private readonly _buttonIndexToObservableNameMap;
  133456. /**
  133457. * Creates a new GearVRController from a gamepad
  133458. * @param vrGamepad the gamepad that the controller should be created from
  133459. */
  133460. constructor(vrGamepad: any);
  133461. /**
  133462. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133463. * @param scene scene in which to add meshes
  133464. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133465. */
  133466. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133467. /**
  133468. * Called once for each button that changed state since the last frame
  133469. * @param buttonIdx Which button index changed
  133470. * @param state New state of the button
  133471. * @param changes Which properties on the state changed since last frame
  133472. */
  133473. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133474. }
  133475. }
  133476. declare module BABYLON {
  133477. /**
  133478. * Generic Controller
  133479. */
  133480. export class GenericController extends WebVRController {
  133481. /**
  133482. * Base Url for the controller model.
  133483. */
  133484. static readonly MODEL_BASE_URL: string;
  133485. /**
  133486. * File name for the controller model.
  133487. */
  133488. static readonly MODEL_FILENAME: string;
  133489. /**
  133490. * Creates a new GenericController from a gamepad
  133491. * @param vrGamepad the gamepad that the controller should be created from
  133492. */
  133493. constructor(vrGamepad: any);
  133494. /**
  133495. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133496. * @param scene scene in which to add meshes
  133497. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133498. */
  133499. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133500. /**
  133501. * Called once for each button that changed state since the last frame
  133502. * @param buttonIdx Which button index changed
  133503. * @param state New state of the button
  133504. * @param changes Which properties on the state changed since last frame
  133505. */
  133506. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133507. }
  133508. }
  133509. declare module BABYLON {
  133510. /**
  133511. * Oculus Touch Controller
  133512. */
  133513. export class OculusTouchController extends WebVRController {
  133514. /**
  133515. * Base Url for the controller model.
  133516. */
  133517. static MODEL_BASE_URL: string;
  133518. /**
  133519. * File name for the left controller model.
  133520. */
  133521. static MODEL_LEFT_FILENAME: string;
  133522. /**
  133523. * File name for the right controller model.
  133524. */
  133525. static MODEL_RIGHT_FILENAME: string;
  133526. /**
  133527. * Base Url for the Quest controller model.
  133528. */
  133529. static QUEST_MODEL_BASE_URL: string;
  133530. /**
  133531. * @hidden
  133532. * If the controllers are running on a device that needs the updated Quest controller models
  133533. */
  133534. static _IsQuest: boolean;
  133535. /**
  133536. * Fired when the secondary trigger on this controller is modified
  133537. */
  133538. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133539. /**
  133540. * Fired when the thumb rest on this controller is modified
  133541. */
  133542. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133543. /**
  133544. * Creates a new OculusTouchController from a gamepad
  133545. * @param vrGamepad the gamepad that the controller should be created from
  133546. */
  133547. constructor(vrGamepad: any);
  133548. /**
  133549. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133550. * @param scene scene in which to add meshes
  133551. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133552. */
  133553. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133554. /**
  133555. * Fired when the A button on this controller is modified
  133556. */
  133557. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133558. /**
  133559. * Fired when the B button on this controller is modified
  133560. */
  133561. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133562. /**
  133563. * Fired when the X button on this controller is modified
  133564. */
  133565. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133566. /**
  133567. * Fired when the Y button on this controller is modified
  133568. */
  133569. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133570. /**
  133571. * Called once for each button that changed state since the last frame
  133572. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133573. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133574. * 2) secondary trigger (same)
  133575. * 3) A (right) X (left), touch, pressed = value
  133576. * 4) B / Y
  133577. * 5) thumb rest
  133578. * @param buttonIdx Which button index changed
  133579. * @param state New state of the button
  133580. * @param changes Which properties on the state changed since last frame
  133581. */
  133582. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133583. }
  133584. }
  133585. declare module BABYLON {
  133586. /**
  133587. * Vive Controller
  133588. */
  133589. export class ViveController extends WebVRController {
  133590. /**
  133591. * Base Url for the controller model.
  133592. */
  133593. static MODEL_BASE_URL: string;
  133594. /**
  133595. * File name for the controller model.
  133596. */
  133597. static MODEL_FILENAME: string;
  133598. /**
  133599. * Creates a new ViveController from a gamepad
  133600. * @param vrGamepad the gamepad that the controller should be created from
  133601. */
  133602. constructor(vrGamepad: any);
  133603. /**
  133604. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133605. * @param scene scene in which to add meshes
  133606. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133607. */
  133608. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133609. /**
  133610. * Fired when the left button on this controller is modified
  133611. */
  133612. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133613. /**
  133614. * Fired when the right button on this controller is modified
  133615. */
  133616. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133617. /**
  133618. * Fired when the menu button on this controller is modified
  133619. */
  133620. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133621. /**
  133622. * Called once for each button that changed state since the last frame
  133623. * Vive mapping:
  133624. * 0: touchpad
  133625. * 1: trigger
  133626. * 2: left AND right buttons
  133627. * 3: menu button
  133628. * @param buttonIdx Which button index changed
  133629. * @param state New state of the button
  133630. * @param changes Which properties on the state changed since last frame
  133631. */
  133632. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133633. }
  133634. }
  133635. declare module BABYLON {
  133636. /**
  133637. * Defines the WindowsMotionController object that the state of the windows motion controller
  133638. */
  133639. export class WindowsMotionController extends WebVRController {
  133640. /**
  133641. * The base url used to load the left and right controller models
  133642. */
  133643. static MODEL_BASE_URL: string;
  133644. /**
  133645. * The name of the left controller model file
  133646. */
  133647. static MODEL_LEFT_FILENAME: string;
  133648. /**
  133649. * The name of the right controller model file
  133650. */
  133651. static MODEL_RIGHT_FILENAME: string;
  133652. /**
  133653. * The controller name prefix for this controller type
  133654. */
  133655. static readonly GAMEPAD_ID_PREFIX: string;
  133656. /**
  133657. * The controller id pattern for this controller type
  133658. */
  133659. private static readonly GAMEPAD_ID_PATTERN;
  133660. private _loadedMeshInfo;
  133661. protected readonly _mapping: {
  133662. buttons: string[];
  133663. buttonMeshNames: {
  133664. trigger: string;
  133665. menu: string;
  133666. grip: string;
  133667. thumbstick: string;
  133668. trackpad: string;
  133669. };
  133670. buttonObservableNames: {
  133671. trigger: string;
  133672. menu: string;
  133673. grip: string;
  133674. thumbstick: string;
  133675. trackpad: string;
  133676. };
  133677. axisMeshNames: string[];
  133678. pointingPoseMeshName: string;
  133679. };
  133680. /**
  133681. * Fired when the trackpad on this controller is clicked
  133682. */
  133683. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133684. /**
  133685. * Fired when the trackpad on this controller is modified
  133686. */
  133687. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133688. /**
  133689. * The current x and y values of this controller's trackpad
  133690. */
  133691. trackpad: StickValues;
  133692. /**
  133693. * Creates a new WindowsMotionController from a gamepad
  133694. * @param vrGamepad the gamepad that the controller should be created from
  133695. */
  133696. constructor(vrGamepad: any);
  133697. /**
  133698. * Fired when the trigger on this controller is modified
  133699. */
  133700. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133701. /**
  133702. * Fired when the menu button on this controller is modified
  133703. */
  133704. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133705. /**
  133706. * Fired when the grip button on this controller is modified
  133707. */
  133708. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133709. /**
  133710. * Fired when the thumbstick button on this controller is modified
  133711. */
  133712. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133713. /**
  133714. * Fired when the touchpad button on this controller is modified
  133715. */
  133716. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133717. /**
  133718. * Fired when the touchpad values on this controller are modified
  133719. */
  133720. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  133721. protected _updateTrackpad(): void;
  133722. /**
  133723. * Called once per frame by the engine.
  133724. */
  133725. update(): void;
  133726. /**
  133727. * Called once for each button that changed state since the last frame
  133728. * @param buttonIdx Which button index changed
  133729. * @param state New state of the button
  133730. * @param changes Which properties on the state changed since last frame
  133731. */
  133732. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133733. /**
  133734. * Moves the buttons on the controller mesh based on their current state
  133735. * @param buttonName the name of the button to move
  133736. * @param buttonValue the value of the button which determines the buttons new position
  133737. */
  133738. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  133739. /**
  133740. * Moves the axis on the controller mesh based on its current state
  133741. * @param axis the index of the axis
  133742. * @param axisValue the value of the axis which determines the meshes new position
  133743. * @hidden
  133744. */
  133745. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  133746. /**
  133747. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133748. * @param scene scene in which to add meshes
  133749. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133750. */
  133751. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  133752. /**
  133753. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  133754. * can be transformed by button presses and axes values, based on this._mapping.
  133755. *
  133756. * @param scene scene in which the meshes exist
  133757. * @param meshes list of meshes that make up the controller model to process
  133758. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  133759. */
  133760. private processModel;
  133761. private createMeshInfo;
  133762. /**
  133763. * Gets the ray of the controller in the direction the controller is pointing
  133764. * @param length the length the resulting ray should be
  133765. * @returns a ray in the direction the controller is pointing
  133766. */
  133767. getForwardRay(length?: number): Ray;
  133768. /**
  133769. * Disposes of the controller
  133770. */
  133771. dispose(): void;
  133772. }
  133773. /**
  133774. * This class represents a new windows motion controller in XR.
  133775. */
  133776. export class XRWindowsMotionController extends WindowsMotionController {
  133777. /**
  133778. * Changing the original WIndowsMotionController mapping to fir the new mapping
  133779. */
  133780. protected readonly _mapping: {
  133781. buttons: string[];
  133782. buttonMeshNames: {
  133783. trigger: string;
  133784. menu: string;
  133785. grip: string;
  133786. thumbstick: string;
  133787. trackpad: string;
  133788. };
  133789. buttonObservableNames: {
  133790. trigger: string;
  133791. menu: string;
  133792. grip: string;
  133793. thumbstick: string;
  133794. trackpad: string;
  133795. };
  133796. axisMeshNames: string[];
  133797. pointingPoseMeshName: string;
  133798. };
  133799. /**
  133800. * Construct a new XR-Based windows motion controller
  133801. *
  133802. * @param gamepadInfo the gamepad object from the browser
  133803. */
  133804. constructor(gamepadInfo: any);
  133805. /**
  133806. * holds the thumbstick values (X,Y)
  133807. */
  133808. thumbstickValues: StickValues;
  133809. /**
  133810. * Fired when the thumbstick on this controller is clicked
  133811. */
  133812. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  133813. /**
  133814. * Fired when the thumbstick on this controller is modified
  133815. */
  133816. onThumbstickValuesChangedObservable: Observable<StickValues>;
  133817. /**
  133818. * Fired when the touchpad button on this controller is modified
  133819. */
  133820. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  133821. /**
  133822. * Fired when the touchpad values on this controller are modified
  133823. */
  133824. onTrackpadValuesChangedObservable: Observable<StickValues>;
  133825. /**
  133826. * Fired when the thumbstick button on this controller is modified
  133827. * here to prevent breaking changes
  133828. */
  133829. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133830. /**
  133831. * updating the thumbstick(!) and not the trackpad.
  133832. * This is named this way due to the difference between WebVR and XR and to avoid
  133833. * changing the parent class.
  133834. */
  133835. protected _updateTrackpad(): void;
  133836. /**
  133837. * Disposes the class with joy
  133838. */
  133839. dispose(): void;
  133840. }
  133841. }
  133842. declare module BABYLON {
  133843. /**
  133844. * Class containing static functions to help procedurally build meshes
  133845. */
  133846. export class PolyhedronBuilder {
  133847. /**
  133848. * Creates a polyhedron mesh
  133849. * * 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
  133850. * * The parameter `size` (positive float, default 1) sets the polygon size
  133851. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  133852. * * 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`
  133853. * * 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
  133854. * * 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)`)
  133855. * * 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
  133856. * * 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
  133857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133858. * * 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
  133859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133860. * @param name defines the name of the mesh
  133861. * @param options defines the options used to create the mesh
  133862. * @param scene defines the hosting scene
  133863. * @returns the polyhedron mesh
  133864. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  133865. */
  133866. static CreatePolyhedron(name: string, options: {
  133867. type?: number;
  133868. size?: number;
  133869. sizeX?: number;
  133870. sizeY?: number;
  133871. sizeZ?: number;
  133872. custom?: any;
  133873. faceUV?: Vector4[];
  133874. faceColors?: Color4[];
  133875. flat?: boolean;
  133876. updatable?: boolean;
  133877. sideOrientation?: number;
  133878. frontUVs?: Vector4;
  133879. backUVs?: Vector4;
  133880. }, scene?: Nullable<Scene>): Mesh;
  133881. }
  133882. }
  133883. declare module BABYLON {
  133884. /**
  133885. * Gizmo that enables scaling a mesh along 3 axis
  133886. */
  133887. export class ScaleGizmo extends Gizmo {
  133888. /**
  133889. * Internal gizmo used for interactions on the x axis
  133890. */
  133891. xGizmo: AxisScaleGizmo;
  133892. /**
  133893. * Internal gizmo used for interactions on the y axis
  133894. */
  133895. yGizmo: AxisScaleGizmo;
  133896. /**
  133897. * Internal gizmo used for interactions on the z axis
  133898. */
  133899. zGizmo: AxisScaleGizmo;
  133900. /**
  133901. * Internal gizmo used to scale all axis equally
  133902. */
  133903. uniformScaleGizmo: AxisScaleGizmo;
  133904. private _meshAttached;
  133905. private _nodeAttached;
  133906. private _snapDistance;
  133907. private _uniformScalingMesh;
  133908. private _octahedron;
  133909. private _sensitivity;
  133910. /** Fires an event when any of it's sub gizmos are dragged */
  133911. onDragStartObservable: Observable<unknown>;
  133912. /** Fires an event when any of it's sub gizmos are released from dragging */
  133913. onDragEndObservable: Observable<unknown>;
  133914. get attachedMesh(): Nullable<AbstractMesh>;
  133915. set attachedMesh(mesh: Nullable<AbstractMesh>);
  133916. get attachedNode(): Nullable<Node>;
  133917. set attachedNode(node: Nullable<Node>);
  133918. /**
  133919. * Creates a ScaleGizmo
  133920. * @param gizmoLayer The utility layer the gizmo will be added to
  133921. * @param thickness display gizmo axis thickness
  133922. */
  133923. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  133924. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  133925. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  133926. /**
  133927. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133928. */
  133929. set snapDistance(value: number);
  133930. get snapDistance(): number;
  133931. /**
  133932. * Ratio for the scale of the gizmo (Default: 1)
  133933. */
  133934. set scaleRatio(value: number);
  133935. get scaleRatio(): number;
  133936. /**
  133937. * Sensitivity factor for dragging (Default: 1)
  133938. */
  133939. set sensitivity(value: number);
  133940. get sensitivity(): number;
  133941. /**
  133942. * Disposes of the gizmo
  133943. */
  133944. dispose(): void;
  133945. }
  133946. }
  133947. declare module BABYLON {
  133948. /**
  133949. * Single axis scale gizmo
  133950. */
  133951. export class AxisScaleGizmo extends Gizmo {
  133952. /**
  133953. * Drag behavior responsible for the gizmos dragging interactions
  133954. */
  133955. dragBehavior: PointerDragBehavior;
  133956. private _pointerObserver;
  133957. /**
  133958. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  133959. */
  133960. snapDistance: number;
  133961. /**
  133962. * Event that fires each time the gizmo snaps to a new location.
  133963. * * snapDistance is the the change in distance
  133964. */
  133965. onSnapObservable: Observable<{
  133966. snapDistance: number;
  133967. }>;
  133968. /**
  133969. * If the scaling operation should be done on all axis (default: false)
  133970. */
  133971. uniformScaling: boolean;
  133972. /**
  133973. * Custom sensitivity value for the drag strength
  133974. */
  133975. sensitivity: number;
  133976. private _isEnabled;
  133977. private _parent;
  133978. private _arrow;
  133979. private _coloredMaterial;
  133980. private _hoverMaterial;
  133981. /**
  133982. * Creates an AxisScaleGizmo
  133983. * @param gizmoLayer The utility layer the gizmo will be added to
  133984. * @param dragAxis The axis which the gizmo will be able to scale on
  133985. * @param color The color of the gizmo
  133986. * @param thickness display gizmo axis thickness
  133987. */
  133988. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  133989. protected _attachedNodeChanged(value: Nullable<Node>): void;
  133990. /**
  133991. * If the gizmo is enabled
  133992. */
  133993. set isEnabled(value: boolean);
  133994. get isEnabled(): boolean;
  133995. /**
  133996. * Disposes of the gizmo
  133997. */
  133998. dispose(): void;
  133999. /**
  134000. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134001. * @param mesh The mesh to replace the default mesh of the gizmo
  134002. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134003. */
  134004. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134005. }
  134006. }
  134007. declare module BABYLON {
  134008. /**
  134009. * Bounding box gizmo
  134010. */
  134011. export class BoundingBoxGizmo extends Gizmo {
  134012. private _lineBoundingBox;
  134013. private _rotateSpheresParent;
  134014. private _scaleBoxesParent;
  134015. private _boundingDimensions;
  134016. private _renderObserver;
  134017. private _pointerObserver;
  134018. private _scaleDragSpeed;
  134019. private _tmpQuaternion;
  134020. private _tmpVector;
  134021. private _tmpRotationMatrix;
  134022. /**
  134023. * 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)
  134024. */
  134025. ignoreChildren: boolean;
  134026. /**
  134027. * 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)
  134028. */
  134029. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134030. /**
  134031. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134032. */
  134033. rotationSphereSize: number;
  134034. /**
  134035. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134036. */
  134037. scaleBoxSize: number;
  134038. /**
  134039. * 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)
  134040. */
  134041. fixedDragMeshScreenSize: boolean;
  134042. /**
  134043. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134044. */
  134045. fixedDragMeshScreenSizeDistanceFactor: number;
  134046. /**
  134047. * Fired when a rotation sphere or scale box is dragged
  134048. */
  134049. onDragStartObservable: Observable<{}>;
  134050. /**
  134051. * Fired when a scale box is dragged
  134052. */
  134053. onScaleBoxDragObservable: Observable<{}>;
  134054. /**
  134055. * Fired when a scale box drag is ended
  134056. */
  134057. onScaleBoxDragEndObservable: Observable<{}>;
  134058. /**
  134059. * Fired when a rotation sphere is dragged
  134060. */
  134061. onRotationSphereDragObservable: Observable<{}>;
  134062. /**
  134063. * Fired when a rotation sphere drag is ended
  134064. */
  134065. onRotationSphereDragEndObservable: Observable<{}>;
  134066. /**
  134067. * Relative bounding box pivot used when scaling the attached node. 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)
  134068. */
  134069. scalePivot: Nullable<Vector3>;
  134070. /**
  134071. * Mesh used as a pivot to rotate the attached node
  134072. */
  134073. private _anchorMesh;
  134074. private _existingMeshScale;
  134075. private _dragMesh;
  134076. private pointerDragBehavior;
  134077. private coloredMaterial;
  134078. private hoverColoredMaterial;
  134079. /**
  134080. * Sets the color of the bounding box gizmo
  134081. * @param color the color to set
  134082. */
  134083. setColor(color: Color3): void;
  134084. /**
  134085. * Creates an BoundingBoxGizmo
  134086. * @param gizmoLayer The utility layer the gizmo will be added to
  134087. * @param color The color of the gizmo
  134088. */
  134089. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134090. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134091. private _selectNode;
  134092. /**
  134093. * Updates the bounding box information for the Gizmo
  134094. */
  134095. updateBoundingBox(): void;
  134096. private _updateRotationSpheres;
  134097. private _updateScaleBoxes;
  134098. /**
  134099. * Enables rotation on the specified axis and disables rotation on the others
  134100. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134101. */
  134102. setEnabledRotationAxis(axis: string): void;
  134103. /**
  134104. * Enables/disables scaling
  134105. * @param enable if scaling should be enabled
  134106. * @param homogeneousScaling defines if scaling should only be homogeneous
  134107. */
  134108. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134109. private _updateDummy;
  134110. /**
  134111. * Enables a pointer drag behavior on the bounding box of the gizmo
  134112. */
  134113. enableDragBehavior(): void;
  134114. /**
  134115. * Disposes of the gizmo
  134116. */
  134117. dispose(): void;
  134118. /**
  134119. * 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)
  134120. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134121. * @returns the bounding box mesh with the passed in mesh as a child
  134122. */
  134123. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134124. /**
  134125. * CustomMeshes are not supported by this gizmo
  134126. * @param mesh The mesh to replace the default mesh of the gizmo
  134127. */
  134128. setCustomMesh(mesh: Mesh): void;
  134129. }
  134130. }
  134131. declare module BABYLON {
  134132. /**
  134133. * Single plane rotation gizmo
  134134. */
  134135. export class PlaneRotationGizmo extends Gizmo {
  134136. /**
  134137. * Drag behavior responsible for the gizmos dragging interactions
  134138. */
  134139. dragBehavior: PointerDragBehavior;
  134140. private _pointerObserver;
  134141. /**
  134142. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134143. */
  134144. snapDistance: number;
  134145. /**
  134146. * Event that fires each time the gizmo snaps to a new location.
  134147. * * snapDistance is the the change in distance
  134148. */
  134149. onSnapObservable: Observable<{
  134150. snapDistance: number;
  134151. }>;
  134152. private _isEnabled;
  134153. private _parent;
  134154. /**
  134155. * Creates a PlaneRotationGizmo
  134156. * @param gizmoLayer The utility layer the gizmo will be added to
  134157. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134158. * @param color The color of the gizmo
  134159. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134160. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134161. * @param thickness display gizmo axis thickness
  134162. */
  134163. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134164. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134165. /**
  134166. * If the gizmo is enabled
  134167. */
  134168. set isEnabled(value: boolean);
  134169. get isEnabled(): boolean;
  134170. /**
  134171. * Disposes of the gizmo
  134172. */
  134173. dispose(): void;
  134174. }
  134175. }
  134176. declare module BABYLON {
  134177. /**
  134178. * Gizmo that enables rotating a mesh along 3 axis
  134179. */
  134180. export class RotationGizmo extends Gizmo {
  134181. /**
  134182. * Internal gizmo used for interactions on the x axis
  134183. */
  134184. xGizmo: PlaneRotationGizmo;
  134185. /**
  134186. * Internal gizmo used for interactions on the y axis
  134187. */
  134188. yGizmo: PlaneRotationGizmo;
  134189. /**
  134190. * Internal gizmo used for interactions on the z axis
  134191. */
  134192. zGizmo: PlaneRotationGizmo;
  134193. /** Fires an event when any of it's sub gizmos are dragged */
  134194. onDragStartObservable: Observable<unknown>;
  134195. /** Fires an event when any of it's sub gizmos are released from dragging */
  134196. onDragEndObservable: Observable<unknown>;
  134197. private _meshAttached;
  134198. private _nodeAttached;
  134199. get attachedMesh(): Nullable<AbstractMesh>;
  134200. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134201. get attachedNode(): Nullable<Node>;
  134202. set attachedNode(node: Nullable<Node>);
  134203. /**
  134204. * Creates a RotationGizmo
  134205. * @param gizmoLayer The utility layer the gizmo will be added to
  134206. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134207. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134208. * @param thickness display gizmo axis thickness
  134209. */
  134210. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134211. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134212. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134213. /**
  134214. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134215. */
  134216. set snapDistance(value: number);
  134217. get snapDistance(): number;
  134218. /**
  134219. * Ratio for the scale of the gizmo (Default: 1)
  134220. */
  134221. set scaleRatio(value: number);
  134222. get scaleRatio(): number;
  134223. /**
  134224. * Disposes of the gizmo
  134225. */
  134226. dispose(): void;
  134227. /**
  134228. * CustomMeshes are not supported by this gizmo
  134229. * @param mesh The mesh to replace the default mesh of the gizmo
  134230. */
  134231. setCustomMesh(mesh: Mesh): void;
  134232. }
  134233. }
  134234. declare module BABYLON {
  134235. /**
  134236. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134237. */
  134238. export class GizmoManager implements IDisposable {
  134239. private scene;
  134240. /**
  134241. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134242. */
  134243. gizmos: {
  134244. positionGizmo: Nullable<PositionGizmo>;
  134245. rotationGizmo: Nullable<RotationGizmo>;
  134246. scaleGizmo: Nullable<ScaleGizmo>;
  134247. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134248. };
  134249. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134250. clearGizmoOnEmptyPointerEvent: boolean;
  134251. /** Fires an event when the manager is attached to a mesh */
  134252. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134253. /** Fires an event when the manager is attached to a node */
  134254. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134255. private _gizmosEnabled;
  134256. private _pointerObserver;
  134257. private _attachedMesh;
  134258. private _attachedNode;
  134259. private _boundingBoxColor;
  134260. private _defaultUtilityLayer;
  134261. private _defaultKeepDepthUtilityLayer;
  134262. private _thickness;
  134263. /**
  134264. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134265. */
  134266. boundingBoxDragBehavior: SixDofDragBehavior;
  134267. /**
  134268. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134269. */
  134270. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134271. /**
  134272. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134273. */
  134274. attachableNodes: Nullable<Array<Node>>;
  134275. /**
  134276. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134277. */
  134278. usePointerToAttachGizmos: boolean;
  134279. /**
  134280. * Utility layer that the bounding box gizmo belongs to
  134281. */
  134282. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134283. /**
  134284. * Utility layer that all gizmos besides bounding box belong to
  134285. */
  134286. get utilityLayer(): UtilityLayerRenderer;
  134287. /**
  134288. * Instatiates a gizmo manager
  134289. * @param scene the scene to overlay the gizmos on top of
  134290. * @param thickness display gizmo axis thickness
  134291. */
  134292. constructor(scene: Scene, thickness?: number);
  134293. /**
  134294. * Attaches a set of gizmos to the specified mesh
  134295. * @param mesh The mesh the gizmo's should be attached to
  134296. */
  134297. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134298. /**
  134299. * Attaches a set of gizmos to the specified node
  134300. * @param node The node the gizmo's should be attached to
  134301. */
  134302. attachToNode(node: Nullable<Node>): void;
  134303. /**
  134304. * If the position gizmo is enabled
  134305. */
  134306. set positionGizmoEnabled(value: boolean);
  134307. get positionGizmoEnabled(): boolean;
  134308. /**
  134309. * If the rotation gizmo is enabled
  134310. */
  134311. set rotationGizmoEnabled(value: boolean);
  134312. get rotationGizmoEnabled(): boolean;
  134313. /**
  134314. * If the scale gizmo is enabled
  134315. */
  134316. set scaleGizmoEnabled(value: boolean);
  134317. get scaleGizmoEnabled(): boolean;
  134318. /**
  134319. * If the boundingBox gizmo is enabled
  134320. */
  134321. set boundingBoxGizmoEnabled(value: boolean);
  134322. get boundingBoxGizmoEnabled(): boolean;
  134323. /**
  134324. * Disposes of the gizmo manager
  134325. */
  134326. dispose(): void;
  134327. }
  134328. }
  134329. declare module BABYLON {
  134330. /**
  134331. * A directional light is defined by a direction (what a surprise!).
  134332. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134333. * 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.
  134334. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134335. */
  134336. export class DirectionalLight extends ShadowLight {
  134337. private _shadowFrustumSize;
  134338. /**
  134339. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134340. */
  134341. get shadowFrustumSize(): number;
  134342. /**
  134343. * Specifies a fix frustum size for the shadow generation.
  134344. */
  134345. set shadowFrustumSize(value: number);
  134346. private _shadowOrthoScale;
  134347. /**
  134348. * Gets the shadow projection scale against the optimal computed one.
  134349. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134350. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134351. */
  134352. get shadowOrthoScale(): number;
  134353. /**
  134354. * Sets the shadow projection scale against the optimal computed one.
  134355. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134356. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134357. */
  134358. set shadowOrthoScale(value: number);
  134359. /**
  134360. * Automatically compute the projection matrix to best fit (including all the casters)
  134361. * on each frame.
  134362. */
  134363. autoUpdateExtends: boolean;
  134364. /**
  134365. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134366. * on each frame. autoUpdateExtends must be set to true for this to work
  134367. */
  134368. autoCalcShadowZBounds: boolean;
  134369. private _orthoLeft;
  134370. private _orthoRight;
  134371. private _orthoTop;
  134372. private _orthoBottom;
  134373. /**
  134374. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134375. * The directional light is emitted from everywhere in the given direction.
  134376. * It can cast shadows.
  134377. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134378. * @param name The friendly name of the light
  134379. * @param direction The direction of the light
  134380. * @param scene The scene the light belongs to
  134381. */
  134382. constructor(name: string, direction: Vector3, scene: Scene);
  134383. /**
  134384. * Returns the string "DirectionalLight".
  134385. * @return The class name
  134386. */
  134387. getClassName(): string;
  134388. /**
  134389. * Returns the integer 1.
  134390. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134391. */
  134392. getTypeID(): number;
  134393. /**
  134394. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134395. * Returns the DirectionalLight Shadow projection matrix.
  134396. */
  134397. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134398. /**
  134399. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134400. * Returns the DirectionalLight Shadow projection matrix.
  134401. */
  134402. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134403. /**
  134404. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134405. * Returns the DirectionalLight Shadow projection matrix.
  134406. */
  134407. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134408. protected _buildUniformLayout(): void;
  134409. /**
  134410. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134411. * @param effect The effect to update
  134412. * @param lightIndex The index of the light in the effect to update
  134413. * @returns The directional light
  134414. */
  134415. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134416. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134417. /**
  134418. * Gets the minZ used for shadow according to both the scene and the light.
  134419. *
  134420. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134421. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134422. * @param activeCamera The camera we are returning the min for
  134423. * @returns the depth min z
  134424. */
  134425. getDepthMinZ(activeCamera: Camera): number;
  134426. /**
  134427. * Gets the maxZ used for shadow according to both the scene and the light.
  134428. *
  134429. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134430. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134431. * @param activeCamera The camera we are returning the max for
  134432. * @returns the depth max z
  134433. */
  134434. getDepthMaxZ(activeCamera: Camera): number;
  134435. /**
  134436. * Prepares the list of defines specific to the light type.
  134437. * @param defines the list of defines
  134438. * @param lightIndex defines the index of the light for the effect
  134439. */
  134440. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134441. }
  134442. }
  134443. declare module BABYLON {
  134444. /**
  134445. * Class containing static functions to help procedurally build meshes
  134446. */
  134447. export class HemisphereBuilder {
  134448. /**
  134449. * Creates a hemisphere mesh
  134450. * @param name defines the name of the mesh
  134451. * @param options defines the options used to create the mesh
  134452. * @param scene defines the hosting scene
  134453. * @returns the hemisphere mesh
  134454. */
  134455. static CreateHemisphere(name: string, options: {
  134456. segments?: number;
  134457. diameter?: number;
  134458. sideOrientation?: number;
  134459. }, scene: any): Mesh;
  134460. }
  134461. }
  134462. declare module BABYLON {
  134463. /**
  134464. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134465. * These values define a cone of light starting from the position, emitting toward the direction.
  134466. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134467. * and the exponent defines the speed of the decay of the light with distance (reach).
  134468. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134469. */
  134470. export class SpotLight extends ShadowLight {
  134471. private _angle;
  134472. private _innerAngle;
  134473. private _cosHalfAngle;
  134474. private _lightAngleScale;
  134475. private _lightAngleOffset;
  134476. /**
  134477. * Gets the cone angle of the spot light in Radians.
  134478. */
  134479. get angle(): number;
  134480. /**
  134481. * Sets the cone angle of the spot light in Radians.
  134482. */
  134483. set angle(value: number);
  134484. /**
  134485. * Only used in gltf falloff mode, this defines the angle where
  134486. * the directional falloff will start before cutting at angle which could be seen
  134487. * as outer angle.
  134488. */
  134489. get innerAngle(): number;
  134490. /**
  134491. * Only used in gltf falloff mode, this defines the angle where
  134492. * the directional falloff will start before cutting at angle which could be seen
  134493. * as outer angle.
  134494. */
  134495. set innerAngle(value: number);
  134496. private _shadowAngleScale;
  134497. /**
  134498. * Allows scaling the angle of the light for shadow generation only.
  134499. */
  134500. get shadowAngleScale(): number;
  134501. /**
  134502. * Allows scaling the angle of the light for shadow generation only.
  134503. */
  134504. set shadowAngleScale(value: number);
  134505. /**
  134506. * The light decay speed with the distance from the emission spot.
  134507. */
  134508. exponent: number;
  134509. private _projectionTextureMatrix;
  134510. /**
  134511. * Allows reading the projecton texture
  134512. */
  134513. get projectionTextureMatrix(): Matrix;
  134514. protected _projectionTextureLightNear: number;
  134515. /**
  134516. * Gets the near clip of the Spotlight for texture projection.
  134517. */
  134518. get projectionTextureLightNear(): number;
  134519. /**
  134520. * Sets the near clip of the Spotlight for texture projection.
  134521. */
  134522. set projectionTextureLightNear(value: number);
  134523. protected _projectionTextureLightFar: number;
  134524. /**
  134525. * Gets the far clip of the Spotlight for texture projection.
  134526. */
  134527. get projectionTextureLightFar(): number;
  134528. /**
  134529. * Sets the far clip of the Spotlight for texture projection.
  134530. */
  134531. set projectionTextureLightFar(value: number);
  134532. protected _projectionTextureUpDirection: Vector3;
  134533. /**
  134534. * Gets the Up vector of the Spotlight for texture projection.
  134535. */
  134536. get projectionTextureUpDirection(): Vector3;
  134537. /**
  134538. * Sets the Up vector of the Spotlight for texture projection.
  134539. */
  134540. set projectionTextureUpDirection(value: Vector3);
  134541. private _projectionTexture;
  134542. /**
  134543. * Gets the projection texture of the light.
  134544. */
  134545. get projectionTexture(): Nullable<BaseTexture>;
  134546. /**
  134547. * Sets the projection texture of the light.
  134548. */
  134549. set projectionTexture(value: Nullable<BaseTexture>);
  134550. private _projectionTextureViewLightDirty;
  134551. private _projectionTextureProjectionLightDirty;
  134552. private _projectionTextureDirty;
  134553. private _projectionTextureViewTargetVector;
  134554. private _projectionTextureViewLightMatrix;
  134555. private _projectionTextureProjectionLightMatrix;
  134556. private _projectionTextureScalingMatrix;
  134557. /**
  134558. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134559. * It can cast shadows.
  134560. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134561. * @param name The light friendly name
  134562. * @param position The position of the spot light in the scene
  134563. * @param direction The direction of the light in the scene
  134564. * @param angle The cone angle of the light in Radians
  134565. * @param exponent The light decay speed with the distance from the emission spot
  134566. * @param scene The scene the lights belongs to
  134567. */
  134568. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134569. /**
  134570. * Returns the string "SpotLight".
  134571. * @returns the class name
  134572. */
  134573. getClassName(): string;
  134574. /**
  134575. * Returns the integer 2.
  134576. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134577. */
  134578. getTypeID(): number;
  134579. /**
  134580. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134581. */
  134582. protected _setDirection(value: Vector3): void;
  134583. /**
  134584. * Overrides the position setter to recompute the projection texture view light Matrix.
  134585. */
  134586. protected _setPosition(value: Vector3): void;
  134587. /**
  134588. * 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.
  134589. * Returns the SpotLight.
  134590. */
  134591. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134592. protected _computeProjectionTextureViewLightMatrix(): void;
  134593. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134594. /**
  134595. * Main function for light texture projection matrix computing.
  134596. */
  134597. protected _computeProjectionTextureMatrix(): void;
  134598. protected _buildUniformLayout(): void;
  134599. private _computeAngleValues;
  134600. /**
  134601. * Sets the passed Effect "effect" with the Light textures.
  134602. * @param effect The effect to update
  134603. * @param lightIndex The index of the light in the effect to update
  134604. * @returns The light
  134605. */
  134606. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134607. /**
  134608. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134609. * @param effect The effect to update
  134610. * @param lightIndex The index of the light in the effect to update
  134611. * @returns The spot light
  134612. */
  134613. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  134614. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  134615. /**
  134616. * Disposes the light and the associated resources.
  134617. */
  134618. dispose(): void;
  134619. /**
  134620. * Prepares the list of defines specific to the light type.
  134621. * @param defines the list of defines
  134622. * @param lightIndex defines the index of the light for the effect
  134623. */
  134624. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134625. }
  134626. }
  134627. declare module BABYLON {
  134628. /**
  134629. * Gizmo that enables viewing a light
  134630. */
  134631. export class LightGizmo extends Gizmo {
  134632. private _lightMesh;
  134633. private _material;
  134634. private _cachedPosition;
  134635. private _cachedForward;
  134636. private _attachedMeshParent;
  134637. private _pointerObserver;
  134638. /**
  134639. * Event that fires each time the gizmo is clicked
  134640. */
  134641. onClickedObservable: Observable<Light>;
  134642. /**
  134643. * Creates a LightGizmo
  134644. * @param gizmoLayer The utility layer the gizmo will be added to
  134645. */
  134646. constructor(gizmoLayer?: UtilityLayerRenderer);
  134647. private _light;
  134648. /**
  134649. * The light that the gizmo is attached to
  134650. */
  134651. set light(light: Nullable<Light>);
  134652. get light(): Nullable<Light>;
  134653. /**
  134654. * Gets the material used to render the light gizmo
  134655. */
  134656. get material(): StandardMaterial;
  134657. /**
  134658. * @hidden
  134659. * Updates the gizmo to match the attached mesh's position/rotation
  134660. */
  134661. protected _update(): void;
  134662. private static _Scale;
  134663. /**
  134664. * Creates the lines for a light mesh
  134665. */
  134666. private static _CreateLightLines;
  134667. /**
  134668. * Disposes of the light gizmo
  134669. */
  134670. dispose(): void;
  134671. private static _CreateHemisphericLightMesh;
  134672. private static _CreatePointLightMesh;
  134673. private static _CreateSpotLightMesh;
  134674. private static _CreateDirectionalLightMesh;
  134675. }
  134676. }
  134677. declare module BABYLON {
  134678. /**
  134679. * Gizmo that enables viewing a camera
  134680. */
  134681. export class CameraGizmo extends Gizmo {
  134682. private _cameraMesh;
  134683. private _cameraLinesMesh;
  134684. private _material;
  134685. private _pointerObserver;
  134686. /**
  134687. * Event that fires each time the gizmo is clicked
  134688. */
  134689. onClickedObservable: Observable<Camera>;
  134690. /**
  134691. * Creates a CameraGizmo
  134692. * @param gizmoLayer The utility layer the gizmo will be added to
  134693. */
  134694. constructor(gizmoLayer?: UtilityLayerRenderer);
  134695. private _camera;
  134696. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  134697. get displayFrustum(): boolean;
  134698. set displayFrustum(value: boolean);
  134699. /**
  134700. * The camera that the gizmo is attached to
  134701. */
  134702. set camera(camera: Nullable<Camera>);
  134703. get camera(): Nullable<Camera>;
  134704. /**
  134705. * Gets the material used to render the camera gizmo
  134706. */
  134707. get material(): StandardMaterial;
  134708. /**
  134709. * @hidden
  134710. * Updates the gizmo to match the attached mesh's position/rotation
  134711. */
  134712. protected _update(): void;
  134713. private static _Scale;
  134714. private _invProjection;
  134715. /**
  134716. * Disposes of the camera gizmo
  134717. */
  134718. dispose(): void;
  134719. private static _CreateCameraMesh;
  134720. private static _CreateCameraFrustum;
  134721. }
  134722. }
  134723. declare module BABYLON {
  134724. /** @hidden */
  134725. export var backgroundFragmentDeclaration: {
  134726. name: string;
  134727. shader: string;
  134728. };
  134729. }
  134730. declare module BABYLON {
  134731. /** @hidden */
  134732. export var backgroundUboDeclaration: {
  134733. name: string;
  134734. shader: string;
  134735. };
  134736. }
  134737. declare module BABYLON {
  134738. /** @hidden */
  134739. export var backgroundPixelShader: {
  134740. name: string;
  134741. shader: string;
  134742. };
  134743. }
  134744. declare module BABYLON {
  134745. /** @hidden */
  134746. export var backgroundVertexDeclaration: {
  134747. name: string;
  134748. shader: string;
  134749. };
  134750. }
  134751. declare module BABYLON {
  134752. /** @hidden */
  134753. export var backgroundVertexShader: {
  134754. name: string;
  134755. shader: string;
  134756. };
  134757. }
  134758. declare module BABYLON {
  134759. /**
  134760. * Background material used to create an efficient environement around your scene.
  134761. */
  134762. export class BackgroundMaterial extends PushMaterial {
  134763. /**
  134764. * Standard reflectance value at parallel view angle.
  134765. */
  134766. static StandardReflectance0: number;
  134767. /**
  134768. * Standard reflectance value at grazing angle.
  134769. */
  134770. static StandardReflectance90: number;
  134771. protected _primaryColor: Color3;
  134772. /**
  134773. * Key light Color (multiply against the environement texture)
  134774. */
  134775. primaryColor: Color3;
  134776. protected __perceptualColor: Nullable<Color3>;
  134777. /**
  134778. * Experimental Internal Use Only.
  134779. *
  134780. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  134781. * This acts as a helper to set the primary color to a more "human friendly" value.
  134782. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  134783. * output color as close as possible from the chosen value.
  134784. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  134785. * part of lighting setup.)
  134786. */
  134787. get _perceptualColor(): Nullable<Color3>;
  134788. set _perceptualColor(value: Nullable<Color3>);
  134789. protected _primaryColorShadowLevel: float;
  134790. /**
  134791. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  134792. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  134793. */
  134794. get primaryColorShadowLevel(): float;
  134795. set primaryColorShadowLevel(value: float);
  134796. protected _primaryColorHighlightLevel: float;
  134797. /**
  134798. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  134799. * The primary color is used at the level chosen to define what the white area would look.
  134800. */
  134801. get primaryColorHighlightLevel(): float;
  134802. set primaryColorHighlightLevel(value: float);
  134803. protected _reflectionTexture: Nullable<BaseTexture>;
  134804. /**
  134805. * Reflection Texture used in the material.
  134806. * Should be author in a specific way for the best result (refer to the documentation).
  134807. */
  134808. reflectionTexture: Nullable<BaseTexture>;
  134809. protected _reflectionBlur: float;
  134810. /**
  134811. * Reflection Texture level of blur.
  134812. *
  134813. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  134814. * texture twice.
  134815. */
  134816. reflectionBlur: float;
  134817. protected _diffuseTexture: Nullable<BaseTexture>;
  134818. /**
  134819. * Diffuse Texture used in the material.
  134820. * Should be author in a specific way for the best result (refer to the documentation).
  134821. */
  134822. diffuseTexture: Nullable<BaseTexture>;
  134823. protected _shadowLights: Nullable<IShadowLight[]>;
  134824. /**
  134825. * Specify the list of lights casting shadow on the material.
  134826. * All scene shadow lights will be included if null.
  134827. */
  134828. shadowLights: Nullable<IShadowLight[]>;
  134829. protected _shadowLevel: float;
  134830. /**
  134831. * Helps adjusting the shadow to a softer level if required.
  134832. * 0 means black shadows and 1 means no shadows.
  134833. */
  134834. shadowLevel: float;
  134835. protected _sceneCenter: Vector3;
  134836. /**
  134837. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  134838. * It is usually zero but might be interesting to modify according to your setup.
  134839. */
  134840. sceneCenter: Vector3;
  134841. protected _opacityFresnel: boolean;
  134842. /**
  134843. * This helps specifying that the material is falling off to the sky box at grazing angle.
  134844. * This helps ensuring a nice transition when the camera goes under the ground.
  134845. */
  134846. opacityFresnel: boolean;
  134847. protected _reflectionFresnel: boolean;
  134848. /**
  134849. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  134850. * This helps adding a mirror texture on the ground.
  134851. */
  134852. reflectionFresnel: boolean;
  134853. protected _reflectionFalloffDistance: number;
  134854. /**
  134855. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  134856. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  134857. */
  134858. reflectionFalloffDistance: number;
  134859. protected _reflectionAmount: number;
  134860. /**
  134861. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  134862. */
  134863. reflectionAmount: number;
  134864. protected _reflectionReflectance0: number;
  134865. /**
  134866. * This specifies the weight of the reflection at grazing angle.
  134867. */
  134868. reflectionReflectance0: number;
  134869. protected _reflectionReflectance90: number;
  134870. /**
  134871. * This specifies the weight of the reflection at a perpendicular point of view.
  134872. */
  134873. reflectionReflectance90: number;
  134874. /**
  134875. * Sets the reflection reflectance fresnel values according to the default standard
  134876. * empirically know to work well :-)
  134877. */
  134878. set reflectionStandardFresnelWeight(value: number);
  134879. protected _useRGBColor: boolean;
  134880. /**
  134881. * Helps to directly use the maps channels instead of their level.
  134882. */
  134883. useRGBColor: boolean;
  134884. protected _enableNoise: boolean;
  134885. /**
  134886. * This helps reducing the banding effect that could occur on the background.
  134887. */
  134888. enableNoise: boolean;
  134889. /**
  134890. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  134891. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  134892. * Recommended to be keep at 1.0 except for special cases.
  134893. */
  134894. get fovMultiplier(): number;
  134895. set fovMultiplier(value: number);
  134896. private _fovMultiplier;
  134897. /**
  134898. * Enable the FOV adjustment feature controlled by fovMultiplier.
  134899. */
  134900. useEquirectangularFOV: boolean;
  134901. private _maxSimultaneousLights;
  134902. /**
  134903. * Number of Simultaneous lights allowed on the material.
  134904. */
  134905. maxSimultaneousLights: int;
  134906. private _shadowOnly;
  134907. /**
  134908. * Make the material only render shadows
  134909. */
  134910. shadowOnly: boolean;
  134911. /**
  134912. * Default configuration related to image processing available in the Background Material.
  134913. */
  134914. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  134915. /**
  134916. * Keep track of the image processing observer to allow dispose and replace.
  134917. */
  134918. private _imageProcessingObserver;
  134919. /**
  134920. * Attaches a new image processing configuration to the PBR Material.
  134921. * @param configuration (if null the scene configuration will be use)
  134922. */
  134923. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  134924. /**
  134925. * Gets the image processing configuration used either in this material.
  134926. */
  134927. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  134928. /**
  134929. * Sets the Default image processing configuration used either in the this material.
  134930. *
  134931. * If sets to null, the scene one is in use.
  134932. */
  134933. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  134934. /**
  134935. * Gets wether the color curves effect is enabled.
  134936. */
  134937. get cameraColorCurvesEnabled(): boolean;
  134938. /**
  134939. * Sets wether the color curves effect is enabled.
  134940. */
  134941. set cameraColorCurvesEnabled(value: boolean);
  134942. /**
  134943. * Gets wether the color grading effect is enabled.
  134944. */
  134945. get cameraColorGradingEnabled(): boolean;
  134946. /**
  134947. * Gets wether the color grading effect is enabled.
  134948. */
  134949. set cameraColorGradingEnabled(value: boolean);
  134950. /**
  134951. * Gets wether tonemapping is enabled or not.
  134952. */
  134953. get cameraToneMappingEnabled(): boolean;
  134954. /**
  134955. * Sets wether tonemapping is enabled or not
  134956. */
  134957. set cameraToneMappingEnabled(value: boolean);
  134958. /**
  134959. * The camera exposure used on this material.
  134960. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134961. * This corresponds to a photographic exposure.
  134962. */
  134963. get cameraExposure(): float;
  134964. /**
  134965. * The camera exposure used on this material.
  134966. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  134967. * This corresponds to a photographic exposure.
  134968. */
  134969. set cameraExposure(value: float);
  134970. /**
  134971. * Gets The camera contrast used on this material.
  134972. */
  134973. get cameraContrast(): float;
  134974. /**
  134975. * Sets The camera contrast used on this material.
  134976. */
  134977. set cameraContrast(value: float);
  134978. /**
  134979. * Gets the Color Grading 2D Lookup Texture.
  134980. */
  134981. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  134982. /**
  134983. * Sets the Color Grading 2D Lookup Texture.
  134984. */
  134985. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  134986. /**
  134987. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134988. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134989. * 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;
  134990. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134991. */
  134992. get cameraColorCurves(): Nullable<ColorCurves>;
  134993. /**
  134994. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  134995. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  134996. * 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;
  134997. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  134998. */
  134999. set cameraColorCurves(value: Nullable<ColorCurves>);
  135000. /**
  135001. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135002. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135003. */
  135004. switchToBGR: boolean;
  135005. private _renderTargets;
  135006. private _reflectionControls;
  135007. private _white;
  135008. private _primaryShadowColor;
  135009. private _primaryHighlightColor;
  135010. /**
  135011. * Instantiates a Background Material in the given scene
  135012. * @param name The friendly name of the material
  135013. * @param scene The scene to add the material to
  135014. */
  135015. constructor(name: string, scene: Scene);
  135016. /**
  135017. * Gets a boolean indicating that current material needs to register RTT
  135018. */
  135019. get hasRenderTargetTextures(): boolean;
  135020. /**
  135021. * The entire material has been created in order to prevent overdraw.
  135022. * @returns false
  135023. */
  135024. needAlphaTesting(): boolean;
  135025. /**
  135026. * The entire material has been created in order to prevent overdraw.
  135027. * @returns true if blending is enable
  135028. */
  135029. needAlphaBlending(): boolean;
  135030. /**
  135031. * Checks wether the material is ready to be rendered for a given mesh.
  135032. * @param mesh The mesh to render
  135033. * @param subMesh The submesh to check against
  135034. * @param useInstances Specify wether or not the material is used with instances
  135035. * @returns true if all the dependencies are ready (Textures, Effects...)
  135036. */
  135037. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135038. /**
  135039. * Compute the primary color according to the chosen perceptual color.
  135040. */
  135041. private _computePrimaryColorFromPerceptualColor;
  135042. /**
  135043. * Compute the highlights and shadow colors according to their chosen levels.
  135044. */
  135045. private _computePrimaryColors;
  135046. /**
  135047. * Build the uniform buffer used in the material.
  135048. */
  135049. buildUniformLayout(): void;
  135050. /**
  135051. * Unbind the material.
  135052. */
  135053. unbind(): void;
  135054. /**
  135055. * Bind only the world matrix to the material.
  135056. * @param world The world matrix to bind.
  135057. */
  135058. bindOnlyWorldMatrix(world: Matrix): void;
  135059. /**
  135060. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135061. * @param world The world matrix to bind.
  135062. * @param subMesh The submesh to bind for.
  135063. */
  135064. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135065. /**
  135066. * Checks to see if a texture is used in the material.
  135067. * @param texture - Base texture to use.
  135068. * @returns - Boolean specifying if a texture is used in the material.
  135069. */
  135070. hasTexture(texture: BaseTexture): boolean;
  135071. /**
  135072. * Dispose the material.
  135073. * @param forceDisposeEffect Force disposal of the associated effect.
  135074. * @param forceDisposeTextures Force disposal of the associated textures.
  135075. */
  135076. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135077. /**
  135078. * Clones the material.
  135079. * @param name The cloned name.
  135080. * @returns The cloned material.
  135081. */
  135082. clone(name: string): BackgroundMaterial;
  135083. /**
  135084. * Serializes the current material to its JSON representation.
  135085. * @returns The JSON representation.
  135086. */
  135087. serialize(): any;
  135088. /**
  135089. * Gets the class name of the material
  135090. * @returns "BackgroundMaterial"
  135091. */
  135092. getClassName(): string;
  135093. /**
  135094. * Parse a JSON input to create back a background material.
  135095. * @param source The JSON data to parse
  135096. * @param scene The scene to create the parsed material in
  135097. * @param rootUrl The root url of the assets the material depends upon
  135098. * @returns the instantiated BackgroundMaterial.
  135099. */
  135100. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135101. }
  135102. }
  135103. declare module BABYLON {
  135104. /**
  135105. * Represents the different options available during the creation of
  135106. * a Environment helper.
  135107. *
  135108. * This can control the default ground, skybox and image processing setup of your scene.
  135109. */
  135110. export interface IEnvironmentHelperOptions {
  135111. /**
  135112. * Specifies whether or not to create a ground.
  135113. * True by default.
  135114. */
  135115. createGround: boolean;
  135116. /**
  135117. * Specifies the ground size.
  135118. * 15 by default.
  135119. */
  135120. groundSize: number;
  135121. /**
  135122. * The texture used on the ground for the main color.
  135123. * Comes from the BabylonJS CDN by default.
  135124. *
  135125. * Remarks: Can be either a texture or a url.
  135126. */
  135127. groundTexture: string | BaseTexture;
  135128. /**
  135129. * The color mixed in the ground texture by default.
  135130. * BabylonJS clearColor by default.
  135131. */
  135132. groundColor: Color3;
  135133. /**
  135134. * Specifies the ground opacity.
  135135. * 1 by default.
  135136. */
  135137. groundOpacity: number;
  135138. /**
  135139. * Enables the ground to receive shadows.
  135140. * True by default.
  135141. */
  135142. enableGroundShadow: boolean;
  135143. /**
  135144. * Helps preventing the shadow to be fully black on the ground.
  135145. * 0.5 by default.
  135146. */
  135147. groundShadowLevel: number;
  135148. /**
  135149. * Creates a mirror texture attach to the ground.
  135150. * false by default.
  135151. */
  135152. enableGroundMirror: boolean;
  135153. /**
  135154. * Specifies the ground mirror size ratio.
  135155. * 0.3 by default as the default kernel is 64.
  135156. */
  135157. groundMirrorSizeRatio: number;
  135158. /**
  135159. * Specifies the ground mirror blur kernel size.
  135160. * 64 by default.
  135161. */
  135162. groundMirrorBlurKernel: number;
  135163. /**
  135164. * Specifies the ground mirror visibility amount.
  135165. * 1 by default
  135166. */
  135167. groundMirrorAmount: number;
  135168. /**
  135169. * Specifies the ground mirror reflectance weight.
  135170. * This uses the standard weight of the background material to setup the fresnel effect
  135171. * of the mirror.
  135172. * 1 by default.
  135173. */
  135174. groundMirrorFresnelWeight: number;
  135175. /**
  135176. * Specifies the ground mirror Falloff distance.
  135177. * This can helps reducing the size of the reflection.
  135178. * 0 by Default.
  135179. */
  135180. groundMirrorFallOffDistance: number;
  135181. /**
  135182. * Specifies the ground mirror texture type.
  135183. * Unsigned Int by Default.
  135184. */
  135185. groundMirrorTextureType: number;
  135186. /**
  135187. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135188. * the shown objects.
  135189. */
  135190. groundYBias: number;
  135191. /**
  135192. * Specifies whether or not to create a skybox.
  135193. * True by default.
  135194. */
  135195. createSkybox: boolean;
  135196. /**
  135197. * Specifies the skybox size.
  135198. * 20 by default.
  135199. */
  135200. skyboxSize: number;
  135201. /**
  135202. * The texture used on the skybox for the main color.
  135203. * Comes from the BabylonJS CDN by default.
  135204. *
  135205. * Remarks: Can be either a texture or a url.
  135206. */
  135207. skyboxTexture: string | BaseTexture;
  135208. /**
  135209. * The color mixed in the skybox texture by default.
  135210. * BabylonJS clearColor by default.
  135211. */
  135212. skyboxColor: Color3;
  135213. /**
  135214. * The background rotation around the Y axis of the scene.
  135215. * This helps aligning the key lights of your scene with the background.
  135216. * 0 by default.
  135217. */
  135218. backgroundYRotation: number;
  135219. /**
  135220. * Compute automatically the size of the elements to best fit with the scene.
  135221. */
  135222. sizeAuto: boolean;
  135223. /**
  135224. * Default position of the rootMesh if autoSize is not true.
  135225. */
  135226. rootPosition: Vector3;
  135227. /**
  135228. * Sets up the image processing in the scene.
  135229. * true by default.
  135230. */
  135231. setupImageProcessing: boolean;
  135232. /**
  135233. * The texture used as your environment texture in the scene.
  135234. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135235. *
  135236. * Remarks: Can be either a texture or a url.
  135237. */
  135238. environmentTexture: string | BaseTexture;
  135239. /**
  135240. * The value of the exposure to apply to the scene.
  135241. * 0.6 by default if setupImageProcessing is true.
  135242. */
  135243. cameraExposure: number;
  135244. /**
  135245. * The value of the contrast to apply to the scene.
  135246. * 1.6 by default if setupImageProcessing is true.
  135247. */
  135248. cameraContrast: number;
  135249. /**
  135250. * Specifies whether or not tonemapping should be enabled in the scene.
  135251. * true by default if setupImageProcessing is true.
  135252. */
  135253. toneMappingEnabled: boolean;
  135254. }
  135255. /**
  135256. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135257. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135258. * It also helps with the default setup of your imageProcessing configuration.
  135259. */
  135260. export class EnvironmentHelper {
  135261. /**
  135262. * Default ground texture URL.
  135263. */
  135264. private static _groundTextureCDNUrl;
  135265. /**
  135266. * Default skybox texture URL.
  135267. */
  135268. private static _skyboxTextureCDNUrl;
  135269. /**
  135270. * Default environment texture URL.
  135271. */
  135272. private static _environmentTextureCDNUrl;
  135273. /**
  135274. * Creates the default options for the helper.
  135275. */
  135276. private static _getDefaultOptions;
  135277. private _rootMesh;
  135278. /**
  135279. * Gets the root mesh created by the helper.
  135280. */
  135281. get rootMesh(): Mesh;
  135282. private _skybox;
  135283. /**
  135284. * Gets the skybox created by the helper.
  135285. */
  135286. get skybox(): Nullable<Mesh>;
  135287. private _skyboxTexture;
  135288. /**
  135289. * Gets the skybox texture created by the helper.
  135290. */
  135291. get skyboxTexture(): Nullable<BaseTexture>;
  135292. private _skyboxMaterial;
  135293. /**
  135294. * Gets the skybox material created by the helper.
  135295. */
  135296. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135297. private _ground;
  135298. /**
  135299. * Gets the ground mesh created by the helper.
  135300. */
  135301. get ground(): Nullable<Mesh>;
  135302. private _groundTexture;
  135303. /**
  135304. * Gets the ground texture created by the helper.
  135305. */
  135306. get groundTexture(): Nullable<BaseTexture>;
  135307. private _groundMirror;
  135308. /**
  135309. * Gets the ground mirror created by the helper.
  135310. */
  135311. get groundMirror(): Nullable<MirrorTexture>;
  135312. /**
  135313. * Gets the ground mirror render list to helps pushing the meshes
  135314. * you wish in the ground reflection.
  135315. */
  135316. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135317. private _groundMaterial;
  135318. /**
  135319. * Gets the ground material created by the helper.
  135320. */
  135321. get groundMaterial(): Nullable<BackgroundMaterial>;
  135322. /**
  135323. * Stores the creation options.
  135324. */
  135325. private readonly _scene;
  135326. private _options;
  135327. /**
  135328. * This observable will be notified with any error during the creation of the environment,
  135329. * mainly texture creation errors.
  135330. */
  135331. onErrorObservable: Observable<{
  135332. message?: string;
  135333. exception?: any;
  135334. }>;
  135335. /**
  135336. * constructor
  135337. * @param options Defines the options we want to customize the helper
  135338. * @param scene The scene to add the material to
  135339. */
  135340. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135341. /**
  135342. * Updates the background according to the new options
  135343. * @param options
  135344. */
  135345. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135346. /**
  135347. * Sets the primary color of all the available elements.
  135348. * @param color the main color to affect to the ground and the background
  135349. */
  135350. setMainColor(color: Color3): void;
  135351. /**
  135352. * Setup the image processing according to the specified options.
  135353. */
  135354. private _setupImageProcessing;
  135355. /**
  135356. * Setup the environment texture according to the specified options.
  135357. */
  135358. private _setupEnvironmentTexture;
  135359. /**
  135360. * Setup the background according to the specified options.
  135361. */
  135362. private _setupBackground;
  135363. /**
  135364. * Get the scene sizes according to the setup.
  135365. */
  135366. private _getSceneSize;
  135367. /**
  135368. * Setup the ground according to the specified options.
  135369. */
  135370. private _setupGround;
  135371. /**
  135372. * Setup the ground material according to the specified options.
  135373. */
  135374. private _setupGroundMaterial;
  135375. /**
  135376. * Setup the ground diffuse texture according to the specified options.
  135377. */
  135378. private _setupGroundDiffuseTexture;
  135379. /**
  135380. * Setup the ground mirror texture according to the specified options.
  135381. */
  135382. private _setupGroundMirrorTexture;
  135383. /**
  135384. * Setup the ground to receive the mirror texture.
  135385. */
  135386. private _setupMirrorInGroundMaterial;
  135387. /**
  135388. * Setup the skybox according to the specified options.
  135389. */
  135390. private _setupSkybox;
  135391. /**
  135392. * Setup the skybox material according to the specified options.
  135393. */
  135394. private _setupSkyboxMaterial;
  135395. /**
  135396. * Setup the skybox reflection texture according to the specified options.
  135397. */
  135398. private _setupSkyboxReflectionTexture;
  135399. private _errorHandler;
  135400. /**
  135401. * Dispose all the elements created by the Helper.
  135402. */
  135403. dispose(): void;
  135404. }
  135405. }
  135406. declare module BABYLON {
  135407. /**
  135408. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135409. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135410. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135411. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135412. */
  135413. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135414. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135415. /**
  135416. * Define the source as a Monoscopic panoramic 360/180.
  135417. */
  135418. static readonly MODE_MONOSCOPIC: number;
  135419. /**
  135420. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135421. */
  135422. static readonly MODE_TOPBOTTOM: number;
  135423. /**
  135424. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135425. */
  135426. static readonly MODE_SIDEBYSIDE: number;
  135427. private _halfDome;
  135428. protected _useDirectMapping: boolean;
  135429. /**
  135430. * The texture being displayed on the sphere
  135431. */
  135432. protected _texture: T;
  135433. /**
  135434. * Gets the texture being displayed on the sphere
  135435. */
  135436. get texture(): T;
  135437. /**
  135438. * Sets the texture being displayed on the sphere
  135439. */
  135440. set texture(newTexture: T);
  135441. /**
  135442. * The skybox material
  135443. */
  135444. protected _material: BackgroundMaterial;
  135445. /**
  135446. * The surface used for the dome
  135447. */
  135448. protected _mesh: Mesh;
  135449. /**
  135450. * Gets the mesh used for the dome.
  135451. */
  135452. get mesh(): Mesh;
  135453. /**
  135454. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135455. */
  135456. private _halfDomeMask;
  135457. /**
  135458. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135459. * Also see the options.resolution property.
  135460. */
  135461. get fovMultiplier(): number;
  135462. set fovMultiplier(value: number);
  135463. protected _textureMode: number;
  135464. /**
  135465. * Gets or set the current texture mode for the texture. It can be:
  135466. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135467. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135468. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135469. */
  135470. get textureMode(): number;
  135471. /**
  135472. * Sets the current texture mode for the texture. It can be:
  135473. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135474. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135475. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135476. */
  135477. set textureMode(value: number);
  135478. /**
  135479. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135480. */
  135481. get halfDome(): boolean;
  135482. /**
  135483. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135484. */
  135485. set halfDome(enabled: boolean);
  135486. /**
  135487. * Oberserver used in Stereoscopic VR Mode.
  135488. */
  135489. private _onBeforeCameraRenderObserver;
  135490. /**
  135491. * Observable raised when an error occured while loading the 360 image
  135492. */
  135493. onLoadErrorObservable: Observable<string>;
  135494. /**
  135495. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135496. * @param name Element's name, child elements will append suffixes for their own names.
  135497. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135498. * @param options An object containing optional or exposed sub element properties
  135499. */
  135500. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135501. resolution?: number;
  135502. clickToPlay?: boolean;
  135503. autoPlay?: boolean;
  135504. loop?: boolean;
  135505. size?: number;
  135506. poster?: string;
  135507. faceForward?: boolean;
  135508. useDirectMapping?: boolean;
  135509. halfDomeMode?: boolean;
  135510. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135511. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135512. protected _changeTextureMode(value: number): void;
  135513. /**
  135514. * Releases resources associated with this node.
  135515. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135516. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135517. */
  135518. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135519. }
  135520. }
  135521. declare module BABYLON {
  135522. /**
  135523. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135524. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135525. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135526. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135527. */
  135528. export class PhotoDome extends TextureDome<Texture> {
  135529. /**
  135530. * Define the image as a Monoscopic panoramic 360 image.
  135531. */
  135532. static readonly MODE_MONOSCOPIC: number;
  135533. /**
  135534. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135535. */
  135536. static readonly MODE_TOPBOTTOM: number;
  135537. /**
  135538. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135539. */
  135540. static readonly MODE_SIDEBYSIDE: number;
  135541. /**
  135542. * Gets or sets the texture being displayed on the sphere
  135543. */
  135544. get photoTexture(): Texture;
  135545. /**
  135546. * sets the texture being displayed on the sphere
  135547. */
  135548. set photoTexture(value: Texture);
  135549. /**
  135550. * Gets the current video mode for the video. It can be:
  135551. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135552. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135553. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135554. */
  135555. get imageMode(): number;
  135556. /**
  135557. * Sets the current video mode for the video. It can be:
  135558. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135559. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135560. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135561. */
  135562. set imageMode(value: number);
  135563. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135564. }
  135565. }
  135566. declare module BABYLON {
  135567. /**
  135568. * Class used to host RGBD texture specific utilities
  135569. */
  135570. export class RGBDTextureTools {
  135571. /**
  135572. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135573. * @param texture the texture to expand.
  135574. */
  135575. static ExpandRGBDTexture(texture: Texture): void;
  135576. }
  135577. }
  135578. declare module BABYLON {
  135579. /**
  135580. * Class used to host texture specific utilities
  135581. */
  135582. export class BRDFTextureTools {
  135583. /**
  135584. * Prevents texture cache collision
  135585. */
  135586. private static _instanceNumber;
  135587. /**
  135588. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135589. * @param scene defines the hosting scene
  135590. * @returns the environment BRDF texture
  135591. */
  135592. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135593. private static _environmentBRDFBase64Texture;
  135594. }
  135595. }
  135596. declare module BABYLON {
  135597. /**
  135598. * @hidden
  135599. */
  135600. export interface IMaterialClearCoatDefines {
  135601. CLEARCOAT: boolean;
  135602. CLEARCOAT_DEFAULTIOR: boolean;
  135603. CLEARCOAT_TEXTURE: boolean;
  135604. CLEARCOAT_TEXTUREDIRECTUV: number;
  135605. CLEARCOAT_BUMP: boolean;
  135606. CLEARCOAT_BUMPDIRECTUV: number;
  135607. CLEARCOAT_TINT: boolean;
  135608. CLEARCOAT_TINT_TEXTURE: boolean;
  135609. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135610. /** @hidden */
  135611. _areTexturesDirty: boolean;
  135612. }
  135613. /**
  135614. * Define the code related to the clear coat parameters of the pbr material.
  135615. */
  135616. export class PBRClearCoatConfiguration {
  135617. /**
  135618. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135619. * The default fits with a polyurethane material.
  135620. */
  135621. private static readonly _DefaultIndexOfRefraction;
  135622. private _isEnabled;
  135623. /**
  135624. * Defines if the clear coat is enabled in the material.
  135625. */
  135626. isEnabled: boolean;
  135627. /**
  135628. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  135629. */
  135630. intensity: number;
  135631. /**
  135632. * Defines the clear coat layer roughness.
  135633. */
  135634. roughness: number;
  135635. private _indexOfRefraction;
  135636. /**
  135637. * Defines the index of refraction of the clear coat.
  135638. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  135639. * The default fits with a polyurethane material.
  135640. * Changing the default value is more performance intensive.
  135641. */
  135642. indexOfRefraction: number;
  135643. private _texture;
  135644. /**
  135645. * Stores the clear coat values in a texture.
  135646. */
  135647. texture: Nullable<BaseTexture>;
  135648. private _bumpTexture;
  135649. /**
  135650. * Define the clear coat specific bump texture.
  135651. */
  135652. bumpTexture: Nullable<BaseTexture>;
  135653. private _isTintEnabled;
  135654. /**
  135655. * Defines if the clear coat tint is enabled in the material.
  135656. */
  135657. isTintEnabled: boolean;
  135658. /**
  135659. * Defines the clear coat tint of the material.
  135660. * This is only use if tint is enabled
  135661. */
  135662. tintColor: Color3;
  135663. /**
  135664. * Defines the distance at which the tint color should be found in the
  135665. * clear coat media.
  135666. * This is only use if tint is enabled
  135667. */
  135668. tintColorAtDistance: number;
  135669. /**
  135670. * Defines the clear coat layer thickness.
  135671. * This is only use if tint is enabled
  135672. */
  135673. tintThickness: number;
  135674. private _tintTexture;
  135675. /**
  135676. * Stores the clear tint values in a texture.
  135677. * rgb is tint
  135678. * a is a thickness factor
  135679. */
  135680. tintTexture: Nullable<BaseTexture>;
  135681. /** @hidden */
  135682. private _internalMarkAllSubMeshesAsTexturesDirty;
  135683. /** @hidden */
  135684. _markAllSubMeshesAsTexturesDirty(): void;
  135685. /**
  135686. * Instantiate a new istance of clear coat configuration.
  135687. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135688. */
  135689. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135690. /**
  135691. * Gets wehter the submesh is ready to be used or not.
  135692. * @param defines the list of "defines" to update.
  135693. * @param scene defines the scene the material belongs to.
  135694. * @param engine defines the engine the material belongs to.
  135695. * @param disableBumpMap defines wether the material disables bump or not.
  135696. * @returns - boolean indicating that the submesh is ready or not.
  135697. */
  135698. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  135699. /**
  135700. * Checks to see if a texture is used in the material.
  135701. * @param defines the list of "defines" to update.
  135702. * @param scene defines the scene to the material belongs to.
  135703. */
  135704. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  135705. /**
  135706. * Binds the material data.
  135707. * @param uniformBuffer defines the Uniform buffer to fill in.
  135708. * @param scene defines the scene the material belongs to.
  135709. * @param engine defines the engine the material belongs to.
  135710. * @param disableBumpMap defines wether the material disables bump or not.
  135711. * @param isFrozen defines wether the material is frozen or not.
  135712. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  135713. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  135714. */
  135715. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  135716. /**
  135717. * Checks to see if a texture is used in the material.
  135718. * @param texture - Base texture to use.
  135719. * @returns - Boolean specifying if a texture is used in the material.
  135720. */
  135721. hasTexture(texture: BaseTexture): boolean;
  135722. /**
  135723. * Returns an array of the actively used textures.
  135724. * @param activeTextures Array of BaseTextures
  135725. */
  135726. getActiveTextures(activeTextures: BaseTexture[]): void;
  135727. /**
  135728. * Returns the animatable textures.
  135729. * @param animatables Array of animatable textures.
  135730. */
  135731. getAnimatables(animatables: IAnimatable[]): void;
  135732. /**
  135733. * Disposes the resources of the material.
  135734. * @param forceDisposeTextures - Forces the disposal of all textures.
  135735. */
  135736. dispose(forceDisposeTextures?: boolean): void;
  135737. /**
  135738. * Get the current class name of the texture useful for serialization or dynamic coding.
  135739. * @returns "PBRClearCoatConfiguration"
  135740. */
  135741. getClassName(): string;
  135742. /**
  135743. * Add fallbacks to the effect fallbacks list.
  135744. * @param defines defines the Base texture to use.
  135745. * @param fallbacks defines the current fallback list.
  135746. * @param currentRank defines the current fallback rank.
  135747. * @returns the new fallback rank.
  135748. */
  135749. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135750. /**
  135751. * Add the required uniforms to the current list.
  135752. * @param uniforms defines the current uniform list.
  135753. */
  135754. static AddUniforms(uniforms: string[]): void;
  135755. /**
  135756. * Add the required samplers to the current list.
  135757. * @param samplers defines the current sampler list.
  135758. */
  135759. static AddSamplers(samplers: string[]): void;
  135760. /**
  135761. * Add the required uniforms to the current buffer.
  135762. * @param uniformBuffer defines the current uniform buffer.
  135763. */
  135764. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135765. /**
  135766. * Makes a duplicate of the current configuration into another one.
  135767. * @param clearCoatConfiguration define the config where to copy the info
  135768. */
  135769. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  135770. /**
  135771. * Serializes this clear coat configuration.
  135772. * @returns - An object with the serialized config.
  135773. */
  135774. serialize(): any;
  135775. /**
  135776. * Parses a anisotropy Configuration from a serialized object.
  135777. * @param source - Serialized object.
  135778. * @param scene Defines the scene we are parsing for
  135779. * @param rootUrl Defines the rootUrl to load from
  135780. */
  135781. parse(source: any, scene: Scene, rootUrl: string): void;
  135782. }
  135783. }
  135784. declare module BABYLON {
  135785. /**
  135786. * @hidden
  135787. */
  135788. export interface IMaterialAnisotropicDefines {
  135789. ANISOTROPIC: boolean;
  135790. ANISOTROPIC_TEXTURE: boolean;
  135791. ANISOTROPIC_TEXTUREDIRECTUV: number;
  135792. MAINUV1: boolean;
  135793. _areTexturesDirty: boolean;
  135794. _needUVs: boolean;
  135795. }
  135796. /**
  135797. * Define the code related to the anisotropic parameters of the pbr material.
  135798. */
  135799. export class PBRAnisotropicConfiguration {
  135800. private _isEnabled;
  135801. /**
  135802. * Defines if the anisotropy is enabled in the material.
  135803. */
  135804. isEnabled: boolean;
  135805. /**
  135806. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  135807. */
  135808. intensity: number;
  135809. /**
  135810. * Defines if the effect is along the tangents, bitangents or in between.
  135811. * By default, the effect is "strectching" the highlights along the tangents.
  135812. */
  135813. direction: Vector2;
  135814. private _texture;
  135815. /**
  135816. * Stores the anisotropy values in a texture.
  135817. * rg is direction (like normal from -1 to 1)
  135818. * b is a intensity
  135819. */
  135820. texture: Nullable<BaseTexture>;
  135821. /** @hidden */
  135822. private _internalMarkAllSubMeshesAsTexturesDirty;
  135823. /** @hidden */
  135824. _markAllSubMeshesAsTexturesDirty(): void;
  135825. /**
  135826. * Instantiate a new istance of anisotropy configuration.
  135827. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  135828. */
  135829. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  135830. /**
  135831. * Specifies that the submesh is ready to be used.
  135832. * @param defines the list of "defines" to update.
  135833. * @param scene defines the scene the material belongs to.
  135834. * @returns - boolean indicating that the submesh is ready or not.
  135835. */
  135836. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  135837. /**
  135838. * Checks to see if a texture is used in the material.
  135839. * @param defines the list of "defines" to update.
  135840. * @param mesh the mesh we are preparing the defines for.
  135841. * @param scene defines the scene the material belongs to.
  135842. */
  135843. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  135844. /**
  135845. * Binds the material data.
  135846. * @param uniformBuffer defines the Uniform buffer to fill in.
  135847. * @param scene defines the scene the material belongs to.
  135848. * @param isFrozen defines wether the material is frozen or not.
  135849. */
  135850. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  135851. /**
  135852. * Checks to see if a texture is used in the material.
  135853. * @param texture - Base texture to use.
  135854. * @returns - Boolean specifying if a texture is used in the material.
  135855. */
  135856. hasTexture(texture: BaseTexture): boolean;
  135857. /**
  135858. * Returns an array of the actively used textures.
  135859. * @param activeTextures Array of BaseTextures
  135860. */
  135861. getActiveTextures(activeTextures: BaseTexture[]): void;
  135862. /**
  135863. * Returns the animatable textures.
  135864. * @param animatables Array of animatable textures.
  135865. */
  135866. getAnimatables(animatables: IAnimatable[]): void;
  135867. /**
  135868. * Disposes the resources of the material.
  135869. * @param forceDisposeTextures - Forces the disposal of all textures.
  135870. */
  135871. dispose(forceDisposeTextures?: boolean): void;
  135872. /**
  135873. * Get the current class name of the texture useful for serialization or dynamic coding.
  135874. * @returns "PBRAnisotropicConfiguration"
  135875. */
  135876. getClassName(): string;
  135877. /**
  135878. * Add fallbacks to the effect fallbacks list.
  135879. * @param defines defines the Base texture to use.
  135880. * @param fallbacks defines the current fallback list.
  135881. * @param currentRank defines the current fallback rank.
  135882. * @returns the new fallback rank.
  135883. */
  135884. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  135885. /**
  135886. * Add the required uniforms to the current list.
  135887. * @param uniforms defines the current uniform list.
  135888. */
  135889. static AddUniforms(uniforms: string[]): void;
  135890. /**
  135891. * Add the required uniforms to the current buffer.
  135892. * @param uniformBuffer defines the current uniform buffer.
  135893. */
  135894. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  135895. /**
  135896. * Add the required samplers to the current list.
  135897. * @param samplers defines the current sampler list.
  135898. */
  135899. static AddSamplers(samplers: string[]): void;
  135900. /**
  135901. * Makes a duplicate of the current configuration into another one.
  135902. * @param anisotropicConfiguration define the config where to copy the info
  135903. */
  135904. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  135905. /**
  135906. * Serializes this anisotropy configuration.
  135907. * @returns - An object with the serialized config.
  135908. */
  135909. serialize(): any;
  135910. /**
  135911. * Parses a anisotropy Configuration from a serialized object.
  135912. * @param source - Serialized object.
  135913. * @param scene Defines the scene we are parsing for
  135914. * @param rootUrl Defines the rootUrl to load from
  135915. */
  135916. parse(source: any, scene: Scene, rootUrl: string): void;
  135917. }
  135918. }
  135919. declare module BABYLON {
  135920. /**
  135921. * @hidden
  135922. */
  135923. export interface IMaterialBRDFDefines {
  135924. BRDF_V_HEIGHT_CORRELATED: boolean;
  135925. MS_BRDF_ENERGY_CONSERVATION: boolean;
  135926. SPHERICAL_HARMONICS: boolean;
  135927. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  135928. /** @hidden */
  135929. _areMiscDirty: boolean;
  135930. }
  135931. /**
  135932. * Define the code related to the BRDF parameters of the pbr material.
  135933. */
  135934. export class PBRBRDFConfiguration {
  135935. /**
  135936. * Default value used for the energy conservation.
  135937. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135938. */
  135939. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  135940. /**
  135941. * Default value used for the Smith Visibility Height Correlated mode.
  135942. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  135943. */
  135944. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  135945. /**
  135946. * Default value used for the IBL diffuse part.
  135947. * This can help switching back to the polynomials mode globally which is a tiny bit
  135948. * less GPU intensive at the drawback of a lower quality.
  135949. */
  135950. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  135951. /**
  135952. * Default value used for activating energy conservation for the specular workflow.
  135953. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135954. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135955. */
  135956. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  135957. private _useEnergyConservation;
  135958. /**
  135959. * Defines if the material uses energy conservation.
  135960. */
  135961. useEnergyConservation: boolean;
  135962. private _useSmithVisibilityHeightCorrelated;
  135963. /**
  135964. * LEGACY Mode set to false
  135965. * Defines if the material uses height smith correlated visibility term.
  135966. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  135967. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  135968. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  135969. * Not relying on height correlated will also disable energy conservation.
  135970. */
  135971. useSmithVisibilityHeightCorrelated: boolean;
  135972. private _useSphericalHarmonics;
  135973. /**
  135974. * LEGACY Mode set to false
  135975. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  135976. * diffuse part of the IBL.
  135977. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  135978. * to the ground truth.
  135979. */
  135980. useSphericalHarmonics: boolean;
  135981. private _useSpecularGlossinessInputEnergyConservation;
  135982. /**
  135983. * Defines if the material uses energy conservation, when the specular workflow is active.
  135984. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  135985. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  135986. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  135987. */
  135988. useSpecularGlossinessInputEnergyConservation: boolean;
  135989. /** @hidden */
  135990. private _internalMarkAllSubMeshesAsMiscDirty;
  135991. /** @hidden */
  135992. _markAllSubMeshesAsMiscDirty(): void;
  135993. /**
  135994. * Instantiate a new istance of clear coat configuration.
  135995. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  135996. */
  135997. constructor(markAllSubMeshesAsMiscDirty: () => void);
  135998. /**
  135999. * Checks to see if a texture is used in the material.
  136000. * @param defines the list of "defines" to update.
  136001. */
  136002. prepareDefines(defines: IMaterialBRDFDefines): void;
  136003. /**
  136004. * Get the current class name of the texture useful for serialization or dynamic coding.
  136005. * @returns "PBRClearCoatConfiguration"
  136006. */
  136007. getClassName(): string;
  136008. /**
  136009. * Makes a duplicate of the current configuration into another one.
  136010. * @param brdfConfiguration define the config where to copy the info
  136011. */
  136012. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136013. /**
  136014. * Serializes this BRDF configuration.
  136015. * @returns - An object with the serialized config.
  136016. */
  136017. serialize(): any;
  136018. /**
  136019. * Parses a anisotropy Configuration from a serialized object.
  136020. * @param source - Serialized object.
  136021. * @param scene Defines the scene we are parsing for
  136022. * @param rootUrl Defines the rootUrl to load from
  136023. */
  136024. parse(source: any, scene: Scene, rootUrl: string): void;
  136025. }
  136026. }
  136027. declare module BABYLON {
  136028. /**
  136029. * @hidden
  136030. */
  136031. export interface IMaterialSheenDefines {
  136032. SHEEN: boolean;
  136033. SHEEN_TEXTURE: boolean;
  136034. SHEEN_TEXTUREDIRECTUV: number;
  136035. SHEEN_LINKWITHALBEDO: boolean;
  136036. SHEEN_ROUGHNESS: boolean;
  136037. SHEEN_ALBEDOSCALING: boolean;
  136038. /** @hidden */
  136039. _areTexturesDirty: boolean;
  136040. }
  136041. /**
  136042. * Define the code related to the Sheen parameters of the pbr material.
  136043. */
  136044. export class PBRSheenConfiguration {
  136045. private _isEnabled;
  136046. /**
  136047. * Defines if the material uses sheen.
  136048. */
  136049. isEnabled: boolean;
  136050. private _linkSheenWithAlbedo;
  136051. /**
  136052. * Defines if the sheen is linked to the sheen color.
  136053. */
  136054. linkSheenWithAlbedo: boolean;
  136055. /**
  136056. * Defines the sheen intensity.
  136057. */
  136058. intensity: number;
  136059. /**
  136060. * Defines the sheen color.
  136061. */
  136062. color: Color3;
  136063. private _texture;
  136064. /**
  136065. * Stores the sheen tint values in a texture.
  136066. * rgb is tint
  136067. * a is a intensity or roughness if roughness has been defined
  136068. */
  136069. texture: Nullable<BaseTexture>;
  136070. private _roughness;
  136071. /**
  136072. * Defines the sheen roughness.
  136073. * It is not taken into account if linkSheenWithAlbedo is true.
  136074. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136075. */
  136076. roughness: Nullable<number>;
  136077. private _albedoScaling;
  136078. /**
  136079. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136080. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136081. * making it easier to setup and tweak the effect
  136082. */
  136083. albedoScaling: boolean;
  136084. /** @hidden */
  136085. private _internalMarkAllSubMeshesAsTexturesDirty;
  136086. /** @hidden */
  136087. _markAllSubMeshesAsTexturesDirty(): void;
  136088. /**
  136089. * Instantiate a new istance of clear coat configuration.
  136090. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136091. */
  136092. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136093. /**
  136094. * Specifies that the submesh is ready to be used.
  136095. * @param defines the list of "defines" to update.
  136096. * @param scene defines the scene the material belongs to.
  136097. * @returns - boolean indicating that the submesh is ready or not.
  136098. */
  136099. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136100. /**
  136101. * Checks to see if a texture is used in the material.
  136102. * @param defines the list of "defines" to update.
  136103. * @param scene defines the scene the material belongs to.
  136104. */
  136105. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136106. /**
  136107. * Binds the material data.
  136108. * @param uniformBuffer defines the Uniform buffer to fill in.
  136109. * @param scene defines the scene the material belongs to.
  136110. * @param isFrozen defines wether the material is frozen or not.
  136111. */
  136112. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136113. /**
  136114. * Checks to see if a texture is used in the material.
  136115. * @param texture - Base texture to use.
  136116. * @returns - Boolean specifying if a texture is used in the material.
  136117. */
  136118. hasTexture(texture: BaseTexture): boolean;
  136119. /**
  136120. * Returns an array of the actively used textures.
  136121. * @param activeTextures Array of BaseTextures
  136122. */
  136123. getActiveTextures(activeTextures: BaseTexture[]): void;
  136124. /**
  136125. * Returns the animatable textures.
  136126. * @param animatables Array of animatable textures.
  136127. */
  136128. getAnimatables(animatables: IAnimatable[]): void;
  136129. /**
  136130. * Disposes the resources of the material.
  136131. * @param forceDisposeTextures - Forces the disposal of all textures.
  136132. */
  136133. dispose(forceDisposeTextures?: boolean): void;
  136134. /**
  136135. * Get the current class name of the texture useful for serialization or dynamic coding.
  136136. * @returns "PBRSheenConfiguration"
  136137. */
  136138. getClassName(): string;
  136139. /**
  136140. * Add fallbacks to the effect fallbacks list.
  136141. * @param defines defines the Base texture to use.
  136142. * @param fallbacks defines the current fallback list.
  136143. * @param currentRank defines the current fallback rank.
  136144. * @returns the new fallback rank.
  136145. */
  136146. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136147. /**
  136148. * Add the required uniforms to the current list.
  136149. * @param uniforms defines the current uniform list.
  136150. */
  136151. static AddUniforms(uniforms: string[]): void;
  136152. /**
  136153. * Add the required uniforms to the current buffer.
  136154. * @param uniformBuffer defines the current uniform buffer.
  136155. */
  136156. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136157. /**
  136158. * Add the required samplers to the current list.
  136159. * @param samplers defines the current sampler list.
  136160. */
  136161. static AddSamplers(samplers: string[]): void;
  136162. /**
  136163. * Makes a duplicate of the current configuration into another one.
  136164. * @param sheenConfiguration define the config where to copy the info
  136165. */
  136166. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136167. /**
  136168. * Serializes this BRDF configuration.
  136169. * @returns - An object with the serialized config.
  136170. */
  136171. serialize(): any;
  136172. /**
  136173. * Parses a anisotropy Configuration from a serialized object.
  136174. * @param source - Serialized object.
  136175. * @param scene Defines the scene we are parsing for
  136176. * @param rootUrl Defines the rootUrl to load from
  136177. */
  136178. parse(source: any, scene: Scene, rootUrl: string): void;
  136179. }
  136180. }
  136181. declare module BABYLON {
  136182. /**
  136183. * @hidden
  136184. */
  136185. export interface IMaterialSubSurfaceDefines {
  136186. SUBSURFACE: boolean;
  136187. SS_REFRACTION: boolean;
  136188. SS_TRANSLUCENCY: boolean;
  136189. SS_SCATTERING: boolean;
  136190. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136191. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136192. SS_REFRACTIONMAP_3D: boolean;
  136193. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136194. SS_LODINREFRACTIONALPHA: boolean;
  136195. SS_GAMMAREFRACTION: boolean;
  136196. SS_RGBDREFRACTION: boolean;
  136197. SS_LINEARSPECULARREFRACTION: boolean;
  136198. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136199. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136200. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136201. /** @hidden */
  136202. _areTexturesDirty: boolean;
  136203. }
  136204. /**
  136205. * Define the code related to the sub surface parameters of the pbr material.
  136206. */
  136207. export class PBRSubSurfaceConfiguration {
  136208. private _isRefractionEnabled;
  136209. /**
  136210. * Defines if the refraction is enabled in the material.
  136211. */
  136212. isRefractionEnabled: boolean;
  136213. private _isTranslucencyEnabled;
  136214. /**
  136215. * Defines if the translucency is enabled in the material.
  136216. */
  136217. isTranslucencyEnabled: boolean;
  136218. private _isScatteringEnabled;
  136219. /**
  136220. * Defines if the sub surface scattering is enabled in the material.
  136221. */
  136222. isScatteringEnabled: boolean;
  136223. private _scatteringDiffusionProfileIndex;
  136224. /**
  136225. * Diffusion profile for subsurface scattering.
  136226. * Useful for better scattering in the skins or foliages.
  136227. */
  136228. get scatteringDiffusionProfile(): Nullable<Color3>;
  136229. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136230. /**
  136231. * Defines the refraction intensity of the material.
  136232. * The refraction when enabled replaces the Diffuse part of the material.
  136233. * The intensity helps transitionning between diffuse and refraction.
  136234. */
  136235. refractionIntensity: number;
  136236. /**
  136237. * Defines the translucency intensity of the material.
  136238. * When translucency has been enabled, this defines how much of the "translucency"
  136239. * is addded to the diffuse part of the material.
  136240. */
  136241. translucencyIntensity: number;
  136242. /**
  136243. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136244. */
  136245. useAlbedoToTintRefraction: boolean;
  136246. private _thicknessTexture;
  136247. /**
  136248. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136249. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136250. * 0 would mean minimumThickness
  136251. * 1 would mean maximumThickness
  136252. * The other channels might be use as a mask to vary the different effects intensity.
  136253. */
  136254. thicknessTexture: Nullable<BaseTexture>;
  136255. private _refractionTexture;
  136256. /**
  136257. * Defines the texture to use for refraction.
  136258. */
  136259. refractionTexture: Nullable<BaseTexture>;
  136260. private _indexOfRefraction;
  136261. /**
  136262. * Index of refraction of the material base layer.
  136263. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136264. *
  136265. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136266. *
  136267. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136268. */
  136269. indexOfRefraction: number;
  136270. private _volumeIndexOfRefraction;
  136271. /**
  136272. * Index of refraction of the material's volume.
  136273. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136274. *
  136275. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136276. * the volume will use the same IOR as the surface.
  136277. */
  136278. get volumeIndexOfRefraction(): number;
  136279. set volumeIndexOfRefraction(value: number);
  136280. private _invertRefractionY;
  136281. /**
  136282. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136283. */
  136284. invertRefractionY: boolean;
  136285. private _linkRefractionWithTransparency;
  136286. /**
  136287. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136288. * Materials half opaque for instance using refraction could benefit from this control.
  136289. */
  136290. linkRefractionWithTransparency: boolean;
  136291. /**
  136292. * Defines the minimum thickness stored in the thickness map.
  136293. * If no thickness map is defined, this value will be used to simulate thickness.
  136294. */
  136295. minimumThickness: number;
  136296. /**
  136297. * Defines the maximum thickness stored in the thickness map.
  136298. */
  136299. maximumThickness: number;
  136300. /**
  136301. * Defines the volume tint of the material.
  136302. * This is used for both translucency and scattering.
  136303. */
  136304. tintColor: Color3;
  136305. /**
  136306. * Defines the distance at which the tint color should be found in the media.
  136307. * This is used for refraction only.
  136308. */
  136309. tintColorAtDistance: number;
  136310. /**
  136311. * Defines how far each channel transmit through the media.
  136312. * It is defined as a color to simplify it selection.
  136313. */
  136314. diffusionDistance: Color3;
  136315. private _useMaskFromThicknessTexture;
  136316. /**
  136317. * Stores the intensity of the different subsurface effects in the thickness texture.
  136318. * * the green channel is the translucency intensity.
  136319. * * the blue channel is the scattering intensity.
  136320. * * the alpha channel is the refraction intensity.
  136321. */
  136322. useMaskFromThicknessTexture: boolean;
  136323. private _scene;
  136324. /** @hidden */
  136325. private _internalMarkAllSubMeshesAsTexturesDirty;
  136326. private _internalMarkScenePrePassDirty;
  136327. /** @hidden */
  136328. _markAllSubMeshesAsTexturesDirty(): void;
  136329. /** @hidden */
  136330. _markScenePrePassDirty(): void;
  136331. /**
  136332. * Instantiate a new istance of sub surface configuration.
  136333. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136334. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136335. * @param scene The scene
  136336. */
  136337. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136338. /**
  136339. * Gets wehter the submesh is ready to be used or not.
  136340. * @param defines the list of "defines" to update.
  136341. * @param scene defines the scene the material belongs to.
  136342. * @returns - boolean indicating that the submesh is ready or not.
  136343. */
  136344. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136345. /**
  136346. * Checks to see if a texture is used in the material.
  136347. * @param defines the list of "defines" to update.
  136348. * @param scene defines the scene to the material belongs to.
  136349. */
  136350. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136351. /**
  136352. * Binds the material data.
  136353. * @param uniformBuffer defines the Uniform buffer to fill in.
  136354. * @param scene defines the scene the material belongs to.
  136355. * @param engine defines the engine the material belongs to.
  136356. * @param isFrozen defines whether the material is frozen or not.
  136357. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136358. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136359. */
  136360. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136361. /**
  136362. * Unbinds the material from the mesh.
  136363. * @param activeEffect defines the effect that should be unbound from.
  136364. * @returns true if unbound, otherwise false
  136365. */
  136366. unbind(activeEffect: Effect): boolean;
  136367. /**
  136368. * Returns the texture used for refraction or null if none is used.
  136369. * @param scene defines the scene the material belongs to.
  136370. * @returns - Refraction texture if present. If no refraction texture and refraction
  136371. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136372. */
  136373. private _getRefractionTexture;
  136374. /**
  136375. * Returns true if alpha blending should be disabled.
  136376. */
  136377. get disableAlphaBlending(): boolean;
  136378. /**
  136379. * Fills the list of render target textures.
  136380. * @param renderTargets the list of render targets to update
  136381. */
  136382. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136383. /**
  136384. * Checks to see if a texture is used in the material.
  136385. * @param texture - Base texture to use.
  136386. * @returns - Boolean specifying if a texture is used in the material.
  136387. */
  136388. hasTexture(texture: BaseTexture): boolean;
  136389. /**
  136390. * Gets a boolean indicating that current material needs to register RTT
  136391. * @returns true if this uses a render target otherwise false.
  136392. */
  136393. hasRenderTargetTextures(): boolean;
  136394. /**
  136395. * Returns an array of the actively used textures.
  136396. * @param activeTextures Array of BaseTextures
  136397. */
  136398. getActiveTextures(activeTextures: BaseTexture[]): void;
  136399. /**
  136400. * Returns the animatable textures.
  136401. * @param animatables Array of animatable textures.
  136402. */
  136403. getAnimatables(animatables: IAnimatable[]): void;
  136404. /**
  136405. * Disposes the resources of the material.
  136406. * @param forceDisposeTextures - Forces the disposal of all textures.
  136407. */
  136408. dispose(forceDisposeTextures?: boolean): void;
  136409. /**
  136410. * Get the current class name of the texture useful for serialization or dynamic coding.
  136411. * @returns "PBRSubSurfaceConfiguration"
  136412. */
  136413. getClassName(): string;
  136414. /**
  136415. * Add fallbacks to the effect fallbacks list.
  136416. * @param defines defines the Base texture to use.
  136417. * @param fallbacks defines the current fallback list.
  136418. * @param currentRank defines the current fallback rank.
  136419. * @returns the new fallback rank.
  136420. */
  136421. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136422. /**
  136423. * Add the required uniforms to the current list.
  136424. * @param uniforms defines the current uniform list.
  136425. */
  136426. static AddUniforms(uniforms: string[]): void;
  136427. /**
  136428. * Add the required samplers to the current list.
  136429. * @param samplers defines the current sampler list.
  136430. */
  136431. static AddSamplers(samplers: string[]): void;
  136432. /**
  136433. * Add the required uniforms to the current buffer.
  136434. * @param uniformBuffer defines the current uniform buffer.
  136435. */
  136436. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136437. /**
  136438. * Makes a duplicate of the current configuration into another one.
  136439. * @param configuration define the config where to copy the info
  136440. */
  136441. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136442. /**
  136443. * Serializes this Sub Surface configuration.
  136444. * @returns - An object with the serialized config.
  136445. */
  136446. serialize(): any;
  136447. /**
  136448. * Parses a anisotropy Configuration from a serialized object.
  136449. * @param source - Serialized object.
  136450. * @param scene Defines the scene we are parsing for
  136451. * @param rootUrl Defines the rootUrl to load from
  136452. */
  136453. parse(source: any, scene: Scene, rootUrl: string): void;
  136454. }
  136455. }
  136456. declare module BABYLON {
  136457. /** @hidden */
  136458. export var pbrFragmentDeclaration: {
  136459. name: string;
  136460. shader: string;
  136461. };
  136462. }
  136463. declare module BABYLON {
  136464. /** @hidden */
  136465. export var pbrUboDeclaration: {
  136466. name: string;
  136467. shader: string;
  136468. };
  136469. }
  136470. declare module BABYLON {
  136471. /** @hidden */
  136472. export var pbrFragmentExtraDeclaration: {
  136473. name: string;
  136474. shader: string;
  136475. };
  136476. }
  136477. declare module BABYLON {
  136478. /** @hidden */
  136479. export var pbrFragmentSamplersDeclaration: {
  136480. name: string;
  136481. shader: string;
  136482. };
  136483. }
  136484. declare module BABYLON {
  136485. /** @hidden */
  136486. export var subSurfaceScatteringFunctions: {
  136487. name: string;
  136488. shader: string;
  136489. };
  136490. }
  136491. declare module BABYLON {
  136492. /** @hidden */
  136493. export var importanceSampling: {
  136494. name: string;
  136495. shader: string;
  136496. };
  136497. }
  136498. declare module BABYLON {
  136499. /** @hidden */
  136500. export var pbrHelperFunctions: {
  136501. name: string;
  136502. shader: string;
  136503. };
  136504. }
  136505. declare module BABYLON {
  136506. /** @hidden */
  136507. export var harmonicsFunctions: {
  136508. name: string;
  136509. shader: string;
  136510. };
  136511. }
  136512. declare module BABYLON {
  136513. /** @hidden */
  136514. export var pbrDirectLightingSetupFunctions: {
  136515. name: string;
  136516. shader: string;
  136517. };
  136518. }
  136519. declare module BABYLON {
  136520. /** @hidden */
  136521. export var pbrDirectLightingFalloffFunctions: {
  136522. name: string;
  136523. shader: string;
  136524. };
  136525. }
  136526. declare module BABYLON {
  136527. /** @hidden */
  136528. export var pbrBRDFFunctions: {
  136529. name: string;
  136530. shader: string;
  136531. };
  136532. }
  136533. declare module BABYLON {
  136534. /** @hidden */
  136535. export var hdrFilteringFunctions: {
  136536. name: string;
  136537. shader: string;
  136538. };
  136539. }
  136540. declare module BABYLON {
  136541. /** @hidden */
  136542. export var pbrDirectLightingFunctions: {
  136543. name: string;
  136544. shader: string;
  136545. };
  136546. }
  136547. declare module BABYLON {
  136548. /** @hidden */
  136549. export var pbrIBLFunctions: {
  136550. name: string;
  136551. shader: string;
  136552. };
  136553. }
  136554. declare module BABYLON {
  136555. /** @hidden */
  136556. export var pbrBlockAlbedoOpacity: {
  136557. name: string;
  136558. shader: string;
  136559. };
  136560. }
  136561. declare module BABYLON {
  136562. /** @hidden */
  136563. export var pbrBlockReflectivity: {
  136564. name: string;
  136565. shader: string;
  136566. };
  136567. }
  136568. declare module BABYLON {
  136569. /** @hidden */
  136570. export var pbrBlockAmbientOcclusion: {
  136571. name: string;
  136572. shader: string;
  136573. };
  136574. }
  136575. declare module BABYLON {
  136576. /** @hidden */
  136577. export var pbrBlockAlphaFresnel: {
  136578. name: string;
  136579. shader: string;
  136580. };
  136581. }
  136582. declare module BABYLON {
  136583. /** @hidden */
  136584. export var pbrBlockAnisotropic: {
  136585. name: string;
  136586. shader: string;
  136587. };
  136588. }
  136589. declare module BABYLON {
  136590. /** @hidden */
  136591. export var pbrBlockReflection: {
  136592. name: string;
  136593. shader: string;
  136594. };
  136595. }
  136596. declare module BABYLON {
  136597. /** @hidden */
  136598. export var pbrBlockSheen: {
  136599. name: string;
  136600. shader: string;
  136601. };
  136602. }
  136603. declare module BABYLON {
  136604. /** @hidden */
  136605. export var pbrBlockClearcoat: {
  136606. name: string;
  136607. shader: string;
  136608. };
  136609. }
  136610. declare module BABYLON {
  136611. /** @hidden */
  136612. export var pbrBlockSubSurface: {
  136613. name: string;
  136614. shader: string;
  136615. };
  136616. }
  136617. declare module BABYLON {
  136618. /** @hidden */
  136619. export var pbrBlockNormalGeometric: {
  136620. name: string;
  136621. shader: string;
  136622. };
  136623. }
  136624. declare module BABYLON {
  136625. /** @hidden */
  136626. export var pbrBlockNormalFinal: {
  136627. name: string;
  136628. shader: string;
  136629. };
  136630. }
  136631. declare module BABYLON {
  136632. /** @hidden */
  136633. export var pbrBlockLightmapInit: {
  136634. name: string;
  136635. shader: string;
  136636. };
  136637. }
  136638. declare module BABYLON {
  136639. /** @hidden */
  136640. export var pbrBlockGeometryInfo: {
  136641. name: string;
  136642. shader: string;
  136643. };
  136644. }
  136645. declare module BABYLON {
  136646. /** @hidden */
  136647. export var pbrBlockReflectance0: {
  136648. name: string;
  136649. shader: string;
  136650. };
  136651. }
  136652. declare module BABYLON {
  136653. /** @hidden */
  136654. export var pbrBlockReflectance: {
  136655. name: string;
  136656. shader: string;
  136657. };
  136658. }
  136659. declare module BABYLON {
  136660. /** @hidden */
  136661. export var pbrBlockDirectLighting: {
  136662. name: string;
  136663. shader: string;
  136664. };
  136665. }
  136666. declare module BABYLON {
  136667. /** @hidden */
  136668. export var pbrBlockFinalLitComponents: {
  136669. name: string;
  136670. shader: string;
  136671. };
  136672. }
  136673. declare module BABYLON {
  136674. /** @hidden */
  136675. export var pbrBlockFinalUnlitComponents: {
  136676. name: string;
  136677. shader: string;
  136678. };
  136679. }
  136680. declare module BABYLON {
  136681. /** @hidden */
  136682. export var pbrBlockFinalColorComposition: {
  136683. name: string;
  136684. shader: string;
  136685. };
  136686. }
  136687. declare module BABYLON {
  136688. /** @hidden */
  136689. export var pbrBlockImageProcessing: {
  136690. name: string;
  136691. shader: string;
  136692. };
  136693. }
  136694. declare module BABYLON {
  136695. /** @hidden */
  136696. export var pbrDebug: {
  136697. name: string;
  136698. shader: string;
  136699. };
  136700. }
  136701. declare module BABYLON {
  136702. /** @hidden */
  136703. export var pbrPixelShader: {
  136704. name: string;
  136705. shader: string;
  136706. };
  136707. }
  136708. declare module BABYLON {
  136709. /** @hidden */
  136710. export var pbrVertexDeclaration: {
  136711. name: string;
  136712. shader: string;
  136713. };
  136714. }
  136715. declare module BABYLON {
  136716. /** @hidden */
  136717. export var pbrVertexShader: {
  136718. name: string;
  136719. shader: string;
  136720. };
  136721. }
  136722. declare module BABYLON {
  136723. /**
  136724. * Manages the defines for the PBR Material.
  136725. * @hidden
  136726. */
  136727. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  136728. PBR: boolean;
  136729. NUM_SAMPLES: string;
  136730. REALTIME_FILTERING: boolean;
  136731. MAINUV1: boolean;
  136732. MAINUV2: boolean;
  136733. UV1: boolean;
  136734. UV2: boolean;
  136735. ALBEDO: boolean;
  136736. GAMMAALBEDO: boolean;
  136737. ALBEDODIRECTUV: number;
  136738. VERTEXCOLOR: boolean;
  136739. DETAIL: boolean;
  136740. DETAILDIRECTUV: number;
  136741. DETAIL_NORMALBLENDMETHOD: number;
  136742. AMBIENT: boolean;
  136743. AMBIENTDIRECTUV: number;
  136744. AMBIENTINGRAYSCALE: boolean;
  136745. OPACITY: boolean;
  136746. VERTEXALPHA: boolean;
  136747. OPACITYDIRECTUV: number;
  136748. OPACITYRGB: boolean;
  136749. ALPHATEST: boolean;
  136750. DEPTHPREPASS: boolean;
  136751. ALPHABLEND: boolean;
  136752. ALPHAFROMALBEDO: boolean;
  136753. ALPHATESTVALUE: string;
  136754. SPECULAROVERALPHA: boolean;
  136755. RADIANCEOVERALPHA: boolean;
  136756. ALPHAFRESNEL: boolean;
  136757. LINEARALPHAFRESNEL: boolean;
  136758. PREMULTIPLYALPHA: boolean;
  136759. EMISSIVE: boolean;
  136760. EMISSIVEDIRECTUV: number;
  136761. REFLECTIVITY: boolean;
  136762. REFLECTIVITYDIRECTUV: number;
  136763. SPECULARTERM: boolean;
  136764. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  136765. MICROSURFACEAUTOMATIC: boolean;
  136766. LODBASEDMICROSFURACE: boolean;
  136767. MICROSURFACEMAP: boolean;
  136768. MICROSURFACEMAPDIRECTUV: number;
  136769. METALLICWORKFLOW: boolean;
  136770. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  136771. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  136772. METALLNESSSTOREINMETALMAPBLUE: boolean;
  136773. AOSTOREINMETALMAPRED: boolean;
  136774. METALLIC_REFLECTANCE: boolean;
  136775. METALLIC_REFLECTANCEDIRECTUV: number;
  136776. ENVIRONMENTBRDF: boolean;
  136777. ENVIRONMENTBRDF_RGBD: boolean;
  136778. NORMAL: boolean;
  136779. TANGENT: boolean;
  136780. BUMP: boolean;
  136781. BUMPDIRECTUV: number;
  136782. OBJECTSPACE_NORMALMAP: boolean;
  136783. PARALLAX: boolean;
  136784. PARALLAXOCCLUSION: boolean;
  136785. NORMALXYSCALE: boolean;
  136786. LIGHTMAP: boolean;
  136787. LIGHTMAPDIRECTUV: number;
  136788. USELIGHTMAPASSHADOWMAP: boolean;
  136789. GAMMALIGHTMAP: boolean;
  136790. RGBDLIGHTMAP: boolean;
  136791. REFLECTION: boolean;
  136792. REFLECTIONMAP_3D: boolean;
  136793. REFLECTIONMAP_SPHERICAL: boolean;
  136794. REFLECTIONMAP_PLANAR: boolean;
  136795. REFLECTIONMAP_CUBIC: boolean;
  136796. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  136797. REFLECTIONMAP_PROJECTION: boolean;
  136798. REFLECTIONMAP_SKYBOX: boolean;
  136799. REFLECTIONMAP_EXPLICIT: boolean;
  136800. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  136801. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  136802. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  136803. INVERTCUBICMAP: boolean;
  136804. USESPHERICALFROMREFLECTIONMAP: boolean;
  136805. USEIRRADIANCEMAP: boolean;
  136806. SPHERICAL_HARMONICS: boolean;
  136807. USESPHERICALINVERTEX: boolean;
  136808. REFLECTIONMAP_OPPOSITEZ: boolean;
  136809. LODINREFLECTIONALPHA: boolean;
  136810. GAMMAREFLECTION: boolean;
  136811. RGBDREFLECTION: boolean;
  136812. LINEARSPECULARREFLECTION: boolean;
  136813. RADIANCEOCCLUSION: boolean;
  136814. HORIZONOCCLUSION: boolean;
  136815. INSTANCES: boolean;
  136816. THIN_INSTANCES: boolean;
  136817. PREPASS: boolean;
  136818. PREPASS_IRRADIANCE: boolean;
  136819. PREPASS_IRRADIANCE_INDEX: number;
  136820. PREPASS_ALBEDO: boolean;
  136821. PREPASS_ALBEDO_INDEX: number;
  136822. PREPASS_DEPTHNORMAL: boolean;
  136823. PREPASS_DEPTHNORMAL_INDEX: number;
  136824. SCENE_MRT_COUNT: number;
  136825. NUM_BONE_INFLUENCERS: number;
  136826. BonesPerMesh: number;
  136827. BONETEXTURE: boolean;
  136828. NONUNIFORMSCALING: boolean;
  136829. MORPHTARGETS: boolean;
  136830. MORPHTARGETS_NORMAL: boolean;
  136831. MORPHTARGETS_TANGENT: boolean;
  136832. MORPHTARGETS_UV: boolean;
  136833. NUM_MORPH_INFLUENCERS: number;
  136834. IMAGEPROCESSING: boolean;
  136835. VIGNETTE: boolean;
  136836. VIGNETTEBLENDMODEMULTIPLY: boolean;
  136837. VIGNETTEBLENDMODEOPAQUE: boolean;
  136838. TONEMAPPING: boolean;
  136839. TONEMAPPING_ACES: boolean;
  136840. CONTRAST: boolean;
  136841. COLORCURVES: boolean;
  136842. COLORGRADING: boolean;
  136843. COLORGRADING3D: boolean;
  136844. SAMPLER3DGREENDEPTH: boolean;
  136845. SAMPLER3DBGRMAP: boolean;
  136846. IMAGEPROCESSINGPOSTPROCESS: boolean;
  136847. EXPOSURE: boolean;
  136848. MULTIVIEW: boolean;
  136849. USEPHYSICALLIGHTFALLOFF: boolean;
  136850. USEGLTFLIGHTFALLOFF: boolean;
  136851. TWOSIDEDLIGHTING: boolean;
  136852. SHADOWFLOAT: boolean;
  136853. CLIPPLANE: boolean;
  136854. CLIPPLANE2: boolean;
  136855. CLIPPLANE3: boolean;
  136856. CLIPPLANE4: boolean;
  136857. CLIPPLANE5: boolean;
  136858. CLIPPLANE6: boolean;
  136859. POINTSIZE: boolean;
  136860. FOG: boolean;
  136861. LOGARITHMICDEPTH: boolean;
  136862. FORCENORMALFORWARD: boolean;
  136863. SPECULARAA: boolean;
  136864. CLEARCOAT: boolean;
  136865. CLEARCOAT_DEFAULTIOR: boolean;
  136866. CLEARCOAT_TEXTURE: boolean;
  136867. CLEARCOAT_TEXTUREDIRECTUV: number;
  136868. CLEARCOAT_BUMP: boolean;
  136869. CLEARCOAT_BUMPDIRECTUV: number;
  136870. CLEARCOAT_TINT: boolean;
  136871. CLEARCOAT_TINT_TEXTURE: boolean;
  136872. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  136873. ANISOTROPIC: boolean;
  136874. ANISOTROPIC_TEXTURE: boolean;
  136875. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136876. BRDF_V_HEIGHT_CORRELATED: boolean;
  136877. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136878. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136879. SHEEN: boolean;
  136880. SHEEN_TEXTURE: boolean;
  136881. SHEEN_TEXTUREDIRECTUV: number;
  136882. SHEEN_LINKWITHALBEDO: boolean;
  136883. SHEEN_ROUGHNESS: boolean;
  136884. SHEEN_ALBEDOSCALING: boolean;
  136885. SUBSURFACE: boolean;
  136886. SS_REFRACTION: boolean;
  136887. SS_TRANSLUCENCY: boolean;
  136888. SS_SCATTERING: boolean;
  136889. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136890. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136891. SS_REFRACTIONMAP_3D: boolean;
  136892. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136893. SS_LODINREFRACTIONALPHA: boolean;
  136894. SS_GAMMAREFRACTION: boolean;
  136895. SS_RGBDREFRACTION: boolean;
  136896. SS_LINEARSPECULARREFRACTION: boolean;
  136897. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136898. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136899. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136900. UNLIT: boolean;
  136901. DEBUGMODE: number;
  136902. /**
  136903. * Initializes the PBR Material defines.
  136904. */
  136905. constructor();
  136906. /**
  136907. * Resets the PBR Material defines.
  136908. */
  136909. reset(): void;
  136910. }
  136911. /**
  136912. * The Physically based material base class of BJS.
  136913. *
  136914. * This offers the main features of a standard PBR material.
  136915. * For more information, please refer to the documentation :
  136916. * https://doc.babylonjs.com/how_to/physically_based_rendering
  136917. */
  136918. export abstract class PBRBaseMaterial extends PushMaterial {
  136919. /**
  136920. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  136921. */
  136922. static readonly PBRMATERIAL_OPAQUE: number;
  136923. /**
  136924. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  136925. */
  136926. static readonly PBRMATERIAL_ALPHATEST: number;
  136927. /**
  136928. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136929. */
  136930. static readonly PBRMATERIAL_ALPHABLEND: number;
  136931. /**
  136932. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  136933. * They are also discarded below the alpha cutoff threshold to improve performances.
  136934. */
  136935. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  136936. /**
  136937. * Defines the default value of how much AO map is occluding the analytical lights
  136938. * (point spot...).
  136939. */
  136940. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  136941. /**
  136942. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  136943. */
  136944. static readonly LIGHTFALLOFF_PHYSICAL: number;
  136945. /**
  136946. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  136947. * to enhance interoperability with other engines.
  136948. */
  136949. static readonly LIGHTFALLOFF_GLTF: number;
  136950. /**
  136951. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  136952. * to enhance interoperability with other materials.
  136953. */
  136954. static readonly LIGHTFALLOFF_STANDARD: number;
  136955. /**
  136956. * Intensity of the direct lights e.g. the four lights available in your scene.
  136957. * This impacts both the direct diffuse and specular highlights.
  136958. */
  136959. protected _directIntensity: number;
  136960. /**
  136961. * Intensity of the emissive part of the material.
  136962. * This helps controlling the emissive effect without modifying the emissive color.
  136963. */
  136964. protected _emissiveIntensity: number;
  136965. /**
  136966. * Intensity of the environment e.g. how much the environment will light the object
  136967. * either through harmonics for rough material or through the refelction for shiny ones.
  136968. */
  136969. protected _environmentIntensity: number;
  136970. /**
  136971. * This is a special control allowing the reduction of the specular highlights coming from the
  136972. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  136973. */
  136974. protected _specularIntensity: number;
  136975. /**
  136976. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  136977. */
  136978. private _lightingInfos;
  136979. /**
  136980. * Debug Control allowing disabling the bump map on this material.
  136981. */
  136982. protected _disableBumpMap: boolean;
  136983. /**
  136984. * AKA Diffuse Texture in standard nomenclature.
  136985. */
  136986. protected _albedoTexture: Nullable<BaseTexture>;
  136987. /**
  136988. * AKA Occlusion Texture in other nomenclature.
  136989. */
  136990. protected _ambientTexture: Nullable<BaseTexture>;
  136991. /**
  136992. * AKA Occlusion Texture Intensity in other nomenclature.
  136993. */
  136994. protected _ambientTextureStrength: number;
  136995. /**
  136996. * Defines how much the AO map is occluding the analytical lights (point spot...).
  136997. * 1 means it completely occludes it
  136998. * 0 mean it has no impact
  136999. */
  137000. protected _ambientTextureImpactOnAnalyticalLights: number;
  137001. /**
  137002. * Stores the alpha values in a texture.
  137003. */
  137004. protected _opacityTexture: Nullable<BaseTexture>;
  137005. /**
  137006. * Stores the reflection values in a texture.
  137007. */
  137008. protected _reflectionTexture: Nullable<BaseTexture>;
  137009. /**
  137010. * Stores the emissive values in a texture.
  137011. */
  137012. protected _emissiveTexture: Nullable<BaseTexture>;
  137013. /**
  137014. * AKA Specular texture in other nomenclature.
  137015. */
  137016. protected _reflectivityTexture: Nullable<BaseTexture>;
  137017. /**
  137018. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137019. */
  137020. protected _metallicTexture: Nullable<BaseTexture>;
  137021. /**
  137022. * Specifies the metallic scalar of the metallic/roughness workflow.
  137023. * Can also be used to scale the metalness values of the metallic texture.
  137024. */
  137025. protected _metallic: Nullable<number>;
  137026. /**
  137027. * Specifies the roughness scalar of the metallic/roughness workflow.
  137028. * Can also be used to scale the roughness values of the metallic texture.
  137029. */
  137030. protected _roughness: Nullable<number>;
  137031. /**
  137032. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137033. * By default the indexOfrefraction is used to compute F0;
  137034. *
  137035. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137036. *
  137037. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137038. * F90 = metallicReflectanceColor;
  137039. */
  137040. protected _metallicF0Factor: number;
  137041. /**
  137042. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137043. * By default the F90 is always 1;
  137044. *
  137045. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137046. *
  137047. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137048. * F90 = metallicReflectanceColor;
  137049. */
  137050. protected _metallicReflectanceColor: Color3;
  137051. /**
  137052. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137053. * This is multiply against the scalar values defined in the material.
  137054. */
  137055. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137056. /**
  137057. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137058. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137059. */
  137060. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137061. /**
  137062. * Stores surface normal data used to displace a mesh in a texture.
  137063. */
  137064. protected _bumpTexture: Nullable<BaseTexture>;
  137065. /**
  137066. * Stores the pre-calculated light information of a mesh in a texture.
  137067. */
  137068. protected _lightmapTexture: Nullable<BaseTexture>;
  137069. /**
  137070. * The color of a material in ambient lighting.
  137071. */
  137072. protected _ambientColor: Color3;
  137073. /**
  137074. * AKA Diffuse Color in other nomenclature.
  137075. */
  137076. protected _albedoColor: Color3;
  137077. /**
  137078. * AKA Specular Color in other nomenclature.
  137079. */
  137080. protected _reflectivityColor: Color3;
  137081. /**
  137082. * The color applied when light is reflected from a material.
  137083. */
  137084. protected _reflectionColor: Color3;
  137085. /**
  137086. * The color applied when light is emitted from a material.
  137087. */
  137088. protected _emissiveColor: Color3;
  137089. /**
  137090. * AKA Glossiness in other nomenclature.
  137091. */
  137092. protected _microSurface: number;
  137093. /**
  137094. * Specifies that the material will use the light map as a show map.
  137095. */
  137096. protected _useLightmapAsShadowmap: boolean;
  137097. /**
  137098. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137099. * makes the reflect vector face the model (under horizon).
  137100. */
  137101. protected _useHorizonOcclusion: boolean;
  137102. /**
  137103. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137104. * too much the area relying on ambient texture to define their ambient occlusion.
  137105. */
  137106. protected _useRadianceOcclusion: boolean;
  137107. /**
  137108. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137109. */
  137110. protected _useAlphaFromAlbedoTexture: boolean;
  137111. /**
  137112. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137113. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137114. */
  137115. protected _useSpecularOverAlpha: boolean;
  137116. /**
  137117. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137118. */
  137119. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137120. /**
  137121. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137122. */
  137123. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137124. /**
  137125. * Specifies if the metallic texture contains the roughness information in its green channel.
  137126. */
  137127. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137128. /**
  137129. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137130. */
  137131. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137132. /**
  137133. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137134. */
  137135. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137136. /**
  137137. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137138. */
  137139. protected _useAmbientInGrayScale: boolean;
  137140. /**
  137141. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137142. * The material will try to infer what glossiness each pixel should be.
  137143. */
  137144. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137145. /**
  137146. * Defines the falloff type used in this material.
  137147. * It by default is Physical.
  137148. */
  137149. protected _lightFalloff: number;
  137150. /**
  137151. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137152. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137153. */
  137154. protected _useRadianceOverAlpha: boolean;
  137155. /**
  137156. * Allows using an object space normal map (instead of tangent space).
  137157. */
  137158. protected _useObjectSpaceNormalMap: boolean;
  137159. /**
  137160. * Allows using the bump map in parallax mode.
  137161. */
  137162. protected _useParallax: boolean;
  137163. /**
  137164. * Allows using the bump map in parallax occlusion mode.
  137165. */
  137166. protected _useParallaxOcclusion: boolean;
  137167. /**
  137168. * Controls the scale bias of the parallax mode.
  137169. */
  137170. protected _parallaxScaleBias: number;
  137171. /**
  137172. * If sets to true, disables all the lights affecting the material.
  137173. */
  137174. protected _disableLighting: boolean;
  137175. /**
  137176. * Number of Simultaneous lights allowed on the material.
  137177. */
  137178. protected _maxSimultaneousLights: number;
  137179. /**
  137180. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137181. */
  137182. protected _invertNormalMapX: boolean;
  137183. /**
  137184. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137185. */
  137186. protected _invertNormalMapY: boolean;
  137187. /**
  137188. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137189. */
  137190. protected _twoSidedLighting: boolean;
  137191. /**
  137192. * Defines the alpha limits in alpha test mode.
  137193. */
  137194. protected _alphaCutOff: number;
  137195. /**
  137196. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137197. */
  137198. protected _forceAlphaTest: boolean;
  137199. /**
  137200. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137201. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137202. */
  137203. protected _useAlphaFresnel: boolean;
  137204. /**
  137205. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137206. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137207. */
  137208. protected _useLinearAlphaFresnel: boolean;
  137209. /**
  137210. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137211. * from cos thetav and roughness:
  137212. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137213. */
  137214. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137215. /**
  137216. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137217. */
  137218. protected _forceIrradianceInFragment: boolean;
  137219. private _realTimeFiltering;
  137220. /**
  137221. * Enables realtime filtering on the texture.
  137222. */
  137223. get realTimeFiltering(): boolean;
  137224. set realTimeFiltering(b: boolean);
  137225. private _realTimeFilteringQuality;
  137226. /**
  137227. * Quality switch for realtime filtering
  137228. */
  137229. get realTimeFilteringQuality(): number;
  137230. set realTimeFilteringQuality(n: number);
  137231. /**
  137232. * Can this material render to several textures at once
  137233. */
  137234. get canRenderToMRT(): boolean;
  137235. /**
  137236. * Force normal to face away from face.
  137237. */
  137238. protected _forceNormalForward: boolean;
  137239. /**
  137240. * Enables specular anti aliasing in the PBR shader.
  137241. * It will both interacts on the Geometry for analytical and IBL lighting.
  137242. * It also prefilter the roughness map based on the bump values.
  137243. */
  137244. protected _enableSpecularAntiAliasing: boolean;
  137245. /**
  137246. * Default configuration related to image processing available in the PBR Material.
  137247. */
  137248. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137249. /**
  137250. * Keep track of the image processing observer to allow dispose and replace.
  137251. */
  137252. private _imageProcessingObserver;
  137253. /**
  137254. * Attaches a new image processing configuration to the PBR Material.
  137255. * @param configuration
  137256. */
  137257. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137258. /**
  137259. * Stores the available render targets.
  137260. */
  137261. private _renderTargets;
  137262. /**
  137263. * Sets the global ambient color for the material used in lighting calculations.
  137264. */
  137265. private _globalAmbientColor;
  137266. /**
  137267. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137268. */
  137269. private _useLogarithmicDepth;
  137270. /**
  137271. * If set to true, no lighting calculations will be applied.
  137272. */
  137273. private _unlit;
  137274. private _debugMode;
  137275. /**
  137276. * @hidden
  137277. * This is reserved for the inspector.
  137278. * Defines the material debug mode.
  137279. * It helps seeing only some components of the material while troubleshooting.
  137280. */
  137281. debugMode: number;
  137282. /**
  137283. * @hidden
  137284. * This is reserved for the inspector.
  137285. * Specify from where on screen the debug mode should start.
  137286. * The value goes from -1 (full screen) to 1 (not visible)
  137287. * It helps with side by side comparison against the final render
  137288. * This defaults to -1
  137289. */
  137290. private debugLimit;
  137291. /**
  137292. * @hidden
  137293. * This is reserved for the inspector.
  137294. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137295. * You can use the factor to better multiply the final value.
  137296. */
  137297. private debugFactor;
  137298. /**
  137299. * Defines the clear coat layer parameters for the material.
  137300. */
  137301. readonly clearCoat: PBRClearCoatConfiguration;
  137302. /**
  137303. * Defines the anisotropic parameters for the material.
  137304. */
  137305. readonly anisotropy: PBRAnisotropicConfiguration;
  137306. /**
  137307. * Defines the BRDF parameters for the material.
  137308. */
  137309. readonly brdf: PBRBRDFConfiguration;
  137310. /**
  137311. * Defines the Sheen parameters for the material.
  137312. */
  137313. readonly sheen: PBRSheenConfiguration;
  137314. /**
  137315. * Defines the SubSurface parameters for the material.
  137316. */
  137317. readonly subSurface: PBRSubSurfaceConfiguration;
  137318. /**
  137319. * Defines the detail map parameters for the material.
  137320. */
  137321. readonly detailMap: DetailMapConfiguration;
  137322. protected _rebuildInParallel: boolean;
  137323. /**
  137324. * Instantiates a new PBRMaterial instance.
  137325. *
  137326. * @param name The material name
  137327. * @param scene The scene the material will be use in.
  137328. */
  137329. constructor(name: string, scene: Scene);
  137330. /**
  137331. * Gets a boolean indicating that current material needs to register RTT
  137332. */
  137333. get hasRenderTargetTextures(): boolean;
  137334. /**
  137335. * Gets the name of the material class.
  137336. */
  137337. getClassName(): string;
  137338. /**
  137339. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137340. */
  137341. get useLogarithmicDepth(): boolean;
  137342. /**
  137343. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137344. */
  137345. set useLogarithmicDepth(value: boolean);
  137346. /**
  137347. * Returns true if alpha blending should be disabled.
  137348. */
  137349. protected get _disableAlphaBlending(): boolean;
  137350. /**
  137351. * Specifies whether or not this material should be rendered in alpha blend mode.
  137352. */
  137353. needAlphaBlending(): boolean;
  137354. /**
  137355. * Specifies whether or not this material should be rendered in alpha test mode.
  137356. */
  137357. needAlphaTesting(): boolean;
  137358. /**
  137359. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137360. */
  137361. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137362. /**
  137363. * Gets the texture used for the alpha test.
  137364. */
  137365. getAlphaTestTexture(): Nullable<BaseTexture>;
  137366. /**
  137367. * Specifies that the submesh is ready to be used.
  137368. * @param mesh - BJS mesh.
  137369. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137370. * @param useInstances - Specifies that instances should be used.
  137371. * @returns - boolean indicating that the submesh is ready or not.
  137372. */
  137373. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137374. /**
  137375. * Specifies if the material uses metallic roughness workflow.
  137376. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137377. */
  137378. isMetallicWorkflow(): boolean;
  137379. private _prepareEffect;
  137380. private _prepareDefines;
  137381. /**
  137382. * Force shader compilation
  137383. */
  137384. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137385. /**
  137386. * Initializes the uniform buffer layout for the shader.
  137387. */
  137388. buildUniformLayout(): void;
  137389. /**
  137390. * Unbinds the material from the mesh
  137391. */
  137392. unbind(): void;
  137393. /**
  137394. * Binds the submesh data.
  137395. * @param world - The world matrix.
  137396. * @param mesh - The BJS mesh.
  137397. * @param subMesh - A submesh of the BJS mesh.
  137398. */
  137399. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137400. /**
  137401. * Returns the animatable textures.
  137402. * @returns - Array of animatable textures.
  137403. */
  137404. getAnimatables(): IAnimatable[];
  137405. /**
  137406. * Returns the texture used for reflections.
  137407. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137408. */
  137409. private _getReflectionTexture;
  137410. /**
  137411. * Returns an array of the actively used textures.
  137412. * @returns - Array of BaseTextures
  137413. */
  137414. getActiveTextures(): BaseTexture[];
  137415. /**
  137416. * Checks to see if a texture is used in the material.
  137417. * @param texture - Base texture to use.
  137418. * @returns - Boolean specifying if a texture is used in the material.
  137419. */
  137420. hasTexture(texture: BaseTexture): boolean;
  137421. /**
  137422. * Sets the required values to the prepass renderer.
  137423. * @param prePassRenderer defines the prepass renderer to setup
  137424. */
  137425. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137426. /**
  137427. * Disposes the resources of the material.
  137428. * @param forceDisposeEffect - Forces the disposal of effects.
  137429. * @param forceDisposeTextures - Forces the disposal of all textures.
  137430. */
  137431. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137432. }
  137433. }
  137434. declare module BABYLON {
  137435. /**
  137436. * The Physically based material of BJS.
  137437. *
  137438. * This offers the main features of a standard PBR material.
  137439. * For more information, please refer to the documentation :
  137440. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137441. */
  137442. export class PBRMaterial extends PBRBaseMaterial {
  137443. /**
  137444. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137445. */
  137446. static readonly PBRMATERIAL_OPAQUE: number;
  137447. /**
  137448. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137449. */
  137450. static readonly PBRMATERIAL_ALPHATEST: number;
  137451. /**
  137452. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137453. */
  137454. static readonly PBRMATERIAL_ALPHABLEND: number;
  137455. /**
  137456. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137457. * They are also discarded below the alpha cutoff threshold to improve performances.
  137458. */
  137459. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137460. /**
  137461. * Defines the default value of how much AO map is occluding the analytical lights
  137462. * (point spot...).
  137463. */
  137464. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137465. /**
  137466. * Intensity of the direct lights e.g. the four lights available in your scene.
  137467. * This impacts both the direct diffuse and specular highlights.
  137468. */
  137469. directIntensity: number;
  137470. /**
  137471. * Intensity of the emissive part of the material.
  137472. * This helps controlling the emissive effect without modifying the emissive color.
  137473. */
  137474. emissiveIntensity: number;
  137475. /**
  137476. * Intensity of the environment e.g. how much the environment will light the object
  137477. * either through harmonics for rough material or through the refelction for shiny ones.
  137478. */
  137479. environmentIntensity: number;
  137480. /**
  137481. * This is a special control allowing the reduction of the specular highlights coming from the
  137482. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137483. */
  137484. specularIntensity: number;
  137485. /**
  137486. * Debug Control allowing disabling the bump map on this material.
  137487. */
  137488. disableBumpMap: boolean;
  137489. /**
  137490. * AKA Diffuse Texture in standard nomenclature.
  137491. */
  137492. albedoTexture: BaseTexture;
  137493. /**
  137494. * AKA Occlusion Texture in other nomenclature.
  137495. */
  137496. ambientTexture: BaseTexture;
  137497. /**
  137498. * AKA Occlusion Texture Intensity in other nomenclature.
  137499. */
  137500. ambientTextureStrength: number;
  137501. /**
  137502. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137503. * 1 means it completely occludes it
  137504. * 0 mean it has no impact
  137505. */
  137506. ambientTextureImpactOnAnalyticalLights: number;
  137507. /**
  137508. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137509. */
  137510. opacityTexture: BaseTexture;
  137511. /**
  137512. * Stores the reflection values in a texture.
  137513. */
  137514. reflectionTexture: Nullable<BaseTexture>;
  137515. /**
  137516. * Stores the emissive values in a texture.
  137517. */
  137518. emissiveTexture: BaseTexture;
  137519. /**
  137520. * AKA Specular texture in other nomenclature.
  137521. */
  137522. reflectivityTexture: BaseTexture;
  137523. /**
  137524. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137525. */
  137526. metallicTexture: BaseTexture;
  137527. /**
  137528. * Specifies the metallic scalar of the metallic/roughness workflow.
  137529. * Can also be used to scale the metalness values of the metallic texture.
  137530. */
  137531. metallic: Nullable<number>;
  137532. /**
  137533. * Specifies the roughness scalar of the metallic/roughness workflow.
  137534. * Can also be used to scale the roughness values of the metallic texture.
  137535. */
  137536. roughness: Nullable<number>;
  137537. /**
  137538. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137539. * By default the indexOfrefraction is used to compute F0;
  137540. *
  137541. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137542. *
  137543. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137544. * F90 = metallicReflectanceColor;
  137545. */
  137546. metallicF0Factor: number;
  137547. /**
  137548. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137549. * By default the F90 is always 1;
  137550. *
  137551. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137552. *
  137553. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137554. * F90 = metallicReflectanceColor;
  137555. */
  137556. metallicReflectanceColor: Color3;
  137557. /**
  137558. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137559. * This is multiply against the scalar values defined in the material.
  137560. */
  137561. metallicReflectanceTexture: Nullable<BaseTexture>;
  137562. /**
  137563. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137564. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137565. */
  137566. microSurfaceTexture: BaseTexture;
  137567. /**
  137568. * Stores surface normal data used to displace a mesh in a texture.
  137569. */
  137570. bumpTexture: BaseTexture;
  137571. /**
  137572. * Stores the pre-calculated light information of a mesh in a texture.
  137573. */
  137574. lightmapTexture: BaseTexture;
  137575. /**
  137576. * Stores the refracted light information in a texture.
  137577. */
  137578. get refractionTexture(): Nullable<BaseTexture>;
  137579. set refractionTexture(value: Nullable<BaseTexture>);
  137580. /**
  137581. * The color of a material in ambient lighting.
  137582. */
  137583. ambientColor: Color3;
  137584. /**
  137585. * AKA Diffuse Color in other nomenclature.
  137586. */
  137587. albedoColor: Color3;
  137588. /**
  137589. * AKA Specular Color in other nomenclature.
  137590. */
  137591. reflectivityColor: Color3;
  137592. /**
  137593. * The color reflected from the material.
  137594. */
  137595. reflectionColor: Color3;
  137596. /**
  137597. * The color emitted from the material.
  137598. */
  137599. emissiveColor: Color3;
  137600. /**
  137601. * AKA Glossiness in other nomenclature.
  137602. */
  137603. microSurface: number;
  137604. /**
  137605. * Index of refraction of the material base layer.
  137606. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  137607. *
  137608. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  137609. *
  137610. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  137611. */
  137612. get indexOfRefraction(): number;
  137613. set indexOfRefraction(value: number);
  137614. /**
  137615. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  137616. */
  137617. get invertRefractionY(): boolean;
  137618. set invertRefractionY(value: boolean);
  137619. /**
  137620. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  137621. * Materials half opaque for instance using refraction could benefit from this control.
  137622. */
  137623. get linkRefractionWithTransparency(): boolean;
  137624. set linkRefractionWithTransparency(value: boolean);
  137625. /**
  137626. * If true, the light map contains occlusion information instead of lighting info.
  137627. */
  137628. useLightmapAsShadowmap: boolean;
  137629. /**
  137630. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137631. */
  137632. useAlphaFromAlbedoTexture: boolean;
  137633. /**
  137634. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137635. */
  137636. forceAlphaTest: boolean;
  137637. /**
  137638. * Defines the alpha limits in alpha test mode.
  137639. */
  137640. alphaCutOff: number;
  137641. /**
  137642. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  137643. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137644. */
  137645. useSpecularOverAlpha: boolean;
  137646. /**
  137647. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137648. */
  137649. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137650. /**
  137651. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137652. */
  137653. useRoughnessFromMetallicTextureAlpha: boolean;
  137654. /**
  137655. * Specifies if the metallic texture contains the roughness information in its green channel.
  137656. */
  137657. useRoughnessFromMetallicTextureGreen: boolean;
  137658. /**
  137659. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137660. */
  137661. useMetallnessFromMetallicTextureBlue: boolean;
  137662. /**
  137663. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137664. */
  137665. useAmbientOcclusionFromMetallicTextureRed: boolean;
  137666. /**
  137667. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137668. */
  137669. useAmbientInGrayScale: boolean;
  137670. /**
  137671. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137672. * The material will try to infer what glossiness each pixel should be.
  137673. */
  137674. useAutoMicroSurfaceFromReflectivityMap: boolean;
  137675. /**
  137676. * BJS is using an harcoded light falloff based on a manually sets up range.
  137677. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137678. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137679. */
  137680. get usePhysicalLightFalloff(): boolean;
  137681. /**
  137682. * BJS is using an harcoded light falloff based on a manually sets up range.
  137683. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  137684. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  137685. */
  137686. set usePhysicalLightFalloff(value: boolean);
  137687. /**
  137688. * In order to support the falloff compatibility with gltf, a special mode has been added
  137689. * to reproduce the gltf light falloff.
  137690. */
  137691. get useGLTFLightFalloff(): boolean;
  137692. /**
  137693. * In order to support the falloff compatibility with gltf, a special mode has been added
  137694. * to reproduce the gltf light falloff.
  137695. */
  137696. set useGLTFLightFalloff(value: boolean);
  137697. /**
  137698. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137699. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137700. */
  137701. useRadianceOverAlpha: boolean;
  137702. /**
  137703. * Allows using an object space normal map (instead of tangent space).
  137704. */
  137705. useObjectSpaceNormalMap: boolean;
  137706. /**
  137707. * Allows using the bump map in parallax mode.
  137708. */
  137709. useParallax: boolean;
  137710. /**
  137711. * Allows using the bump map in parallax occlusion mode.
  137712. */
  137713. useParallaxOcclusion: boolean;
  137714. /**
  137715. * Controls the scale bias of the parallax mode.
  137716. */
  137717. parallaxScaleBias: number;
  137718. /**
  137719. * If sets to true, disables all the lights affecting the material.
  137720. */
  137721. disableLighting: boolean;
  137722. /**
  137723. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137724. */
  137725. forceIrradianceInFragment: boolean;
  137726. /**
  137727. * Number of Simultaneous lights allowed on the material.
  137728. */
  137729. maxSimultaneousLights: number;
  137730. /**
  137731. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  137732. */
  137733. invertNormalMapX: boolean;
  137734. /**
  137735. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  137736. */
  137737. invertNormalMapY: boolean;
  137738. /**
  137739. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137740. */
  137741. twoSidedLighting: boolean;
  137742. /**
  137743. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137744. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137745. */
  137746. useAlphaFresnel: boolean;
  137747. /**
  137748. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137749. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137750. */
  137751. useLinearAlphaFresnel: boolean;
  137752. /**
  137753. * Let user defines the brdf lookup texture used for IBL.
  137754. * A default 8bit version is embedded but you could point at :
  137755. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  137756. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  137757. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  137758. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  137759. */
  137760. environmentBRDFTexture: Nullable<BaseTexture>;
  137761. /**
  137762. * Force normal to face away from face.
  137763. */
  137764. forceNormalForward: boolean;
  137765. /**
  137766. * Enables specular anti aliasing in the PBR shader.
  137767. * It will both interacts on the Geometry for analytical and IBL lighting.
  137768. * It also prefilter the roughness map based on the bump values.
  137769. */
  137770. enableSpecularAntiAliasing: boolean;
  137771. /**
  137772. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137773. * makes the reflect vector face the model (under horizon).
  137774. */
  137775. useHorizonOcclusion: boolean;
  137776. /**
  137777. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137778. * too much the area relying on ambient texture to define their ambient occlusion.
  137779. */
  137780. useRadianceOcclusion: boolean;
  137781. /**
  137782. * If set to true, no lighting calculations will be applied.
  137783. */
  137784. unlit: boolean;
  137785. /**
  137786. * Gets the image processing configuration used either in this material.
  137787. */
  137788. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  137789. /**
  137790. * Sets the Default image processing configuration used either in the this material.
  137791. *
  137792. * If sets to null, the scene one is in use.
  137793. */
  137794. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  137795. /**
  137796. * Gets wether the color curves effect is enabled.
  137797. */
  137798. get cameraColorCurvesEnabled(): boolean;
  137799. /**
  137800. * Sets wether the color curves effect is enabled.
  137801. */
  137802. set cameraColorCurvesEnabled(value: boolean);
  137803. /**
  137804. * Gets wether the color grading effect is enabled.
  137805. */
  137806. get cameraColorGradingEnabled(): boolean;
  137807. /**
  137808. * Gets wether the color grading effect is enabled.
  137809. */
  137810. set cameraColorGradingEnabled(value: boolean);
  137811. /**
  137812. * Gets wether tonemapping is enabled or not.
  137813. */
  137814. get cameraToneMappingEnabled(): boolean;
  137815. /**
  137816. * Sets wether tonemapping is enabled or not
  137817. */
  137818. set cameraToneMappingEnabled(value: boolean);
  137819. /**
  137820. * The camera exposure used on this material.
  137821. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137822. * This corresponds to a photographic exposure.
  137823. */
  137824. get cameraExposure(): number;
  137825. /**
  137826. * The camera exposure used on this material.
  137827. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  137828. * This corresponds to a photographic exposure.
  137829. */
  137830. set cameraExposure(value: number);
  137831. /**
  137832. * Gets The camera contrast used on this material.
  137833. */
  137834. get cameraContrast(): number;
  137835. /**
  137836. * Sets The camera contrast used on this material.
  137837. */
  137838. set cameraContrast(value: number);
  137839. /**
  137840. * Gets the Color Grading 2D Lookup Texture.
  137841. */
  137842. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  137843. /**
  137844. * Sets the Color Grading 2D Lookup Texture.
  137845. */
  137846. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  137847. /**
  137848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137850. * 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;
  137851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137852. */
  137853. get cameraColorCurves(): Nullable<ColorCurves>;
  137854. /**
  137855. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  137856. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  137857. * 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;
  137858. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  137859. */
  137860. set cameraColorCurves(value: Nullable<ColorCurves>);
  137861. /**
  137862. * Instantiates a new PBRMaterial instance.
  137863. *
  137864. * @param name The material name
  137865. * @param scene The scene the material will be use in.
  137866. */
  137867. constructor(name: string, scene: Scene);
  137868. /**
  137869. * Returns the name of this material class.
  137870. */
  137871. getClassName(): string;
  137872. /**
  137873. * Makes a duplicate of the current material.
  137874. * @param name - name to use for the new material.
  137875. */
  137876. clone(name: string): PBRMaterial;
  137877. /**
  137878. * Serializes this PBR Material.
  137879. * @returns - An object with the serialized material.
  137880. */
  137881. serialize(): any;
  137882. /**
  137883. * Parses a PBR Material from a serialized object.
  137884. * @param source - Serialized object.
  137885. * @param scene - BJS scene instance.
  137886. * @param rootUrl - url for the scene object
  137887. * @returns - PBRMaterial
  137888. */
  137889. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  137890. }
  137891. }
  137892. declare module BABYLON {
  137893. /**
  137894. * Direct draw surface info
  137895. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  137896. */
  137897. export interface DDSInfo {
  137898. /**
  137899. * Width of the texture
  137900. */
  137901. width: number;
  137902. /**
  137903. * Width of the texture
  137904. */
  137905. height: number;
  137906. /**
  137907. * Number of Mipmaps for the texture
  137908. * @see https://en.wikipedia.org/wiki/Mipmap
  137909. */
  137910. mipmapCount: number;
  137911. /**
  137912. * If the textures format is a known fourCC format
  137913. * @see https://www.fourcc.org/
  137914. */
  137915. isFourCC: boolean;
  137916. /**
  137917. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  137918. */
  137919. isRGB: boolean;
  137920. /**
  137921. * If the texture is a lumincance format
  137922. */
  137923. isLuminance: boolean;
  137924. /**
  137925. * If this is a cube texture
  137926. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  137927. */
  137928. isCube: boolean;
  137929. /**
  137930. * If the texture is a compressed format eg. FOURCC_DXT1
  137931. */
  137932. isCompressed: boolean;
  137933. /**
  137934. * The dxgiFormat of the texture
  137935. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  137936. */
  137937. dxgiFormat: number;
  137938. /**
  137939. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  137940. */
  137941. textureType: number;
  137942. /**
  137943. * Sphericle polynomial created for the dds texture
  137944. */
  137945. sphericalPolynomial?: SphericalPolynomial;
  137946. }
  137947. /**
  137948. * Class used to provide DDS decompression tools
  137949. */
  137950. export class DDSTools {
  137951. /**
  137952. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  137953. */
  137954. static StoreLODInAlphaChannel: boolean;
  137955. /**
  137956. * Gets DDS information from an array buffer
  137957. * @param data defines the array buffer view to read data from
  137958. * @returns the DDS information
  137959. */
  137960. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  137961. private static _FloatView;
  137962. private static _Int32View;
  137963. private static _ToHalfFloat;
  137964. private static _FromHalfFloat;
  137965. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  137966. private static _GetHalfFloatRGBAArrayBuffer;
  137967. private static _GetFloatRGBAArrayBuffer;
  137968. private static _GetFloatAsUIntRGBAArrayBuffer;
  137969. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  137970. private static _GetRGBAArrayBuffer;
  137971. private static _ExtractLongWordOrder;
  137972. private static _GetRGBArrayBuffer;
  137973. private static _GetLuminanceArrayBuffer;
  137974. /**
  137975. * Uploads DDS Levels to a Babylon Texture
  137976. * @hidden
  137977. */
  137978. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  137979. }
  137980. interface ThinEngine {
  137981. /**
  137982. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  137983. * @param rootUrl defines the url where the file to load is located
  137984. * @param scene defines the current scene
  137985. * @param lodScale defines scale to apply to the mip map selection
  137986. * @param lodOffset defines offset to apply to the mip map selection
  137987. * @param onLoad defines an optional callback raised when the texture is loaded
  137988. * @param onError defines an optional callback raised if there is an issue to load the texture
  137989. * @param format defines the format of the data
  137990. * @param forcedExtension defines the extension to use to pick the right loader
  137991. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  137992. * @returns the cube texture as an InternalTexture
  137993. */
  137994. 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;
  137995. }
  137996. }
  137997. declare module BABYLON {
  137998. /**
  137999. * Implementation of the DDS Texture Loader.
  138000. * @hidden
  138001. */
  138002. export class _DDSTextureLoader implements IInternalTextureLoader {
  138003. /**
  138004. * Defines wether the loader supports cascade loading the different faces.
  138005. */
  138006. readonly supportCascades: boolean;
  138007. /**
  138008. * This returns if the loader support the current file information.
  138009. * @param extension defines the file extension of the file being loaded
  138010. * @returns true if the loader can load the specified file
  138011. */
  138012. canLoad(extension: string): boolean;
  138013. /**
  138014. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138015. * @param data contains the texture data
  138016. * @param texture defines the BabylonJS internal texture
  138017. * @param createPolynomials will be true if polynomials have been requested
  138018. * @param onLoad defines the callback to trigger once the texture is ready
  138019. * @param onError defines the callback to trigger in case of error
  138020. */
  138021. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138022. /**
  138023. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138024. * @param data contains the texture data
  138025. * @param texture defines the BabylonJS internal texture
  138026. * @param callback defines the method to call once ready to upload
  138027. */
  138028. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138029. }
  138030. }
  138031. declare module BABYLON {
  138032. /**
  138033. * Implementation of the ENV Texture Loader.
  138034. * @hidden
  138035. */
  138036. export class _ENVTextureLoader implements IInternalTextureLoader {
  138037. /**
  138038. * Defines wether the loader supports cascade loading the different faces.
  138039. */
  138040. readonly supportCascades: boolean;
  138041. /**
  138042. * This returns if the loader support the current file information.
  138043. * @param extension defines the file extension of the file being loaded
  138044. * @returns true if the loader can load the specified file
  138045. */
  138046. canLoad(extension: string): boolean;
  138047. /**
  138048. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138049. * @param data contains the texture data
  138050. * @param texture defines the BabylonJS internal texture
  138051. * @param createPolynomials will be true if polynomials have been requested
  138052. * @param onLoad defines the callback to trigger once the texture is ready
  138053. * @param onError defines the callback to trigger in case of error
  138054. */
  138055. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138056. /**
  138057. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138058. * @param data contains the texture data
  138059. * @param texture defines the BabylonJS internal texture
  138060. * @param callback defines the method to call once ready to upload
  138061. */
  138062. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138063. }
  138064. }
  138065. declare module BABYLON {
  138066. /**
  138067. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138068. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138069. */
  138070. export class KhronosTextureContainer {
  138071. /** contents of the KTX container file */
  138072. data: ArrayBufferView;
  138073. private static HEADER_LEN;
  138074. private static COMPRESSED_2D;
  138075. private static COMPRESSED_3D;
  138076. private static TEX_2D;
  138077. private static TEX_3D;
  138078. /**
  138079. * Gets the openGL type
  138080. */
  138081. glType: number;
  138082. /**
  138083. * Gets the openGL type size
  138084. */
  138085. glTypeSize: number;
  138086. /**
  138087. * Gets the openGL format
  138088. */
  138089. glFormat: number;
  138090. /**
  138091. * Gets the openGL internal format
  138092. */
  138093. glInternalFormat: number;
  138094. /**
  138095. * Gets the base internal format
  138096. */
  138097. glBaseInternalFormat: number;
  138098. /**
  138099. * Gets image width in pixel
  138100. */
  138101. pixelWidth: number;
  138102. /**
  138103. * Gets image height in pixel
  138104. */
  138105. pixelHeight: number;
  138106. /**
  138107. * Gets image depth in pixels
  138108. */
  138109. pixelDepth: number;
  138110. /**
  138111. * Gets the number of array elements
  138112. */
  138113. numberOfArrayElements: number;
  138114. /**
  138115. * Gets the number of faces
  138116. */
  138117. numberOfFaces: number;
  138118. /**
  138119. * Gets the number of mipmap levels
  138120. */
  138121. numberOfMipmapLevels: number;
  138122. /**
  138123. * Gets the bytes of key value data
  138124. */
  138125. bytesOfKeyValueData: number;
  138126. /**
  138127. * Gets the load type
  138128. */
  138129. loadType: number;
  138130. /**
  138131. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138132. */
  138133. isInvalid: boolean;
  138134. /**
  138135. * Creates a new KhronosTextureContainer
  138136. * @param data contents of the KTX container file
  138137. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138138. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138139. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138140. */
  138141. constructor(
  138142. /** contents of the KTX container file */
  138143. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138144. /**
  138145. * Uploads KTX content to a Babylon Texture.
  138146. * It is assumed that the texture has already been created & is currently bound
  138147. * @hidden
  138148. */
  138149. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138150. private _upload2DCompressedLevels;
  138151. /**
  138152. * Checks if the given data starts with a KTX file identifier.
  138153. * @param data the data to check
  138154. * @returns true if the data is a KTX file or false otherwise
  138155. */
  138156. static IsValid(data: ArrayBufferView): boolean;
  138157. }
  138158. }
  138159. declare module BABYLON {
  138160. /**
  138161. * Helper class to push actions to a pool of workers.
  138162. */
  138163. export class WorkerPool implements IDisposable {
  138164. private _workerInfos;
  138165. private _pendingActions;
  138166. /**
  138167. * Constructor
  138168. * @param workers Array of workers to use for actions
  138169. */
  138170. constructor(workers: Array<Worker>);
  138171. /**
  138172. * Terminates all workers and clears any pending actions.
  138173. */
  138174. dispose(): void;
  138175. /**
  138176. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138177. * pended until a worker has completed its action.
  138178. * @param action The action to perform. Call onComplete when the action is complete.
  138179. */
  138180. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138181. private _execute;
  138182. }
  138183. }
  138184. declare module BABYLON {
  138185. /**
  138186. * Class for loading KTX2 files
  138187. * @hidden
  138188. */
  138189. export class KhronosTextureContainer2 {
  138190. private static _WorkerPoolPromise?;
  138191. private static _Initialized;
  138192. private static _Ktx2Decoder;
  138193. /**
  138194. * URL to use when loading the KTX2 decoder module
  138195. */
  138196. static JSModuleURL: string;
  138197. /**
  138198. * Default number of workers used to handle data decoding
  138199. */
  138200. static DefaultNumWorkers: number;
  138201. private static GetDefaultNumWorkers;
  138202. private _engine;
  138203. private static _CreateWorkerPool;
  138204. /**
  138205. * Constructor
  138206. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138207. */
  138208. constructor(engine: ThinEngine, numWorkers?: number);
  138209. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138210. /**
  138211. * Stop all async operations and release resources.
  138212. */
  138213. dispose(): void;
  138214. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138215. /**
  138216. * Checks if the given data starts with a KTX2 file identifier.
  138217. * @param data the data to check
  138218. * @returns true if the data is a KTX2 file or false otherwise
  138219. */
  138220. static IsValid(data: ArrayBufferView): boolean;
  138221. }
  138222. export function workerFunc(): void;
  138223. }
  138224. declare module BABYLON {
  138225. /**
  138226. * Implementation of the KTX Texture Loader.
  138227. * @hidden
  138228. */
  138229. export class _KTXTextureLoader implements IInternalTextureLoader {
  138230. /**
  138231. * Defines wether the loader supports cascade loading the different faces.
  138232. */
  138233. readonly supportCascades: boolean;
  138234. /**
  138235. * This returns if the loader support the current file information.
  138236. * @param extension defines the file extension of the file being loaded
  138237. * @param mimeType defines the optional mime type of the file being loaded
  138238. * @returns true if the loader can load the specified file
  138239. */
  138240. canLoad(extension: string, mimeType?: string): boolean;
  138241. /**
  138242. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138243. * @param data contains the texture data
  138244. * @param texture defines the BabylonJS internal texture
  138245. * @param createPolynomials will be true if polynomials have been requested
  138246. * @param onLoad defines the callback to trigger once the texture is ready
  138247. * @param onError defines the callback to trigger in case of error
  138248. */
  138249. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138250. /**
  138251. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138252. * @param data contains the texture data
  138253. * @param texture defines the BabylonJS internal texture
  138254. * @param callback defines the method to call once ready to upload
  138255. */
  138256. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138257. }
  138258. }
  138259. declare module BABYLON {
  138260. /** @hidden */
  138261. export var _forceSceneHelpersToBundle: boolean;
  138262. interface Scene {
  138263. /**
  138264. * Creates a default light for the scene.
  138265. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138266. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138267. */
  138268. createDefaultLight(replace?: boolean): void;
  138269. /**
  138270. * Creates a default camera for the scene.
  138271. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138272. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138273. * @param replace has default false, when true replaces the active camera in the scene
  138274. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138275. */
  138276. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138277. /**
  138278. * Creates a default camera and a default light.
  138279. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138280. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138281. * @param replace has the default false, when true replaces the active camera/light in the scene
  138282. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138283. */
  138284. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138285. /**
  138286. * Creates a new sky box
  138287. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138288. * @param environmentTexture defines the texture to use as environment texture
  138289. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138290. * @param scale defines the overall scale of the skybox
  138291. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138292. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138293. * @returns a new mesh holding the sky box
  138294. */
  138295. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138296. /**
  138297. * Creates a new environment
  138298. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138299. * @param options defines the options you can use to configure the environment
  138300. * @returns the new EnvironmentHelper
  138301. */
  138302. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138303. /**
  138304. * Creates a new VREXperienceHelper
  138305. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138306. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138307. * @returns a new VREXperienceHelper
  138308. */
  138309. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138310. /**
  138311. * Creates a new WebXRDefaultExperience
  138312. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138313. * @param options experience options
  138314. * @returns a promise for a new WebXRDefaultExperience
  138315. */
  138316. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138317. }
  138318. }
  138319. declare module BABYLON {
  138320. /**
  138321. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138322. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138323. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138324. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138325. */
  138326. export class VideoDome extends TextureDome<VideoTexture> {
  138327. /**
  138328. * Define the video source as a Monoscopic panoramic 360 video.
  138329. */
  138330. static readonly MODE_MONOSCOPIC: number;
  138331. /**
  138332. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138333. */
  138334. static readonly MODE_TOPBOTTOM: number;
  138335. /**
  138336. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138337. */
  138338. static readonly MODE_SIDEBYSIDE: number;
  138339. /**
  138340. * Get the video texture associated with this video dome
  138341. */
  138342. get videoTexture(): VideoTexture;
  138343. /**
  138344. * Get the video mode of this dome
  138345. */
  138346. get videoMode(): number;
  138347. /**
  138348. * Set the video mode of this dome.
  138349. * @see textureMode
  138350. */
  138351. set videoMode(value: number);
  138352. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138353. }
  138354. }
  138355. declare module BABYLON {
  138356. /**
  138357. * This class can be used to get instrumentation data from a Babylon engine
  138358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138359. */
  138360. export class EngineInstrumentation implements IDisposable {
  138361. /**
  138362. * Define the instrumented engine.
  138363. */
  138364. engine: Engine;
  138365. private _captureGPUFrameTime;
  138366. private _gpuFrameTimeToken;
  138367. private _gpuFrameTime;
  138368. private _captureShaderCompilationTime;
  138369. private _shaderCompilationTime;
  138370. private _onBeginFrameObserver;
  138371. private _onEndFrameObserver;
  138372. private _onBeforeShaderCompilationObserver;
  138373. private _onAfterShaderCompilationObserver;
  138374. /**
  138375. * Gets the perf counter used for GPU frame time
  138376. */
  138377. get gpuFrameTimeCounter(): PerfCounter;
  138378. /**
  138379. * Gets the GPU frame time capture status
  138380. */
  138381. get captureGPUFrameTime(): boolean;
  138382. /**
  138383. * Enable or disable the GPU frame time capture
  138384. */
  138385. set captureGPUFrameTime(value: boolean);
  138386. /**
  138387. * Gets the perf counter used for shader compilation time
  138388. */
  138389. get shaderCompilationTimeCounter(): PerfCounter;
  138390. /**
  138391. * Gets the shader compilation time capture status
  138392. */
  138393. get captureShaderCompilationTime(): boolean;
  138394. /**
  138395. * Enable or disable the shader compilation time capture
  138396. */
  138397. set captureShaderCompilationTime(value: boolean);
  138398. /**
  138399. * Instantiates a new engine instrumentation.
  138400. * This class can be used to get instrumentation data from a Babylon engine
  138401. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138402. * @param engine Defines the engine to instrument
  138403. */
  138404. constructor(
  138405. /**
  138406. * Define the instrumented engine.
  138407. */
  138408. engine: Engine);
  138409. /**
  138410. * Dispose and release associated resources.
  138411. */
  138412. dispose(): void;
  138413. }
  138414. }
  138415. declare module BABYLON {
  138416. /**
  138417. * This class can be used to get instrumentation data from a Babylon engine
  138418. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138419. */
  138420. export class SceneInstrumentation implements IDisposable {
  138421. /**
  138422. * Defines the scene to instrument
  138423. */
  138424. scene: Scene;
  138425. private _captureActiveMeshesEvaluationTime;
  138426. private _activeMeshesEvaluationTime;
  138427. private _captureRenderTargetsRenderTime;
  138428. private _renderTargetsRenderTime;
  138429. private _captureFrameTime;
  138430. private _frameTime;
  138431. private _captureRenderTime;
  138432. private _renderTime;
  138433. private _captureInterFrameTime;
  138434. private _interFrameTime;
  138435. private _captureParticlesRenderTime;
  138436. private _particlesRenderTime;
  138437. private _captureSpritesRenderTime;
  138438. private _spritesRenderTime;
  138439. private _capturePhysicsTime;
  138440. private _physicsTime;
  138441. private _captureAnimationsTime;
  138442. private _animationsTime;
  138443. private _captureCameraRenderTime;
  138444. private _cameraRenderTime;
  138445. private _onBeforeActiveMeshesEvaluationObserver;
  138446. private _onAfterActiveMeshesEvaluationObserver;
  138447. private _onBeforeRenderTargetsRenderObserver;
  138448. private _onAfterRenderTargetsRenderObserver;
  138449. private _onAfterRenderObserver;
  138450. private _onBeforeDrawPhaseObserver;
  138451. private _onAfterDrawPhaseObserver;
  138452. private _onBeforeAnimationsObserver;
  138453. private _onBeforeParticlesRenderingObserver;
  138454. private _onAfterParticlesRenderingObserver;
  138455. private _onBeforeSpritesRenderingObserver;
  138456. private _onAfterSpritesRenderingObserver;
  138457. private _onBeforePhysicsObserver;
  138458. private _onAfterPhysicsObserver;
  138459. private _onAfterAnimationsObserver;
  138460. private _onBeforeCameraRenderObserver;
  138461. private _onAfterCameraRenderObserver;
  138462. /**
  138463. * Gets the perf counter used for active meshes evaluation time
  138464. */
  138465. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138466. /**
  138467. * Gets the active meshes evaluation time capture status
  138468. */
  138469. get captureActiveMeshesEvaluationTime(): boolean;
  138470. /**
  138471. * Enable or disable the active meshes evaluation time capture
  138472. */
  138473. set captureActiveMeshesEvaluationTime(value: boolean);
  138474. /**
  138475. * Gets the perf counter used for render targets render time
  138476. */
  138477. get renderTargetsRenderTimeCounter(): PerfCounter;
  138478. /**
  138479. * Gets the render targets render time capture status
  138480. */
  138481. get captureRenderTargetsRenderTime(): boolean;
  138482. /**
  138483. * Enable or disable the render targets render time capture
  138484. */
  138485. set captureRenderTargetsRenderTime(value: boolean);
  138486. /**
  138487. * Gets the perf counter used for particles render time
  138488. */
  138489. get particlesRenderTimeCounter(): PerfCounter;
  138490. /**
  138491. * Gets the particles render time capture status
  138492. */
  138493. get captureParticlesRenderTime(): boolean;
  138494. /**
  138495. * Enable or disable the particles render time capture
  138496. */
  138497. set captureParticlesRenderTime(value: boolean);
  138498. /**
  138499. * Gets the perf counter used for sprites render time
  138500. */
  138501. get spritesRenderTimeCounter(): PerfCounter;
  138502. /**
  138503. * Gets the sprites render time capture status
  138504. */
  138505. get captureSpritesRenderTime(): boolean;
  138506. /**
  138507. * Enable or disable the sprites render time capture
  138508. */
  138509. set captureSpritesRenderTime(value: boolean);
  138510. /**
  138511. * Gets the perf counter used for physics time
  138512. */
  138513. get physicsTimeCounter(): PerfCounter;
  138514. /**
  138515. * Gets the physics time capture status
  138516. */
  138517. get capturePhysicsTime(): boolean;
  138518. /**
  138519. * Enable or disable the physics time capture
  138520. */
  138521. set capturePhysicsTime(value: boolean);
  138522. /**
  138523. * Gets the perf counter used for animations time
  138524. */
  138525. get animationsTimeCounter(): PerfCounter;
  138526. /**
  138527. * Gets the animations time capture status
  138528. */
  138529. get captureAnimationsTime(): boolean;
  138530. /**
  138531. * Enable or disable the animations time capture
  138532. */
  138533. set captureAnimationsTime(value: boolean);
  138534. /**
  138535. * Gets the perf counter used for frame time capture
  138536. */
  138537. get frameTimeCounter(): PerfCounter;
  138538. /**
  138539. * Gets the frame time capture status
  138540. */
  138541. get captureFrameTime(): boolean;
  138542. /**
  138543. * Enable or disable the frame time capture
  138544. */
  138545. set captureFrameTime(value: boolean);
  138546. /**
  138547. * Gets the perf counter used for inter-frames time capture
  138548. */
  138549. get interFrameTimeCounter(): PerfCounter;
  138550. /**
  138551. * Gets the inter-frames time capture status
  138552. */
  138553. get captureInterFrameTime(): boolean;
  138554. /**
  138555. * Enable or disable the inter-frames time capture
  138556. */
  138557. set captureInterFrameTime(value: boolean);
  138558. /**
  138559. * Gets the perf counter used for render time capture
  138560. */
  138561. get renderTimeCounter(): PerfCounter;
  138562. /**
  138563. * Gets the render time capture status
  138564. */
  138565. get captureRenderTime(): boolean;
  138566. /**
  138567. * Enable or disable the render time capture
  138568. */
  138569. set captureRenderTime(value: boolean);
  138570. /**
  138571. * Gets the perf counter used for camera render time capture
  138572. */
  138573. get cameraRenderTimeCounter(): PerfCounter;
  138574. /**
  138575. * Gets the camera render time capture status
  138576. */
  138577. get captureCameraRenderTime(): boolean;
  138578. /**
  138579. * Enable or disable the camera render time capture
  138580. */
  138581. set captureCameraRenderTime(value: boolean);
  138582. /**
  138583. * Gets the perf counter used for draw calls
  138584. */
  138585. get drawCallsCounter(): PerfCounter;
  138586. /**
  138587. * Instantiates a new scene instrumentation.
  138588. * This class can be used to get instrumentation data from a Babylon engine
  138589. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138590. * @param scene Defines the scene to instrument
  138591. */
  138592. constructor(
  138593. /**
  138594. * Defines the scene to instrument
  138595. */
  138596. scene: Scene);
  138597. /**
  138598. * Dispose and release associated resources.
  138599. */
  138600. dispose(): void;
  138601. }
  138602. }
  138603. declare module BABYLON {
  138604. /** @hidden */
  138605. export var glowMapGenerationPixelShader: {
  138606. name: string;
  138607. shader: string;
  138608. };
  138609. }
  138610. declare module BABYLON {
  138611. /** @hidden */
  138612. export var glowMapGenerationVertexShader: {
  138613. name: string;
  138614. shader: string;
  138615. };
  138616. }
  138617. declare module BABYLON {
  138618. /**
  138619. * Effect layer options. This helps customizing the behaviour
  138620. * of the effect layer.
  138621. */
  138622. export interface IEffectLayerOptions {
  138623. /**
  138624. * Multiplication factor apply to the canvas size to compute the render target size
  138625. * used to generated the objects (the smaller the faster).
  138626. */
  138627. mainTextureRatio: number;
  138628. /**
  138629. * Enforces a fixed size texture to ensure effect stability across devices.
  138630. */
  138631. mainTextureFixedSize?: number;
  138632. /**
  138633. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  138634. */
  138635. alphaBlendingMode: number;
  138636. /**
  138637. * The camera attached to the layer.
  138638. */
  138639. camera: Nullable<Camera>;
  138640. /**
  138641. * The rendering group to draw the layer in.
  138642. */
  138643. renderingGroupId: number;
  138644. }
  138645. /**
  138646. * The effect layer Helps adding post process effect blended with the main pass.
  138647. *
  138648. * This can be for instance use to generate glow or higlight effects on the scene.
  138649. *
  138650. * The effect layer class can not be used directly and is intented to inherited from to be
  138651. * customized per effects.
  138652. */
  138653. export abstract class EffectLayer {
  138654. private _vertexBuffers;
  138655. private _indexBuffer;
  138656. private _cachedDefines;
  138657. private _effectLayerMapGenerationEffect;
  138658. private _effectLayerOptions;
  138659. private _mergeEffect;
  138660. protected _scene: Scene;
  138661. protected _engine: Engine;
  138662. protected _maxSize: number;
  138663. protected _mainTextureDesiredSize: ISize;
  138664. protected _mainTexture: RenderTargetTexture;
  138665. protected _shouldRender: boolean;
  138666. protected _postProcesses: PostProcess[];
  138667. protected _textures: BaseTexture[];
  138668. protected _emissiveTextureAndColor: {
  138669. texture: Nullable<BaseTexture>;
  138670. color: Color4;
  138671. };
  138672. /**
  138673. * The name of the layer
  138674. */
  138675. name: string;
  138676. /**
  138677. * The clear color of the texture used to generate the glow map.
  138678. */
  138679. neutralColor: Color4;
  138680. /**
  138681. * Specifies whether the highlight layer is enabled or not.
  138682. */
  138683. isEnabled: boolean;
  138684. /**
  138685. * Gets the camera attached to the layer.
  138686. */
  138687. get camera(): Nullable<Camera>;
  138688. /**
  138689. * Gets the rendering group id the layer should render in.
  138690. */
  138691. get renderingGroupId(): number;
  138692. set renderingGroupId(renderingGroupId: number);
  138693. /**
  138694. * An event triggered when the effect layer has been disposed.
  138695. */
  138696. onDisposeObservable: Observable<EffectLayer>;
  138697. /**
  138698. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  138699. */
  138700. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  138701. /**
  138702. * An event triggered when the generated texture is being merged in the scene.
  138703. */
  138704. onBeforeComposeObservable: Observable<EffectLayer>;
  138705. /**
  138706. * An event triggered when the mesh is rendered into the effect render target.
  138707. */
  138708. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  138709. /**
  138710. * An event triggered after the mesh has been rendered into the effect render target.
  138711. */
  138712. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  138713. /**
  138714. * An event triggered when the generated texture has been merged in the scene.
  138715. */
  138716. onAfterComposeObservable: Observable<EffectLayer>;
  138717. /**
  138718. * An event triggered when the efffect layer changes its size.
  138719. */
  138720. onSizeChangedObservable: Observable<EffectLayer>;
  138721. /** @hidden */
  138722. static _SceneComponentInitialization: (scene: Scene) => void;
  138723. /**
  138724. * Instantiates a new effect Layer and references it in the scene.
  138725. * @param name The name of the layer
  138726. * @param scene The scene to use the layer in
  138727. */
  138728. constructor(
  138729. /** The Friendly of the effect in the scene */
  138730. name: string, scene: Scene);
  138731. /**
  138732. * Get the effect name of the layer.
  138733. * @return The effect name
  138734. */
  138735. abstract getEffectName(): string;
  138736. /**
  138737. * Checks for the readiness of the element composing the layer.
  138738. * @param subMesh the mesh to check for
  138739. * @param useInstances specify whether or not to use instances to render the mesh
  138740. * @return true if ready otherwise, false
  138741. */
  138742. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138743. /**
  138744. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  138745. * @returns true if the effect requires stencil during the main canvas render pass.
  138746. */
  138747. abstract needStencil(): boolean;
  138748. /**
  138749. * Create the merge effect. This is the shader use to blit the information back
  138750. * to the main canvas at the end of the scene rendering.
  138751. * @returns The effect containing the shader used to merge the effect on the main canvas
  138752. */
  138753. protected abstract _createMergeEffect(): Effect;
  138754. /**
  138755. * Creates the render target textures and post processes used in the effect layer.
  138756. */
  138757. protected abstract _createTextureAndPostProcesses(): void;
  138758. /**
  138759. * Implementation specific of rendering the generating effect on the main canvas.
  138760. * @param effect The effect used to render through
  138761. */
  138762. protected abstract _internalRender(effect: Effect): void;
  138763. /**
  138764. * Sets the required values for both the emissive texture and and the main color.
  138765. */
  138766. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  138767. /**
  138768. * Free any resources and references associated to a mesh.
  138769. * Internal use
  138770. * @param mesh The mesh to free.
  138771. */
  138772. abstract _disposeMesh(mesh: Mesh): void;
  138773. /**
  138774. * Serializes this layer (Glow or Highlight for example)
  138775. * @returns a serialized layer object
  138776. */
  138777. abstract serialize?(): any;
  138778. /**
  138779. * Initializes the effect layer with the required options.
  138780. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  138781. */
  138782. protected _init(options: Partial<IEffectLayerOptions>): void;
  138783. /**
  138784. * Generates the index buffer of the full screen quad blending to the main canvas.
  138785. */
  138786. private _generateIndexBuffer;
  138787. /**
  138788. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  138789. */
  138790. private _generateVertexBuffer;
  138791. /**
  138792. * Sets the main texture desired size which is the closest power of two
  138793. * of the engine canvas size.
  138794. */
  138795. private _setMainTextureSize;
  138796. /**
  138797. * Creates the main texture for the effect layer.
  138798. */
  138799. protected _createMainTexture(): void;
  138800. /**
  138801. * Adds specific effects defines.
  138802. * @param defines The defines to add specifics to.
  138803. */
  138804. protected _addCustomEffectDefines(defines: string[]): void;
  138805. /**
  138806. * Checks for the readiness of the element composing the layer.
  138807. * @param subMesh the mesh to check for
  138808. * @param useInstances specify whether or not to use instances to render the mesh
  138809. * @param emissiveTexture the associated emissive texture used to generate the glow
  138810. * @return true if ready otherwise, false
  138811. */
  138812. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  138813. /**
  138814. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  138815. */
  138816. render(): void;
  138817. /**
  138818. * Determine if a given mesh will be used in the current effect.
  138819. * @param mesh mesh to test
  138820. * @returns true if the mesh will be used
  138821. */
  138822. hasMesh(mesh: AbstractMesh): boolean;
  138823. /**
  138824. * Returns true if the layer contains information to display, otherwise false.
  138825. * @returns true if the glow layer should be rendered
  138826. */
  138827. shouldRender(): boolean;
  138828. /**
  138829. * Returns true if the mesh should render, otherwise false.
  138830. * @param mesh The mesh to render
  138831. * @returns true if it should render otherwise false
  138832. */
  138833. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  138834. /**
  138835. * Returns true if the mesh can be rendered, otherwise false.
  138836. * @param mesh The mesh to render
  138837. * @param material The material used on the mesh
  138838. * @returns true if it can be rendered otherwise false
  138839. */
  138840. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  138841. /**
  138842. * Returns true if the mesh should render, otherwise false.
  138843. * @param mesh The mesh to render
  138844. * @returns true if it should render otherwise false
  138845. */
  138846. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  138847. /**
  138848. * Renders the submesh passed in parameter to the generation map.
  138849. */
  138850. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  138851. /**
  138852. * Defines whether the current material of the mesh should be use to render the effect.
  138853. * @param mesh defines the current mesh to render
  138854. */
  138855. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  138856. /**
  138857. * Rebuild the required buffers.
  138858. * @hidden Internal use only.
  138859. */
  138860. _rebuild(): void;
  138861. /**
  138862. * Dispose only the render target textures and post process.
  138863. */
  138864. private _disposeTextureAndPostProcesses;
  138865. /**
  138866. * Dispose the highlight layer and free resources.
  138867. */
  138868. dispose(): void;
  138869. /**
  138870. * Gets the class name of the effect layer
  138871. * @returns the string with the class name of the effect layer
  138872. */
  138873. getClassName(): string;
  138874. /**
  138875. * Creates an effect layer from parsed effect layer data
  138876. * @param parsedEffectLayer defines effect layer data
  138877. * @param scene defines the current scene
  138878. * @param rootUrl defines the root URL containing the effect layer information
  138879. * @returns a parsed effect Layer
  138880. */
  138881. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  138882. }
  138883. }
  138884. declare module BABYLON {
  138885. interface AbstractScene {
  138886. /**
  138887. * The list of effect layers (highlights/glow) added to the scene
  138888. * @see https://doc.babylonjs.com/how_to/highlight_layer
  138889. * @see https://doc.babylonjs.com/how_to/glow_layer
  138890. */
  138891. effectLayers: Array<EffectLayer>;
  138892. /**
  138893. * Removes the given effect layer from this scene.
  138894. * @param toRemove defines the effect layer to remove
  138895. * @returns the index of the removed effect layer
  138896. */
  138897. removeEffectLayer(toRemove: EffectLayer): number;
  138898. /**
  138899. * Adds the given effect layer to this scene
  138900. * @param newEffectLayer defines the effect layer to add
  138901. */
  138902. addEffectLayer(newEffectLayer: EffectLayer): void;
  138903. }
  138904. /**
  138905. * Defines the layer scene component responsible to manage any effect layers
  138906. * in a given scene.
  138907. */
  138908. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  138909. /**
  138910. * The component name helpfull to identify the component in the list of scene components.
  138911. */
  138912. readonly name: string;
  138913. /**
  138914. * The scene the component belongs to.
  138915. */
  138916. scene: Scene;
  138917. private _engine;
  138918. private _renderEffects;
  138919. private _needStencil;
  138920. private _previousStencilState;
  138921. /**
  138922. * Creates a new instance of the component for the given scene
  138923. * @param scene Defines the scene to register the component in
  138924. */
  138925. constructor(scene: Scene);
  138926. /**
  138927. * Registers the component in a given scene
  138928. */
  138929. register(): void;
  138930. /**
  138931. * Rebuilds the elements related to this component in case of
  138932. * context lost for instance.
  138933. */
  138934. rebuild(): void;
  138935. /**
  138936. * Serializes the component data to the specified json object
  138937. * @param serializationObject The object to serialize to
  138938. */
  138939. serialize(serializationObject: any): void;
  138940. /**
  138941. * Adds all the elements from the container to the scene
  138942. * @param container the container holding the elements
  138943. */
  138944. addFromContainer(container: AbstractScene): void;
  138945. /**
  138946. * Removes all the elements in the container from the scene
  138947. * @param container contains the elements to remove
  138948. * @param dispose if the removed element should be disposed (default: false)
  138949. */
  138950. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  138951. /**
  138952. * Disposes the component and the associated ressources.
  138953. */
  138954. dispose(): void;
  138955. private _isReadyForMesh;
  138956. private _renderMainTexture;
  138957. private _setStencil;
  138958. private _setStencilBack;
  138959. private _draw;
  138960. private _drawCamera;
  138961. private _drawRenderingGroup;
  138962. }
  138963. }
  138964. declare module BABYLON {
  138965. /** @hidden */
  138966. export var glowMapMergePixelShader: {
  138967. name: string;
  138968. shader: string;
  138969. };
  138970. }
  138971. declare module BABYLON {
  138972. /** @hidden */
  138973. export var glowMapMergeVertexShader: {
  138974. name: string;
  138975. shader: string;
  138976. };
  138977. }
  138978. declare module BABYLON {
  138979. interface AbstractScene {
  138980. /**
  138981. * Return a the first highlight layer of the scene with a given name.
  138982. * @param name The name of the highlight layer to look for.
  138983. * @return The highlight layer if found otherwise null.
  138984. */
  138985. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  138986. }
  138987. /**
  138988. * Glow layer options. This helps customizing the behaviour
  138989. * of the glow layer.
  138990. */
  138991. export interface IGlowLayerOptions {
  138992. /**
  138993. * Multiplication factor apply to the canvas size to compute the render target size
  138994. * used to generated the glowing objects (the smaller the faster).
  138995. */
  138996. mainTextureRatio: number;
  138997. /**
  138998. * Enforces a fixed size texture to ensure resize independant blur.
  138999. */
  139000. mainTextureFixedSize?: number;
  139001. /**
  139002. * How big is the kernel of the blur texture.
  139003. */
  139004. blurKernelSize: number;
  139005. /**
  139006. * The camera attached to the layer.
  139007. */
  139008. camera: Nullable<Camera>;
  139009. /**
  139010. * Enable MSAA by chosing the number of samples.
  139011. */
  139012. mainTextureSamples?: number;
  139013. /**
  139014. * The rendering group to draw the layer in.
  139015. */
  139016. renderingGroupId: number;
  139017. }
  139018. /**
  139019. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139020. *
  139021. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139022. *
  139023. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139024. */
  139025. export class GlowLayer extends EffectLayer {
  139026. /**
  139027. * Effect Name of the layer.
  139028. */
  139029. static readonly EffectName: string;
  139030. /**
  139031. * The default blur kernel size used for the glow.
  139032. */
  139033. static DefaultBlurKernelSize: number;
  139034. /**
  139035. * The default texture size ratio used for the glow.
  139036. */
  139037. static DefaultTextureRatio: number;
  139038. /**
  139039. * Sets the kernel size of the blur.
  139040. */
  139041. set blurKernelSize(value: number);
  139042. /**
  139043. * Gets the kernel size of the blur.
  139044. */
  139045. get blurKernelSize(): number;
  139046. /**
  139047. * Sets the glow intensity.
  139048. */
  139049. set intensity(value: number);
  139050. /**
  139051. * Gets the glow intensity.
  139052. */
  139053. get intensity(): number;
  139054. private _options;
  139055. private _intensity;
  139056. private _horizontalBlurPostprocess1;
  139057. private _verticalBlurPostprocess1;
  139058. private _horizontalBlurPostprocess2;
  139059. private _verticalBlurPostprocess2;
  139060. private _blurTexture1;
  139061. private _blurTexture2;
  139062. private _postProcesses1;
  139063. private _postProcesses2;
  139064. private _includedOnlyMeshes;
  139065. private _excludedMeshes;
  139066. private _meshesUsingTheirOwnMaterials;
  139067. /**
  139068. * Callback used to let the user override the color selection on a per mesh basis
  139069. */
  139070. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139071. /**
  139072. * Callback used to let the user override the texture selection on a per mesh basis
  139073. */
  139074. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139075. /**
  139076. * Instantiates a new glow Layer and references it to the scene.
  139077. * @param name The name of the layer
  139078. * @param scene The scene to use the layer in
  139079. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139080. */
  139081. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139082. /**
  139083. * Get the effect name of the layer.
  139084. * @return The effect name
  139085. */
  139086. getEffectName(): string;
  139087. /**
  139088. * Create the merge effect. This is the shader use to blit the information back
  139089. * to the main canvas at the end of the scene rendering.
  139090. */
  139091. protected _createMergeEffect(): Effect;
  139092. /**
  139093. * Creates the render target textures and post processes used in the glow layer.
  139094. */
  139095. protected _createTextureAndPostProcesses(): void;
  139096. /**
  139097. * Checks for the readiness of the element composing the layer.
  139098. * @param subMesh the mesh to check for
  139099. * @param useInstances specify wether or not to use instances to render the mesh
  139100. * @param emissiveTexture the associated emissive texture used to generate the glow
  139101. * @return true if ready otherwise, false
  139102. */
  139103. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139104. /**
  139105. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139106. */
  139107. needStencil(): boolean;
  139108. /**
  139109. * Returns true if the mesh can be rendered, otherwise false.
  139110. * @param mesh The mesh to render
  139111. * @param material The material used on the mesh
  139112. * @returns true if it can be rendered otherwise false
  139113. */
  139114. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139115. /**
  139116. * Implementation specific of rendering the generating effect on the main canvas.
  139117. * @param effect The effect used to render through
  139118. */
  139119. protected _internalRender(effect: Effect): void;
  139120. /**
  139121. * Sets the required values for both the emissive texture and and the main color.
  139122. */
  139123. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139124. /**
  139125. * Returns true if the mesh should render, otherwise false.
  139126. * @param mesh The mesh to render
  139127. * @returns true if it should render otherwise false
  139128. */
  139129. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139130. /**
  139131. * Adds specific effects defines.
  139132. * @param defines The defines to add specifics to.
  139133. */
  139134. protected _addCustomEffectDefines(defines: string[]): void;
  139135. /**
  139136. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139137. * @param mesh The mesh to exclude from the glow layer
  139138. */
  139139. addExcludedMesh(mesh: Mesh): void;
  139140. /**
  139141. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139142. * @param mesh The mesh to remove
  139143. */
  139144. removeExcludedMesh(mesh: Mesh): void;
  139145. /**
  139146. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139147. * @param mesh The mesh to include in the glow layer
  139148. */
  139149. addIncludedOnlyMesh(mesh: Mesh): void;
  139150. /**
  139151. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139152. * @param mesh The mesh to remove
  139153. */
  139154. removeIncludedOnlyMesh(mesh: Mesh): void;
  139155. /**
  139156. * Determine if a given mesh will be used in the glow layer
  139157. * @param mesh The mesh to test
  139158. * @returns true if the mesh will be highlighted by the current glow layer
  139159. */
  139160. hasMesh(mesh: AbstractMesh): boolean;
  139161. /**
  139162. * Defines whether the current material of the mesh should be use to render the effect.
  139163. * @param mesh defines the current mesh to render
  139164. */
  139165. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139166. /**
  139167. * Add a mesh to be rendered through its own material and not with emissive only.
  139168. * @param mesh The mesh for which we need to use its material
  139169. */
  139170. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139171. /**
  139172. * Remove a mesh from being rendered through its own material and not with emissive only.
  139173. * @param mesh The mesh for which we need to not use its material
  139174. */
  139175. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139176. /**
  139177. * Free any resources and references associated to a mesh.
  139178. * Internal use
  139179. * @param mesh The mesh to free.
  139180. * @hidden
  139181. */
  139182. _disposeMesh(mesh: Mesh): void;
  139183. /**
  139184. * Gets the class name of the effect layer
  139185. * @returns the string with the class name of the effect layer
  139186. */
  139187. getClassName(): string;
  139188. /**
  139189. * Serializes this glow layer
  139190. * @returns a serialized glow layer object
  139191. */
  139192. serialize(): any;
  139193. /**
  139194. * Creates a Glow Layer from parsed glow layer data
  139195. * @param parsedGlowLayer defines glow layer data
  139196. * @param scene defines the current scene
  139197. * @param rootUrl defines the root URL containing the glow layer information
  139198. * @returns a parsed Glow Layer
  139199. */
  139200. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139201. }
  139202. }
  139203. declare module BABYLON {
  139204. /** @hidden */
  139205. export var glowBlurPostProcessPixelShader: {
  139206. name: string;
  139207. shader: string;
  139208. };
  139209. }
  139210. declare module BABYLON {
  139211. interface AbstractScene {
  139212. /**
  139213. * Return a the first highlight layer of the scene with a given name.
  139214. * @param name The name of the highlight layer to look for.
  139215. * @return The highlight layer if found otherwise null.
  139216. */
  139217. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139218. }
  139219. /**
  139220. * Highlight layer options. This helps customizing the behaviour
  139221. * of the highlight layer.
  139222. */
  139223. export interface IHighlightLayerOptions {
  139224. /**
  139225. * Multiplication factor apply to the canvas size to compute the render target size
  139226. * used to generated the glowing objects (the smaller the faster).
  139227. */
  139228. mainTextureRatio: number;
  139229. /**
  139230. * Enforces a fixed size texture to ensure resize independant blur.
  139231. */
  139232. mainTextureFixedSize?: number;
  139233. /**
  139234. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139235. * of the picture to blur (the smaller the faster).
  139236. */
  139237. blurTextureSizeRatio: number;
  139238. /**
  139239. * How big in texel of the blur texture is the vertical blur.
  139240. */
  139241. blurVerticalSize: number;
  139242. /**
  139243. * How big in texel of the blur texture is the horizontal blur.
  139244. */
  139245. blurHorizontalSize: number;
  139246. /**
  139247. * Alpha blending mode used to apply the blur. Default is combine.
  139248. */
  139249. alphaBlendingMode: number;
  139250. /**
  139251. * The camera attached to the layer.
  139252. */
  139253. camera: Nullable<Camera>;
  139254. /**
  139255. * Should we display highlight as a solid stroke?
  139256. */
  139257. isStroke?: boolean;
  139258. /**
  139259. * The rendering group to draw the layer in.
  139260. */
  139261. renderingGroupId: number;
  139262. }
  139263. /**
  139264. * The highlight layer Helps adding a glow effect around a mesh.
  139265. *
  139266. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139267. * glowy meshes to your scene.
  139268. *
  139269. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139270. */
  139271. export class HighlightLayer extends EffectLayer {
  139272. name: string;
  139273. /**
  139274. * Effect Name of the highlight layer.
  139275. */
  139276. static readonly EffectName: string;
  139277. /**
  139278. * The neutral color used during the preparation of the glow effect.
  139279. * This is black by default as the blend operation is a blend operation.
  139280. */
  139281. static NeutralColor: Color4;
  139282. /**
  139283. * Stencil value used for glowing meshes.
  139284. */
  139285. static GlowingMeshStencilReference: number;
  139286. /**
  139287. * Stencil value used for the other meshes in the scene.
  139288. */
  139289. static NormalMeshStencilReference: number;
  139290. /**
  139291. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139292. */
  139293. innerGlow: boolean;
  139294. /**
  139295. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139296. */
  139297. outerGlow: boolean;
  139298. /**
  139299. * Specifies the horizontal size of the blur.
  139300. */
  139301. set blurHorizontalSize(value: number);
  139302. /**
  139303. * Specifies the vertical size of the blur.
  139304. */
  139305. set blurVerticalSize(value: number);
  139306. /**
  139307. * Gets the horizontal size of the blur.
  139308. */
  139309. get blurHorizontalSize(): number;
  139310. /**
  139311. * Gets the vertical size of the blur.
  139312. */
  139313. get blurVerticalSize(): number;
  139314. /**
  139315. * An event triggered when the highlight layer is being blurred.
  139316. */
  139317. onBeforeBlurObservable: Observable<HighlightLayer>;
  139318. /**
  139319. * An event triggered when the highlight layer has been blurred.
  139320. */
  139321. onAfterBlurObservable: Observable<HighlightLayer>;
  139322. private _instanceGlowingMeshStencilReference;
  139323. private _options;
  139324. private _downSamplePostprocess;
  139325. private _horizontalBlurPostprocess;
  139326. private _verticalBlurPostprocess;
  139327. private _blurTexture;
  139328. private _meshes;
  139329. private _excludedMeshes;
  139330. /**
  139331. * Instantiates a new highlight Layer and references it to the scene..
  139332. * @param name The name of the layer
  139333. * @param scene The scene to use the layer in
  139334. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139335. */
  139336. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139337. /**
  139338. * Get the effect name of the layer.
  139339. * @return The effect name
  139340. */
  139341. getEffectName(): string;
  139342. /**
  139343. * Create the merge effect. This is the shader use to blit the information back
  139344. * to the main canvas at the end of the scene rendering.
  139345. */
  139346. protected _createMergeEffect(): Effect;
  139347. /**
  139348. * Creates the render target textures and post processes used in the highlight layer.
  139349. */
  139350. protected _createTextureAndPostProcesses(): void;
  139351. /**
  139352. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139353. */
  139354. needStencil(): boolean;
  139355. /**
  139356. * Checks for the readiness of the element composing the layer.
  139357. * @param subMesh the mesh to check for
  139358. * @param useInstances specify wether or not to use instances to render the mesh
  139359. * @param emissiveTexture the associated emissive texture used to generate the glow
  139360. * @return true if ready otherwise, false
  139361. */
  139362. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139363. /**
  139364. * Implementation specific of rendering the generating effect on the main canvas.
  139365. * @param effect The effect used to render through
  139366. */
  139367. protected _internalRender(effect: Effect): void;
  139368. /**
  139369. * Returns true if the layer contains information to display, otherwise false.
  139370. */
  139371. shouldRender(): boolean;
  139372. /**
  139373. * Returns true if the mesh should render, otherwise false.
  139374. * @param mesh The mesh to render
  139375. * @returns true if it should render otherwise false
  139376. */
  139377. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139378. /**
  139379. * Returns true if the mesh can be rendered, otherwise false.
  139380. * @param mesh The mesh to render
  139381. * @param material The material used on the mesh
  139382. * @returns true if it can be rendered otherwise false
  139383. */
  139384. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139385. /**
  139386. * Adds specific effects defines.
  139387. * @param defines The defines to add specifics to.
  139388. */
  139389. protected _addCustomEffectDefines(defines: string[]): void;
  139390. /**
  139391. * Sets the required values for both the emissive texture and and the main color.
  139392. */
  139393. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139394. /**
  139395. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139396. * @param mesh The mesh to exclude from the highlight layer
  139397. */
  139398. addExcludedMesh(mesh: Mesh): void;
  139399. /**
  139400. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139401. * @param mesh The mesh to highlight
  139402. */
  139403. removeExcludedMesh(mesh: Mesh): void;
  139404. /**
  139405. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139406. * @param mesh mesh to test
  139407. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139408. */
  139409. hasMesh(mesh: AbstractMesh): boolean;
  139410. /**
  139411. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139412. * @param mesh The mesh to highlight
  139413. * @param color The color of the highlight
  139414. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139415. */
  139416. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139417. /**
  139418. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139419. * @param mesh The mesh to highlight
  139420. */
  139421. removeMesh(mesh: Mesh): void;
  139422. /**
  139423. * Remove all the meshes currently referenced in the highlight layer
  139424. */
  139425. removeAllMeshes(): void;
  139426. /**
  139427. * Force the stencil to the normal expected value for none glowing parts
  139428. */
  139429. private _defaultStencilReference;
  139430. /**
  139431. * Free any resources and references associated to a mesh.
  139432. * Internal use
  139433. * @param mesh The mesh to free.
  139434. * @hidden
  139435. */
  139436. _disposeMesh(mesh: Mesh): void;
  139437. /**
  139438. * Dispose the highlight layer and free resources.
  139439. */
  139440. dispose(): void;
  139441. /**
  139442. * Gets the class name of the effect layer
  139443. * @returns the string with the class name of the effect layer
  139444. */
  139445. getClassName(): string;
  139446. /**
  139447. * Serializes this Highlight layer
  139448. * @returns a serialized Highlight layer object
  139449. */
  139450. serialize(): any;
  139451. /**
  139452. * Creates a Highlight layer from parsed Highlight layer data
  139453. * @param parsedHightlightLayer defines the Highlight layer data
  139454. * @param scene defines the current scene
  139455. * @param rootUrl defines the root URL containing the Highlight layer information
  139456. * @returns a parsed Highlight layer
  139457. */
  139458. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139459. }
  139460. }
  139461. declare module BABYLON {
  139462. interface AbstractScene {
  139463. /**
  139464. * The list of layers (background and foreground) of the scene
  139465. */
  139466. layers: Array<Layer>;
  139467. }
  139468. /**
  139469. * Defines the layer scene component responsible to manage any layers
  139470. * in a given scene.
  139471. */
  139472. export class LayerSceneComponent implements ISceneComponent {
  139473. /**
  139474. * The component name helpfull to identify the component in the list of scene components.
  139475. */
  139476. readonly name: string;
  139477. /**
  139478. * The scene the component belongs to.
  139479. */
  139480. scene: Scene;
  139481. private _engine;
  139482. /**
  139483. * Creates a new instance of the component for the given scene
  139484. * @param scene Defines the scene to register the component in
  139485. */
  139486. constructor(scene: Scene);
  139487. /**
  139488. * Registers the component in a given scene
  139489. */
  139490. register(): void;
  139491. /**
  139492. * Rebuilds the elements related to this component in case of
  139493. * context lost for instance.
  139494. */
  139495. rebuild(): void;
  139496. /**
  139497. * Disposes the component and the associated ressources.
  139498. */
  139499. dispose(): void;
  139500. private _draw;
  139501. private _drawCameraPredicate;
  139502. private _drawCameraBackground;
  139503. private _drawCameraForeground;
  139504. private _drawRenderTargetPredicate;
  139505. private _drawRenderTargetBackground;
  139506. private _drawRenderTargetForeground;
  139507. /**
  139508. * Adds all the elements from the container to the scene
  139509. * @param container the container holding the elements
  139510. */
  139511. addFromContainer(container: AbstractScene): void;
  139512. /**
  139513. * Removes all the elements in the container from the scene
  139514. * @param container contains the elements to remove
  139515. * @param dispose if the removed element should be disposed (default: false)
  139516. */
  139517. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139518. }
  139519. }
  139520. declare module BABYLON {
  139521. /** @hidden */
  139522. export var layerPixelShader: {
  139523. name: string;
  139524. shader: string;
  139525. };
  139526. }
  139527. declare module BABYLON {
  139528. /** @hidden */
  139529. export var layerVertexShader: {
  139530. name: string;
  139531. shader: string;
  139532. };
  139533. }
  139534. declare module BABYLON {
  139535. /**
  139536. * This represents a full screen 2d layer.
  139537. * This can be useful to display a picture in the background of your scene for instance.
  139538. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139539. */
  139540. export class Layer {
  139541. /**
  139542. * Define the name of the layer.
  139543. */
  139544. name: string;
  139545. /**
  139546. * Define the texture the layer should display.
  139547. */
  139548. texture: Nullable<Texture>;
  139549. /**
  139550. * Is the layer in background or foreground.
  139551. */
  139552. isBackground: boolean;
  139553. /**
  139554. * Define the color of the layer (instead of texture).
  139555. */
  139556. color: Color4;
  139557. /**
  139558. * Define the scale of the layer in order to zoom in out of the texture.
  139559. */
  139560. scale: Vector2;
  139561. /**
  139562. * Define an offset for the layer in order to shift the texture.
  139563. */
  139564. offset: Vector2;
  139565. /**
  139566. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139567. */
  139568. alphaBlendingMode: number;
  139569. /**
  139570. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139571. * Alpha test will not mix with the background color in case of transparency.
  139572. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139573. */
  139574. alphaTest: boolean;
  139575. /**
  139576. * Define a mask to restrict the layer to only some of the scene cameras.
  139577. */
  139578. layerMask: number;
  139579. /**
  139580. * Define the list of render target the layer is visible into.
  139581. */
  139582. renderTargetTextures: RenderTargetTexture[];
  139583. /**
  139584. * Define if the layer is only used in renderTarget or if it also
  139585. * renders in the main frame buffer of the canvas.
  139586. */
  139587. renderOnlyInRenderTargetTextures: boolean;
  139588. private _scene;
  139589. private _vertexBuffers;
  139590. private _indexBuffer;
  139591. private _effect;
  139592. private _previousDefines;
  139593. /**
  139594. * An event triggered when the layer is disposed.
  139595. */
  139596. onDisposeObservable: Observable<Layer>;
  139597. private _onDisposeObserver;
  139598. /**
  139599. * Back compatibility with callback before the onDisposeObservable existed.
  139600. * The set callback will be triggered when the layer has been disposed.
  139601. */
  139602. set onDispose(callback: () => void);
  139603. /**
  139604. * An event triggered before rendering the scene
  139605. */
  139606. onBeforeRenderObservable: Observable<Layer>;
  139607. private _onBeforeRenderObserver;
  139608. /**
  139609. * Back compatibility with callback before the onBeforeRenderObservable existed.
  139610. * The set callback will be triggered just before rendering the layer.
  139611. */
  139612. set onBeforeRender(callback: () => void);
  139613. /**
  139614. * An event triggered after rendering the scene
  139615. */
  139616. onAfterRenderObservable: Observable<Layer>;
  139617. private _onAfterRenderObserver;
  139618. /**
  139619. * Back compatibility with callback before the onAfterRenderObservable existed.
  139620. * The set callback will be triggered just after rendering the layer.
  139621. */
  139622. set onAfterRender(callback: () => void);
  139623. /**
  139624. * Instantiates a new layer.
  139625. * This represents a full screen 2d layer.
  139626. * This can be useful to display a picture in the background of your scene for instance.
  139627. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139628. * @param name Define the name of the layer in the scene
  139629. * @param imgUrl Define the url of the texture to display in the layer
  139630. * @param scene Define the scene the layer belongs to
  139631. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  139632. * @param color Defines a color for the layer
  139633. */
  139634. constructor(
  139635. /**
  139636. * Define the name of the layer.
  139637. */
  139638. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  139639. private _createIndexBuffer;
  139640. /** @hidden */
  139641. _rebuild(): void;
  139642. /**
  139643. * Renders the layer in the scene.
  139644. */
  139645. render(): void;
  139646. /**
  139647. * Disposes and releases the associated ressources.
  139648. */
  139649. dispose(): void;
  139650. }
  139651. }
  139652. declare module BABYLON {
  139653. /** @hidden */
  139654. export var lensFlarePixelShader: {
  139655. name: string;
  139656. shader: string;
  139657. };
  139658. }
  139659. declare module BABYLON {
  139660. /** @hidden */
  139661. export var lensFlareVertexShader: {
  139662. name: string;
  139663. shader: string;
  139664. };
  139665. }
  139666. declare module BABYLON {
  139667. /**
  139668. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139669. * It is usually composed of several `lensFlare`.
  139670. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139671. */
  139672. export class LensFlareSystem {
  139673. /**
  139674. * Define the name of the lens flare system
  139675. */
  139676. name: string;
  139677. /**
  139678. * List of lens flares used in this system.
  139679. */
  139680. lensFlares: LensFlare[];
  139681. /**
  139682. * Define a limit from the border the lens flare can be visible.
  139683. */
  139684. borderLimit: number;
  139685. /**
  139686. * Define a viewport border we do not want to see the lens flare in.
  139687. */
  139688. viewportBorder: number;
  139689. /**
  139690. * Define a predicate which could limit the list of meshes able to occlude the effect.
  139691. */
  139692. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  139693. /**
  139694. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  139695. */
  139696. layerMask: number;
  139697. /**
  139698. * Define the id of the lens flare system in the scene.
  139699. * (equal to name by default)
  139700. */
  139701. id: string;
  139702. private _scene;
  139703. private _emitter;
  139704. private _vertexBuffers;
  139705. private _indexBuffer;
  139706. private _effect;
  139707. private _positionX;
  139708. private _positionY;
  139709. private _isEnabled;
  139710. /** @hidden */
  139711. static _SceneComponentInitialization: (scene: Scene) => void;
  139712. /**
  139713. * Instantiates a lens flare system.
  139714. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  139715. * It is usually composed of several `lensFlare`.
  139716. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139717. * @param name Define the name of the lens flare system in the scene
  139718. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  139719. * @param scene Define the scene the lens flare system belongs to
  139720. */
  139721. constructor(
  139722. /**
  139723. * Define the name of the lens flare system
  139724. */
  139725. name: string, emitter: any, scene: Scene);
  139726. /**
  139727. * Define if the lens flare system is enabled.
  139728. */
  139729. get isEnabled(): boolean;
  139730. set isEnabled(value: boolean);
  139731. /**
  139732. * Get the scene the effects belongs to.
  139733. * @returns the scene holding the lens flare system
  139734. */
  139735. getScene(): Scene;
  139736. /**
  139737. * Get the emitter of the lens flare system.
  139738. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139739. * @returns the emitter of the lens flare system
  139740. */
  139741. getEmitter(): any;
  139742. /**
  139743. * Set the emitter of the lens flare system.
  139744. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  139745. * @param newEmitter Define the new emitter of the system
  139746. */
  139747. setEmitter(newEmitter: any): void;
  139748. /**
  139749. * Get the lens flare system emitter position.
  139750. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  139751. * @returns the position
  139752. */
  139753. getEmitterPosition(): Vector3;
  139754. /**
  139755. * @hidden
  139756. */
  139757. computeEffectivePosition(globalViewport: Viewport): boolean;
  139758. /** @hidden */
  139759. _isVisible(): boolean;
  139760. /**
  139761. * @hidden
  139762. */
  139763. render(): boolean;
  139764. /**
  139765. * Dispose and release the lens flare with its associated resources.
  139766. */
  139767. dispose(): void;
  139768. /**
  139769. * Parse a lens flare system from a JSON repressentation
  139770. * @param parsedLensFlareSystem Define the JSON to parse
  139771. * @param scene Define the scene the parsed system should be instantiated in
  139772. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  139773. * @returns the parsed system
  139774. */
  139775. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  139776. /**
  139777. * Serialize the current Lens Flare System into a JSON representation.
  139778. * @returns the serialized JSON
  139779. */
  139780. serialize(): any;
  139781. }
  139782. }
  139783. declare module BABYLON {
  139784. /**
  139785. * This represents one of the lens effect in a `lensFlareSystem`.
  139786. * It controls one of the indiviual texture used in the effect.
  139787. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139788. */
  139789. export class LensFlare {
  139790. /**
  139791. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139792. */
  139793. size: number;
  139794. /**
  139795. * 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.
  139796. */
  139797. position: number;
  139798. /**
  139799. * Define the lens color.
  139800. */
  139801. color: Color3;
  139802. /**
  139803. * Define the lens texture.
  139804. */
  139805. texture: Nullable<Texture>;
  139806. /**
  139807. * Define the alpha mode to render this particular lens.
  139808. */
  139809. alphaMode: number;
  139810. private _system;
  139811. /**
  139812. * Creates a new Lens Flare.
  139813. * This represents one of the lens effect in a `lensFlareSystem`.
  139814. * It controls one of the indiviual texture used in the effect.
  139815. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139816. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  139817. * @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.
  139818. * @param color Define the lens color
  139819. * @param imgUrl Define the lens texture url
  139820. * @param system Define the `lensFlareSystem` this flare is part of
  139821. * @returns The newly created Lens Flare
  139822. */
  139823. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  139824. /**
  139825. * Instantiates a new Lens Flare.
  139826. * This represents one of the lens effect in a `lensFlareSystem`.
  139827. * It controls one of the indiviual texture used in the effect.
  139828. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139829. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  139830. * @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.
  139831. * @param color Define the lens color
  139832. * @param imgUrl Define the lens texture url
  139833. * @param system Define the `lensFlareSystem` this flare is part of
  139834. */
  139835. constructor(
  139836. /**
  139837. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  139838. */
  139839. size: number,
  139840. /**
  139841. * 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.
  139842. */
  139843. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  139844. /**
  139845. * Dispose and release the lens flare with its associated resources.
  139846. */
  139847. dispose(): void;
  139848. }
  139849. }
  139850. declare module BABYLON {
  139851. interface AbstractScene {
  139852. /**
  139853. * The list of lens flare system added to the scene
  139854. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  139855. */
  139856. lensFlareSystems: Array<LensFlareSystem>;
  139857. /**
  139858. * Removes the given lens flare system from this scene.
  139859. * @param toRemove The lens flare system to remove
  139860. * @returns The index of the removed lens flare system
  139861. */
  139862. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  139863. /**
  139864. * Adds the given lens flare system to this scene
  139865. * @param newLensFlareSystem The lens flare system to add
  139866. */
  139867. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  139868. /**
  139869. * Gets a lens flare system using its name
  139870. * @param name defines the name to look for
  139871. * @returns the lens flare system or null if not found
  139872. */
  139873. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  139874. /**
  139875. * Gets a lens flare system using its id
  139876. * @param id defines the id to look for
  139877. * @returns the lens flare system or null if not found
  139878. */
  139879. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  139880. }
  139881. /**
  139882. * Defines the lens flare scene component responsible to manage any lens flares
  139883. * in a given scene.
  139884. */
  139885. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  139886. /**
  139887. * The component name helpfull to identify the component in the list of scene components.
  139888. */
  139889. readonly name: string;
  139890. /**
  139891. * The scene the component belongs to.
  139892. */
  139893. scene: Scene;
  139894. /**
  139895. * Creates a new instance of the component for the given scene
  139896. * @param scene Defines the scene to register the component in
  139897. */
  139898. constructor(scene: Scene);
  139899. /**
  139900. * Registers the component in a given scene
  139901. */
  139902. register(): void;
  139903. /**
  139904. * Rebuilds the elements related to this component in case of
  139905. * context lost for instance.
  139906. */
  139907. rebuild(): void;
  139908. /**
  139909. * Adds all the elements from the container to the scene
  139910. * @param container the container holding the elements
  139911. */
  139912. addFromContainer(container: AbstractScene): void;
  139913. /**
  139914. * Removes all the elements in the container from the scene
  139915. * @param container contains the elements to remove
  139916. * @param dispose if the removed element should be disposed (default: false)
  139917. */
  139918. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139919. /**
  139920. * Serializes the component data to the specified json object
  139921. * @param serializationObject The object to serialize to
  139922. */
  139923. serialize(serializationObject: any): void;
  139924. /**
  139925. * Disposes the component and the associated ressources.
  139926. */
  139927. dispose(): void;
  139928. private _draw;
  139929. }
  139930. }
  139931. declare module BABYLON {
  139932. /** @hidden */
  139933. export var depthPixelShader: {
  139934. name: string;
  139935. shader: string;
  139936. };
  139937. }
  139938. declare module BABYLON {
  139939. /** @hidden */
  139940. export var depthVertexShader: {
  139941. name: string;
  139942. shader: string;
  139943. };
  139944. }
  139945. declare module BABYLON {
  139946. /**
  139947. * This represents a depth renderer in Babylon.
  139948. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  139949. */
  139950. export class DepthRenderer {
  139951. private _scene;
  139952. private _depthMap;
  139953. private _effect;
  139954. private readonly _storeNonLinearDepth;
  139955. private readonly _clearColor;
  139956. /** Get if the depth renderer is using packed depth or not */
  139957. readonly isPacked: boolean;
  139958. private _cachedDefines;
  139959. private _camera;
  139960. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  139961. enabled: boolean;
  139962. /**
  139963. * Specifiess that the depth renderer will only be used within
  139964. * the camera it is created for.
  139965. * This can help forcing its rendering during the camera processing.
  139966. */
  139967. useOnlyInActiveCamera: boolean;
  139968. /** @hidden */
  139969. static _SceneComponentInitialization: (scene: Scene) => void;
  139970. /**
  139971. * Instantiates a depth renderer
  139972. * @param scene The scene the renderer belongs to
  139973. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  139974. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  139975. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139976. */
  139977. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  139978. /**
  139979. * Creates the depth rendering effect and checks if the effect is ready.
  139980. * @param subMesh The submesh to be used to render the depth map of
  139981. * @param useInstances If multiple world instances should be used
  139982. * @returns if the depth renderer is ready to render the depth map
  139983. */
  139984. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139985. /**
  139986. * Gets the texture which the depth map will be written to.
  139987. * @returns The depth map texture
  139988. */
  139989. getDepthMap(): RenderTargetTexture;
  139990. /**
  139991. * Disposes of the depth renderer.
  139992. */
  139993. dispose(): void;
  139994. }
  139995. }
  139996. declare module BABYLON {
  139997. /** @hidden */
  139998. export var minmaxReduxPixelShader: {
  139999. name: string;
  140000. shader: string;
  140001. };
  140002. }
  140003. declare module BABYLON {
  140004. /**
  140005. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140006. * and maximum values from all values of the texture.
  140007. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140008. * The source values are read from the red channel of the texture.
  140009. */
  140010. export class MinMaxReducer {
  140011. /**
  140012. * Observable triggered when the computation has been performed
  140013. */
  140014. onAfterReductionPerformed: Observable<{
  140015. min: number;
  140016. max: number;
  140017. }>;
  140018. protected _camera: Camera;
  140019. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140020. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140021. protected _postProcessManager: PostProcessManager;
  140022. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140023. protected _forceFullscreenViewport: boolean;
  140024. /**
  140025. * Creates a min/max reducer
  140026. * @param camera The camera to use for the post processes
  140027. */
  140028. constructor(camera: Camera);
  140029. /**
  140030. * Gets the texture used to read the values from.
  140031. */
  140032. get sourceTexture(): Nullable<RenderTargetTexture>;
  140033. /**
  140034. * Sets the source texture to read the values from.
  140035. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140036. * because in such textures '1' value must not be taken into account to compute the maximum
  140037. * as this value is used to clear the texture.
  140038. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140039. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140040. * @param depthRedux Indicates if the texture is a depth texture or not
  140041. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140042. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140043. */
  140044. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140045. /**
  140046. * Defines the refresh rate of the computation.
  140047. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140048. */
  140049. get refreshRate(): number;
  140050. set refreshRate(value: number);
  140051. protected _activated: boolean;
  140052. /**
  140053. * Gets the activation status of the reducer
  140054. */
  140055. get activated(): boolean;
  140056. /**
  140057. * Activates the reduction computation.
  140058. * When activated, the observers registered in onAfterReductionPerformed are
  140059. * called after the compuation is performed
  140060. */
  140061. activate(): void;
  140062. /**
  140063. * Deactivates the reduction computation.
  140064. */
  140065. deactivate(): void;
  140066. /**
  140067. * Disposes the min/max reducer
  140068. * @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.
  140069. */
  140070. dispose(disposeAll?: boolean): void;
  140071. }
  140072. }
  140073. declare module BABYLON {
  140074. /**
  140075. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140076. */
  140077. export class DepthReducer extends MinMaxReducer {
  140078. private _depthRenderer;
  140079. private _depthRendererId;
  140080. /**
  140081. * Gets the depth renderer used for the computation.
  140082. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140083. */
  140084. get depthRenderer(): Nullable<DepthRenderer>;
  140085. /**
  140086. * Creates a depth reducer
  140087. * @param camera The camera used to render the depth texture
  140088. */
  140089. constructor(camera: Camera);
  140090. /**
  140091. * Sets the depth renderer to use to generate the depth map
  140092. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140093. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140094. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140095. */
  140096. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140097. /** @hidden */
  140098. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140099. /**
  140100. * Activates the reduction computation.
  140101. * When activated, the observers registered in onAfterReductionPerformed are
  140102. * called after the compuation is performed
  140103. */
  140104. activate(): void;
  140105. /**
  140106. * Deactivates the reduction computation.
  140107. */
  140108. deactivate(): void;
  140109. /**
  140110. * Disposes the depth reducer
  140111. * @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.
  140112. */
  140113. dispose(disposeAll?: boolean): void;
  140114. }
  140115. }
  140116. declare module BABYLON {
  140117. /**
  140118. * A CSM implementation allowing casting shadows on large scenes.
  140119. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140120. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140121. */
  140122. export class CascadedShadowGenerator extends ShadowGenerator {
  140123. private static readonly frustumCornersNDCSpace;
  140124. /**
  140125. * Name of the CSM class
  140126. */
  140127. static CLASSNAME: string;
  140128. /**
  140129. * Defines the default number of cascades used by the CSM.
  140130. */
  140131. static readonly DEFAULT_CASCADES_COUNT: number;
  140132. /**
  140133. * Defines the minimum number of cascades used by the CSM.
  140134. */
  140135. static readonly MIN_CASCADES_COUNT: number;
  140136. /**
  140137. * Defines the maximum number of cascades used by the CSM.
  140138. */
  140139. static readonly MAX_CASCADES_COUNT: number;
  140140. protected _validateFilter(filter: number): number;
  140141. /**
  140142. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140143. */
  140144. penumbraDarkness: number;
  140145. private _numCascades;
  140146. /**
  140147. * Gets or set the number of cascades used by the CSM.
  140148. */
  140149. get numCascades(): number;
  140150. set numCascades(value: number);
  140151. /**
  140152. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140153. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140154. */
  140155. stabilizeCascades: boolean;
  140156. private _freezeShadowCastersBoundingInfo;
  140157. private _freezeShadowCastersBoundingInfoObservable;
  140158. /**
  140159. * Enables or disables the shadow casters bounding info computation.
  140160. * If your shadow casters don't move, you can disable this feature.
  140161. * If it is enabled, the bounding box computation is done every frame.
  140162. */
  140163. get freezeShadowCastersBoundingInfo(): boolean;
  140164. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140165. private _scbiMin;
  140166. private _scbiMax;
  140167. protected _computeShadowCastersBoundingInfo(): void;
  140168. protected _shadowCastersBoundingInfo: BoundingInfo;
  140169. /**
  140170. * Gets or sets the shadow casters bounding info.
  140171. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140172. * so that the system won't overwrite the bounds you provide
  140173. */
  140174. get shadowCastersBoundingInfo(): BoundingInfo;
  140175. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140176. protected _breaksAreDirty: boolean;
  140177. protected _minDistance: number;
  140178. protected _maxDistance: number;
  140179. /**
  140180. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140181. *
  140182. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140183. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140184. * @param min minimal distance for the breaks (default to 0.)
  140185. * @param max maximal distance for the breaks (default to 1.)
  140186. */
  140187. setMinMaxDistance(min: number, max: number): void;
  140188. /** Gets the minimal distance used in the cascade break computation */
  140189. get minDistance(): number;
  140190. /** Gets the maximal distance used in the cascade break computation */
  140191. get maxDistance(): number;
  140192. /**
  140193. * Gets the class name of that object
  140194. * @returns "CascadedShadowGenerator"
  140195. */
  140196. getClassName(): string;
  140197. private _cascadeMinExtents;
  140198. private _cascadeMaxExtents;
  140199. /**
  140200. * Gets a cascade minimum extents
  140201. * @param cascadeIndex index of the cascade
  140202. * @returns the minimum cascade extents
  140203. */
  140204. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140205. /**
  140206. * Gets a cascade maximum extents
  140207. * @param cascadeIndex index of the cascade
  140208. * @returns the maximum cascade extents
  140209. */
  140210. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140211. private _cascades;
  140212. private _currentLayer;
  140213. private _viewSpaceFrustumsZ;
  140214. private _viewMatrices;
  140215. private _projectionMatrices;
  140216. private _transformMatrices;
  140217. private _transformMatricesAsArray;
  140218. private _frustumLengths;
  140219. private _lightSizeUVCorrection;
  140220. private _depthCorrection;
  140221. private _frustumCornersWorldSpace;
  140222. private _frustumCenter;
  140223. private _shadowCameraPos;
  140224. private _shadowMaxZ;
  140225. /**
  140226. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140227. * It defaults to camera.maxZ
  140228. */
  140229. get shadowMaxZ(): number;
  140230. /**
  140231. * Sets the shadow max z distance.
  140232. */
  140233. set shadowMaxZ(value: number);
  140234. protected _debug: boolean;
  140235. /**
  140236. * Gets or sets the debug flag.
  140237. * When enabled, the cascades are materialized by different colors on the screen.
  140238. */
  140239. get debug(): boolean;
  140240. set debug(dbg: boolean);
  140241. private _depthClamp;
  140242. /**
  140243. * Gets or sets the depth clamping value.
  140244. *
  140245. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140246. * to account for the shadow casters far away.
  140247. *
  140248. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140249. */
  140250. get depthClamp(): boolean;
  140251. set depthClamp(value: boolean);
  140252. private _cascadeBlendPercentage;
  140253. /**
  140254. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140255. * It defaults to 0.1 (10% blending).
  140256. */
  140257. get cascadeBlendPercentage(): number;
  140258. set cascadeBlendPercentage(value: number);
  140259. private _lambda;
  140260. /**
  140261. * Gets or set the lambda parameter.
  140262. * This parameter is used to split the camera frustum and create the cascades.
  140263. * 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.
  140264. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140265. */
  140266. get lambda(): number;
  140267. set lambda(value: number);
  140268. /**
  140269. * Gets the view matrix corresponding to a given cascade
  140270. * @param cascadeNum cascade to retrieve the view matrix from
  140271. * @returns the cascade view matrix
  140272. */
  140273. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140274. /**
  140275. * Gets the projection matrix corresponding to a given cascade
  140276. * @param cascadeNum cascade to retrieve the projection matrix from
  140277. * @returns the cascade projection matrix
  140278. */
  140279. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140280. /**
  140281. * Gets the transformation matrix corresponding to a given cascade
  140282. * @param cascadeNum cascade to retrieve the transformation matrix from
  140283. * @returns the cascade transformation matrix
  140284. */
  140285. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140286. private _depthRenderer;
  140287. /**
  140288. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140289. *
  140290. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140291. *
  140292. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140293. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140294. * @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
  140295. */
  140296. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140297. private _depthReducer;
  140298. private _autoCalcDepthBounds;
  140299. /**
  140300. * Gets or sets the autoCalcDepthBounds property.
  140301. *
  140302. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140303. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140304. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140305. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140306. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140307. */
  140308. get autoCalcDepthBounds(): boolean;
  140309. set autoCalcDepthBounds(value: boolean);
  140310. /**
  140311. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140312. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140313. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140314. * for setting the refresh rate on the renderer yourself!
  140315. */
  140316. get autoCalcDepthBoundsRefreshRate(): number;
  140317. set autoCalcDepthBoundsRefreshRate(value: number);
  140318. /**
  140319. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140320. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140321. * you change the camera near/far planes!
  140322. */
  140323. splitFrustum(): void;
  140324. private _splitFrustum;
  140325. private _computeMatrices;
  140326. private _computeFrustumInWorldSpace;
  140327. private _computeCascadeFrustum;
  140328. /**
  140329. * Support test.
  140330. */
  140331. static get IsSupported(): boolean;
  140332. /** @hidden */
  140333. static _SceneComponentInitialization: (scene: Scene) => void;
  140334. /**
  140335. * Creates a Cascaded Shadow Generator object.
  140336. * A ShadowGenerator is the required tool to use the shadows.
  140337. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140338. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140339. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140340. * @param light The directional light object generating the shadows.
  140341. * @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.
  140342. */
  140343. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140344. protected _initializeGenerator(): void;
  140345. protected _createTargetRenderTexture(): void;
  140346. protected _initializeShadowMap(): void;
  140347. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140348. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140349. /**
  140350. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140351. * @param defines Defines of the material we want to update
  140352. * @param lightIndex Index of the light in the enabled light list of the material
  140353. */
  140354. prepareDefines(defines: any, lightIndex: number): void;
  140355. /**
  140356. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140357. * defined in the generator but impacting the effect).
  140358. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140359. * @param effect The effect we are binfing the information for
  140360. */
  140361. bindShadowLight(lightIndex: string, effect: Effect): void;
  140362. /**
  140363. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140364. * (eq to view projection * shadow projection matrices)
  140365. * @returns The transform matrix used to create the shadow map
  140366. */
  140367. getTransformMatrix(): Matrix;
  140368. /**
  140369. * Disposes the ShadowGenerator.
  140370. * Returns nothing.
  140371. */
  140372. dispose(): void;
  140373. /**
  140374. * Serializes the shadow generator setup to a json object.
  140375. * @returns The serialized JSON object
  140376. */
  140377. serialize(): any;
  140378. /**
  140379. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140380. * @param parsedShadowGenerator The JSON object to parse
  140381. * @param scene The scene to create the shadow map for
  140382. * @returns The parsed shadow generator
  140383. */
  140384. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140385. }
  140386. }
  140387. declare module BABYLON {
  140388. /**
  140389. * Defines the shadow generator component responsible to manage any shadow generators
  140390. * in a given scene.
  140391. */
  140392. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140393. /**
  140394. * The component name helpfull to identify the component in the list of scene components.
  140395. */
  140396. readonly name: string;
  140397. /**
  140398. * The scene the component belongs to.
  140399. */
  140400. scene: Scene;
  140401. /**
  140402. * Creates a new instance of the component for the given scene
  140403. * @param scene Defines the scene to register the component in
  140404. */
  140405. constructor(scene: Scene);
  140406. /**
  140407. * Registers the component in a given scene
  140408. */
  140409. register(): void;
  140410. /**
  140411. * Rebuilds the elements related to this component in case of
  140412. * context lost for instance.
  140413. */
  140414. rebuild(): void;
  140415. /**
  140416. * Serializes the component data to the specified json object
  140417. * @param serializationObject The object to serialize to
  140418. */
  140419. serialize(serializationObject: any): void;
  140420. /**
  140421. * Adds all the elements from the container to the scene
  140422. * @param container the container holding the elements
  140423. */
  140424. addFromContainer(container: AbstractScene): void;
  140425. /**
  140426. * Removes all the elements in the container from the scene
  140427. * @param container contains the elements to remove
  140428. * @param dispose if the removed element should be disposed (default: false)
  140429. */
  140430. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140431. /**
  140432. * Rebuilds the elements related to this component in case of
  140433. * context lost for instance.
  140434. */
  140435. dispose(): void;
  140436. private _gatherRenderTargets;
  140437. }
  140438. }
  140439. declare module BABYLON {
  140440. /**
  140441. * A point light is a light defined by an unique point in world space.
  140442. * The light is emitted in every direction from this point.
  140443. * A good example of a point light is a standard light bulb.
  140444. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140445. */
  140446. export class PointLight extends ShadowLight {
  140447. private _shadowAngle;
  140448. /**
  140449. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140450. * This specifies what angle the shadow will use to be created.
  140451. *
  140452. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140453. */
  140454. get shadowAngle(): number;
  140455. /**
  140456. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140457. * This specifies what angle the shadow will use to be created.
  140458. *
  140459. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140460. */
  140461. set shadowAngle(value: number);
  140462. /**
  140463. * Gets the direction if it has been set.
  140464. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140465. */
  140466. get direction(): Vector3;
  140467. /**
  140468. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140469. */
  140470. set direction(value: Vector3);
  140471. /**
  140472. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140473. * A PointLight emits the light in every direction.
  140474. * It can cast shadows.
  140475. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140476. * ```javascript
  140477. * var pointLight = new PointLight("pl", camera.position, scene);
  140478. * ```
  140479. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140480. * @param name The light friendly name
  140481. * @param position The position of the point light in the scene
  140482. * @param scene The scene the lights belongs to
  140483. */
  140484. constructor(name: string, position: Vector3, scene: Scene);
  140485. /**
  140486. * Returns the string "PointLight"
  140487. * @returns the class name
  140488. */
  140489. getClassName(): string;
  140490. /**
  140491. * Returns the integer 0.
  140492. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140493. */
  140494. getTypeID(): number;
  140495. /**
  140496. * Specifies wether or not the shadowmap should be a cube texture.
  140497. * @returns true if the shadowmap needs to be a cube texture.
  140498. */
  140499. needCube(): boolean;
  140500. /**
  140501. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140502. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140503. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140504. */
  140505. getShadowDirection(faceIndex?: number): Vector3;
  140506. /**
  140507. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140508. * - fov = PI / 2
  140509. * - aspect ratio : 1.0
  140510. * - z-near and far equal to the active camera minZ and maxZ.
  140511. * Returns the PointLight.
  140512. */
  140513. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140514. protected _buildUniformLayout(): void;
  140515. /**
  140516. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140517. * @param effect The effect to update
  140518. * @param lightIndex The index of the light in the effect to update
  140519. * @returns The point light
  140520. */
  140521. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140522. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140523. /**
  140524. * Prepares the list of defines specific to the light type.
  140525. * @param defines the list of defines
  140526. * @param lightIndex defines the index of the light for the effect
  140527. */
  140528. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140529. }
  140530. }
  140531. declare module BABYLON {
  140532. /**
  140533. * Header information of HDR texture files.
  140534. */
  140535. export interface HDRInfo {
  140536. /**
  140537. * The height of the texture in pixels.
  140538. */
  140539. height: number;
  140540. /**
  140541. * The width of the texture in pixels.
  140542. */
  140543. width: number;
  140544. /**
  140545. * The index of the beginning of the data in the binary file.
  140546. */
  140547. dataPosition: number;
  140548. }
  140549. /**
  140550. * This groups tools to convert HDR texture to native colors array.
  140551. */
  140552. export class HDRTools {
  140553. private static Ldexp;
  140554. private static Rgbe2float;
  140555. private static readStringLine;
  140556. /**
  140557. * Reads header information from an RGBE texture stored in a native array.
  140558. * More information on this format are available here:
  140559. * https://en.wikipedia.org/wiki/RGBE_image_format
  140560. *
  140561. * @param uint8array The binary file stored in native array.
  140562. * @return The header information.
  140563. */
  140564. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140565. /**
  140566. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140567. * This RGBE texture needs to store the information as a panorama.
  140568. *
  140569. * More information on this format are available here:
  140570. * https://en.wikipedia.org/wiki/RGBE_image_format
  140571. *
  140572. * @param buffer The binary file stored in an array buffer.
  140573. * @param size The expected size of the extracted cubemap.
  140574. * @return The Cube Map information.
  140575. */
  140576. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140577. /**
  140578. * Returns the pixels data extracted from an RGBE texture.
  140579. * This pixels will be stored left to right up to down in the R G B order in one array.
  140580. *
  140581. * More information on this format are available here:
  140582. * https://en.wikipedia.org/wiki/RGBE_image_format
  140583. *
  140584. * @param uint8array The binary file stored in an array buffer.
  140585. * @param hdrInfo The header information of the file.
  140586. * @return The pixels data in RGB right to left up to down order.
  140587. */
  140588. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  140589. private static RGBE_ReadPixels_RLE;
  140590. private static RGBE_ReadPixels_NOT_RLE;
  140591. }
  140592. }
  140593. declare module BABYLON {
  140594. /**
  140595. * Effect Render Options
  140596. */
  140597. export interface IEffectRendererOptions {
  140598. /**
  140599. * Defines the vertices positions.
  140600. */
  140601. positions?: number[];
  140602. /**
  140603. * Defines the indices.
  140604. */
  140605. indices?: number[];
  140606. }
  140607. /**
  140608. * Helper class to render one or more effects.
  140609. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  140610. */
  140611. export class EffectRenderer {
  140612. private engine;
  140613. private static _DefaultOptions;
  140614. private _vertexBuffers;
  140615. private _indexBuffer;
  140616. private _fullscreenViewport;
  140617. /**
  140618. * Creates an effect renderer
  140619. * @param engine the engine to use for rendering
  140620. * @param options defines the options of the effect renderer
  140621. */
  140622. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  140623. /**
  140624. * Sets the current viewport in normalized coordinates 0-1
  140625. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  140626. */
  140627. setViewport(viewport?: Viewport): void;
  140628. /**
  140629. * Binds the embedded attributes buffer to the effect.
  140630. * @param effect Defines the effect to bind the attributes for
  140631. */
  140632. bindBuffers(effect: Effect): void;
  140633. /**
  140634. * Sets the current effect wrapper to use during draw.
  140635. * The effect needs to be ready before calling this api.
  140636. * This also sets the default full screen position attribute.
  140637. * @param effectWrapper Defines the effect to draw with
  140638. */
  140639. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  140640. /**
  140641. * Restores engine states
  140642. */
  140643. restoreStates(): void;
  140644. /**
  140645. * Draws a full screen quad.
  140646. */
  140647. draw(): void;
  140648. private isRenderTargetTexture;
  140649. /**
  140650. * renders one or more effects to a specified texture
  140651. * @param effectWrapper the effect to renderer
  140652. * @param outputTexture texture to draw to, if null it will render to the screen.
  140653. */
  140654. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  140655. /**
  140656. * Disposes of the effect renderer
  140657. */
  140658. dispose(): void;
  140659. }
  140660. /**
  140661. * Options to create an EffectWrapper
  140662. */
  140663. interface EffectWrapperCreationOptions {
  140664. /**
  140665. * Engine to use to create the effect
  140666. */
  140667. engine: ThinEngine;
  140668. /**
  140669. * Fragment shader for the effect
  140670. */
  140671. fragmentShader: string;
  140672. /**
  140673. * Use the shader store instead of direct source code
  140674. */
  140675. useShaderStore?: boolean;
  140676. /**
  140677. * Vertex shader for the effect
  140678. */
  140679. vertexShader?: string;
  140680. /**
  140681. * Attributes to use in the shader
  140682. */
  140683. attributeNames?: Array<string>;
  140684. /**
  140685. * Uniforms to use in the shader
  140686. */
  140687. uniformNames?: Array<string>;
  140688. /**
  140689. * Texture sampler names to use in the shader
  140690. */
  140691. samplerNames?: Array<string>;
  140692. /**
  140693. * Defines to use in the shader
  140694. */
  140695. defines?: Array<string>;
  140696. /**
  140697. * Callback when effect is compiled
  140698. */
  140699. onCompiled?: Nullable<(effect: Effect) => void>;
  140700. /**
  140701. * The friendly name of the effect displayed in Spector.
  140702. */
  140703. name?: string;
  140704. }
  140705. /**
  140706. * Wraps an effect to be used for rendering
  140707. */
  140708. export class EffectWrapper {
  140709. /**
  140710. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  140711. */
  140712. onApplyObservable: Observable<{}>;
  140713. /**
  140714. * The underlying effect
  140715. */
  140716. effect: Effect;
  140717. /**
  140718. * Creates an effect to be renderer
  140719. * @param creationOptions options to create the effect
  140720. */
  140721. constructor(creationOptions: EffectWrapperCreationOptions);
  140722. /**
  140723. * Disposes of the effect wrapper
  140724. */
  140725. dispose(): void;
  140726. }
  140727. }
  140728. declare module BABYLON {
  140729. /** @hidden */
  140730. export var hdrFilteringVertexShader: {
  140731. name: string;
  140732. shader: string;
  140733. };
  140734. }
  140735. declare module BABYLON {
  140736. /** @hidden */
  140737. export var hdrFilteringPixelShader: {
  140738. name: string;
  140739. shader: string;
  140740. };
  140741. }
  140742. declare module BABYLON {
  140743. /**
  140744. * Options for texture filtering
  140745. */
  140746. interface IHDRFilteringOptions {
  140747. /**
  140748. * Scales pixel intensity for the input HDR map.
  140749. */
  140750. hdrScale?: number;
  140751. /**
  140752. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  140753. */
  140754. quality?: number;
  140755. }
  140756. /**
  140757. * Filters HDR maps to get correct renderings of PBR reflections
  140758. */
  140759. export class HDRFiltering {
  140760. private _engine;
  140761. private _effectRenderer;
  140762. private _effectWrapper;
  140763. private _lodGenerationOffset;
  140764. private _lodGenerationScale;
  140765. /**
  140766. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  140767. * you care about baking speed.
  140768. */
  140769. quality: number;
  140770. /**
  140771. * Scales pixel intensity for the input HDR map.
  140772. */
  140773. hdrScale: number;
  140774. /**
  140775. * Instantiates HDR filter for reflection maps
  140776. *
  140777. * @param engine Thin engine
  140778. * @param options Options
  140779. */
  140780. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  140781. private _createRenderTarget;
  140782. private _prefilterInternal;
  140783. private _createEffect;
  140784. /**
  140785. * Get a value indicating if the filter is ready to be used
  140786. * @param texture Texture to filter
  140787. * @returns true if the filter is ready
  140788. */
  140789. isReady(texture: BaseTexture): boolean;
  140790. /**
  140791. * Prefilters a cube texture to have mipmap levels representing roughness values.
  140792. * Prefiltering will be invoked at the end of next rendering pass.
  140793. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  140794. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  140795. * @param texture Texture to filter
  140796. * @param onFinished Callback when filtering is done
  140797. * @return Promise called when prefiltering is done
  140798. */
  140799. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  140800. }
  140801. }
  140802. declare module BABYLON {
  140803. /**
  140804. * This represents a texture coming from an HDR input.
  140805. *
  140806. * The only supported format is currently panorama picture stored in RGBE format.
  140807. * Example of such files can be found on HDRLib: http://hdrlib.com/
  140808. */
  140809. export class HDRCubeTexture extends BaseTexture {
  140810. private static _facesMapping;
  140811. private _generateHarmonics;
  140812. private _noMipmap;
  140813. private _prefilterOnLoad;
  140814. private _textureMatrix;
  140815. private _size;
  140816. private _onLoad;
  140817. private _onError;
  140818. /**
  140819. * The texture URL.
  140820. */
  140821. url: string;
  140822. protected _isBlocking: boolean;
  140823. /**
  140824. * Sets wether or not the texture is blocking during loading.
  140825. */
  140826. set isBlocking(value: boolean);
  140827. /**
  140828. * Gets wether or not the texture is blocking during loading.
  140829. */
  140830. get isBlocking(): boolean;
  140831. protected _rotationY: number;
  140832. /**
  140833. * Sets texture matrix rotation angle around Y axis in radians.
  140834. */
  140835. set rotationY(value: number);
  140836. /**
  140837. * Gets texture matrix rotation angle around Y axis radians.
  140838. */
  140839. get rotationY(): number;
  140840. /**
  140841. * Gets or sets the center of the bounding box associated with the cube texture
  140842. * It must define where the camera used to render the texture was set
  140843. */
  140844. boundingBoxPosition: Vector3;
  140845. private _boundingBoxSize;
  140846. /**
  140847. * Gets or sets the size of the bounding box associated with the cube texture
  140848. * When defined, the cubemap will switch to local mode
  140849. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  140850. * @example https://www.babylonjs-playground.com/#RNASML
  140851. */
  140852. set boundingBoxSize(value: Vector3);
  140853. get boundingBoxSize(): Vector3;
  140854. /**
  140855. * Instantiates an HDRTexture from the following parameters.
  140856. *
  140857. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  140858. * @param sceneOrEngine The scene or engine the texture will be used in
  140859. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  140860. * @param noMipmap Forces to not generate the mipmap if true
  140861. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  140862. * @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)
  140863. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  140864. */
  140865. 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>);
  140866. /**
  140867. * Get the current class name of the texture useful for serialization or dynamic coding.
  140868. * @returns "HDRCubeTexture"
  140869. */
  140870. getClassName(): string;
  140871. /**
  140872. * Occurs when the file is raw .hdr file.
  140873. */
  140874. private loadTexture;
  140875. clone(): HDRCubeTexture;
  140876. delayLoad(): void;
  140877. /**
  140878. * Get the texture reflection matrix used to rotate/transform the reflection.
  140879. * @returns the reflection matrix
  140880. */
  140881. getReflectionTextureMatrix(): Matrix;
  140882. /**
  140883. * Set the texture reflection matrix used to rotate/transform the reflection.
  140884. * @param value Define the reflection matrix to set
  140885. */
  140886. setReflectionTextureMatrix(value: Matrix): void;
  140887. /**
  140888. * Parses a JSON representation of an HDR Texture in order to create the texture
  140889. * @param parsedTexture Define the JSON representation
  140890. * @param scene Define the scene the texture should be created in
  140891. * @param rootUrl Define the root url in case we need to load relative dependencies
  140892. * @returns the newly created texture after parsing
  140893. */
  140894. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  140895. serialize(): any;
  140896. }
  140897. }
  140898. declare module BABYLON {
  140899. /**
  140900. * Class used to control physics engine
  140901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  140902. */
  140903. export class PhysicsEngine implements IPhysicsEngine {
  140904. private _physicsPlugin;
  140905. /**
  140906. * Global value used to control the smallest number supported by the simulation
  140907. */
  140908. static Epsilon: number;
  140909. private _impostors;
  140910. private _joints;
  140911. private _subTimeStep;
  140912. /**
  140913. * Gets the gravity vector used by the simulation
  140914. */
  140915. gravity: Vector3;
  140916. /**
  140917. * Factory used to create the default physics plugin.
  140918. * @returns The default physics plugin
  140919. */
  140920. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  140921. /**
  140922. * Creates a new Physics Engine
  140923. * @param gravity defines the gravity vector used by the simulation
  140924. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  140925. */
  140926. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  140927. /**
  140928. * Sets the gravity vector used by the simulation
  140929. * @param gravity defines the gravity vector to use
  140930. */
  140931. setGravity(gravity: Vector3): void;
  140932. /**
  140933. * Set the time step of the physics engine.
  140934. * Default is 1/60.
  140935. * To slow it down, enter 1/600 for example.
  140936. * To speed it up, 1/30
  140937. * @param newTimeStep defines the new timestep to apply to this world.
  140938. */
  140939. setTimeStep(newTimeStep?: number): void;
  140940. /**
  140941. * Get the time step of the physics engine.
  140942. * @returns the current time step
  140943. */
  140944. getTimeStep(): number;
  140945. /**
  140946. * Set the sub time step of the physics engine.
  140947. * Default is 0 meaning there is no sub steps
  140948. * To increase physics resolution precision, set a small value (like 1 ms)
  140949. * @param subTimeStep defines the new sub timestep used for physics resolution.
  140950. */
  140951. setSubTimeStep(subTimeStep?: number): void;
  140952. /**
  140953. * Get the sub time step of the physics engine.
  140954. * @returns the current sub time step
  140955. */
  140956. getSubTimeStep(): number;
  140957. /**
  140958. * Release all resources
  140959. */
  140960. dispose(): void;
  140961. /**
  140962. * Gets the name of the current physics plugin
  140963. * @returns the name of the plugin
  140964. */
  140965. getPhysicsPluginName(): string;
  140966. /**
  140967. * Adding a new impostor for the impostor tracking.
  140968. * This will be done by the impostor itself.
  140969. * @param impostor the impostor to add
  140970. */
  140971. addImpostor(impostor: PhysicsImpostor): void;
  140972. /**
  140973. * Remove an impostor from the engine.
  140974. * This impostor and its mesh will not longer be updated by the physics engine.
  140975. * @param impostor the impostor to remove
  140976. */
  140977. removeImpostor(impostor: PhysicsImpostor): void;
  140978. /**
  140979. * Add a joint to the physics engine
  140980. * @param mainImpostor defines the main impostor to which the joint is added.
  140981. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  140982. * @param joint defines the joint that will connect both impostors.
  140983. */
  140984. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140985. /**
  140986. * Removes a joint from the simulation
  140987. * @param mainImpostor defines the impostor used with the joint
  140988. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  140989. * @param joint defines the joint to remove
  140990. */
  140991. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  140992. /**
  140993. * Called by the scene. No need to call it.
  140994. * @param delta defines the timespam between frames
  140995. */
  140996. _step(delta: number): void;
  140997. /**
  140998. * Gets the current plugin used to run the simulation
  140999. * @returns current plugin
  141000. */
  141001. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141002. /**
  141003. * Gets the list of physic impostors
  141004. * @returns an array of PhysicsImpostor
  141005. */
  141006. getImpostors(): Array<PhysicsImpostor>;
  141007. /**
  141008. * Gets the impostor for a physics enabled object
  141009. * @param object defines the object impersonated by the impostor
  141010. * @returns the PhysicsImpostor or null if not found
  141011. */
  141012. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141013. /**
  141014. * Gets the impostor for a physics body object
  141015. * @param body defines physics body used by the impostor
  141016. * @returns the PhysicsImpostor or null if not found
  141017. */
  141018. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141019. /**
  141020. * Does a raycast in the physics world
  141021. * @param from when should the ray start?
  141022. * @param to when should the ray end?
  141023. * @returns PhysicsRaycastResult
  141024. */
  141025. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141026. }
  141027. }
  141028. declare module BABYLON {
  141029. /** @hidden */
  141030. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141031. private _useDeltaForWorldStep;
  141032. world: any;
  141033. name: string;
  141034. private _physicsMaterials;
  141035. private _fixedTimeStep;
  141036. private _cannonRaycastResult;
  141037. private _raycastResult;
  141038. private _physicsBodysToRemoveAfterStep;
  141039. private _firstFrame;
  141040. BJSCANNON: any;
  141041. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141042. setGravity(gravity: Vector3): void;
  141043. setTimeStep(timeStep: number): void;
  141044. getTimeStep(): number;
  141045. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141046. private _removeMarkedPhysicsBodiesFromWorld;
  141047. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141048. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141049. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141050. private _processChildMeshes;
  141051. removePhysicsBody(impostor: PhysicsImpostor): void;
  141052. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141053. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141054. private _addMaterial;
  141055. private _checkWithEpsilon;
  141056. private _createShape;
  141057. private _createHeightmap;
  141058. private _minus90X;
  141059. private _plus90X;
  141060. private _tmpPosition;
  141061. private _tmpDeltaPosition;
  141062. private _tmpUnityRotation;
  141063. private _updatePhysicsBodyTransformation;
  141064. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141065. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141066. isSupported(): boolean;
  141067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141068. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141069. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141072. getBodyMass(impostor: PhysicsImpostor): number;
  141073. getBodyFriction(impostor: PhysicsImpostor): number;
  141074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141075. getBodyRestitution(impostor: PhysicsImpostor): number;
  141076. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141077. sleepBody(impostor: PhysicsImpostor): void;
  141078. wakeUpBody(impostor: PhysicsImpostor): void;
  141079. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141080. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141081. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141082. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141083. getRadius(impostor: PhysicsImpostor): number;
  141084. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141085. dispose(): void;
  141086. private _extendNamespace;
  141087. /**
  141088. * Does a raycast in the physics world
  141089. * @param from when should the ray start?
  141090. * @param to when should the ray end?
  141091. * @returns PhysicsRaycastResult
  141092. */
  141093. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141094. }
  141095. }
  141096. declare module BABYLON {
  141097. /** @hidden */
  141098. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141099. private _useDeltaForWorldStep;
  141100. world: any;
  141101. name: string;
  141102. BJSOIMO: any;
  141103. private _raycastResult;
  141104. private _fixedTimeStep;
  141105. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141106. setGravity(gravity: Vector3): void;
  141107. setTimeStep(timeStep: number): void;
  141108. getTimeStep(): number;
  141109. private _tmpImpostorsArray;
  141110. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141111. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141112. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141113. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141114. private _tmpPositionVector;
  141115. removePhysicsBody(impostor: PhysicsImpostor): void;
  141116. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141117. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141118. isSupported(): boolean;
  141119. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141120. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141121. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141122. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141123. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141124. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141125. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141126. getBodyMass(impostor: PhysicsImpostor): number;
  141127. getBodyFriction(impostor: PhysicsImpostor): number;
  141128. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141129. getBodyRestitution(impostor: PhysicsImpostor): number;
  141130. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141131. sleepBody(impostor: PhysicsImpostor): void;
  141132. wakeUpBody(impostor: PhysicsImpostor): void;
  141133. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141134. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141135. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141136. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141137. getRadius(impostor: PhysicsImpostor): number;
  141138. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141139. dispose(): void;
  141140. /**
  141141. * Does a raycast in the physics world
  141142. * @param from when should the ray start?
  141143. * @param to when should the ray end?
  141144. * @returns PhysicsRaycastResult
  141145. */
  141146. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141147. }
  141148. }
  141149. declare module BABYLON {
  141150. /**
  141151. * AmmoJS Physics plugin
  141152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141153. * @see https://github.com/kripken/ammo.js/
  141154. */
  141155. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141156. private _useDeltaForWorldStep;
  141157. /**
  141158. * Reference to the Ammo library
  141159. */
  141160. bjsAMMO: any;
  141161. /**
  141162. * Created ammoJS world which physics bodies are added to
  141163. */
  141164. world: any;
  141165. /**
  141166. * Name of the plugin
  141167. */
  141168. name: string;
  141169. private _timeStep;
  141170. private _fixedTimeStep;
  141171. private _maxSteps;
  141172. private _tmpQuaternion;
  141173. private _tmpAmmoTransform;
  141174. private _tmpAmmoQuaternion;
  141175. private _tmpAmmoConcreteContactResultCallback;
  141176. private _collisionConfiguration;
  141177. private _dispatcher;
  141178. private _overlappingPairCache;
  141179. private _solver;
  141180. private _softBodySolver;
  141181. private _tmpAmmoVectorA;
  141182. private _tmpAmmoVectorB;
  141183. private _tmpAmmoVectorC;
  141184. private _tmpAmmoVectorD;
  141185. private _tmpContactCallbackResult;
  141186. private _tmpAmmoVectorRCA;
  141187. private _tmpAmmoVectorRCB;
  141188. private _raycastResult;
  141189. private static readonly DISABLE_COLLISION_FLAG;
  141190. private static readonly KINEMATIC_FLAG;
  141191. private static readonly DISABLE_DEACTIVATION_FLAG;
  141192. /**
  141193. * Initializes the ammoJS plugin
  141194. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141195. * @param ammoInjection can be used to inject your own ammo reference
  141196. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141197. */
  141198. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141199. /**
  141200. * Sets the gravity of the physics world (m/(s^2))
  141201. * @param gravity Gravity to set
  141202. */
  141203. setGravity(gravity: Vector3): void;
  141204. /**
  141205. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141206. * @param timeStep timestep to use in seconds
  141207. */
  141208. setTimeStep(timeStep: number): void;
  141209. /**
  141210. * 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)
  141211. * @param fixedTimeStep fixedTimeStep to use in seconds
  141212. */
  141213. setFixedTimeStep(fixedTimeStep: number): void;
  141214. /**
  141215. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141216. * @param maxSteps the maximum number of steps by the physics engine per frame
  141217. */
  141218. setMaxSteps(maxSteps: number): void;
  141219. /**
  141220. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141221. * @returns the current timestep in seconds
  141222. */
  141223. getTimeStep(): number;
  141224. /**
  141225. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141226. */
  141227. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141228. private _isImpostorInContact;
  141229. private _isImpostorPairInContact;
  141230. private _stepSimulation;
  141231. /**
  141232. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141233. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141234. * After the step the babylon meshes are set to the position of the physics imposters
  141235. * @param delta amount of time to step forward
  141236. * @param impostors array of imposters to update before/after the step
  141237. */
  141238. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141239. /**
  141240. * Update babylon mesh to match physics world object
  141241. * @param impostor imposter to match
  141242. */
  141243. private _afterSoftStep;
  141244. /**
  141245. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141246. * @param impostor imposter to match
  141247. */
  141248. private _ropeStep;
  141249. /**
  141250. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141251. * @param impostor imposter to match
  141252. */
  141253. private _softbodyOrClothStep;
  141254. private _tmpMatrix;
  141255. /**
  141256. * Applies an impulse on the imposter
  141257. * @param impostor imposter to apply impulse to
  141258. * @param force amount of force to be applied to the imposter
  141259. * @param contactPoint the location to apply the impulse on the imposter
  141260. */
  141261. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141262. /**
  141263. * Applies a force on the imposter
  141264. * @param impostor imposter to apply force
  141265. * @param force amount of force to be applied to the imposter
  141266. * @param contactPoint the location to apply the force on the imposter
  141267. */
  141268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141269. /**
  141270. * Creates a physics body using the plugin
  141271. * @param impostor the imposter to create the physics body on
  141272. */
  141273. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141274. /**
  141275. * Removes the physics body from the imposter and disposes of the body's memory
  141276. * @param impostor imposter to remove the physics body from
  141277. */
  141278. removePhysicsBody(impostor: PhysicsImpostor): void;
  141279. /**
  141280. * Generates a joint
  141281. * @param impostorJoint the imposter joint to create the joint with
  141282. */
  141283. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141284. /**
  141285. * Removes a joint
  141286. * @param impostorJoint the imposter joint to remove the joint from
  141287. */
  141288. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141289. private _addMeshVerts;
  141290. /**
  141291. * Initialise the soft body vertices to match its object's (mesh) vertices
  141292. * Softbody vertices (nodes) are in world space and to match this
  141293. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141294. * @param impostor to create the softbody for
  141295. */
  141296. private _softVertexData;
  141297. /**
  141298. * Create an impostor's soft body
  141299. * @param impostor to create the softbody for
  141300. */
  141301. private _createSoftbody;
  141302. /**
  141303. * Create cloth for an impostor
  141304. * @param impostor to create the softbody for
  141305. */
  141306. private _createCloth;
  141307. /**
  141308. * Create rope for an impostor
  141309. * @param impostor to create the softbody for
  141310. */
  141311. private _createRope;
  141312. /**
  141313. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141314. * @param impostor to create the custom physics shape for
  141315. */
  141316. private _createCustom;
  141317. private _addHullVerts;
  141318. private _createShape;
  141319. /**
  141320. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141321. * @param impostor imposter containing the physics body and babylon object
  141322. */
  141323. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141324. /**
  141325. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141326. * @param impostor imposter containing the physics body and babylon object
  141327. * @param newPosition new position
  141328. * @param newRotation new rotation
  141329. */
  141330. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141331. /**
  141332. * If this plugin is supported
  141333. * @returns true if its supported
  141334. */
  141335. isSupported(): boolean;
  141336. /**
  141337. * Sets the linear velocity of the physics body
  141338. * @param impostor imposter to set the velocity on
  141339. * @param velocity velocity to set
  141340. */
  141341. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141342. /**
  141343. * Sets the angular velocity of the physics body
  141344. * @param impostor imposter to set the velocity on
  141345. * @param velocity velocity to set
  141346. */
  141347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141348. /**
  141349. * gets the linear velocity
  141350. * @param impostor imposter to get linear velocity from
  141351. * @returns linear velocity
  141352. */
  141353. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141354. /**
  141355. * gets the angular velocity
  141356. * @param impostor imposter to get angular velocity from
  141357. * @returns angular velocity
  141358. */
  141359. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141360. /**
  141361. * Sets the mass of physics body
  141362. * @param impostor imposter to set the mass on
  141363. * @param mass mass to set
  141364. */
  141365. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141366. /**
  141367. * Gets the mass of the physics body
  141368. * @param impostor imposter to get the mass from
  141369. * @returns mass
  141370. */
  141371. getBodyMass(impostor: PhysicsImpostor): number;
  141372. /**
  141373. * Gets friction of the impostor
  141374. * @param impostor impostor to get friction from
  141375. * @returns friction value
  141376. */
  141377. getBodyFriction(impostor: PhysicsImpostor): number;
  141378. /**
  141379. * Sets friction of the impostor
  141380. * @param impostor impostor to set friction on
  141381. * @param friction friction value
  141382. */
  141383. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141384. /**
  141385. * Gets restitution of the impostor
  141386. * @param impostor impostor to get restitution from
  141387. * @returns restitution value
  141388. */
  141389. getBodyRestitution(impostor: PhysicsImpostor): number;
  141390. /**
  141391. * Sets resitution of the impostor
  141392. * @param impostor impostor to set resitution on
  141393. * @param restitution resitution value
  141394. */
  141395. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141396. /**
  141397. * Gets pressure inside the impostor
  141398. * @param impostor impostor to get pressure from
  141399. * @returns pressure value
  141400. */
  141401. getBodyPressure(impostor: PhysicsImpostor): number;
  141402. /**
  141403. * Sets pressure inside a soft body impostor
  141404. * Cloth and rope must remain 0 pressure
  141405. * @param impostor impostor to set pressure on
  141406. * @param pressure pressure value
  141407. */
  141408. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141409. /**
  141410. * Gets stiffness of the impostor
  141411. * @param impostor impostor to get stiffness from
  141412. * @returns pressure value
  141413. */
  141414. getBodyStiffness(impostor: PhysicsImpostor): number;
  141415. /**
  141416. * Sets stiffness of the impostor
  141417. * @param impostor impostor to set stiffness on
  141418. * @param stiffness stiffness value from 0 to 1
  141419. */
  141420. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141421. /**
  141422. * Gets velocityIterations of the impostor
  141423. * @param impostor impostor to get velocity iterations from
  141424. * @returns velocityIterations value
  141425. */
  141426. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141427. /**
  141428. * Sets velocityIterations of the impostor
  141429. * @param impostor impostor to set velocity iterations on
  141430. * @param velocityIterations velocityIterations value
  141431. */
  141432. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141433. /**
  141434. * Gets positionIterations of the impostor
  141435. * @param impostor impostor to get position iterations from
  141436. * @returns positionIterations value
  141437. */
  141438. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141439. /**
  141440. * Sets positionIterations of the impostor
  141441. * @param impostor impostor to set position on
  141442. * @param positionIterations positionIterations value
  141443. */
  141444. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141445. /**
  141446. * Append an anchor to a cloth object
  141447. * @param impostor is the cloth impostor to add anchor to
  141448. * @param otherImpostor is the rigid impostor to anchor to
  141449. * @param width ratio across width from 0 to 1
  141450. * @param height ratio up height from 0 to 1
  141451. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141452. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141453. */
  141454. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141455. /**
  141456. * Append an hook to a rope object
  141457. * @param impostor is the rope impostor to add hook to
  141458. * @param otherImpostor is the rigid impostor to hook to
  141459. * @param length ratio along the rope from 0 to 1
  141460. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141461. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141462. */
  141463. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141464. /**
  141465. * Sleeps the physics body and stops it from being active
  141466. * @param impostor impostor to sleep
  141467. */
  141468. sleepBody(impostor: PhysicsImpostor): void;
  141469. /**
  141470. * Activates the physics body
  141471. * @param impostor impostor to activate
  141472. */
  141473. wakeUpBody(impostor: PhysicsImpostor): void;
  141474. /**
  141475. * Updates the distance parameters of the joint
  141476. * @param joint joint to update
  141477. * @param maxDistance maximum distance of the joint
  141478. * @param minDistance minimum distance of the joint
  141479. */
  141480. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141481. /**
  141482. * Sets a motor on the joint
  141483. * @param joint joint to set motor on
  141484. * @param speed speed of the motor
  141485. * @param maxForce maximum force of the motor
  141486. * @param motorIndex index of the motor
  141487. */
  141488. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141489. /**
  141490. * Sets the motors limit
  141491. * @param joint joint to set limit on
  141492. * @param upperLimit upper limit
  141493. * @param lowerLimit lower limit
  141494. */
  141495. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141496. /**
  141497. * Syncs the position and rotation of a mesh with the impostor
  141498. * @param mesh mesh to sync
  141499. * @param impostor impostor to update the mesh with
  141500. */
  141501. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141502. /**
  141503. * Gets the radius of the impostor
  141504. * @param impostor impostor to get radius from
  141505. * @returns the radius
  141506. */
  141507. getRadius(impostor: PhysicsImpostor): number;
  141508. /**
  141509. * Gets the box size of the impostor
  141510. * @param impostor impostor to get box size from
  141511. * @param result the resulting box size
  141512. */
  141513. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141514. /**
  141515. * Disposes of the impostor
  141516. */
  141517. dispose(): void;
  141518. /**
  141519. * Does a raycast in the physics world
  141520. * @param from when should the ray start?
  141521. * @param to when should the ray end?
  141522. * @returns PhysicsRaycastResult
  141523. */
  141524. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141525. }
  141526. }
  141527. declare module BABYLON {
  141528. interface AbstractScene {
  141529. /**
  141530. * The list of reflection probes added to the scene
  141531. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141532. */
  141533. reflectionProbes: Array<ReflectionProbe>;
  141534. /**
  141535. * Removes the given reflection probe from this scene.
  141536. * @param toRemove The reflection probe to remove
  141537. * @returns The index of the removed reflection probe
  141538. */
  141539. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141540. /**
  141541. * Adds the given reflection probe to this scene.
  141542. * @param newReflectionProbe The reflection probe to add
  141543. */
  141544. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141545. }
  141546. /**
  141547. * Class used to generate realtime reflection / refraction cube textures
  141548. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141549. */
  141550. export class ReflectionProbe {
  141551. /** defines the name of the probe */
  141552. name: string;
  141553. private _scene;
  141554. private _renderTargetTexture;
  141555. private _projectionMatrix;
  141556. private _viewMatrix;
  141557. private _target;
  141558. private _add;
  141559. private _attachedMesh;
  141560. private _invertYAxis;
  141561. /** Gets or sets probe position (center of the cube map) */
  141562. position: Vector3;
  141563. /**
  141564. * Creates a new reflection probe
  141565. * @param name defines the name of the probe
  141566. * @param size defines the texture resolution (for each face)
  141567. * @param scene defines the hosting scene
  141568. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141569. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141570. */
  141571. constructor(
  141572. /** defines the name of the probe */
  141573. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141574. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141575. get samples(): number;
  141576. set samples(value: number);
  141577. /** Gets or sets the refresh rate to use (on every frame by default) */
  141578. get refreshRate(): number;
  141579. set refreshRate(value: number);
  141580. /**
  141581. * Gets the hosting scene
  141582. * @returns a Scene
  141583. */
  141584. getScene(): Scene;
  141585. /** Gets the internal CubeTexture used to render to */
  141586. get cubeTexture(): RenderTargetTexture;
  141587. /** Gets the list of meshes to render */
  141588. get renderList(): Nullable<AbstractMesh[]>;
  141589. /**
  141590. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  141591. * @param mesh defines the mesh to attach to
  141592. */
  141593. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  141594. /**
  141595. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  141596. * @param renderingGroupId The rendering group id corresponding to its index
  141597. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  141598. */
  141599. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  141600. /**
  141601. * Clean all associated resources
  141602. */
  141603. dispose(): void;
  141604. /**
  141605. * Converts the reflection probe information to a readable string for debug purpose.
  141606. * @param fullDetails Supports for multiple levels of logging within scene loading
  141607. * @returns the human readable reflection probe info
  141608. */
  141609. toString(fullDetails?: boolean): string;
  141610. /**
  141611. * Get the class name of the relfection probe.
  141612. * @returns "ReflectionProbe"
  141613. */
  141614. getClassName(): string;
  141615. /**
  141616. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  141617. * @returns The JSON representation of the texture
  141618. */
  141619. serialize(): any;
  141620. /**
  141621. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  141622. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  141623. * @param scene Define the scene the parsed reflection probe should be instantiated in
  141624. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  141625. * @returns The parsed reflection probe if successful
  141626. */
  141627. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  141628. }
  141629. }
  141630. declare module BABYLON {
  141631. /** @hidden */
  141632. export var _BabylonLoaderRegistered: boolean;
  141633. /**
  141634. * Helps setting up some configuration for the babylon file loader.
  141635. */
  141636. export class BabylonFileLoaderConfiguration {
  141637. /**
  141638. * The loader does not allow injecting custom physix engine into the plugins.
  141639. * Unfortunately in ES6, we need to manually inject them into the plugin.
  141640. * So you could set this variable to your engine import to make it work.
  141641. */
  141642. static LoaderInjectedPhysicsEngine: any;
  141643. }
  141644. }
  141645. declare module BABYLON {
  141646. /**
  141647. * The Physically based simple base material of BJS.
  141648. *
  141649. * This enables better naming and convention enforcements on top of the pbrMaterial.
  141650. * It is used as the base class for both the specGloss and metalRough conventions.
  141651. */
  141652. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  141653. /**
  141654. * Number of Simultaneous lights allowed on the material.
  141655. */
  141656. maxSimultaneousLights: number;
  141657. /**
  141658. * If sets to true, disables all the lights affecting the material.
  141659. */
  141660. disableLighting: boolean;
  141661. /**
  141662. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  141663. */
  141664. environmentTexture: BaseTexture;
  141665. /**
  141666. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  141667. */
  141668. invertNormalMapX: boolean;
  141669. /**
  141670. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  141671. */
  141672. invertNormalMapY: boolean;
  141673. /**
  141674. * Normal map used in the model.
  141675. */
  141676. normalTexture: BaseTexture;
  141677. /**
  141678. * Emissivie color used to self-illuminate the model.
  141679. */
  141680. emissiveColor: Color3;
  141681. /**
  141682. * Emissivie texture used to self-illuminate the model.
  141683. */
  141684. emissiveTexture: BaseTexture;
  141685. /**
  141686. * Occlusion Channel Strenght.
  141687. */
  141688. occlusionStrength: number;
  141689. /**
  141690. * Occlusion Texture of the material (adding extra occlusion effects).
  141691. */
  141692. occlusionTexture: BaseTexture;
  141693. /**
  141694. * Defines the alpha limits in alpha test mode.
  141695. */
  141696. alphaCutOff: number;
  141697. /**
  141698. * Gets the current double sided mode.
  141699. */
  141700. get doubleSided(): boolean;
  141701. /**
  141702. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  141703. */
  141704. set doubleSided(value: boolean);
  141705. /**
  141706. * Stores the pre-calculated light information of a mesh in a texture.
  141707. */
  141708. lightmapTexture: BaseTexture;
  141709. /**
  141710. * If true, the light map contains occlusion information instead of lighting info.
  141711. */
  141712. useLightmapAsShadowmap: boolean;
  141713. /**
  141714. * Instantiates a new PBRMaterial instance.
  141715. *
  141716. * @param name The material name
  141717. * @param scene The scene the material will be use in.
  141718. */
  141719. constructor(name: string, scene: Scene);
  141720. getClassName(): string;
  141721. }
  141722. }
  141723. declare module BABYLON {
  141724. /**
  141725. * The PBR material of BJS following the metal roughness convention.
  141726. *
  141727. * This fits to the PBR convention in the GLTF definition:
  141728. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  141729. */
  141730. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  141731. /**
  141732. * The base color has two different interpretations depending on the value of metalness.
  141733. * When the material is a metal, the base color is the specific measured reflectance value
  141734. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  141735. * of the material.
  141736. */
  141737. baseColor: Color3;
  141738. /**
  141739. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  141740. * well as opacity information in the alpha channel.
  141741. */
  141742. baseTexture: BaseTexture;
  141743. /**
  141744. * Specifies the metallic scalar value of the material.
  141745. * Can also be used to scale the metalness values of the metallic texture.
  141746. */
  141747. metallic: number;
  141748. /**
  141749. * Specifies the roughness scalar value of the material.
  141750. * Can also be used to scale the roughness values of the metallic texture.
  141751. */
  141752. roughness: number;
  141753. /**
  141754. * Texture containing both the metallic value in the B channel and the
  141755. * roughness value in the G channel to keep better precision.
  141756. */
  141757. metallicRoughnessTexture: BaseTexture;
  141758. /**
  141759. * Instantiates a new PBRMetalRoughnessMaterial instance.
  141760. *
  141761. * @param name The material name
  141762. * @param scene The scene the material will be use in.
  141763. */
  141764. constructor(name: string, scene: Scene);
  141765. /**
  141766. * Return the currrent class name of the material.
  141767. */
  141768. getClassName(): string;
  141769. /**
  141770. * Makes a duplicate of the current material.
  141771. * @param name - name to use for the new material.
  141772. */
  141773. clone(name: string): PBRMetallicRoughnessMaterial;
  141774. /**
  141775. * Serialize the material to a parsable JSON object.
  141776. */
  141777. serialize(): any;
  141778. /**
  141779. * Parses a JSON object correponding to the serialize function.
  141780. */
  141781. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  141782. }
  141783. }
  141784. declare module BABYLON {
  141785. /**
  141786. * The PBR material of BJS following the specular glossiness convention.
  141787. *
  141788. * This fits to the PBR convention in the GLTF definition:
  141789. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  141790. */
  141791. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  141792. /**
  141793. * Specifies the diffuse color of the material.
  141794. */
  141795. diffuseColor: Color3;
  141796. /**
  141797. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  141798. * channel.
  141799. */
  141800. diffuseTexture: BaseTexture;
  141801. /**
  141802. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  141803. */
  141804. specularColor: Color3;
  141805. /**
  141806. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  141807. */
  141808. glossiness: number;
  141809. /**
  141810. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  141811. */
  141812. specularGlossinessTexture: BaseTexture;
  141813. /**
  141814. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  141815. *
  141816. * @param name The material name
  141817. * @param scene The scene the material will be use in.
  141818. */
  141819. constructor(name: string, scene: Scene);
  141820. /**
  141821. * Return the currrent class name of the material.
  141822. */
  141823. getClassName(): string;
  141824. /**
  141825. * Makes a duplicate of the current material.
  141826. * @param name - name to use for the new material.
  141827. */
  141828. clone(name: string): PBRSpecularGlossinessMaterial;
  141829. /**
  141830. * Serialize the material to a parsable JSON object.
  141831. */
  141832. serialize(): any;
  141833. /**
  141834. * Parses a JSON object correponding to the serialize function.
  141835. */
  141836. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  141837. }
  141838. }
  141839. declare module BABYLON {
  141840. /**
  141841. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  141842. * It can help converting any input color in a desired output one. This can then be used to create effects
  141843. * from sepia, black and white to sixties or futuristic rendering...
  141844. *
  141845. * The only supported format is currently 3dl.
  141846. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  141847. */
  141848. export class ColorGradingTexture extends BaseTexture {
  141849. /**
  141850. * The texture URL.
  141851. */
  141852. url: string;
  141853. /**
  141854. * Empty line regex stored for GC.
  141855. */
  141856. private static _noneEmptyLineRegex;
  141857. private _textureMatrix;
  141858. private _onLoad;
  141859. /**
  141860. * Instantiates a ColorGradingTexture from the following parameters.
  141861. *
  141862. * @param url The location of the color gradind data (currently only supporting 3dl)
  141863. * @param sceneOrEngine The scene or engine the texture will be used in
  141864. * @param onLoad defines a callback triggered when the texture has been loaded
  141865. */
  141866. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  141867. /**
  141868. * Fires the onload event from the constructor if requested.
  141869. */
  141870. private _triggerOnLoad;
  141871. /**
  141872. * Returns the texture matrix used in most of the material.
  141873. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  141874. */
  141875. getTextureMatrix(): Matrix;
  141876. /**
  141877. * Occurs when the file being loaded is a .3dl LUT file.
  141878. */
  141879. private load3dlTexture;
  141880. /**
  141881. * Starts the loading process of the texture.
  141882. */
  141883. private loadTexture;
  141884. /**
  141885. * Clones the color gradind texture.
  141886. */
  141887. clone(): ColorGradingTexture;
  141888. /**
  141889. * Called during delayed load for textures.
  141890. */
  141891. delayLoad(): void;
  141892. /**
  141893. * Parses a color grading texture serialized by Babylon.
  141894. * @param parsedTexture The texture information being parsedTexture
  141895. * @param scene The scene to load the texture in
  141896. * @param rootUrl The root url of the data assets to load
  141897. * @return A color gradind texture
  141898. */
  141899. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  141900. /**
  141901. * Serializes the LUT texture to json format.
  141902. */
  141903. serialize(): any;
  141904. }
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  141909. */
  141910. export class EquiRectangularCubeTexture extends BaseTexture {
  141911. /** The six faces of the cube. */
  141912. private static _FacesMapping;
  141913. private _noMipmap;
  141914. private _onLoad;
  141915. private _onError;
  141916. /** The size of the cubemap. */
  141917. private _size;
  141918. /** The buffer of the image. */
  141919. private _buffer;
  141920. /** The width of the input image. */
  141921. private _width;
  141922. /** The height of the input image. */
  141923. private _height;
  141924. /** The URL to the image. */
  141925. url: string;
  141926. /**
  141927. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  141928. * @param url The location of the image
  141929. * @param scene The scene the texture will be used in
  141930. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141931. * @param noMipmap Forces to not generate the mipmap if true
  141932. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141933. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141934. * @param onLoad — defines a callback called when texture is loaded
  141935. * @param onError — defines a callback called if there is an error
  141936. */
  141937. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  141938. /**
  141939. * Load the image data, by putting the image on a canvas and extracting its buffer.
  141940. */
  141941. private loadImage;
  141942. /**
  141943. * Convert the image buffer into a cubemap and create a CubeTexture.
  141944. */
  141945. private loadTexture;
  141946. /**
  141947. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  141948. * @param buffer The ArrayBuffer that should be converted.
  141949. * @returns The buffer as Float32Array.
  141950. */
  141951. private getFloat32ArrayFromArrayBuffer;
  141952. /**
  141953. * Get the current class name of the texture useful for serialization or dynamic coding.
  141954. * @returns "EquiRectangularCubeTexture"
  141955. */
  141956. getClassName(): string;
  141957. /**
  141958. * Create a clone of the current EquiRectangularCubeTexture and return it.
  141959. * @returns A clone of the current EquiRectangularCubeTexture.
  141960. */
  141961. clone(): EquiRectangularCubeTexture;
  141962. }
  141963. }
  141964. declare module BABYLON {
  141965. /**
  141966. * Defines the options related to the creation of an HtmlElementTexture
  141967. */
  141968. export interface IHtmlElementTextureOptions {
  141969. /**
  141970. * Defines wether mip maps should be created or not.
  141971. */
  141972. generateMipMaps?: boolean;
  141973. /**
  141974. * Defines the sampling mode of the texture.
  141975. */
  141976. samplingMode?: number;
  141977. /**
  141978. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  141979. */
  141980. engine: Nullable<ThinEngine>;
  141981. /**
  141982. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  141983. */
  141984. scene: Nullable<Scene>;
  141985. }
  141986. /**
  141987. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  141988. * To be as efficient as possible depending on your constraints nothing aside the first upload
  141989. * is automatically managed.
  141990. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  141991. * in your application.
  141992. *
  141993. * As the update is not automatic, you need to call them manually.
  141994. */
  141995. export class HtmlElementTexture extends BaseTexture {
  141996. /**
  141997. * The texture URL.
  141998. */
  141999. element: HTMLVideoElement | HTMLCanvasElement;
  142000. private static readonly DefaultOptions;
  142001. private _textureMatrix;
  142002. private _isVideo;
  142003. private _generateMipMaps;
  142004. private _samplingMode;
  142005. /**
  142006. * Instantiates a HtmlElementTexture from the following parameters.
  142007. *
  142008. * @param name Defines the name of the texture
  142009. * @param element Defines the video or canvas the texture is filled with
  142010. * @param options Defines the other none mandatory texture creation options
  142011. */
  142012. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142013. private _createInternalTexture;
  142014. /**
  142015. * Returns the texture matrix used in most of the material.
  142016. */
  142017. getTextureMatrix(): Matrix;
  142018. /**
  142019. * Updates the content of the texture.
  142020. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142021. */
  142022. update(invertY?: Nullable<boolean>): void;
  142023. }
  142024. }
  142025. declare module BABYLON {
  142026. /**
  142027. * Based on jsTGALoader - Javascript loader for TGA file
  142028. * By Vincent Thibault
  142029. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142030. */
  142031. export class TGATools {
  142032. private static _TYPE_INDEXED;
  142033. private static _TYPE_RGB;
  142034. private static _TYPE_GREY;
  142035. private static _TYPE_RLE_INDEXED;
  142036. private static _TYPE_RLE_RGB;
  142037. private static _TYPE_RLE_GREY;
  142038. private static _ORIGIN_MASK;
  142039. private static _ORIGIN_SHIFT;
  142040. private static _ORIGIN_BL;
  142041. private static _ORIGIN_BR;
  142042. private static _ORIGIN_UL;
  142043. private static _ORIGIN_UR;
  142044. /**
  142045. * Gets the header of a TGA file
  142046. * @param data defines the TGA data
  142047. * @returns the header
  142048. */
  142049. static GetTGAHeader(data: Uint8Array): any;
  142050. /**
  142051. * Uploads TGA content to a Babylon Texture
  142052. * @hidden
  142053. */
  142054. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142055. /** @hidden */
  142056. 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;
  142057. /** @hidden */
  142058. 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;
  142059. /** @hidden */
  142060. 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;
  142061. /** @hidden */
  142062. 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;
  142063. /** @hidden */
  142064. 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;
  142065. /** @hidden */
  142066. 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;
  142067. }
  142068. }
  142069. declare module BABYLON {
  142070. /**
  142071. * Implementation of the TGA Texture Loader.
  142072. * @hidden
  142073. */
  142074. export class _TGATextureLoader implements IInternalTextureLoader {
  142075. /**
  142076. * Defines wether the loader supports cascade loading the different faces.
  142077. */
  142078. readonly supportCascades: boolean;
  142079. /**
  142080. * This returns if the loader support the current file information.
  142081. * @param extension defines the file extension of the file being loaded
  142082. * @returns true if the loader can load the specified file
  142083. */
  142084. canLoad(extension: string): boolean;
  142085. /**
  142086. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142087. * @param data contains the texture data
  142088. * @param texture defines the BabylonJS internal texture
  142089. * @param createPolynomials will be true if polynomials have been requested
  142090. * @param onLoad defines the callback to trigger once the texture is ready
  142091. * @param onError defines the callback to trigger in case of error
  142092. */
  142093. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142094. /**
  142095. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142096. * @param data contains the texture data
  142097. * @param texture defines the BabylonJS internal texture
  142098. * @param callback defines the method to call once ready to upload
  142099. */
  142100. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142101. }
  142102. }
  142103. declare module BABYLON {
  142104. /**
  142105. * Info about the .basis files
  142106. */
  142107. class BasisFileInfo {
  142108. /**
  142109. * If the file has alpha
  142110. */
  142111. hasAlpha: boolean;
  142112. /**
  142113. * Info about each image of the basis file
  142114. */
  142115. images: Array<{
  142116. levels: Array<{
  142117. width: number;
  142118. height: number;
  142119. transcodedPixels: ArrayBufferView;
  142120. }>;
  142121. }>;
  142122. }
  142123. /**
  142124. * Result of transcoding a basis file
  142125. */
  142126. class TranscodeResult {
  142127. /**
  142128. * Info about the .basis file
  142129. */
  142130. fileInfo: BasisFileInfo;
  142131. /**
  142132. * Format to use when loading the file
  142133. */
  142134. format: number;
  142135. }
  142136. /**
  142137. * Configuration options for the Basis transcoder
  142138. */
  142139. export class BasisTranscodeConfiguration {
  142140. /**
  142141. * Supported compression formats used to determine the supported output format of the transcoder
  142142. */
  142143. supportedCompressionFormats?: {
  142144. /**
  142145. * etc1 compression format
  142146. */
  142147. etc1?: boolean;
  142148. /**
  142149. * s3tc compression format
  142150. */
  142151. s3tc?: boolean;
  142152. /**
  142153. * pvrtc compression format
  142154. */
  142155. pvrtc?: boolean;
  142156. /**
  142157. * etc2 compression format
  142158. */
  142159. etc2?: boolean;
  142160. };
  142161. /**
  142162. * If mipmap levels should be loaded for transcoded images (Default: true)
  142163. */
  142164. loadMipmapLevels?: boolean;
  142165. /**
  142166. * Index of a single image to load (Default: all images)
  142167. */
  142168. loadSingleImage?: number;
  142169. }
  142170. /**
  142171. * Used to load .Basis files
  142172. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142173. */
  142174. export class BasisTools {
  142175. private static _IgnoreSupportedFormats;
  142176. /**
  142177. * URL to use when loading the basis transcoder
  142178. */
  142179. static JSModuleURL: string;
  142180. /**
  142181. * URL to use when loading the wasm module for the transcoder
  142182. */
  142183. static WasmModuleURL: string;
  142184. /**
  142185. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142186. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142187. * @returns internal format corresponding to the Basis format
  142188. */
  142189. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142190. private static _WorkerPromise;
  142191. private static _Worker;
  142192. private static _actionId;
  142193. private static _CreateWorkerAsync;
  142194. /**
  142195. * Transcodes a loaded image file to compressed pixel data
  142196. * @param data image data to transcode
  142197. * @param config configuration options for the transcoding
  142198. * @returns a promise resulting in the transcoded image
  142199. */
  142200. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142201. /**
  142202. * Loads a texture from the transcode result
  142203. * @param texture texture load to
  142204. * @param transcodeResult the result of transcoding the basis file to load from
  142205. */
  142206. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142207. }
  142208. }
  142209. declare module BABYLON {
  142210. /**
  142211. * Loader for .basis file format
  142212. */
  142213. export class _BasisTextureLoader implements IInternalTextureLoader {
  142214. /**
  142215. * Defines whether the loader supports cascade loading the different faces.
  142216. */
  142217. readonly supportCascades: boolean;
  142218. /**
  142219. * This returns if the loader support the current file information.
  142220. * @param extension defines the file extension of the file being loaded
  142221. * @returns true if the loader can load the specified file
  142222. */
  142223. canLoad(extension: string): boolean;
  142224. /**
  142225. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142226. * @param data contains the texture data
  142227. * @param texture defines the BabylonJS internal texture
  142228. * @param createPolynomials will be true if polynomials have been requested
  142229. * @param onLoad defines the callback to trigger once the texture is ready
  142230. * @param onError defines the callback to trigger in case of error
  142231. */
  142232. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142233. /**
  142234. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142235. * @param data contains the texture data
  142236. * @param texture defines the BabylonJS internal texture
  142237. * @param callback defines the method to call once ready to upload
  142238. */
  142239. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142240. }
  142241. }
  142242. declare module BABYLON {
  142243. /**
  142244. * Defines the basic options interface of a TexturePacker Frame
  142245. */
  142246. export interface ITexturePackerFrame {
  142247. /**
  142248. * The frame ID
  142249. */
  142250. id: number;
  142251. /**
  142252. * The frames Scale
  142253. */
  142254. scale: Vector2;
  142255. /**
  142256. * The Frames offset
  142257. */
  142258. offset: Vector2;
  142259. }
  142260. /**
  142261. * This is a support class for frame Data on texture packer sets.
  142262. */
  142263. export class TexturePackerFrame implements ITexturePackerFrame {
  142264. /**
  142265. * The frame ID
  142266. */
  142267. id: number;
  142268. /**
  142269. * The frames Scale
  142270. */
  142271. scale: Vector2;
  142272. /**
  142273. * The Frames offset
  142274. */
  142275. offset: Vector2;
  142276. /**
  142277. * Initializes a texture package frame.
  142278. * @param id The numerical frame identifier
  142279. * @param scale Scalar Vector2 for UV frame
  142280. * @param offset Vector2 for the frame position in UV units.
  142281. * @returns TexturePackerFrame
  142282. */
  142283. constructor(id: number, scale: Vector2, offset: Vector2);
  142284. }
  142285. }
  142286. declare module BABYLON {
  142287. /**
  142288. * Defines the basic options interface of a TexturePacker
  142289. */
  142290. export interface ITexturePackerOptions {
  142291. /**
  142292. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142293. */
  142294. map?: string[];
  142295. /**
  142296. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142297. */
  142298. uvsIn?: string;
  142299. /**
  142300. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142301. */
  142302. uvsOut?: string;
  142303. /**
  142304. * number representing the layout style. Defaults to LAYOUT_STRIP
  142305. */
  142306. layout?: number;
  142307. /**
  142308. * number of columns if using custom column count layout(2). This defaults to 4.
  142309. */
  142310. colnum?: number;
  142311. /**
  142312. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142313. */
  142314. updateInputMeshes?: boolean;
  142315. /**
  142316. * boolean flag to dispose all the source textures. Defaults to true.
  142317. */
  142318. disposeSources?: boolean;
  142319. /**
  142320. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142321. */
  142322. fillBlanks?: boolean;
  142323. /**
  142324. * string value representing the context fill style color. Defaults to 'black'.
  142325. */
  142326. customFillColor?: string;
  142327. /**
  142328. * Width and Height Value of each Frame in the TexturePacker Sets
  142329. */
  142330. frameSize?: number;
  142331. /**
  142332. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142333. */
  142334. paddingRatio?: number;
  142335. /**
  142336. * Number that declares the fill method for the padding gutter.
  142337. */
  142338. paddingMode?: number;
  142339. /**
  142340. * If in SUBUV_COLOR padding mode what color to use.
  142341. */
  142342. paddingColor?: Color3 | Color4;
  142343. }
  142344. /**
  142345. * Defines the basic interface of a TexturePacker JSON File
  142346. */
  142347. export interface ITexturePackerJSON {
  142348. /**
  142349. * The frame ID
  142350. */
  142351. name: string;
  142352. /**
  142353. * The base64 channel data
  142354. */
  142355. sets: any;
  142356. /**
  142357. * The options of the Packer
  142358. */
  142359. options: ITexturePackerOptions;
  142360. /**
  142361. * The frame data of the Packer
  142362. */
  142363. frames: Array<number>;
  142364. }
  142365. /**
  142366. * This is a support class that generates a series of packed texture sets.
  142367. * @see https://doc.babylonjs.com/babylon101/materials
  142368. */
  142369. export class TexturePacker {
  142370. /** Packer Layout Constant 0 */
  142371. static readonly LAYOUT_STRIP: number;
  142372. /** Packer Layout Constant 1 */
  142373. static readonly LAYOUT_POWER2: number;
  142374. /** Packer Layout Constant 2 */
  142375. static readonly LAYOUT_COLNUM: number;
  142376. /** Packer Layout Constant 0 */
  142377. static readonly SUBUV_WRAP: number;
  142378. /** Packer Layout Constant 1 */
  142379. static readonly SUBUV_EXTEND: number;
  142380. /** Packer Layout Constant 2 */
  142381. static readonly SUBUV_COLOR: number;
  142382. /** The Name of the Texture Package */
  142383. name: string;
  142384. /** The scene scope of the TexturePacker */
  142385. scene: Scene;
  142386. /** The Meshes to target */
  142387. meshes: AbstractMesh[];
  142388. /** Arguments passed with the Constructor */
  142389. options: ITexturePackerOptions;
  142390. /** The promise that is started upon initialization */
  142391. promise: Nullable<Promise<TexturePacker | string>>;
  142392. /** The Container object for the channel sets that are generated */
  142393. sets: object;
  142394. /** The Container array for the frames that are generated */
  142395. frames: TexturePackerFrame[];
  142396. /** The expected number of textures the system is parsing. */
  142397. private _expecting;
  142398. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142399. private _paddingValue;
  142400. /**
  142401. * Initializes a texture package series from an array of meshes or a single mesh.
  142402. * @param name The name of the package
  142403. * @param meshes The target meshes to compose the package from
  142404. * @param options The arguments that texture packer should follow while building.
  142405. * @param scene The scene which the textures are scoped to.
  142406. * @returns TexturePacker
  142407. */
  142408. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142409. /**
  142410. * Starts the package process
  142411. * @param resolve The promises resolution function
  142412. * @returns TexturePacker
  142413. */
  142414. private _createFrames;
  142415. /**
  142416. * Calculates the Size of the Channel Sets
  142417. * @returns Vector2
  142418. */
  142419. private _calculateSize;
  142420. /**
  142421. * Calculates the UV data for the frames.
  142422. * @param baseSize the base frameSize
  142423. * @param padding the base frame padding
  142424. * @param dtSize size of the Dynamic Texture for that channel
  142425. * @param dtUnits is 1/dtSize
  142426. * @param update flag to update the input meshes
  142427. */
  142428. private _calculateMeshUVFrames;
  142429. /**
  142430. * Calculates the frames Offset.
  142431. * @param index of the frame
  142432. * @returns Vector2
  142433. */
  142434. private _getFrameOffset;
  142435. /**
  142436. * Updates a Mesh to the frame data
  142437. * @param mesh that is the target
  142438. * @param frameID or the frame index
  142439. */
  142440. private _updateMeshUV;
  142441. /**
  142442. * Updates a Meshes materials to use the texture packer channels
  142443. * @param m is the mesh to target
  142444. * @param force all channels on the packer to be set.
  142445. */
  142446. private _updateTextureReferences;
  142447. /**
  142448. * Public method to set a Mesh to a frame
  142449. * @param m that is the target
  142450. * @param frameID or the frame index
  142451. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142452. */
  142453. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142454. /**
  142455. * Starts the async promise to compile the texture packer.
  142456. * @returns Promise<void>
  142457. */
  142458. processAsync(): Promise<void>;
  142459. /**
  142460. * Disposes all textures associated with this packer
  142461. */
  142462. dispose(): void;
  142463. /**
  142464. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142465. * @param imageType is the image type to use.
  142466. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142467. */
  142468. download(imageType?: string, quality?: number): void;
  142469. /**
  142470. * Public method to load a texturePacker JSON file.
  142471. * @param data of the JSON file in string format.
  142472. */
  142473. updateFromJSON(data: string): void;
  142474. }
  142475. }
  142476. declare module BABYLON {
  142477. /**
  142478. * 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.
  142479. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142480. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142481. */
  142482. export class CustomProceduralTexture extends ProceduralTexture {
  142483. private _animate;
  142484. private _time;
  142485. private _config;
  142486. private _texturePath;
  142487. /**
  142488. * Instantiates a new Custom Procedural Texture.
  142489. * 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.
  142490. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142491. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142492. * @param name Define the name of the texture
  142493. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142494. * @param size Define the size of the texture to create
  142495. * @param scene Define the scene the texture belongs to
  142496. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142497. * @param generateMipMaps Define if the texture should creates mip maps or not
  142498. */
  142499. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142500. private _loadJson;
  142501. /**
  142502. * Is the texture ready to be used ? (rendered at least once)
  142503. * @returns true if ready, otherwise, false.
  142504. */
  142505. isReady(): boolean;
  142506. /**
  142507. * Render the texture to its associated render target.
  142508. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142509. */
  142510. render(useCameraPostProcess?: boolean): void;
  142511. /**
  142512. * Update the list of dependant textures samplers in the shader.
  142513. */
  142514. updateTextures(): void;
  142515. /**
  142516. * Update the uniform values of the procedural texture in the shader.
  142517. */
  142518. updateShaderUniforms(): void;
  142519. /**
  142520. * Define if the texture animates or not.
  142521. */
  142522. get animate(): boolean;
  142523. set animate(value: boolean);
  142524. }
  142525. }
  142526. declare module BABYLON {
  142527. /** @hidden */
  142528. export var noisePixelShader: {
  142529. name: string;
  142530. shader: string;
  142531. };
  142532. }
  142533. declare module BABYLON {
  142534. /**
  142535. * Class used to generate noise procedural textures
  142536. */
  142537. export class NoiseProceduralTexture extends ProceduralTexture {
  142538. /** Gets or sets the start time (default is 0) */
  142539. time: number;
  142540. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142541. brightness: number;
  142542. /** Defines the number of octaves to process */
  142543. octaves: number;
  142544. /** Defines the level of persistence (0.8 by default) */
  142545. persistence: number;
  142546. /** Gets or sets animation speed factor (default is 1) */
  142547. animationSpeedFactor: number;
  142548. /**
  142549. * Creates a new NoiseProceduralTexture
  142550. * @param name defines the name fo the texture
  142551. * @param size defines the size of the texture (default is 256)
  142552. * @param scene defines the hosting scene
  142553. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142554. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142555. */
  142556. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142557. private _updateShaderUniforms;
  142558. protected _getDefines(): string;
  142559. /** Generate the current state of the procedural texture */
  142560. render(useCameraPostProcess?: boolean): void;
  142561. /**
  142562. * Serializes this noise procedural texture
  142563. * @returns a serialized noise procedural texture object
  142564. */
  142565. serialize(): any;
  142566. /**
  142567. * Clone the texture.
  142568. * @returns the cloned texture
  142569. */
  142570. clone(): NoiseProceduralTexture;
  142571. /**
  142572. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142573. * @param parsedTexture defines parsed texture data
  142574. * @param scene defines the current scene
  142575. * @param rootUrl defines the root URL containing noise procedural texture information
  142576. * @returns a parsed NoiseProceduralTexture
  142577. */
  142578. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142579. }
  142580. }
  142581. declare module BABYLON {
  142582. /**
  142583. * Raw cube texture where the raw buffers are passed in
  142584. */
  142585. export class RawCubeTexture extends CubeTexture {
  142586. /**
  142587. * Creates a cube texture where the raw buffers are passed in.
  142588. * @param scene defines the scene the texture is attached to
  142589. * @param data defines the array of data to use to create each face
  142590. * @param size defines the size of the textures
  142591. * @param format defines the format of the data
  142592. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  142593. * @param generateMipMaps defines if the engine should generate the mip levels
  142594. * @param invertY defines if data must be stored with Y axis inverted
  142595. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  142596. * @param compression defines the compression used (null by default)
  142597. */
  142598. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  142599. /**
  142600. * Updates the raw cube texture.
  142601. * @param data defines the data to store
  142602. * @param format defines the data format
  142603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  142604. * @param invertY defines if data must be stored with Y axis inverted
  142605. * @param compression defines the compression used (null by default)
  142606. * @param level defines which level of the texture to update
  142607. */
  142608. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  142609. /**
  142610. * Updates a raw cube texture with RGBD encoded data.
  142611. * @param data defines the array of data [mipmap][face] to use to create each face
  142612. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  142613. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  142614. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  142615. * @returns a promsie that resolves when the operation is complete
  142616. */
  142617. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  142618. /**
  142619. * Clones the raw cube texture.
  142620. * @return a new cube texture
  142621. */
  142622. clone(): CubeTexture;
  142623. /** @hidden */
  142624. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  142625. }
  142626. }
  142627. declare module BABYLON {
  142628. /**
  142629. * Class used to store 2D array textures containing user data
  142630. */
  142631. export class RawTexture2DArray extends Texture {
  142632. /** Gets or sets the texture format to use */
  142633. format: number;
  142634. /**
  142635. * Create a new RawTexture2DArray
  142636. * @param data defines the data of the texture
  142637. * @param width defines the width of the texture
  142638. * @param height defines the height of the texture
  142639. * @param depth defines the number of layers of the texture
  142640. * @param format defines the texture format to use
  142641. * @param scene defines the hosting scene
  142642. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142643. * @param invertY defines if texture must be stored with Y axis inverted
  142644. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142645. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142646. */
  142647. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142648. /** Gets or sets the texture format to use */
  142649. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142650. /**
  142651. * Update the texture with new data
  142652. * @param data defines the data to store in the texture
  142653. */
  142654. update(data: ArrayBufferView): void;
  142655. }
  142656. }
  142657. declare module BABYLON {
  142658. /**
  142659. * Class used to store 3D textures containing user data
  142660. */
  142661. export class RawTexture3D extends Texture {
  142662. /** Gets or sets the texture format to use */
  142663. format: number;
  142664. /**
  142665. * Create a new RawTexture3D
  142666. * @param data defines the data of the texture
  142667. * @param width defines the width of the texture
  142668. * @param height defines the height of the texture
  142669. * @param depth defines the depth of the texture
  142670. * @param format defines the texture format to use
  142671. * @param scene defines the hosting scene
  142672. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  142673. * @param invertY defines if texture must be stored with Y axis inverted
  142674. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142675. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  142676. */
  142677. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  142678. /** Gets or sets the texture format to use */
  142679. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  142680. /**
  142681. * Update the texture with new data
  142682. * @param data defines the data to store in the texture
  142683. */
  142684. update(data: ArrayBufferView): void;
  142685. }
  142686. }
  142687. declare module BABYLON {
  142688. /**
  142689. * Creates a refraction texture used by refraction channel of the standard material.
  142690. * It is like a mirror but to see through a material.
  142691. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142692. */
  142693. export class RefractionTexture extends RenderTargetTexture {
  142694. /**
  142695. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  142696. * 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.
  142697. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142698. */
  142699. refractionPlane: Plane;
  142700. /**
  142701. * Define how deep under the surface we should see.
  142702. */
  142703. depth: number;
  142704. /**
  142705. * Creates a refraction texture used by refraction channel of the standard material.
  142706. * It is like a mirror but to see through a material.
  142707. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  142708. * @param name Define the texture name
  142709. * @param size Define the size of the underlying texture
  142710. * @param scene Define the scene the refraction belongs to
  142711. * @param generateMipMaps Define if we need to generate mips level for the refraction
  142712. */
  142713. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  142714. /**
  142715. * Clone the refraction texture.
  142716. * @returns the cloned texture
  142717. */
  142718. clone(): RefractionTexture;
  142719. /**
  142720. * Serialize the texture to a JSON representation you could use in Parse later on
  142721. * @returns the serialized JSON representation
  142722. */
  142723. serialize(): any;
  142724. }
  142725. }
  142726. declare module BABYLON {
  142727. /**
  142728. * Block used to add support for vertex skinning (bones)
  142729. */
  142730. export class BonesBlock extends NodeMaterialBlock {
  142731. /**
  142732. * Creates a new BonesBlock
  142733. * @param name defines the block name
  142734. */
  142735. constructor(name: string);
  142736. /**
  142737. * Initialize the block and prepare the context for build
  142738. * @param state defines the state that will be used for the build
  142739. */
  142740. initialize(state: NodeMaterialBuildState): void;
  142741. /**
  142742. * Gets the current class name
  142743. * @returns the class name
  142744. */
  142745. getClassName(): string;
  142746. /**
  142747. * Gets the matrix indices input component
  142748. */
  142749. get matricesIndices(): NodeMaterialConnectionPoint;
  142750. /**
  142751. * Gets the matrix weights input component
  142752. */
  142753. get matricesWeights(): NodeMaterialConnectionPoint;
  142754. /**
  142755. * Gets the extra matrix indices input component
  142756. */
  142757. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  142758. /**
  142759. * Gets the extra matrix weights input component
  142760. */
  142761. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  142762. /**
  142763. * Gets the world input component
  142764. */
  142765. get world(): NodeMaterialConnectionPoint;
  142766. /**
  142767. * Gets the output component
  142768. */
  142769. get output(): NodeMaterialConnectionPoint;
  142770. autoConfigure(material: NodeMaterial): void;
  142771. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  142772. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142773. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142774. protected _buildBlock(state: NodeMaterialBuildState): this;
  142775. }
  142776. }
  142777. declare module BABYLON {
  142778. /**
  142779. * Block used to add support for instances
  142780. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  142781. */
  142782. export class InstancesBlock extends NodeMaterialBlock {
  142783. /**
  142784. * Creates a new InstancesBlock
  142785. * @param name defines the block name
  142786. */
  142787. constructor(name: string);
  142788. /**
  142789. * Gets the current class name
  142790. * @returns the class name
  142791. */
  142792. getClassName(): string;
  142793. /**
  142794. * Gets the first world row input component
  142795. */
  142796. get world0(): NodeMaterialConnectionPoint;
  142797. /**
  142798. * Gets the second world row input component
  142799. */
  142800. get world1(): NodeMaterialConnectionPoint;
  142801. /**
  142802. * Gets the third world row input component
  142803. */
  142804. get world2(): NodeMaterialConnectionPoint;
  142805. /**
  142806. * Gets the forth world row input component
  142807. */
  142808. get world3(): NodeMaterialConnectionPoint;
  142809. /**
  142810. * Gets the world input component
  142811. */
  142812. get world(): NodeMaterialConnectionPoint;
  142813. /**
  142814. * Gets the output component
  142815. */
  142816. get output(): NodeMaterialConnectionPoint;
  142817. /**
  142818. * Gets the isntanceID component
  142819. */
  142820. get instanceID(): NodeMaterialConnectionPoint;
  142821. autoConfigure(material: NodeMaterial): void;
  142822. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  142823. protected _buildBlock(state: NodeMaterialBuildState): this;
  142824. }
  142825. }
  142826. declare module BABYLON {
  142827. /**
  142828. * Block used to add morph targets support to vertex shader
  142829. */
  142830. export class MorphTargetsBlock extends NodeMaterialBlock {
  142831. private _repeatableContentAnchor;
  142832. /**
  142833. * Create a new MorphTargetsBlock
  142834. * @param name defines the block name
  142835. */
  142836. constructor(name: string);
  142837. /**
  142838. * Gets the current class name
  142839. * @returns the class name
  142840. */
  142841. getClassName(): string;
  142842. /**
  142843. * Gets the position input component
  142844. */
  142845. get position(): NodeMaterialConnectionPoint;
  142846. /**
  142847. * Gets the normal input component
  142848. */
  142849. get normal(): NodeMaterialConnectionPoint;
  142850. /**
  142851. * Gets the tangent input component
  142852. */
  142853. get tangent(): NodeMaterialConnectionPoint;
  142854. /**
  142855. * Gets the tangent input component
  142856. */
  142857. get uv(): NodeMaterialConnectionPoint;
  142858. /**
  142859. * Gets the position output component
  142860. */
  142861. get positionOutput(): NodeMaterialConnectionPoint;
  142862. /**
  142863. * Gets the normal output component
  142864. */
  142865. get normalOutput(): NodeMaterialConnectionPoint;
  142866. /**
  142867. * Gets the tangent output component
  142868. */
  142869. get tangentOutput(): NodeMaterialConnectionPoint;
  142870. /**
  142871. * Gets the tangent output component
  142872. */
  142873. get uvOutput(): NodeMaterialConnectionPoint;
  142874. initialize(state: NodeMaterialBuildState): void;
  142875. autoConfigure(material: NodeMaterial): void;
  142876. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142877. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142878. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  142879. protected _buildBlock(state: NodeMaterialBuildState): this;
  142880. }
  142881. }
  142882. declare module BABYLON {
  142883. /**
  142884. * Block used to get data information from a light
  142885. */
  142886. export class LightInformationBlock extends NodeMaterialBlock {
  142887. private _lightDataUniformName;
  142888. private _lightColorUniformName;
  142889. private _lightTypeDefineName;
  142890. /**
  142891. * Gets or sets the light associated with this block
  142892. */
  142893. light: Nullable<Light>;
  142894. /**
  142895. * Creates a new LightInformationBlock
  142896. * @param name defines the block name
  142897. */
  142898. constructor(name: string);
  142899. /**
  142900. * Gets the current class name
  142901. * @returns the class name
  142902. */
  142903. getClassName(): string;
  142904. /**
  142905. * Gets the world position input component
  142906. */
  142907. get worldPosition(): NodeMaterialConnectionPoint;
  142908. /**
  142909. * Gets the direction output component
  142910. */
  142911. get direction(): NodeMaterialConnectionPoint;
  142912. /**
  142913. * Gets the direction output component
  142914. */
  142915. get color(): NodeMaterialConnectionPoint;
  142916. /**
  142917. * Gets the direction output component
  142918. */
  142919. get intensity(): NodeMaterialConnectionPoint;
  142920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142921. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142922. protected _buildBlock(state: NodeMaterialBuildState): this;
  142923. serialize(): any;
  142924. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  142925. }
  142926. }
  142927. declare module BABYLON {
  142928. /**
  142929. * Block used to add image processing support to fragment shader
  142930. */
  142931. export class ImageProcessingBlock extends NodeMaterialBlock {
  142932. /**
  142933. * Create a new ImageProcessingBlock
  142934. * @param name defines the block name
  142935. */
  142936. constructor(name: string);
  142937. /**
  142938. * Gets the current class name
  142939. * @returns the class name
  142940. */
  142941. getClassName(): string;
  142942. /**
  142943. * Gets the color input component
  142944. */
  142945. get color(): NodeMaterialConnectionPoint;
  142946. /**
  142947. * Gets the output component
  142948. */
  142949. get output(): NodeMaterialConnectionPoint;
  142950. /**
  142951. * Initialize the block and prepare the context for build
  142952. * @param state defines the state that will be used for the build
  142953. */
  142954. initialize(state: NodeMaterialBuildState): void;
  142955. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  142956. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  142957. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  142958. protected _buildBlock(state: NodeMaterialBuildState): this;
  142959. }
  142960. }
  142961. declare module BABYLON {
  142962. /**
  142963. * Block used to pertub normals based on a normal map
  142964. */
  142965. export class PerturbNormalBlock extends NodeMaterialBlock {
  142966. private _tangentSpaceParameterName;
  142967. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  142968. invertX: boolean;
  142969. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  142970. invertY: boolean;
  142971. /**
  142972. * Create a new PerturbNormalBlock
  142973. * @param name defines the block name
  142974. */
  142975. constructor(name: string);
  142976. /**
  142977. * Gets the current class name
  142978. * @returns the class name
  142979. */
  142980. getClassName(): string;
  142981. /**
  142982. * Gets the world position input component
  142983. */
  142984. get worldPosition(): NodeMaterialConnectionPoint;
  142985. /**
  142986. * Gets the world normal input component
  142987. */
  142988. get worldNormal(): NodeMaterialConnectionPoint;
  142989. /**
  142990. * Gets the world tangent input component
  142991. */
  142992. get worldTangent(): NodeMaterialConnectionPoint;
  142993. /**
  142994. * Gets the uv input component
  142995. */
  142996. get uv(): NodeMaterialConnectionPoint;
  142997. /**
  142998. * Gets the normal map color input component
  142999. */
  143000. get normalMapColor(): NodeMaterialConnectionPoint;
  143001. /**
  143002. * Gets the strength input component
  143003. */
  143004. get strength(): NodeMaterialConnectionPoint;
  143005. /**
  143006. * Gets the output component
  143007. */
  143008. get output(): NodeMaterialConnectionPoint;
  143009. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143010. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143011. autoConfigure(material: NodeMaterial): void;
  143012. protected _buildBlock(state: NodeMaterialBuildState): this;
  143013. protected _dumpPropertiesCode(): string;
  143014. serialize(): any;
  143015. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143016. }
  143017. }
  143018. declare module BABYLON {
  143019. /**
  143020. * Block used to discard a pixel if a value is smaller than a cutoff
  143021. */
  143022. export class DiscardBlock extends NodeMaterialBlock {
  143023. /**
  143024. * Create a new DiscardBlock
  143025. * @param name defines the block name
  143026. */
  143027. constructor(name: string);
  143028. /**
  143029. * Gets the current class name
  143030. * @returns the class name
  143031. */
  143032. getClassName(): string;
  143033. /**
  143034. * Gets the color input component
  143035. */
  143036. get value(): NodeMaterialConnectionPoint;
  143037. /**
  143038. * Gets the cutoff input component
  143039. */
  143040. get cutoff(): NodeMaterialConnectionPoint;
  143041. protected _buildBlock(state: NodeMaterialBuildState): this;
  143042. }
  143043. }
  143044. declare module BABYLON {
  143045. /**
  143046. * Block used to test if the fragment shader is front facing
  143047. */
  143048. export class FrontFacingBlock extends NodeMaterialBlock {
  143049. /**
  143050. * Creates a new FrontFacingBlock
  143051. * @param name defines the block name
  143052. */
  143053. constructor(name: string);
  143054. /**
  143055. * Gets the current class name
  143056. * @returns the class name
  143057. */
  143058. getClassName(): string;
  143059. /**
  143060. * Gets the output component
  143061. */
  143062. get output(): NodeMaterialConnectionPoint;
  143063. protected _buildBlock(state: NodeMaterialBuildState): this;
  143064. }
  143065. }
  143066. declare module BABYLON {
  143067. /**
  143068. * Block used to get the derivative value on x and y of a given input
  143069. */
  143070. export class DerivativeBlock extends NodeMaterialBlock {
  143071. /**
  143072. * Create a new DerivativeBlock
  143073. * @param name defines the block name
  143074. */
  143075. constructor(name: string);
  143076. /**
  143077. * Gets the current class name
  143078. * @returns the class name
  143079. */
  143080. getClassName(): string;
  143081. /**
  143082. * Gets the input component
  143083. */
  143084. get input(): NodeMaterialConnectionPoint;
  143085. /**
  143086. * Gets the derivative output on x
  143087. */
  143088. get dx(): NodeMaterialConnectionPoint;
  143089. /**
  143090. * Gets the derivative output on y
  143091. */
  143092. get dy(): NodeMaterialConnectionPoint;
  143093. protected _buildBlock(state: NodeMaterialBuildState): this;
  143094. }
  143095. }
  143096. declare module BABYLON {
  143097. /**
  143098. * Block used to make gl_FragCoord available
  143099. */
  143100. export class FragCoordBlock extends NodeMaterialBlock {
  143101. /**
  143102. * Creates a new FragCoordBlock
  143103. * @param name defines the block name
  143104. */
  143105. constructor(name: string);
  143106. /**
  143107. * Gets the current class name
  143108. * @returns the class name
  143109. */
  143110. getClassName(): string;
  143111. /**
  143112. * Gets the xy component
  143113. */
  143114. get xy(): NodeMaterialConnectionPoint;
  143115. /**
  143116. * Gets the xyz component
  143117. */
  143118. get xyz(): NodeMaterialConnectionPoint;
  143119. /**
  143120. * Gets the xyzw component
  143121. */
  143122. get xyzw(): NodeMaterialConnectionPoint;
  143123. /**
  143124. * Gets the x component
  143125. */
  143126. get x(): NodeMaterialConnectionPoint;
  143127. /**
  143128. * Gets the y component
  143129. */
  143130. get y(): NodeMaterialConnectionPoint;
  143131. /**
  143132. * Gets the z component
  143133. */
  143134. get z(): NodeMaterialConnectionPoint;
  143135. /**
  143136. * Gets the w component
  143137. */
  143138. get output(): NodeMaterialConnectionPoint;
  143139. protected writeOutputs(state: NodeMaterialBuildState): string;
  143140. protected _buildBlock(state: NodeMaterialBuildState): this;
  143141. }
  143142. }
  143143. declare module BABYLON {
  143144. /**
  143145. * Block used to get the screen sizes
  143146. */
  143147. export class ScreenSizeBlock extends NodeMaterialBlock {
  143148. private _varName;
  143149. private _scene;
  143150. /**
  143151. * Creates a new ScreenSizeBlock
  143152. * @param name defines the block name
  143153. */
  143154. constructor(name: string);
  143155. /**
  143156. * Gets the current class name
  143157. * @returns the class name
  143158. */
  143159. getClassName(): string;
  143160. /**
  143161. * Gets the xy component
  143162. */
  143163. get xy(): NodeMaterialConnectionPoint;
  143164. /**
  143165. * Gets the x component
  143166. */
  143167. get x(): NodeMaterialConnectionPoint;
  143168. /**
  143169. * Gets the y component
  143170. */
  143171. get y(): NodeMaterialConnectionPoint;
  143172. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143173. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143174. protected _buildBlock(state: NodeMaterialBuildState): this;
  143175. }
  143176. }
  143177. declare module BABYLON {
  143178. /**
  143179. * Block used to add support for scene fog
  143180. */
  143181. export class FogBlock extends NodeMaterialBlock {
  143182. private _fogDistanceName;
  143183. private _fogParameters;
  143184. /**
  143185. * Create a new FogBlock
  143186. * @param name defines the block name
  143187. */
  143188. constructor(name: string);
  143189. /**
  143190. * Gets the current class name
  143191. * @returns the class name
  143192. */
  143193. getClassName(): string;
  143194. /**
  143195. * Gets the world position input component
  143196. */
  143197. get worldPosition(): NodeMaterialConnectionPoint;
  143198. /**
  143199. * Gets the view input component
  143200. */
  143201. get view(): NodeMaterialConnectionPoint;
  143202. /**
  143203. * Gets the color input component
  143204. */
  143205. get input(): NodeMaterialConnectionPoint;
  143206. /**
  143207. * Gets the fog color input component
  143208. */
  143209. get fogColor(): NodeMaterialConnectionPoint;
  143210. /**
  143211. * Gets the output component
  143212. */
  143213. get output(): NodeMaterialConnectionPoint;
  143214. autoConfigure(material: NodeMaterial): void;
  143215. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143216. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143217. protected _buildBlock(state: NodeMaterialBuildState): this;
  143218. }
  143219. }
  143220. declare module BABYLON {
  143221. /**
  143222. * Block used to add light in the fragment shader
  143223. */
  143224. export class LightBlock extends NodeMaterialBlock {
  143225. private _lightId;
  143226. /**
  143227. * Gets or sets the light associated with this block
  143228. */
  143229. light: Nullable<Light>;
  143230. /**
  143231. * Create a new LightBlock
  143232. * @param name defines the block name
  143233. */
  143234. constructor(name: string);
  143235. /**
  143236. * Gets the current class name
  143237. * @returns the class name
  143238. */
  143239. getClassName(): string;
  143240. /**
  143241. * Gets the world position input component
  143242. */
  143243. get worldPosition(): NodeMaterialConnectionPoint;
  143244. /**
  143245. * Gets the world normal input component
  143246. */
  143247. get worldNormal(): NodeMaterialConnectionPoint;
  143248. /**
  143249. * Gets the camera (or eye) position component
  143250. */
  143251. get cameraPosition(): NodeMaterialConnectionPoint;
  143252. /**
  143253. * Gets the glossiness component
  143254. */
  143255. get glossiness(): NodeMaterialConnectionPoint;
  143256. /**
  143257. * Gets the glossinness power component
  143258. */
  143259. get glossPower(): NodeMaterialConnectionPoint;
  143260. /**
  143261. * Gets the diffuse color component
  143262. */
  143263. get diffuseColor(): NodeMaterialConnectionPoint;
  143264. /**
  143265. * Gets the specular color component
  143266. */
  143267. get specularColor(): NodeMaterialConnectionPoint;
  143268. /**
  143269. * Gets the diffuse output component
  143270. */
  143271. get diffuseOutput(): NodeMaterialConnectionPoint;
  143272. /**
  143273. * Gets the specular output component
  143274. */
  143275. get specularOutput(): NodeMaterialConnectionPoint;
  143276. /**
  143277. * Gets the shadow output component
  143278. */
  143279. get shadow(): NodeMaterialConnectionPoint;
  143280. autoConfigure(material: NodeMaterial): void;
  143281. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143282. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143283. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143284. private _injectVertexCode;
  143285. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143286. serialize(): any;
  143287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143288. }
  143289. }
  143290. declare module BABYLON {
  143291. /**
  143292. * Block used to read a reflection texture from a sampler
  143293. */
  143294. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143295. /**
  143296. * Create a new ReflectionTextureBlock
  143297. * @param name defines the block name
  143298. */
  143299. constructor(name: string);
  143300. /**
  143301. * Gets the current class name
  143302. * @returns the class name
  143303. */
  143304. getClassName(): string;
  143305. /**
  143306. * Gets the world position input component
  143307. */
  143308. get position(): NodeMaterialConnectionPoint;
  143309. /**
  143310. * Gets the world position input component
  143311. */
  143312. get worldPosition(): NodeMaterialConnectionPoint;
  143313. /**
  143314. * Gets the world normal input component
  143315. */
  143316. get worldNormal(): NodeMaterialConnectionPoint;
  143317. /**
  143318. * Gets the world input component
  143319. */
  143320. get world(): NodeMaterialConnectionPoint;
  143321. /**
  143322. * Gets the camera (or eye) position component
  143323. */
  143324. get cameraPosition(): NodeMaterialConnectionPoint;
  143325. /**
  143326. * Gets the view input component
  143327. */
  143328. get view(): NodeMaterialConnectionPoint;
  143329. /**
  143330. * Gets the rgb output component
  143331. */
  143332. get rgb(): NodeMaterialConnectionPoint;
  143333. /**
  143334. * Gets the rgba output component
  143335. */
  143336. get rgba(): NodeMaterialConnectionPoint;
  143337. /**
  143338. * Gets the r output component
  143339. */
  143340. get r(): NodeMaterialConnectionPoint;
  143341. /**
  143342. * Gets the g output component
  143343. */
  143344. get g(): NodeMaterialConnectionPoint;
  143345. /**
  143346. * Gets the b output component
  143347. */
  143348. get b(): NodeMaterialConnectionPoint;
  143349. /**
  143350. * Gets the a output component
  143351. */
  143352. get a(): NodeMaterialConnectionPoint;
  143353. autoConfigure(material: NodeMaterial): void;
  143354. protected _buildBlock(state: NodeMaterialBuildState): this;
  143355. }
  143356. }
  143357. declare module BABYLON {
  143358. /**
  143359. * Block used to add 2 vectors
  143360. */
  143361. export class AddBlock extends NodeMaterialBlock {
  143362. /**
  143363. * Creates a new AddBlock
  143364. * @param name defines the block name
  143365. */
  143366. constructor(name: string);
  143367. /**
  143368. * Gets the current class name
  143369. * @returns the class name
  143370. */
  143371. getClassName(): string;
  143372. /**
  143373. * Gets the left operand input component
  143374. */
  143375. get left(): NodeMaterialConnectionPoint;
  143376. /**
  143377. * Gets the right operand input component
  143378. */
  143379. get right(): NodeMaterialConnectionPoint;
  143380. /**
  143381. * Gets the output component
  143382. */
  143383. get output(): NodeMaterialConnectionPoint;
  143384. protected _buildBlock(state: NodeMaterialBuildState): this;
  143385. }
  143386. }
  143387. declare module BABYLON {
  143388. /**
  143389. * Block used to scale a vector by a float
  143390. */
  143391. export class ScaleBlock extends NodeMaterialBlock {
  143392. /**
  143393. * Creates a new ScaleBlock
  143394. * @param name defines the block name
  143395. */
  143396. constructor(name: string);
  143397. /**
  143398. * Gets the current class name
  143399. * @returns the class name
  143400. */
  143401. getClassName(): string;
  143402. /**
  143403. * Gets the input component
  143404. */
  143405. get input(): NodeMaterialConnectionPoint;
  143406. /**
  143407. * Gets the factor input component
  143408. */
  143409. get factor(): NodeMaterialConnectionPoint;
  143410. /**
  143411. * Gets the output component
  143412. */
  143413. get output(): NodeMaterialConnectionPoint;
  143414. protected _buildBlock(state: NodeMaterialBuildState): this;
  143415. }
  143416. }
  143417. declare module BABYLON {
  143418. /**
  143419. * Block used to clamp a float
  143420. */
  143421. export class ClampBlock extends NodeMaterialBlock {
  143422. /** Gets or sets the minimum range */
  143423. minimum: number;
  143424. /** Gets or sets the maximum range */
  143425. maximum: number;
  143426. /**
  143427. * Creates a new ClampBlock
  143428. * @param name defines the block name
  143429. */
  143430. constructor(name: string);
  143431. /**
  143432. * Gets the current class name
  143433. * @returns the class name
  143434. */
  143435. getClassName(): string;
  143436. /**
  143437. * Gets the value input component
  143438. */
  143439. get value(): NodeMaterialConnectionPoint;
  143440. /**
  143441. * Gets the output component
  143442. */
  143443. get output(): NodeMaterialConnectionPoint;
  143444. protected _buildBlock(state: NodeMaterialBuildState): this;
  143445. protected _dumpPropertiesCode(): string;
  143446. serialize(): any;
  143447. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143448. }
  143449. }
  143450. declare module BABYLON {
  143451. /**
  143452. * Block used to apply a cross product between 2 vectors
  143453. */
  143454. export class CrossBlock extends NodeMaterialBlock {
  143455. /**
  143456. * Creates a new CrossBlock
  143457. * @param name defines the block name
  143458. */
  143459. constructor(name: string);
  143460. /**
  143461. * Gets the current class name
  143462. * @returns the class name
  143463. */
  143464. getClassName(): string;
  143465. /**
  143466. * Gets the left operand input component
  143467. */
  143468. get left(): NodeMaterialConnectionPoint;
  143469. /**
  143470. * Gets the right operand input component
  143471. */
  143472. get right(): NodeMaterialConnectionPoint;
  143473. /**
  143474. * Gets the output component
  143475. */
  143476. get output(): NodeMaterialConnectionPoint;
  143477. protected _buildBlock(state: NodeMaterialBuildState): this;
  143478. }
  143479. }
  143480. declare module BABYLON {
  143481. /**
  143482. * Block used to apply a dot product between 2 vectors
  143483. */
  143484. export class DotBlock extends NodeMaterialBlock {
  143485. /**
  143486. * Creates a new DotBlock
  143487. * @param name defines the block name
  143488. */
  143489. constructor(name: string);
  143490. /**
  143491. * Gets the current class name
  143492. * @returns the class name
  143493. */
  143494. getClassName(): string;
  143495. /**
  143496. * Gets the left operand input component
  143497. */
  143498. get left(): NodeMaterialConnectionPoint;
  143499. /**
  143500. * Gets the right operand input component
  143501. */
  143502. get right(): NodeMaterialConnectionPoint;
  143503. /**
  143504. * Gets the output component
  143505. */
  143506. get output(): NodeMaterialConnectionPoint;
  143507. protected _buildBlock(state: NodeMaterialBuildState): this;
  143508. }
  143509. }
  143510. declare module BABYLON {
  143511. /**
  143512. * Block used to normalize a vector
  143513. */
  143514. export class NormalizeBlock extends NodeMaterialBlock {
  143515. /**
  143516. * Creates a new NormalizeBlock
  143517. * @param name defines the block name
  143518. */
  143519. constructor(name: string);
  143520. /**
  143521. * Gets the current class name
  143522. * @returns the class name
  143523. */
  143524. getClassName(): string;
  143525. /**
  143526. * Gets the input component
  143527. */
  143528. get input(): NodeMaterialConnectionPoint;
  143529. /**
  143530. * Gets the output component
  143531. */
  143532. get output(): NodeMaterialConnectionPoint;
  143533. protected _buildBlock(state: NodeMaterialBuildState): this;
  143534. }
  143535. }
  143536. declare module BABYLON {
  143537. /**
  143538. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143539. */
  143540. export class ColorMergerBlock extends NodeMaterialBlock {
  143541. /**
  143542. * Create a new ColorMergerBlock
  143543. * @param name defines the block name
  143544. */
  143545. constructor(name: string);
  143546. /**
  143547. * Gets the current class name
  143548. * @returns the class name
  143549. */
  143550. getClassName(): string;
  143551. /**
  143552. * Gets the rgb component (input)
  143553. */
  143554. get rgbIn(): NodeMaterialConnectionPoint;
  143555. /**
  143556. * Gets the r component (input)
  143557. */
  143558. get r(): NodeMaterialConnectionPoint;
  143559. /**
  143560. * Gets the g component (input)
  143561. */
  143562. get g(): NodeMaterialConnectionPoint;
  143563. /**
  143564. * Gets the b component (input)
  143565. */
  143566. get b(): NodeMaterialConnectionPoint;
  143567. /**
  143568. * Gets the a component (input)
  143569. */
  143570. get a(): NodeMaterialConnectionPoint;
  143571. /**
  143572. * Gets the rgba component (output)
  143573. */
  143574. get rgba(): NodeMaterialConnectionPoint;
  143575. /**
  143576. * Gets the rgb component (output)
  143577. */
  143578. get rgbOut(): NodeMaterialConnectionPoint;
  143579. /**
  143580. * Gets the rgb component (output)
  143581. * @deprecated Please use rgbOut instead.
  143582. */
  143583. get rgb(): NodeMaterialConnectionPoint;
  143584. protected _buildBlock(state: NodeMaterialBuildState): this;
  143585. }
  143586. }
  143587. declare module BABYLON {
  143588. /**
  143589. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  143590. */
  143591. export class VectorSplitterBlock extends NodeMaterialBlock {
  143592. /**
  143593. * Create a new VectorSplitterBlock
  143594. * @param name defines the block name
  143595. */
  143596. constructor(name: string);
  143597. /**
  143598. * Gets the current class name
  143599. * @returns the class name
  143600. */
  143601. getClassName(): string;
  143602. /**
  143603. * Gets the xyzw component (input)
  143604. */
  143605. get xyzw(): NodeMaterialConnectionPoint;
  143606. /**
  143607. * Gets the xyz component (input)
  143608. */
  143609. get xyzIn(): NodeMaterialConnectionPoint;
  143610. /**
  143611. * Gets the xy component (input)
  143612. */
  143613. get xyIn(): NodeMaterialConnectionPoint;
  143614. /**
  143615. * Gets the xyz component (output)
  143616. */
  143617. get xyzOut(): NodeMaterialConnectionPoint;
  143618. /**
  143619. * Gets the xy component (output)
  143620. */
  143621. get xyOut(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the x component (output)
  143624. */
  143625. get x(): NodeMaterialConnectionPoint;
  143626. /**
  143627. * Gets the y component (output)
  143628. */
  143629. get y(): NodeMaterialConnectionPoint;
  143630. /**
  143631. * Gets the z component (output)
  143632. */
  143633. get z(): NodeMaterialConnectionPoint;
  143634. /**
  143635. * Gets the w component (output)
  143636. */
  143637. get w(): NodeMaterialConnectionPoint;
  143638. protected _inputRename(name: string): string;
  143639. protected _outputRename(name: string): string;
  143640. protected _buildBlock(state: NodeMaterialBuildState): this;
  143641. }
  143642. }
  143643. declare module BABYLON {
  143644. /**
  143645. * Block used to lerp between 2 values
  143646. */
  143647. export class LerpBlock extends NodeMaterialBlock {
  143648. /**
  143649. * Creates a new LerpBlock
  143650. * @param name defines the block name
  143651. */
  143652. constructor(name: string);
  143653. /**
  143654. * Gets the current class name
  143655. * @returns the class name
  143656. */
  143657. getClassName(): string;
  143658. /**
  143659. * Gets the left operand input component
  143660. */
  143661. get left(): NodeMaterialConnectionPoint;
  143662. /**
  143663. * Gets the right operand input component
  143664. */
  143665. get right(): NodeMaterialConnectionPoint;
  143666. /**
  143667. * Gets the gradient operand input component
  143668. */
  143669. get gradient(): NodeMaterialConnectionPoint;
  143670. /**
  143671. * Gets the output component
  143672. */
  143673. get output(): NodeMaterialConnectionPoint;
  143674. protected _buildBlock(state: NodeMaterialBuildState): this;
  143675. }
  143676. }
  143677. declare module BABYLON {
  143678. /**
  143679. * Block used to divide 2 vectors
  143680. */
  143681. export class DivideBlock extends NodeMaterialBlock {
  143682. /**
  143683. * Creates a new DivideBlock
  143684. * @param name defines the block name
  143685. */
  143686. constructor(name: string);
  143687. /**
  143688. * Gets the current class name
  143689. * @returns the class name
  143690. */
  143691. getClassName(): string;
  143692. /**
  143693. * Gets the left operand input component
  143694. */
  143695. get left(): NodeMaterialConnectionPoint;
  143696. /**
  143697. * Gets the right operand input component
  143698. */
  143699. get right(): NodeMaterialConnectionPoint;
  143700. /**
  143701. * Gets the output component
  143702. */
  143703. get output(): NodeMaterialConnectionPoint;
  143704. protected _buildBlock(state: NodeMaterialBuildState): this;
  143705. }
  143706. }
  143707. declare module BABYLON {
  143708. /**
  143709. * Block used to subtract 2 vectors
  143710. */
  143711. export class SubtractBlock extends NodeMaterialBlock {
  143712. /**
  143713. * Creates a new SubtractBlock
  143714. * @param name defines the block name
  143715. */
  143716. constructor(name: string);
  143717. /**
  143718. * Gets the current class name
  143719. * @returns the class name
  143720. */
  143721. getClassName(): string;
  143722. /**
  143723. * Gets the left operand input component
  143724. */
  143725. get left(): NodeMaterialConnectionPoint;
  143726. /**
  143727. * Gets the right operand input component
  143728. */
  143729. get right(): NodeMaterialConnectionPoint;
  143730. /**
  143731. * Gets the output component
  143732. */
  143733. get output(): NodeMaterialConnectionPoint;
  143734. protected _buildBlock(state: NodeMaterialBuildState): this;
  143735. }
  143736. }
  143737. declare module BABYLON {
  143738. /**
  143739. * Block used to step a value
  143740. */
  143741. export class StepBlock extends NodeMaterialBlock {
  143742. /**
  143743. * Creates a new StepBlock
  143744. * @param name defines the block name
  143745. */
  143746. constructor(name: string);
  143747. /**
  143748. * Gets the current class name
  143749. * @returns the class name
  143750. */
  143751. getClassName(): string;
  143752. /**
  143753. * Gets the value operand input component
  143754. */
  143755. get value(): NodeMaterialConnectionPoint;
  143756. /**
  143757. * Gets the edge operand input component
  143758. */
  143759. get edge(): NodeMaterialConnectionPoint;
  143760. /**
  143761. * Gets the output component
  143762. */
  143763. get output(): NodeMaterialConnectionPoint;
  143764. protected _buildBlock(state: NodeMaterialBuildState): this;
  143765. }
  143766. }
  143767. declare module BABYLON {
  143768. /**
  143769. * Block used to get the opposite (1 - x) of a value
  143770. */
  143771. export class OneMinusBlock extends NodeMaterialBlock {
  143772. /**
  143773. * Creates a new OneMinusBlock
  143774. * @param name defines the block name
  143775. */
  143776. constructor(name: string);
  143777. /**
  143778. * Gets the current class name
  143779. * @returns the class name
  143780. */
  143781. getClassName(): string;
  143782. /**
  143783. * Gets the input component
  143784. */
  143785. get input(): NodeMaterialConnectionPoint;
  143786. /**
  143787. * Gets the output component
  143788. */
  143789. get output(): NodeMaterialConnectionPoint;
  143790. protected _buildBlock(state: NodeMaterialBuildState): this;
  143791. }
  143792. }
  143793. declare module BABYLON {
  143794. /**
  143795. * Block used to get the view direction
  143796. */
  143797. export class ViewDirectionBlock extends NodeMaterialBlock {
  143798. /**
  143799. * Creates a new ViewDirectionBlock
  143800. * @param name defines the block name
  143801. */
  143802. constructor(name: string);
  143803. /**
  143804. * Gets the current class name
  143805. * @returns the class name
  143806. */
  143807. getClassName(): string;
  143808. /**
  143809. * Gets the world position component
  143810. */
  143811. get worldPosition(): NodeMaterialConnectionPoint;
  143812. /**
  143813. * Gets the camera position component
  143814. */
  143815. get cameraPosition(): NodeMaterialConnectionPoint;
  143816. /**
  143817. * Gets the output component
  143818. */
  143819. get output(): NodeMaterialConnectionPoint;
  143820. autoConfigure(material: NodeMaterial): void;
  143821. protected _buildBlock(state: NodeMaterialBuildState): this;
  143822. }
  143823. }
  143824. declare module BABYLON {
  143825. /**
  143826. * Block used to compute fresnel value
  143827. */
  143828. export class FresnelBlock extends NodeMaterialBlock {
  143829. /**
  143830. * Create a new FresnelBlock
  143831. * @param name defines the block name
  143832. */
  143833. constructor(name: string);
  143834. /**
  143835. * Gets the current class name
  143836. * @returns the class name
  143837. */
  143838. getClassName(): string;
  143839. /**
  143840. * Gets the world normal input component
  143841. */
  143842. get worldNormal(): NodeMaterialConnectionPoint;
  143843. /**
  143844. * Gets the view direction input component
  143845. */
  143846. get viewDirection(): NodeMaterialConnectionPoint;
  143847. /**
  143848. * Gets the bias input component
  143849. */
  143850. get bias(): NodeMaterialConnectionPoint;
  143851. /**
  143852. * Gets the camera (or eye) position component
  143853. */
  143854. get power(): NodeMaterialConnectionPoint;
  143855. /**
  143856. * Gets the fresnel output component
  143857. */
  143858. get fresnel(): NodeMaterialConnectionPoint;
  143859. autoConfigure(material: NodeMaterial): void;
  143860. protected _buildBlock(state: NodeMaterialBuildState): this;
  143861. }
  143862. }
  143863. declare module BABYLON {
  143864. /**
  143865. * Block used to get the max of 2 values
  143866. */
  143867. export class MaxBlock extends NodeMaterialBlock {
  143868. /**
  143869. * Creates a new MaxBlock
  143870. * @param name defines the block name
  143871. */
  143872. constructor(name: string);
  143873. /**
  143874. * Gets the current class name
  143875. * @returns the class name
  143876. */
  143877. getClassName(): string;
  143878. /**
  143879. * Gets the left operand input component
  143880. */
  143881. get left(): NodeMaterialConnectionPoint;
  143882. /**
  143883. * Gets the right operand input component
  143884. */
  143885. get right(): NodeMaterialConnectionPoint;
  143886. /**
  143887. * Gets the output component
  143888. */
  143889. get output(): NodeMaterialConnectionPoint;
  143890. protected _buildBlock(state: NodeMaterialBuildState): this;
  143891. }
  143892. }
  143893. declare module BABYLON {
  143894. /**
  143895. * Block used to get the min of 2 values
  143896. */
  143897. export class MinBlock extends NodeMaterialBlock {
  143898. /**
  143899. * Creates a new MinBlock
  143900. * @param name defines the block name
  143901. */
  143902. constructor(name: string);
  143903. /**
  143904. * Gets the current class name
  143905. * @returns the class name
  143906. */
  143907. getClassName(): string;
  143908. /**
  143909. * Gets the left operand input component
  143910. */
  143911. get left(): NodeMaterialConnectionPoint;
  143912. /**
  143913. * Gets the right operand input component
  143914. */
  143915. get right(): NodeMaterialConnectionPoint;
  143916. /**
  143917. * Gets the output component
  143918. */
  143919. get output(): NodeMaterialConnectionPoint;
  143920. protected _buildBlock(state: NodeMaterialBuildState): this;
  143921. }
  143922. }
  143923. declare module BABYLON {
  143924. /**
  143925. * Block used to get the distance between 2 values
  143926. */
  143927. export class DistanceBlock extends NodeMaterialBlock {
  143928. /**
  143929. * Creates a new DistanceBlock
  143930. * @param name defines the block name
  143931. */
  143932. constructor(name: string);
  143933. /**
  143934. * Gets the current class name
  143935. * @returns the class name
  143936. */
  143937. getClassName(): string;
  143938. /**
  143939. * Gets the left operand input component
  143940. */
  143941. get left(): NodeMaterialConnectionPoint;
  143942. /**
  143943. * Gets the right operand input component
  143944. */
  143945. get right(): NodeMaterialConnectionPoint;
  143946. /**
  143947. * Gets the output component
  143948. */
  143949. get output(): NodeMaterialConnectionPoint;
  143950. protected _buildBlock(state: NodeMaterialBuildState): this;
  143951. }
  143952. }
  143953. declare module BABYLON {
  143954. /**
  143955. * Block used to get the length of a vector
  143956. */
  143957. export class LengthBlock extends NodeMaterialBlock {
  143958. /**
  143959. * Creates a new LengthBlock
  143960. * @param name defines the block name
  143961. */
  143962. constructor(name: string);
  143963. /**
  143964. * Gets the current class name
  143965. * @returns the class name
  143966. */
  143967. getClassName(): string;
  143968. /**
  143969. * Gets the value input component
  143970. */
  143971. get value(): NodeMaterialConnectionPoint;
  143972. /**
  143973. * Gets the output component
  143974. */
  143975. get output(): NodeMaterialConnectionPoint;
  143976. protected _buildBlock(state: NodeMaterialBuildState): this;
  143977. }
  143978. }
  143979. declare module BABYLON {
  143980. /**
  143981. * Block used to get negative version of a value (i.e. x * -1)
  143982. */
  143983. export class NegateBlock extends NodeMaterialBlock {
  143984. /**
  143985. * Creates a new NegateBlock
  143986. * @param name defines the block name
  143987. */
  143988. constructor(name: string);
  143989. /**
  143990. * Gets the current class name
  143991. * @returns the class name
  143992. */
  143993. getClassName(): string;
  143994. /**
  143995. * Gets the value input component
  143996. */
  143997. get value(): NodeMaterialConnectionPoint;
  143998. /**
  143999. * Gets the output component
  144000. */
  144001. get output(): NodeMaterialConnectionPoint;
  144002. protected _buildBlock(state: NodeMaterialBuildState): this;
  144003. }
  144004. }
  144005. declare module BABYLON {
  144006. /**
  144007. * Block used to get the value of the first parameter raised to the power of the second
  144008. */
  144009. export class PowBlock extends NodeMaterialBlock {
  144010. /**
  144011. * Creates a new PowBlock
  144012. * @param name defines the block name
  144013. */
  144014. constructor(name: string);
  144015. /**
  144016. * Gets the current class name
  144017. * @returns the class name
  144018. */
  144019. getClassName(): string;
  144020. /**
  144021. * Gets the value operand input component
  144022. */
  144023. get value(): NodeMaterialConnectionPoint;
  144024. /**
  144025. * Gets the power operand input component
  144026. */
  144027. get power(): NodeMaterialConnectionPoint;
  144028. /**
  144029. * Gets the output component
  144030. */
  144031. get output(): NodeMaterialConnectionPoint;
  144032. protected _buildBlock(state: NodeMaterialBuildState): this;
  144033. }
  144034. }
  144035. declare module BABYLON {
  144036. /**
  144037. * Block used to get a random number
  144038. */
  144039. export class RandomNumberBlock extends NodeMaterialBlock {
  144040. /**
  144041. * Creates a new RandomNumberBlock
  144042. * @param name defines the block name
  144043. */
  144044. constructor(name: string);
  144045. /**
  144046. * Gets the current class name
  144047. * @returns the class name
  144048. */
  144049. getClassName(): string;
  144050. /**
  144051. * Gets the seed input component
  144052. */
  144053. get seed(): NodeMaterialConnectionPoint;
  144054. /**
  144055. * Gets the output component
  144056. */
  144057. get output(): NodeMaterialConnectionPoint;
  144058. protected _buildBlock(state: NodeMaterialBuildState): this;
  144059. }
  144060. }
  144061. declare module BABYLON {
  144062. /**
  144063. * Block used to compute arc tangent of 2 values
  144064. */
  144065. export class ArcTan2Block extends NodeMaterialBlock {
  144066. /**
  144067. * Creates a new ArcTan2Block
  144068. * @param name defines the block name
  144069. */
  144070. constructor(name: string);
  144071. /**
  144072. * Gets the current class name
  144073. * @returns the class name
  144074. */
  144075. getClassName(): string;
  144076. /**
  144077. * Gets the x operand input component
  144078. */
  144079. get x(): NodeMaterialConnectionPoint;
  144080. /**
  144081. * Gets the y operand input component
  144082. */
  144083. get y(): NodeMaterialConnectionPoint;
  144084. /**
  144085. * Gets the output component
  144086. */
  144087. get output(): NodeMaterialConnectionPoint;
  144088. protected _buildBlock(state: NodeMaterialBuildState): this;
  144089. }
  144090. }
  144091. declare module BABYLON {
  144092. /**
  144093. * Block used to smooth step a value
  144094. */
  144095. export class SmoothStepBlock extends NodeMaterialBlock {
  144096. /**
  144097. * Creates a new SmoothStepBlock
  144098. * @param name defines the block name
  144099. */
  144100. constructor(name: string);
  144101. /**
  144102. * Gets the current class name
  144103. * @returns the class name
  144104. */
  144105. getClassName(): string;
  144106. /**
  144107. * Gets the value operand input component
  144108. */
  144109. get value(): NodeMaterialConnectionPoint;
  144110. /**
  144111. * Gets the first edge operand input component
  144112. */
  144113. get edge0(): NodeMaterialConnectionPoint;
  144114. /**
  144115. * Gets the second edge operand input component
  144116. */
  144117. get edge1(): NodeMaterialConnectionPoint;
  144118. /**
  144119. * Gets the output component
  144120. */
  144121. get output(): NodeMaterialConnectionPoint;
  144122. protected _buildBlock(state: NodeMaterialBuildState): this;
  144123. }
  144124. }
  144125. declare module BABYLON {
  144126. /**
  144127. * Block used to get the reciprocal (1 / x) of a value
  144128. */
  144129. export class ReciprocalBlock extends NodeMaterialBlock {
  144130. /**
  144131. * Creates a new ReciprocalBlock
  144132. * @param name defines the block name
  144133. */
  144134. constructor(name: string);
  144135. /**
  144136. * Gets the current class name
  144137. * @returns the class name
  144138. */
  144139. getClassName(): string;
  144140. /**
  144141. * Gets the input component
  144142. */
  144143. get input(): NodeMaterialConnectionPoint;
  144144. /**
  144145. * Gets the output component
  144146. */
  144147. get output(): NodeMaterialConnectionPoint;
  144148. protected _buildBlock(state: NodeMaterialBuildState): this;
  144149. }
  144150. }
  144151. declare module BABYLON {
  144152. /**
  144153. * Block used to replace a color by another one
  144154. */
  144155. export class ReplaceColorBlock extends NodeMaterialBlock {
  144156. /**
  144157. * Creates a new ReplaceColorBlock
  144158. * @param name defines the block name
  144159. */
  144160. constructor(name: string);
  144161. /**
  144162. * Gets the current class name
  144163. * @returns the class name
  144164. */
  144165. getClassName(): string;
  144166. /**
  144167. * Gets the value input component
  144168. */
  144169. get value(): NodeMaterialConnectionPoint;
  144170. /**
  144171. * Gets the reference input component
  144172. */
  144173. get reference(): NodeMaterialConnectionPoint;
  144174. /**
  144175. * Gets the distance input component
  144176. */
  144177. get distance(): NodeMaterialConnectionPoint;
  144178. /**
  144179. * Gets the replacement input component
  144180. */
  144181. get replacement(): NodeMaterialConnectionPoint;
  144182. /**
  144183. * Gets the output component
  144184. */
  144185. get output(): NodeMaterialConnectionPoint;
  144186. protected _buildBlock(state: NodeMaterialBuildState): this;
  144187. }
  144188. }
  144189. declare module BABYLON {
  144190. /**
  144191. * Block used to posterize a value
  144192. * @see https://en.wikipedia.org/wiki/Posterization
  144193. */
  144194. export class PosterizeBlock extends NodeMaterialBlock {
  144195. /**
  144196. * Creates a new PosterizeBlock
  144197. * @param name defines the block name
  144198. */
  144199. constructor(name: string);
  144200. /**
  144201. * Gets the current class name
  144202. * @returns the class name
  144203. */
  144204. getClassName(): string;
  144205. /**
  144206. * Gets the value input component
  144207. */
  144208. get value(): NodeMaterialConnectionPoint;
  144209. /**
  144210. * Gets the steps input component
  144211. */
  144212. get steps(): NodeMaterialConnectionPoint;
  144213. /**
  144214. * Gets the output component
  144215. */
  144216. get output(): NodeMaterialConnectionPoint;
  144217. protected _buildBlock(state: NodeMaterialBuildState): this;
  144218. }
  144219. }
  144220. declare module BABYLON {
  144221. /**
  144222. * Operations supported by the Wave block
  144223. */
  144224. export enum WaveBlockKind {
  144225. /** SawTooth */
  144226. SawTooth = 0,
  144227. /** Square */
  144228. Square = 1,
  144229. /** Triangle */
  144230. Triangle = 2
  144231. }
  144232. /**
  144233. * Block used to apply wave operation to floats
  144234. */
  144235. export class WaveBlock extends NodeMaterialBlock {
  144236. /**
  144237. * Gets or sets the kibnd of wave to be applied by the block
  144238. */
  144239. kind: WaveBlockKind;
  144240. /**
  144241. * Creates a new WaveBlock
  144242. * @param name defines the block name
  144243. */
  144244. constructor(name: string);
  144245. /**
  144246. * Gets the current class name
  144247. * @returns the class name
  144248. */
  144249. getClassName(): string;
  144250. /**
  144251. * Gets the input component
  144252. */
  144253. get input(): NodeMaterialConnectionPoint;
  144254. /**
  144255. * Gets the output component
  144256. */
  144257. get output(): NodeMaterialConnectionPoint;
  144258. protected _buildBlock(state: NodeMaterialBuildState): this;
  144259. serialize(): any;
  144260. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144261. }
  144262. }
  144263. declare module BABYLON {
  144264. /**
  144265. * Class used to store a color step for the GradientBlock
  144266. */
  144267. export class GradientBlockColorStep {
  144268. private _step;
  144269. /**
  144270. * Gets value indicating which step this color is associated with (between 0 and 1)
  144271. */
  144272. get step(): number;
  144273. /**
  144274. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144275. */
  144276. set step(val: number);
  144277. private _color;
  144278. /**
  144279. * Gets the color associated with this step
  144280. */
  144281. get color(): Color3;
  144282. /**
  144283. * Sets the color associated with this step
  144284. */
  144285. set color(val: Color3);
  144286. /**
  144287. * Creates a new GradientBlockColorStep
  144288. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144289. * @param color defines the color associated with this step
  144290. */
  144291. constructor(step: number, color: Color3);
  144292. }
  144293. /**
  144294. * Block used to return a color from a gradient based on an input value between 0 and 1
  144295. */
  144296. export class GradientBlock extends NodeMaterialBlock {
  144297. /**
  144298. * Gets or sets the list of color steps
  144299. */
  144300. colorSteps: GradientBlockColorStep[];
  144301. /** Gets an observable raised when the value is changed */
  144302. onValueChangedObservable: Observable<GradientBlock>;
  144303. /** calls observable when the value is changed*/
  144304. colorStepsUpdated(): void;
  144305. /**
  144306. * Creates a new GradientBlock
  144307. * @param name defines the block name
  144308. */
  144309. constructor(name: string);
  144310. /**
  144311. * Gets the current class name
  144312. * @returns the class name
  144313. */
  144314. getClassName(): string;
  144315. /**
  144316. * Gets the gradient input component
  144317. */
  144318. get gradient(): NodeMaterialConnectionPoint;
  144319. /**
  144320. * Gets the output component
  144321. */
  144322. get output(): NodeMaterialConnectionPoint;
  144323. private _writeColorConstant;
  144324. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144325. serialize(): any;
  144326. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144327. protected _dumpPropertiesCode(): string;
  144328. }
  144329. }
  144330. declare module BABYLON {
  144331. /**
  144332. * Block used to normalize lerp between 2 values
  144333. */
  144334. export class NLerpBlock extends NodeMaterialBlock {
  144335. /**
  144336. * Creates a new NLerpBlock
  144337. * @param name defines the block name
  144338. */
  144339. constructor(name: string);
  144340. /**
  144341. * Gets the current class name
  144342. * @returns the class name
  144343. */
  144344. getClassName(): string;
  144345. /**
  144346. * Gets the left operand input component
  144347. */
  144348. get left(): NodeMaterialConnectionPoint;
  144349. /**
  144350. * Gets the right operand input component
  144351. */
  144352. get right(): NodeMaterialConnectionPoint;
  144353. /**
  144354. * Gets the gradient operand input component
  144355. */
  144356. get gradient(): NodeMaterialConnectionPoint;
  144357. /**
  144358. * Gets the output component
  144359. */
  144360. get output(): NodeMaterialConnectionPoint;
  144361. protected _buildBlock(state: NodeMaterialBuildState): this;
  144362. }
  144363. }
  144364. declare module BABYLON {
  144365. /**
  144366. * block used to Generate a Worley Noise 3D Noise Pattern
  144367. */
  144368. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144369. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144370. manhattanDistance: boolean;
  144371. /**
  144372. * Creates a new WorleyNoise3DBlock
  144373. * @param name defines the block name
  144374. */
  144375. constructor(name: string);
  144376. /**
  144377. * Gets the current class name
  144378. * @returns the class name
  144379. */
  144380. getClassName(): string;
  144381. /**
  144382. * Gets the seed input component
  144383. */
  144384. get seed(): NodeMaterialConnectionPoint;
  144385. /**
  144386. * Gets the jitter input component
  144387. */
  144388. get jitter(): NodeMaterialConnectionPoint;
  144389. /**
  144390. * Gets the output component
  144391. */
  144392. get output(): NodeMaterialConnectionPoint;
  144393. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144394. /**
  144395. * Exposes the properties to the UI?
  144396. */
  144397. protected _dumpPropertiesCode(): string;
  144398. /**
  144399. * Exposes the properties to the Seralize?
  144400. */
  144401. serialize(): any;
  144402. /**
  144403. * Exposes the properties to the deseralize?
  144404. */
  144405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144406. }
  144407. }
  144408. declare module BABYLON {
  144409. /**
  144410. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144411. */
  144412. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144413. /**
  144414. * Creates a new SimplexPerlin3DBlock
  144415. * @param name defines the block name
  144416. */
  144417. constructor(name: string);
  144418. /**
  144419. * Gets the current class name
  144420. * @returns the class name
  144421. */
  144422. getClassName(): string;
  144423. /**
  144424. * Gets the seed operand input component
  144425. */
  144426. get seed(): NodeMaterialConnectionPoint;
  144427. /**
  144428. * Gets the output component
  144429. */
  144430. get output(): NodeMaterialConnectionPoint;
  144431. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144432. }
  144433. }
  144434. declare module BABYLON {
  144435. /**
  144436. * Block used to blend normals
  144437. */
  144438. export class NormalBlendBlock extends NodeMaterialBlock {
  144439. /**
  144440. * Creates a new NormalBlendBlock
  144441. * @param name defines the block name
  144442. */
  144443. constructor(name: string);
  144444. /**
  144445. * Gets the current class name
  144446. * @returns the class name
  144447. */
  144448. getClassName(): string;
  144449. /**
  144450. * Gets the first input component
  144451. */
  144452. get normalMap0(): NodeMaterialConnectionPoint;
  144453. /**
  144454. * Gets the second input component
  144455. */
  144456. get normalMap1(): NodeMaterialConnectionPoint;
  144457. /**
  144458. * Gets the output component
  144459. */
  144460. get output(): NodeMaterialConnectionPoint;
  144461. protected _buildBlock(state: NodeMaterialBuildState): this;
  144462. }
  144463. }
  144464. declare module BABYLON {
  144465. /**
  144466. * Block used to rotate a 2d vector by a given angle
  144467. */
  144468. export class Rotate2dBlock extends NodeMaterialBlock {
  144469. /**
  144470. * Creates a new Rotate2dBlock
  144471. * @param name defines the block name
  144472. */
  144473. constructor(name: string);
  144474. /**
  144475. * Gets the current class name
  144476. * @returns the class name
  144477. */
  144478. getClassName(): string;
  144479. /**
  144480. * Gets the input vector
  144481. */
  144482. get input(): NodeMaterialConnectionPoint;
  144483. /**
  144484. * Gets the input angle
  144485. */
  144486. get angle(): NodeMaterialConnectionPoint;
  144487. /**
  144488. * Gets the output component
  144489. */
  144490. get output(): NodeMaterialConnectionPoint;
  144491. autoConfigure(material: NodeMaterial): void;
  144492. protected _buildBlock(state: NodeMaterialBuildState): this;
  144493. }
  144494. }
  144495. declare module BABYLON {
  144496. /**
  144497. * Block used to get the reflected vector from a direction and a normal
  144498. */
  144499. export class ReflectBlock extends NodeMaterialBlock {
  144500. /**
  144501. * Creates a new ReflectBlock
  144502. * @param name defines the block name
  144503. */
  144504. constructor(name: string);
  144505. /**
  144506. * Gets the current class name
  144507. * @returns the class name
  144508. */
  144509. getClassName(): string;
  144510. /**
  144511. * Gets the incident component
  144512. */
  144513. get incident(): NodeMaterialConnectionPoint;
  144514. /**
  144515. * Gets the normal component
  144516. */
  144517. get normal(): NodeMaterialConnectionPoint;
  144518. /**
  144519. * Gets the output component
  144520. */
  144521. get output(): NodeMaterialConnectionPoint;
  144522. protected _buildBlock(state: NodeMaterialBuildState): this;
  144523. }
  144524. }
  144525. declare module BABYLON {
  144526. /**
  144527. * Block used to get the refracted vector from a direction and a normal
  144528. */
  144529. export class RefractBlock extends NodeMaterialBlock {
  144530. /**
  144531. * Creates a new RefractBlock
  144532. * @param name defines the block name
  144533. */
  144534. constructor(name: string);
  144535. /**
  144536. * Gets the current class name
  144537. * @returns the class name
  144538. */
  144539. getClassName(): string;
  144540. /**
  144541. * Gets the incident component
  144542. */
  144543. get incident(): NodeMaterialConnectionPoint;
  144544. /**
  144545. * Gets the normal component
  144546. */
  144547. get normal(): NodeMaterialConnectionPoint;
  144548. /**
  144549. * Gets the index of refraction component
  144550. */
  144551. get ior(): NodeMaterialConnectionPoint;
  144552. /**
  144553. * Gets the output component
  144554. */
  144555. get output(): NodeMaterialConnectionPoint;
  144556. protected _buildBlock(state: NodeMaterialBuildState): this;
  144557. }
  144558. }
  144559. declare module BABYLON {
  144560. /**
  144561. * Block used to desaturate a color
  144562. */
  144563. export class DesaturateBlock extends NodeMaterialBlock {
  144564. /**
  144565. * Creates a new DesaturateBlock
  144566. * @param name defines the block name
  144567. */
  144568. constructor(name: string);
  144569. /**
  144570. * Gets the current class name
  144571. * @returns the class name
  144572. */
  144573. getClassName(): string;
  144574. /**
  144575. * Gets the color operand input component
  144576. */
  144577. get color(): NodeMaterialConnectionPoint;
  144578. /**
  144579. * Gets the level operand input component
  144580. */
  144581. get level(): NodeMaterialConnectionPoint;
  144582. /**
  144583. * Gets the output component
  144584. */
  144585. get output(): NodeMaterialConnectionPoint;
  144586. protected _buildBlock(state: NodeMaterialBuildState): this;
  144587. }
  144588. }
  144589. declare module BABYLON {
  144590. /**
  144591. * Block used to implement the ambient occlusion module of the PBR material
  144592. */
  144593. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  144594. /**
  144595. * Create a new AmbientOcclusionBlock
  144596. * @param name defines the block name
  144597. */
  144598. constructor(name: string);
  144599. /**
  144600. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  144601. */
  144602. useAmbientInGrayScale: boolean;
  144603. /**
  144604. * Initialize the block and prepare the context for build
  144605. * @param state defines the state that will be used for the build
  144606. */
  144607. initialize(state: NodeMaterialBuildState): void;
  144608. /**
  144609. * Gets the current class name
  144610. * @returns the class name
  144611. */
  144612. getClassName(): string;
  144613. /**
  144614. * Gets the texture input component
  144615. */
  144616. get texture(): NodeMaterialConnectionPoint;
  144617. /**
  144618. * Gets the texture intensity component
  144619. */
  144620. get intensity(): NodeMaterialConnectionPoint;
  144621. /**
  144622. * Gets the direct light intensity input component
  144623. */
  144624. get directLightIntensity(): NodeMaterialConnectionPoint;
  144625. /**
  144626. * Gets the ambient occlusion object output component
  144627. */
  144628. get ambientOcclusion(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the main code of the block (fragment side)
  144631. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  144632. * @returns the shader code
  144633. */
  144634. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  144635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144636. protected _buildBlock(state: NodeMaterialBuildState): this;
  144637. protected _dumpPropertiesCode(): string;
  144638. serialize(): any;
  144639. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144640. }
  144641. }
  144642. declare module BABYLON {
  144643. /**
  144644. * Block used to implement the reflection module of the PBR material
  144645. */
  144646. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  144647. /** @hidden */
  144648. _defineLODReflectionAlpha: string;
  144649. /** @hidden */
  144650. _defineLinearSpecularReflection: string;
  144651. private _vEnvironmentIrradianceName;
  144652. /** @hidden */
  144653. _vReflectionMicrosurfaceInfosName: string;
  144654. /** @hidden */
  144655. _vReflectionInfosName: string;
  144656. /** @hidden */
  144657. _vReflectionFilteringInfoName: string;
  144658. private _scene;
  144659. /**
  144660. * The three properties below are set by the main PBR block prior to calling methods of this class.
  144661. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144662. * It's less burden on the user side in the editor part.
  144663. */
  144664. /** @hidden */
  144665. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144666. /** @hidden */
  144667. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144668. /** @hidden */
  144669. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  144670. /**
  144671. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  144672. * diffuse part of the IBL.
  144673. */
  144674. useSphericalHarmonics: boolean;
  144675. /**
  144676. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  144677. */
  144678. forceIrradianceInFragment: boolean;
  144679. /**
  144680. * Create a new ReflectionBlock
  144681. * @param name defines the block name
  144682. */
  144683. constructor(name: string);
  144684. /**
  144685. * Gets the current class name
  144686. * @returns the class name
  144687. */
  144688. getClassName(): string;
  144689. /**
  144690. * Gets the position input component
  144691. */
  144692. get position(): NodeMaterialConnectionPoint;
  144693. /**
  144694. * Gets the world position input component
  144695. */
  144696. get worldPosition(): NodeMaterialConnectionPoint;
  144697. /**
  144698. * Gets the world normal input component
  144699. */
  144700. get worldNormal(): NodeMaterialConnectionPoint;
  144701. /**
  144702. * Gets the world input component
  144703. */
  144704. get world(): NodeMaterialConnectionPoint;
  144705. /**
  144706. * Gets the camera (or eye) position component
  144707. */
  144708. get cameraPosition(): NodeMaterialConnectionPoint;
  144709. /**
  144710. * Gets the view input component
  144711. */
  144712. get view(): NodeMaterialConnectionPoint;
  144713. /**
  144714. * Gets the color input component
  144715. */
  144716. get color(): NodeMaterialConnectionPoint;
  144717. /**
  144718. * Gets the reflection object output component
  144719. */
  144720. get reflection(): NodeMaterialConnectionPoint;
  144721. /**
  144722. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  144723. */
  144724. get hasTexture(): boolean;
  144725. /**
  144726. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  144727. */
  144728. get reflectionColor(): string;
  144729. protected _getTexture(): Nullable<BaseTexture>;
  144730. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144731. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144732. /**
  144733. * Gets the code to inject in the vertex shader
  144734. * @param state current state of the node material building
  144735. * @returns the shader code
  144736. */
  144737. handleVertexSide(state: NodeMaterialBuildState): string;
  144738. /**
  144739. * Gets the main code of the block (fragment side)
  144740. * @param state current state of the node material building
  144741. * @param normalVarName name of the existing variable corresponding to the normal
  144742. * @returns the shader code
  144743. */
  144744. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  144745. protected _buildBlock(state: NodeMaterialBuildState): this;
  144746. protected _dumpPropertiesCode(): string;
  144747. serialize(): any;
  144748. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144749. }
  144750. }
  144751. declare module BABYLON {
  144752. /**
  144753. * Block used to implement the sheen module of the PBR material
  144754. */
  144755. export class SheenBlock extends NodeMaterialBlock {
  144756. /**
  144757. * Create a new SheenBlock
  144758. * @param name defines the block name
  144759. */
  144760. constructor(name: string);
  144761. /**
  144762. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  144763. * It allows the strength of the sheen effect to not depend on the base color of the material,
  144764. * making it easier to setup and tweak the effect
  144765. */
  144766. albedoScaling: boolean;
  144767. /**
  144768. * Defines if the sheen is linked to the sheen color.
  144769. */
  144770. linkSheenWithAlbedo: boolean;
  144771. /**
  144772. * Initialize the block and prepare the context for build
  144773. * @param state defines the state that will be used for the build
  144774. */
  144775. initialize(state: NodeMaterialBuildState): void;
  144776. /**
  144777. * Gets the current class name
  144778. * @returns the class name
  144779. */
  144780. getClassName(): string;
  144781. /**
  144782. * Gets the intensity input component
  144783. */
  144784. get intensity(): NodeMaterialConnectionPoint;
  144785. /**
  144786. * Gets the color input component
  144787. */
  144788. get color(): NodeMaterialConnectionPoint;
  144789. /**
  144790. * Gets the roughness input component
  144791. */
  144792. get roughness(): NodeMaterialConnectionPoint;
  144793. /**
  144794. * Gets the sheen object output component
  144795. */
  144796. get sheen(): NodeMaterialConnectionPoint;
  144797. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144798. /**
  144799. * Gets the main code of the block (fragment side)
  144800. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  144801. * @returns the shader code
  144802. */
  144803. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  144804. protected _buildBlock(state: NodeMaterialBuildState): this;
  144805. protected _dumpPropertiesCode(): string;
  144806. serialize(): any;
  144807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144808. }
  144809. }
  144810. declare module BABYLON {
  144811. /**
  144812. * Block used to implement the reflectivity module of the PBR material
  144813. */
  144814. export class ReflectivityBlock extends NodeMaterialBlock {
  144815. private _metallicReflectanceColor;
  144816. private _metallicF0Factor;
  144817. /** @hidden */
  144818. _vMetallicReflectanceFactorsName: string;
  144819. /**
  144820. * The property below is set by the main PBR block prior to calling methods of this class.
  144821. */
  144822. /** @hidden */
  144823. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  144824. /**
  144825. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  144826. */
  144827. useAmbientOcclusionFromMetallicTextureRed: boolean;
  144828. /**
  144829. * Specifies if the metallic texture contains the metallness information in its blue channel.
  144830. */
  144831. useMetallnessFromMetallicTextureBlue: boolean;
  144832. /**
  144833. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  144834. */
  144835. useRoughnessFromMetallicTextureAlpha: boolean;
  144836. /**
  144837. * Specifies if the metallic texture contains the roughness information in its green channel.
  144838. */
  144839. useRoughnessFromMetallicTextureGreen: boolean;
  144840. /**
  144841. * Create a new ReflectivityBlock
  144842. * @param name defines the block name
  144843. */
  144844. constructor(name: string);
  144845. /**
  144846. * Initialize the block and prepare the context for build
  144847. * @param state defines the state that will be used for the build
  144848. */
  144849. initialize(state: NodeMaterialBuildState): void;
  144850. /**
  144851. * Gets the current class name
  144852. * @returns the class name
  144853. */
  144854. getClassName(): string;
  144855. /**
  144856. * Gets the metallic input component
  144857. */
  144858. get metallic(): NodeMaterialConnectionPoint;
  144859. /**
  144860. * Gets the roughness input component
  144861. */
  144862. get roughness(): NodeMaterialConnectionPoint;
  144863. /**
  144864. * Gets the texture input component
  144865. */
  144866. get texture(): NodeMaterialConnectionPoint;
  144867. /**
  144868. * Gets the reflectivity object output component
  144869. */
  144870. get reflectivity(): NodeMaterialConnectionPoint;
  144871. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  144872. /**
  144873. * Gets the main code of the block (fragment side)
  144874. * @param state current state of the node material building
  144875. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  144876. * @returns the shader code
  144877. */
  144878. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  144879. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144880. protected _buildBlock(state: NodeMaterialBuildState): this;
  144881. protected _dumpPropertiesCode(): string;
  144882. serialize(): any;
  144883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144884. }
  144885. }
  144886. declare module BABYLON {
  144887. /**
  144888. * Block used to implement the anisotropy module of the PBR material
  144889. */
  144890. export class AnisotropyBlock extends NodeMaterialBlock {
  144891. /**
  144892. * The two properties below are set by the main PBR block prior to calling methods of this class.
  144893. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  144894. * It's less burden on the user side in the editor part.
  144895. */
  144896. /** @hidden */
  144897. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  144898. /** @hidden */
  144899. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  144900. /**
  144901. * Create a new AnisotropyBlock
  144902. * @param name defines the block name
  144903. */
  144904. constructor(name: string);
  144905. /**
  144906. * Initialize the block and prepare the context for build
  144907. * @param state defines the state that will be used for the build
  144908. */
  144909. initialize(state: NodeMaterialBuildState): void;
  144910. /**
  144911. * Gets the current class name
  144912. * @returns the class name
  144913. */
  144914. getClassName(): string;
  144915. /**
  144916. * Gets the intensity input component
  144917. */
  144918. get intensity(): NodeMaterialConnectionPoint;
  144919. /**
  144920. * Gets the direction input component
  144921. */
  144922. get direction(): NodeMaterialConnectionPoint;
  144923. /**
  144924. * Gets the texture input component
  144925. */
  144926. get texture(): NodeMaterialConnectionPoint;
  144927. /**
  144928. * Gets the uv input component
  144929. */
  144930. get uv(): NodeMaterialConnectionPoint;
  144931. /**
  144932. * Gets the worldTangent input component
  144933. */
  144934. get worldTangent(): NodeMaterialConnectionPoint;
  144935. /**
  144936. * Gets the anisotropy object output component
  144937. */
  144938. get anisotropy(): NodeMaterialConnectionPoint;
  144939. private _generateTBNSpace;
  144940. /**
  144941. * Gets the main code of the block (fragment side)
  144942. * @param state current state of the node material building
  144943. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  144944. * @returns the shader code
  144945. */
  144946. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  144947. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  144948. protected _buildBlock(state: NodeMaterialBuildState): this;
  144949. }
  144950. }
  144951. declare module BABYLON {
  144952. /**
  144953. * Block used to implement the clear coat module of the PBR material
  144954. */
  144955. export class ClearCoatBlock extends NodeMaterialBlock {
  144956. private _scene;
  144957. /**
  144958. * Create a new ClearCoatBlock
  144959. * @param name defines the block name
  144960. */
  144961. constructor(name: string);
  144962. /**
  144963. * Initialize the block and prepare the context for build
  144964. * @param state defines the state that will be used for the build
  144965. */
  144966. initialize(state: NodeMaterialBuildState): void;
  144967. /**
  144968. * Gets the current class name
  144969. * @returns the class name
  144970. */
  144971. getClassName(): string;
  144972. /**
  144973. * Gets the intensity input component
  144974. */
  144975. get intensity(): NodeMaterialConnectionPoint;
  144976. /**
  144977. * Gets the roughness input component
  144978. */
  144979. get roughness(): NodeMaterialConnectionPoint;
  144980. /**
  144981. * Gets the ior input component
  144982. */
  144983. get ior(): NodeMaterialConnectionPoint;
  144984. /**
  144985. * Gets the texture input component
  144986. */
  144987. get texture(): NodeMaterialConnectionPoint;
  144988. /**
  144989. * Gets the bump texture input component
  144990. */
  144991. get bumpTexture(): NodeMaterialConnectionPoint;
  144992. /**
  144993. * Gets the uv input component
  144994. */
  144995. get uv(): NodeMaterialConnectionPoint;
  144996. /**
  144997. * Gets the tint color input component
  144998. */
  144999. get tintColor(): NodeMaterialConnectionPoint;
  145000. /**
  145001. * Gets the tint "at distance" input component
  145002. */
  145003. get tintAtDistance(): NodeMaterialConnectionPoint;
  145004. /**
  145005. * Gets the tint thickness input component
  145006. */
  145007. get tintThickness(): NodeMaterialConnectionPoint;
  145008. /**
  145009. * Gets the world tangent input component
  145010. */
  145011. get worldTangent(): NodeMaterialConnectionPoint;
  145012. /**
  145013. * Gets the clear coat object output component
  145014. */
  145015. get clearcoat(): NodeMaterialConnectionPoint;
  145016. autoConfigure(material: NodeMaterial): void;
  145017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145019. private _generateTBNSpace;
  145020. /**
  145021. * Gets the main code of the block (fragment side)
  145022. * @param state current state of the node material building
  145023. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145024. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145025. * @param worldPosVarName name of the variable holding the world position
  145026. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145027. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145028. * @param worldNormalVarName name of the variable holding the world normal
  145029. * @returns the shader code
  145030. */
  145031. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145032. protected _buildBlock(state: NodeMaterialBuildState): this;
  145033. }
  145034. }
  145035. declare module BABYLON {
  145036. /**
  145037. * Block used to implement the sub surface module of the PBR material
  145038. */
  145039. export class SubSurfaceBlock extends NodeMaterialBlock {
  145040. /**
  145041. * Create a new SubSurfaceBlock
  145042. * @param name defines the block name
  145043. */
  145044. constructor(name: string);
  145045. /**
  145046. * Stores the intensity of the different subsurface effects in the thickness texture.
  145047. * * the green channel is the translucency intensity.
  145048. * * the blue channel is the scattering intensity.
  145049. * * the alpha channel is the refraction intensity.
  145050. */
  145051. useMaskFromThicknessTexture: boolean;
  145052. /**
  145053. * Initialize the block and prepare the context for build
  145054. * @param state defines the state that will be used for the build
  145055. */
  145056. initialize(state: NodeMaterialBuildState): void;
  145057. /**
  145058. * Gets the current class name
  145059. * @returns the class name
  145060. */
  145061. getClassName(): string;
  145062. /**
  145063. * Gets the min thickness input component
  145064. */
  145065. get minThickness(): NodeMaterialConnectionPoint;
  145066. /**
  145067. * Gets the max thickness input component
  145068. */
  145069. get maxThickness(): NodeMaterialConnectionPoint;
  145070. /**
  145071. * Gets the thickness texture component
  145072. */
  145073. get thicknessTexture(): NodeMaterialConnectionPoint;
  145074. /**
  145075. * Gets the tint color input component
  145076. */
  145077. get tintColor(): NodeMaterialConnectionPoint;
  145078. /**
  145079. * Gets the translucency intensity input component
  145080. */
  145081. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145082. /**
  145083. * Gets the translucency diffusion distance input component
  145084. */
  145085. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145086. /**
  145087. * Gets the refraction object parameters
  145088. */
  145089. get refraction(): NodeMaterialConnectionPoint;
  145090. /**
  145091. * Gets the sub surface object output component
  145092. */
  145093. get subsurface(): NodeMaterialConnectionPoint;
  145094. autoConfigure(material: NodeMaterial): void;
  145095. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145096. /**
  145097. * Gets the main code of the block (fragment side)
  145098. * @param state current state of the node material building
  145099. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145100. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145101. * @param worldPosVarName name of the variable holding the world position
  145102. * @returns the shader code
  145103. */
  145104. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145105. protected _buildBlock(state: NodeMaterialBuildState): this;
  145106. }
  145107. }
  145108. declare module BABYLON {
  145109. /**
  145110. * Block used to implement the PBR metallic/roughness model
  145111. */
  145112. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145113. /**
  145114. * Gets or sets the light associated with this block
  145115. */
  145116. light: Nullable<Light>;
  145117. private _lightId;
  145118. private _scene;
  145119. private _environmentBRDFTexture;
  145120. private _environmentBrdfSamplerName;
  145121. private _vNormalWName;
  145122. private _invertNormalName;
  145123. /**
  145124. * Create a new ReflectionBlock
  145125. * @param name defines the block name
  145126. */
  145127. constructor(name: string);
  145128. /**
  145129. * Intensity of the direct lights e.g. the four lights available in your scene.
  145130. * This impacts both the direct diffuse and specular highlights.
  145131. */
  145132. directIntensity: number;
  145133. /**
  145134. * Intensity of the environment e.g. how much the environment will light the object
  145135. * either through harmonics for rough material or through the refelction for shiny ones.
  145136. */
  145137. environmentIntensity: number;
  145138. /**
  145139. * This is a special control allowing the reduction of the specular highlights coming from the
  145140. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145141. */
  145142. specularIntensity: number;
  145143. /**
  145144. * Defines the falloff type used in this material.
  145145. * It by default is Physical.
  145146. */
  145147. lightFalloff: number;
  145148. /**
  145149. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145150. */
  145151. useAlphaFromAlbedoTexture: boolean;
  145152. /**
  145153. * Specifies that alpha test should be used
  145154. */
  145155. useAlphaTest: boolean;
  145156. /**
  145157. * Defines the alpha limits in alpha test mode.
  145158. */
  145159. alphaTestCutoff: number;
  145160. /**
  145161. * Specifies that alpha blending should be used
  145162. */
  145163. useAlphaBlending: boolean;
  145164. /**
  145165. * Defines if the alpha value should be determined via the rgb values.
  145166. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145167. */
  145168. opacityRGB: boolean;
  145169. /**
  145170. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145171. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145172. */
  145173. useRadianceOverAlpha: boolean;
  145174. /**
  145175. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145176. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145177. */
  145178. useSpecularOverAlpha: boolean;
  145179. /**
  145180. * Enables specular anti aliasing in the PBR shader.
  145181. * It will both interacts on the Geometry for analytical and IBL lighting.
  145182. * It also prefilter the roughness map based on the bump values.
  145183. */
  145184. enableSpecularAntiAliasing: boolean;
  145185. /**
  145186. * Enables realtime filtering on the texture.
  145187. */
  145188. realTimeFiltering: boolean;
  145189. /**
  145190. * Quality switch for realtime filtering
  145191. */
  145192. realTimeFilteringQuality: number;
  145193. /**
  145194. * Defines if the material uses energy conservation.
  145195. */
  145196. useEnergyConservation: boolean;
  145197. /**
  145198. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145199. * too much the area relying on ambient texture to define their ambient occlusion.
  145200. */
  145201. useRadianceOcclusion: boolean;
  145202. /**
  145203. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145204. * makes the reflect vector face the model (under horizon).
  145205. */
  145206. useHorizonOcclusion: boolean;
  145207. /**
  145208. * If set to true, no lighting calculations will be applied.
  145209. */
  145210. unlit: boolean;
  145211. /**
  145212. * Force normal to face away from face.
  145213. */
  145214. forceNormalForward: boolean;
  145215. /**
  145216. * Defines the material debug mode.
  145217. * It helps seeing only some components of the material while troubleshooting.
  145218. */
  145219. debugMode: number;
  145220. /**
  145221. * Specify from where on screen the debug mode should start.
  145222. * The value goes from -1 (full screen) to 1 (not visible)
  145223. * It helps with side by side comparison against the final render
  145224. * This defaults to 0
  145225. */
  145226. debugLimit: number;
  145227. /**
  145228. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145229. * You can use the factor to better multiply the final value.
  145230. */
  145231. debugFactor: number;
  145232. /**
  145233. * Initialize the block and prepare the context for build
  145234. * @param state defines the state that will be used for the build
  145235. */
  145236. initialize(state: NodeMaterialBuildState): void;
  145237. /**
  145238. * Gets the current class name
  145239. * @returns the class name
  145240. */
  145241. getClassName(): string;
  145242. /**
  145243. * Gets the world position input component
  145244. */
  145245. get worldPosition(): NodeMaterialConnectionPoint;
  145246. /**
  145247. * Gets the world normal input component
  145248. */
  145249. get worldNormal(): NodeMaterialConnectionPoint;
  145250. /**
  145251. * Gets the perturbed normal input component
  145252. */
  145253. get perturbedNormal(): NodeMaterialConnectionPoint;
  145254. /**
  145255. * Gets the camera position input component
  145256. */
  145257. get cameraPosition(): NodeMaterialConnectionPoint;
  145258. /**
  145259. * Gets the base color input component
  145260. */
  145261. get baseColor(): NodeMaterialConnectionPoint;
  145262. /**
  145263. * Gets the opacity texture input component
  145264. */
  145265. get opacityTexture(): NodeMaterialConnectionPoint;
  145266. /**
  145267. * Gets the ambient color input component
  145268. */
  145269. get ambientColor(): NodeMaterialConnectionPoint;
  145270. /**
  145271. * Gets the reflectivity object parameters
  145272. */
  145273. get reflectivity(): NodeMaterialConnectionPoint;
  145274. /**
  145275. * Gets the ambient occlusion object parameters
  145276. */
  145277. get ambientOcclusion(): NodeMaterialConnectionPoint;
  145278. /**
  145279. * Gets the reflection object parameters
  145280. */
  145281. get reflection(): NodeMaterialConnectionPoint;
  145282. /**
  145283. * Gets the sheen object parameters
  145284. */
  145285. get sheen(): NodeMaterialConnectionPoint;
  145286. /**
  145287. * Gets the clear coat object parameters
  145288. */
  145289. get clearcoat(): NodeMaterialConnectionPoint;
  145290. /**
  145291. * Gets the sub surface object parameters
  145292. */
  145293. get subsurface(): NodeMaterialConnectionPoint;
  145294. /**
  145295. * Gets the anisotropy object parameters
  145296. */
  145297. get anisotropy(): NodeMaterialConnectionPoint;
  145298. /**
  145299. * Gets the ambient output component
  145300. */
  145301. get ambient(): NodeMaterialConnectionPoint;
  145302. /**
  145303. * Gets the diffuse output component
  145304. */
  145305. get diffuse(): NodeMaterialConnectionPoint;
  145306. /**
  145307. * Gets the specular output component
  145308. */
  145309. get specular(): NodeMaterialConnectionPoint;
  145310. /**
  145311. * Gets the sheen output component
  145312. */
  145313. get sheenDir(): NodeMaterialConnectionPoint;
  145314. /**
  145315. * Gets the clear coat output component
  145316. */
  145317. get clearcoatDir(): NodeMaterialConnectionPoint;
  145318. /**
  145319. * Gets the indirect diffuse output component
  145320. */
  145321. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145322. /**
  145323. * Gets the indirect specular output component
  145324. */
  145325. get specularIndirect(): NodeMaterialConnectionPoint;
  145326. /**
  145327. * Gets the indirect sheen output component
  145328. */
  145329. get sheenIndirect(): NodeMaterialConnectionPoint;
  145330. /**
  145331. * Gets the indirect clear coat output component
  145332. */
  145333. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145334. /**
  145335. * Gets the refraction output component
  145336. */
  145337. get refraction(): NodeMaterialConnectionPoint;
  145338. /**
  145339. * Gets the global lighting output component
  145340. */
  145341. get lighting(): NodeMaterialConnectionPoint;
  145342. /**
  145343. * Gets the shadow output component
  145344. */
  145345. get shadow(): NodeMaterialConnectionPoint;
  145346. /**
  145347. * Gets the alpha output component
  145348. */
  145349. get alpha(): NodeMaterialConnectionPoint;
  145350. autoConfigure(material: NodeMaterial): void;
  145351. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145352. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145353. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145354. private _injectVertexCode;
  145355. /**
  145356. * Gets the code corresponding to the albedo/opacity module
  145357. * @returns the shader code
  145358. */
  145359. getAlbedoOpacityCode(): string;
  145360. protected _buildBlock(state: NodeMaterialBuildState): this;
  145361. protected _dumpPropertiesCode(): string;
  145362. serialize(): any;
  145363. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145364. }
  145365. }
  145366. declare module BABYLON {
  145367. /**
  145368. * Block used to compute value of one parameter modulo another
  145369. */
  145370. export class ModBlock extends NodeMaterialBlock {
  145371. /**
  145372. * Creates a new ModBlock
  145373. * @param name defines the block name
  145374. */
  145375. constructor(name: string);
  145376. /**
  145377. * Gets the current class name
  145378. * @returns the class name
  145379. */
  145380. getClassName(): string;
  145381. /**
  145382. * Gets the left operand input component
  145383. */
  145384. get left(): NodeMaterialConnectionPoint;
  145385. /**
  145386. * Gets the right operand input component
  145387. */
  145388. get right(): NodeMaterialConnectionPoint;
  145389. /**
  145390. * Gets the output component
  145391. */
  145392. get output(): NodeMaterialConnectionPoint;
  145393. protected _buildBlock(state: NodeMaterialBuildState): this;
  145394. }
  145395. }
  145396. declare module BABYLON {
  145397. /**
  145398. * Configuration for Draco compression
  145399. */
  145400. export interface IDracoCompressionConfiguration {
  145401. /**
  145402. * Configuration for the decoder.
  145403. */
  145404. decoder: {
  145405. /**
  145406. * The url to the WebAssembly module.
  145407. */
  145408. wasmUrl?: string;
  145409. /**
  145410. * The url to the WebAssembly binary.
  145411. */
  145412. wasmBinaryUrl?: string;
  145413. /**
  145414. * The url to the fallback JavaScript module.
  145415. */
  145416. fallbackUrl?: string;
  145417. };
  145418. }
  145419. /**
  145420. * Draco compression (https://google.github.io/draco/)
  145421. *
  145422. * This class wraps the Draco module.
  145423. *
  145424. * **Encoder**
  145425. *
  145426. * The encoder is not currently implemented.
  145427. *
  145428. * **Decoder**
  145429. *
  145430. * 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.
  145431. *
  145432. * To update the configuration, use the following code:
  145433. * ```javascript
  145434. * DracoCompression.Configuration = {
  145435. * decoder: {
  145436. * wasmUrl: "<url to the WebAssembly library>",
  145437. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145438. * fallbackUrl: "<url to the fallback JavaScript library>",
  145439. * }
  145440. * };
  145441. * ```
  145442. *
  145443. * 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.
  145444. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145445. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145446. *
  145447. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145448. * ```javascript
  145449. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145450. * ```
  145451. *
  145452. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145453. */
  145454. export class DracoCompression implements IDisposable {
  145455. private _workerPoolPromise?;
  145456. private _decoderModulePromise?;
  145457. /**
  145458. * The configuration. Defaults to the following urls:
  145459. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145460. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145461. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145462. */
  145463. static Configuration: IDracoCompressionConfiguration;
  145464. /**
  145465. * Returns true if the decoder configuration is available.
  145466. */
  145467. static get DecoderAvailable(): boolean;
  145468. /**
  145469. * Default number of workers to create when creating the draco compression object.
  145470. */
  145471. static DefaultNumWorkers: number;
  145472. private static GetDefaultNumWorkers;
  145473. private static _Default;
  145474. /**
  145475. * Default instance for the draco compression object.
  145476. */
  145477. static get Default(): DracoCompression;
  145478. /**
  145479. * Constructor
  145480. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145481. */
  145482. constructor(numWorkers?: number);
  145483. /**
  145484. * Stop all async operations and release resources.
  145485. */
  145486. dispose(): void;
  145487. /**
  145488. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145489. * @returns a promise that resolves when ready
  145490. */
  145491. whenReadyAsync(): Promise<void>;
  145492. /**
  145493. * Decode Draco compressed mesh data to vertex data.
  145494. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145495. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145496. * @returns A promise that resolves with the decoded vertex data
  145497. */
  145498. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145499. [kind: string]: number;
  145500. }): Promise<VertexData>;
  145501. }
  145502. }
  145503. declare module BABYLON {
  145504. /**
  145505. * Class for building Constructive Solid Geometry
  145506. */
  145507. export class CSG {
  145508. private polygons;
  145509. /**
  145510. * The world matrix
  145511. */
  145512. matrix: Matrix;
  145513. /**
  145514. * Stores the position
  145515. */
  145516. position: Vector3;
  145517. /**
  145518. * Stores the rotation
  145519. */
  145520. rotation: Vector3;
  145521. /**
  145522. * Stores the rotation quaternion
  145523. */
  145524. rotationQuaternion: Nullable<Quaternion>;
  145525. /**
  145526. * Stores the scaling vector
  145527. */
  145528. scaling: Vector3;
  145529. /**
  145530. * Convert the Mesh to CSG
  145531. * @param mesh The Mesh to convert to CSG
  145532. * @returns A new CSG from the Mesh
  145533. */
  145534. static FromMesh(mesh: Mesh): CSG;
  145535. /**
  145536. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145537. * @param polygons Polygons used to construct a CSG solid
  145538. */
  145539. private static FromPolygons;
  145540. /**
  145541. * Clones, or makes a deep copy, of the CSG
  145542. * @returns A new CSG
  145543. */
  145544. clone(): CSG;
  145545. /**
  145546. * Unions this CSG with another CSG
  145547. * @param csg The CSG to union against this CSG
  145548. * @returns The unioned CSG
  145549. */
  145550. union(csg: CSG): CSG;
  145551. /**
  145552. * Unions this CSG with another CSG in place
  145553. * @param csg The CSG to union against this CSG
  145554. */
  145555. unionInPlace(csg: CSG): void;
  145556. /**
  145557. * Subtracts this CSG with another CSG
  145558. * @param csg The CSG to subtract against this CSG
  145559. * @returns A new CSG
  145560. */
  145561. subtract(csg: CSG): CSG;
  145562. /**
  145563. * Subtracts this CSG with another CSG in place
  145564. * @param csg The CSG to subtact against this CSG
  145565. */
  145566. subtractInPlace(csg: CSG): void;
  145567. /**
  145568. * Intersect this CSG with another CSG
  145569. * @param csg The CSG to intersect against this CSG
  145570. * @returns A new CSG
  145571. */
  145572. intersect(csg: CSG): CSG;
  145573. /**
  145574. * Intersects this CSG with another CSG in place
  145575. * @param csg The CSG to intersect against this CSG
  145576. */
  145577. intersectInPlace(csg: CSG): void;
  145578. /**
  145579. * Return a new CSG solid with solid and empty space switched. This solid is
  145580. * not modified.
  145581. * @returns A new CSG solid with solid and empty space switched
  145582. */
  145583. inverse(): CSG;
  145584. /**
  145585. * Inverses the CSG in place
  145586. */
  145587. inverseInPlace(): void;
  145588. /**
  145589. * This is used to keep meshes transformations so they can be restored
  145590. * when we build back a Babylon Mesh
  145591. * NB : All CSG operations are performed in world coordinates
  145592. * @param csg The CSG to copy the transform attributes from
  145593. * @returns This CSG
  145594. */
  145595. copyTransformAttributes(csg: CSG): CSG;
  145596. /**
  145597. * Build Raw mesh from CSG
  145598. * Coordinates here are in world space
  145599. * @param name The name of the mesh geometry
  145600. * @param scene The Scene
  145601. * @param keepSubMeshes Specifies if the submeshes should be kept
  145602. * @returns A new Mesh
  145603. */
  145604. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145605. /**
  145606. * Build Mesh from CSG taking material and transforms into account
  145607. * @param name The name of the Mesh
  145608. * @param material The material of the Mesh
  145609. * @param scene The Scene
  145610. * @param keepSubMeshes Specifies if submeshes should be kept
  145611. * @returns The new Mesh
  145612. */
  145613. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  145614. }
  145615. }
  145616. declare module BABYLON {
  145617. /**
  145618. * Class used to create a trail following a mesh
  145619. */
  145620. export class TrailMesh extends Mesh {
  145621. private _generator;
  145622. private _autoStart;
  145623. private _running;
  145624. private _diameter;
  145625. private _length;
  145626. private _sectionPolygonPointsCount;
  145627. private _sectionVectors;
  145628. private _sectionNormalVectors;
  145629. private _beforeRenderObserver;
  145630. /**
  145631. * @constructor
  145632. * @param name The value used by scene.getMeshByName() to do a lookup.
  145633. * @param generator The mesh or transform node to generate a trail.
  145634. * @param scene The scene to add this mesh to.
  145635. * @param diameter Diameter of trailing mesh. Default is 1.
  145636. * @param length Length of trailing mesh. Default is 60.
  145637. * @param autoStart Automatically start trailing mesh. Default true.
  145638. */
  145639. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  145640. /**
  145641. * "TrailMesh"
  145642. * @returns "TrailMesh"
  145643. */
  145644. getClassName(): string;
  145645. private _createMesh;
  145646. /**
  145647. * Start trailing mesh.
  145648. */
  145649. start(): void;
  145650. /**
  145651. * Stop trailing mesh.
  145652. */
  145653. stop(): void;
  145654. /**
  145655. * Update trailing mesh geometry.
  145656. */
  145657. update(): void;
  145658. /**
  145659. * Returns a new TrailMesh object.
  145660. * @param name is a string, the name given to the new mesh
  145661. * @param newGenerator use new generator object for cloned trail mesh
  145662. * @returns a new mesh
  145663. */
  145664. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  145665. /**
  145666. * Serializes this trail mesh
  145667. * @param serializationObject object to write serialization to
  145668. */
  145669. serialize(serializationObject: any): void;
  145670. /**
  145671. * Parses a serialized trail mesh
  145672. * @param parsedMesh the serialized mesh
  145673. * @param scene the scene to create the trail mesh in
  145674. * @returns the created trail mesh
  145675. */
  145676. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  145677. }
  145678. }
  145679. declare module BABYLON {
  145680. /**
  145681. * Class containing static functions to help procedurally build meshes
  145682. */
  145683. export class TiledBoxBuilder {
  145684. /**
  145685. * Creates a box mesh
  145686. * 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)
  145687. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145689. * * 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
  145690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145691. * @param name defines the name of the mesh
  145692. * @param options defines the options used to create the mesh
  145693. * @param scene defines the hosting scene
  145694. * @returns the box mesh
  145695. */
  145696. static CreateTiledBox(name: string, options: {
  145697. pattern?: number;
  145698. width?: number;
  145699. height?: number;
  145700. depth?: number;
  145701. tileSize?: number;
  145702. tileWidth?: number;
  145703. tileHeight?: number;
  145704. alignHorizontal?: number;
  145705. alignVertical?: number;
  145706. faceUV?: Vector4[];
  145707. faceColors?: Color4[];
  145708. sideOrientation?: number;
  145709. updatable?: boolean;
  145710. }, scene?: Nullable<Scene>): Mesh;
  145711. }
  145712. }
  145713. declare module BABYLON {
  145714. /**
  145715. * Class containing static functions to help procedurally build meshes
  145716. */
  145717. export class TorusKnotBuilder {
  145718. /**
  145719. * Creates a torus knot mesh
  145720. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  145721. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  145722. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  145723. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  145724. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145725. * * 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
  145726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  145727. * @param name defines the name of the mesh
  145728. * @param options defines the options used to create the mesh
  145729. * @param scene defines the hosting scene
  145730. * @returns the torus knot mesh
  145731. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  145732. */
  145733. static CreateTorusKnot(name: string, options: {
  145734. radius?: number;
  145735. tube?: number;
  145736. radialSegments?: number;
  145737. tubularSegments?: number;
  145738. p?: number;
  145739. q?: number;
  145740. updatable?: boolean;
  145741. sideOrientation?: number;
  145742. frontUVs?: Vector4;
  145743. backUVs?: Vector4;
  145744. }, scene: any): Mesh;
  145745. }
  145746. }
  145747. declare module BABYLON {
  145748. /**
  145749. * Polygon
  145750. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  145751. */
  145752. export class Polygon {
  145753. /**
  145754. * Creates a rectangle
  145755. * @param xmin bottom X coord
  145756. * @param ymin bottom Y coord
  145757. * @param xmax top X coord
  145758. * @param ymax top Y coord
  145759. * @returns points that make the resulting rectation
  145760. */
  145761. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  145762. /**
  145763. * Creates a circle
  145764. * @param radius radius of circle
  145765. * @param cx scale in x
  145766. * @param cy scale in y
  145767. * @param numberOfSides number of sides that make up the circle
  145768. * @returns points that make the resulting circle
  145769. */
  145770. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  145771. /**
  145772. * Creates a polygon from input string
  145773. * @param input Input polygon data
  145774. * @returns the parsed points
  145775. */
  145776. static Parse(input: string): Vector2[];
  145777. /**
  145778. * Starts building a polygon from x and y coordinates
  145779. * @param x x coordinate
  145780. * @param y y coordinate
  145781. * @returns the started path2
  145782. */
  145783. static StartingAt(x: number, y: number): Path2;
  145784. }
  145785. /**
  145786. * Builds a polygon
  145787. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  145788. */
  145789. export class PolygonMeshBuilder {
  145790. private _points;
  145791. private _outlinepoints;
  145792. private _holes;
  145793. private _name;
  145794. private _scene;
  145795. private _epoints;
  145796. private _eholes;
  145797. private _addToepoint;
  145798. /**
  145799. * Babylon reference to the earcut plugin.
  145800. */
  145801. bjsEarcut: any;
  145802. /**
  145803. * Creates a PolygonMeshBuilder
  145804. * @param name name of the builder
  145805. * @param contours Path of the polygon
  145806. * @param scene scene to add to when creating the mesh
  145807. * @param earcutInjection can be used to inject your own earcut reference
  145808. */
  145809. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  145810. /**
  145811. * Adds a whole within the polygon
  145812. * @param hole Array of points defining the hole
  145813. * @returns this
  145814. */
  145815. addHole(hole: Vector2[]): PolygonMeshBuilder;
  145816. /**
  145817. * Creates the polygon
  145818. * @param updatable If the mesh should be updatable
  145819. * @param depth The depth of the mesh created
  145820. * @returns the created mesh
  145821. */
  145822. build(updatable?: boolean, depth?: number): Mesh;
  145823. /**
  145824. * Creates the polygon
  145825. * @param depth The depth of the mesh created
  145826. * @returns the created VertexData
  145827. */
  145828. buildVertexData(depth?: number): VertexData;
  145829. /**
  145830. * Adds a side to the polygon
  145831. * @param positions points that make the polygon
  145832. * @param normals normals of the polygon
  145833. * @param uvs uvs of the polygon
  145834. * @param indices indices of the polygon
  145835. * @param bounds bounds of the polygon
  145836. * @param points points of the polygon
  145837. * @param depth depth of the polygon
  145838. * @param flip flip of the polygon
  145839. */
  145840. private addSide;
  145841. }
  145842. }
  145843. declare module BABYLON {
  145844. /**
  145845. * Class containing static functions to help procedurally build meshes
  145846. */
  145847. export class PolygonBuilder {
  145848. /**
  145849. * Creates a polygon mesh
  145850. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  145851. * * 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
  145852. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145853. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145854. * * 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)
  145855. * * Remember you can only change the shape positions, not their number when updating a polygon
  145856. * @param name defines the name of the mesh
  145857. * @param options defines the options used to create the mesh
  145858. * @param scene defines the hosting scene
  145859. * @param earcutInjection can be used to inject your own earcut reference
  145860. * @returns the polygon mesh
  145861. */
  145862. static CreatePolygon(name: string, options: {
  145863. shape: Vector3[];
  145864. holes?: Vector3[][];
  145865. depth?: number;
  145866. faceUV?: Vector4[];
  145867. faceColors?: Color4[];
  145868. updatable?: boolean;
  145869. sideOrientation?: number;
  145870. frontUVs?: Vector4;
  145871. backUVs?: Vector4;
  145872. wrap?: boolean;
  145873. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145874. /**
  145875. * Creates an extruded polygon mesh, with depth in the Y direction.
  145876. * * 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)
  145877. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  145878. * @param name defines the name of the mesh
  145879. * @param options defines the options used to create the mesh
  145880. * @param scene defines the hosting scene
  145881. * @param earcutInjection can be used to inject your own earcut reference
  145882. * @returns the polygon mesh
  145883. */
  145884. static ExtrudePolygon(name: string, options: {
  145885. shape: Vector3[];
  145886. holes?: Vector3[][];
  145887. depth?: number;
  145888. faceUV?: Vector4[];
  145889. faceColors?: Color4[];
  145890. updatable?: boolean;
  145891. sideOrientation?: number;
  145892. frontUVs?: Vector4;
  145893. backUVs?: Vector4;
  145894. wrap?: boolean;
  145895. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  145896. }
  145897. }
  145898. declare module BABYLON {
  145899. /**
  145900. * Class containing static functions to help procedurally build meshes
  145901. */
  145902. export class LatheBuilder {
  145903. /**
  145904. * Creates lathe mesh.
  145905. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  145906. * * 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
  145907. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  145908. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  145909. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  145910. * * 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
  145911. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  145912. * * 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
  145913. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145914. * * 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
  145915. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  145916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  145917. * @param name defines the name of the mesh
  145918. * @param options defines the options used to create the mesh
  145919. * @param scene defines the hosting scene
  145920. * @returns the lathe mesh
  145921. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  145922. */
  145923. static CreateLathe(name: string, options: {
  145924. shape: Vector3[];
  145925. radius?: number;
  145926. tessellation?: number;
  145927. clip?: number;
  145928. arc?: number;
  145929. closed?: boolean;
  145930. updatable?: boolean;
  145931. sideOrientation?: number;
  145932. frontUVs?: Vector4;
  145933. backUVs?: Vector4;
  145934. cap?: number;
  145935. invertUV?: boolean;
  145936. }, scene?: Nullable<Scene>): Mesh;
  145937. }
  145938. }
  145939. declare module BABYLON {
  145940. /**
  145941. * Class containing static functions to help procedurally build meshes
  145942. */
  145943. export class TiledPlaneBuilder {
  145944. /**
  145945. * Creates a tiled plane mesh
  145946. * * The parameter `pattern` will, depending on value, do nothing or
  145947. * * * flip (reflect about central vertical) alternate tiles across and up
  145948. * * * flip every tile on alternate rows
  145949. * * * rotate (180 degs) alternate tiles across and up
  145950. * * * rotate every tile on alternate rows
  145951. * * * flip and rotate alternate tiles across and up
  145952. * * * flip and rotate every tile on alternate rows
  145953. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  145954. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  145955. * * 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
  145956. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  145957. * * 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)
  145958. * * 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)
  145959. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  145960. * @param name defines the name of the mesh
  145961. * @param options defines the options used to create the mesh
  145962. * @param scene defines the hosting scene
  145963. * @returns the box mesh
  145964. */
  145965. static CreateTiledPlane(name: string, options: {
  145966. pattern?: number;
  145967. tileSize?: number;
  145968. tileWidth?: number;
  145969. tileHeight?: number;
  145970. size?: number;
  145971. width?: number;
  145972. height?: number;
  145973. alignHorizontal?: number;
  145974. alignVertical?: number;
  145975. sideOrientation?: number;
  145976. frontUVs?: Vector4;
  145977. backUVs?: Vector4;
  145978. updatable?: boolean;
  145979. }, scene?: Nullable<Scene>): Mesh;
  145980. }
  145981. }
  145982. declare module BABYLON {
  145983. /**
  145984. * Class containing static functions to help procedurally build meshes
  145985. */
  145986. export class TubeBuilder {
  145987. /**
  145988. * Creates a tube mesh.
  145989. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  145990. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  145991. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  145992. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  145993. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  145994. * * 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)
  145995. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  145996. * * 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
  145997. * * 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
  145998. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  145999. * * 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
  146000. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146002. * @param name defines the name of the mesh
  146003. * @param options defines the options used to create the mesh
  146004. * @param scene defines the hosting scene
  146005. * @returns the tube mesh
  146006. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146007. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146008. */
  146009. static CreateTube(name: string, options: {
  146010. path: Vector3[];
  146011. radius?: number;
  146012. tessellation?: number;
  146013. radiusFunction?: {
  146014. (i: number, distance: number): number;
  146015. };
  146016. cap?: number;
  146017. arc?: number;
  146018. updatable?: boolean;
  146019. sideOrientation?: number;
  146020. frontUVs?: Vector4;
  146021. backUVs?: Vector4;
  146022. instance?: Mesh;
  146023. invertUV?: boolean;
  146024. }, scene?: Nullable<Scene>): Mesh;
  146025. }
  146026. }
  146027. declare module BABYLON {
  146028. /**
  146029. * Class containing static functions to help procedurally build meshes
  146030. */
  146031. export class IcoSphereBuilder {
  146032. /**
  146033. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146034. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146035. * * 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`)
  146036. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146037. * * 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
  146038. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146039. * * 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
  146040. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146041. * @param name defines the name of the mesh
  146042. * @param options defines the options used to create the mesh
  146043. * @param scene defines the hosting scene
  146044. * @returns the icosahedron mesh
  146045. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146046. */
  146047. static CreateIcoSphere(name: string, options: {
  146048. radius?: number;
  146049. radiusX?: number;
  146050. radiusY?: number;
  146051. radiusZ?: number;
  146052. flat?: boolean;
  146053. subdivisions?: number;
  146054. sideOrientation?: number;
  146055. frontUVs?: Vector4;
  146056. backUVs?: Vector4;
  146057. updatable?: boolean;
  146058. }, scene?: Nullable<Scene>): Mesh;
  146059. }
  146060. }
  146061. declare module BABYLON {
  146062. /**
  146063. * Class containing static functions to help procedurally build meshes
  146064. */
  146065. export class DecalBuilder {
  146066. /**
  146067. * Creates a decal mesh.
  146068. * 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
  146069. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146070. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146071. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146072. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146073. * @param name defines the name of the mesh
  146074. * @param sourceMesh defines the mesh where the decal must be applied
  146075. * @param options defines the options used to create the mesh
  146076. * @param scene defines the hosting scene
  146077. * @returns the decal mesh
  146078. * @see https://doc.babylonjs.com/how_to/decals
  146079. */
  146080. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146081. position?: Vector3;
  146082. normal?: Vector3;
  146083. size?: Vector3;
  146084. angle?: number;
  146085. }): Mesh;
  146086. }
  146087. }
  146088. declare module BABYLON {
  146089. /**
  146090. * Class containing static functions to help procedurally build meshes
  146091. */
  146092. export class MeshBuilder {
  146093. /**
  146094. * Creates a box mesh
  146095. * * The parameter `size` sets the size (float) of each box side (default 1)
  146096. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146097. * * 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)
  146098. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146100. * * 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
  146101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146103. * @param name defines the name of the mesh
  146104. * @param options defines the options used to create the mesh
  146105. * @param scene defines the hosting scene
  146106. * @returns the box mesh
  146107. */
  146108. static CreateBox(name: string, options: {
  146109. size?: number;
  146110. width?: number;
  146111. height?: number;
  146112. depth?: number;
  146113. faceUV?: Vector4[];
  146114. faceColors?: Color4[];
  146115. sideOrientation?: number;
  146116. frontUVs?: Vector4;
  146117. backUVs?: Vector4;
  146118. wrap?: boolean;
  146119. topBaseAt?: number;
  146120. bottomBaseAt?: number;
  146121. updatable?: boolean;
  146122. }, scene?: Nullable<Scene>): Mesh;
  146123. /**
  146124. * Creates a tiled box mesh
  146125. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146127. * @param name defines the name of the mesh
  146128. * @param options defines the options used to create the mesh
  146129. * @param scene defines the hosting scene
  146130. * @returns the tiled box mesh
  146131. */
  146132. static CreateTiledBox(name: string, options: {
  146133. pattern?: number;
  146134. size?: number;
  146135. width?: number;
  146136. height?: number;
  146137. depth: number;
  146138. tileSize?: number;
  146139. tileWidth?: number;
  146140. tileHeight?: number;
  146141. faceUV?: Vector4[];
  146142. faceColors?: Color4[];
  146143. alignHorizontal?: number;
  146144. alignVertical?: number;
  146145. sideOrientation?: number;
  146146. updatable?: boolean;
  146147. }, scene?: Nullable<Scene>): Mesh;
  146148. /**
  146149. * Creates a sphere mesh
  146150. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146151. * * 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`)
  146152. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146153. * * 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
  146154. * * 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)
  146155. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146156. * * 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
  146157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146158. * @param name defines the name of the mesh
  146159. * @param options defines the options used to create the mesh
  146160. * @param scene defines the hosting scene
  146161. * @returns the sphere mesh
  146162. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146163. */
  146164. static CreateSphere(name: string, options: {
  146165. segments?: number;
  146166. diameter?: number;
  146167. diameterX?: number;
  146168. diameterY?: number;
  146169. diameterZ?: number;
  146170. arc?: number;
  146171. slice?: number;
  146172. sideOrientation?: number;
  146173. frontUVs?: Vector4;
  146174. backUVs?: Vector4;
  146175. updatable?: boolean;
  146176. }, scene?: Nullable<Scene>): Mesh;
  146177. /**
  146178. * Creates a plane polygonal mesh. By default, this is a disc
  146179. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146180. * * 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
  146181. * * 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
  146182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146183. * * 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
  146184. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146185. * @param name defines the name of the mesh
  146186. * @param options defines the options used to create the mesh
  146187. * @param scene defines the hosting scene
  146188. * @returns the plane polygonal mesh
  146189. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146190. */
  146191. static CreateDisc(name: string, options: {
  146192. radius?: number;
  146193. tessellation?: number;
  146194. arc?: number;
  146195. updatable?: boolean;
  146196. sideOrientation?: number;
  146197. frontUVs?: Vector4;
  146198. backUVs?: Vector4;
  146199. }, scene?: Nullable<Scene>): Mesh;
  146200. /**
  146201. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146202. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146203. * * 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`)
  146204. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146205. * * 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
  146206. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146207. * * 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
  146208. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146209. * @param name defines the name of the mesh
  146210. * @param options defines the options used to create the mesh
  146211. * @param scene defines the hosting scene
  146212. * @returns the icosahedron mesh
  146213. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146214. */
  146215. static CreateIcoSphere(name: string, options: {
  146216. radius?: number;
  146217. radiusX?: number;
  146218. radiusY?: number;
  146219. radiusZ?: number;
  146220. flat?: boolean;
  146221. subdivisions?: number;
  146222. sideOrientation?: number;
  146223. frontUVs?: Vector4;
  146224. backUVs?: Vector4;
  146225. updatable?: boolean;
  146226. }, scene?: Nullable<Scene>): Mesh;
  146227. /**
  146228. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146229. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146230. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146231. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146232. * * 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
  146233. * * 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
  146234. * * 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
  146235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146236. * * 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
  146237. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146238. * * 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
  146239. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146240. * * 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
  146241. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146242. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146243. * @param name defines the name of the mesh
  146244. * @param options defines the options used to create the mesh
  146245. * @param scene defines the hosting scene
  146246. * @returns the ribbon mesh
  146247. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146248. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146249. */
  146250. static CreateRibbon(name: string, options: {
  146251. pathArray: Vector3[][];
  146252. closeArray?: boolean;
  146253. closePath?: boolean;
  146254. offset?: number;
  146255. updatable?: boolean;
  146256. sideOrientation?: number;
  146257. frontUVs?: Vector4;
  146258. backUVs?: Vector4;
  146259. instance?: Mesh;
  146260. invertUV?: boolean;
  146261. uvs?: Vector2[];
  146262. colors?: Color4[];
  146263. }, scene?: Nullable<Scene>): Mesh;
  146264. /**
  146265. * Creates a cylinder or a cone mesh
  146266. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146267. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146268. * * 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.
  146269. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146270. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146271. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146272. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146273. * * 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).
  146274. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146275. * * 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).
  146276. * * 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
  146277. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146278. * * 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
  146279. * * 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.
  146280. * * If `enclose` is false, a ring surface is one element.
  146281. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146282. * * 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
  146283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146284. * * 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
  146285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146286. * @param name defines the name of the mesh
  146287. * @param options defines the options used to create the mesh
  146288. * @param scene defines the hosting scene
  146289. * @returns the cylinder mesh
  146290. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146291. */
  146292. static CreateCylinder(name: string, options: {
  146293. height?: number;
  146294. diameterTop?: number;
  146295. diameterBottom?: number;
  146296. diameter?: number;
  146297. tessellation?: number;
  146298. subdivisions?: number;
  146299. arc?: number;
  146300. faceColors?: Color4[];
  146301. faceUV?: Vector4[];
  146302. updatable?: boolean;
  146303. hasRings?: boolean;
  146304. enclose?: boolean;
  146305. cap?: number;
  146306. sideOrientation?: number;
  146307. frontUVs?: Vector4;
  146308. backUVs?: Vector4;
  146309. }, scene?: Nullable<Scene>): Mesh;
  146310. /**
  146311. * Creates a torus mesh
  146312. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146313. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146314. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146315. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146316. * * 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
  146317. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146318. * @param name defines the name of the mesh
  146319. * @param options defines the options used to create the mesh
  146320. * @param scene defines the hosting scene
  146321. * @returns the torus mesh
  146322. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146323. */
  146324. static CreateTorus(name: string, options: {
  146325. diameter?: number;
  146326. thickness?: number;
  146327. tessellation?: number;
  146328. updatable?: boolean;
  146329. sideOrientation?: number;
  146330. frontUVs?: Vector4;
  146331. backUVs?: Vector4;
  146332. }, scene?: Nullable<Scene>): Mesh;
  146333. /**
  146334. * Creates a torus knot mesh
  146335. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146336. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146337. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146338. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146340. * * 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
  146341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146342. * @param name defines the name of the mesh
  146343. * @param options defines the options used to create the mesh
  146344. * @param scene defines the hosting scene
  146345. * @returns the torus knot mesh
  146346. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146347. */
  146348. static CreateTorusKnot(name: string, options: {
  146349. radius?: number;
  146350. tube?: number;
  146351. radialSegments?: number;
  146352. tubularSegments?: number;
  146353. p?: number;
  146354. q?: number;
  146355. updatable?: boolean;
  146356. sideOrientation?: number;
  146357. frontUVs?: Vector4;
  146358. backUVs?: Vector4;
  146359. }, scene?: Nullable<Scene>): Mesh;
  146360. /**
  146361. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146362. * * 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
  146363. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146364. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146365. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146366. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146367. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146368. * * 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
  146369. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146371. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146372. * @param name defines the name of the new line system
  146373. * @param options defines the options used to create the line system
  146374. * @param scene defines the hosting scene
  146375. * @returns a new line system mesh
  146376. */
  146377. static CreateLineSystem(name: string, options: {
  146378. lines: Vector3[][];
  146379. updatable?: boolean;
  146380. instance?: Nullable<LinesMesh>;
  146381. colors?: Nullable<Color4[][]>;
  146382. useVertexAlpha?: boolean;
  146383. }, scene: Nullable<Scene>): LinesMesh;
  146384. /**
  146385. * Creates a line mesh
  146386. * 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
  146387. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146388. * * The parameter `points` is an array successive Vector3
  146389. * * 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
  146390. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146391. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146392. * * When updating an instance, remember that only point positions can change, not the number of points
  146393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146394. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146395. * @param name defines the name of the new line system
  146396. * @param options defines the options used to create the line system
  146397. * @param scene defines the hosting scene
  146398. * @returns a new line mesh
  146399. */
  146400. static CreateLines(name: string, options: {
  146401. points: Vector3[];
  146402. updatable?: boolean;
  146403. instance?: Nullable<LinesMesh>;
  146404. colors?: Color4[];
  146405. useVertexAlpha?: boolean;
  146406. }, scene?: Nullable<Scene>): LinesMesh;
  146407. /**
  146408. * Creates a dashed line mesh
  146409. * * 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
  146410. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146411. * * The parameter `points` is an array successive Vector3
  146412. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146413. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146414. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146415. * * 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
  146416. * * When updating an instance, remember that only point positions can change, not the number of points
  146417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146418. * @param name defines the name of the mesh
  146419. * @param options defines the options used to create the mesh
  146420. * @param scene defines the hosting scene
  146421. * @returns the dashed line mesh
  146422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146423. */
  146424. static CreateDashedLines(name: string, options: {
  146425. points: Vector3[];
  146426. dashSize?: number;
  146427. gapSize?: number;
  146428. dashNb?: number;
  146429. updatable?: boolean;
  146430. instance?: LinesMesh;
  146431. }, scene?: Nullable<Scene>): LinesMesh;
  146432. /**
  146433. * 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.
  146434. * * 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.
  146435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146436. * * 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.
  146437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146438. * * 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
  146439. * * 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
  146440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146442. * * 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
  146443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146445. * @param name defines the name of the mesh
  146446. * @param options defines the options used to create the mesh
  146447. * @param scene defines the hosting scene
  146448. * @returns the extruded shape mesh
  146449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146451. */
  146452. static ExtrudeShape(name: string, options: {
  146453. shape: Vector3[];
  146454. path: Vector3[];
  146455. scale?: number;
  146456. rotation?: number;
  146457. cap?: number;
  146458. updatable?: boolean;
  146459. sideOrientation?: number;
  146460. frontUVs?: Vector4;
  146461. backUVs?: Vector4;
  146462. instance?: Mesh;
  146463. invertUV?: boolean;
  146464. }, scene?: Nullable<Scene>): Mesh;
  146465. /**
  146466. * Creates an custom extruded shape mesh.
  146467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146468. * * 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.
  146469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146470. * * 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
  146471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146472. * * 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
  146473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146476. * * 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
  146477. * * 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
  146478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146480. * * 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
  146481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146483. * @param name defines the name of the mesh
  146484. * @param options defines the options used to create the mesh
  146485. * @param scene defines the hosting scene
  146486. * @returns the custom extruded shape mesh
  146487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146490. */
  146491. static ExtrudeShapeCustom(name: string, options: {
  146492. shape: Vector3[];
  146493. path: Vector3[];
  146494. scaleFunction?: any;
  146495. rotationFunction?: any;
  146496. ribbonCloseArray?: boolean;
  146497. ribbonClosePath?: boolean;
  146498. cap?: number;
  146499. updatable?: boolean;
  146500. sideOrientation?: number;
  146501. frontUVs?: Vector4;
  146502. backUVs?: Vector4;
  146503. instance?: Mesh;
  146504. invertUV?: boolean;
  146505. }, scene?: Nullable<Scene>): Mesh;
  146506. /**
  146507. * Creates lathe mesh.
  146508. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146509. * * 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
  146510. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146511. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146512. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146513. * * 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
  146514. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146515. * * 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
  146516. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146517. * * 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
  146518. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146520. * @param name defines the name of the mesh
  146521. * @param options defines the options used to create the mesh
  146522. * @param scene defines the hosting scene
  146523. * @returns the lathe mesh
  146524. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146525. */
  146526. static CreateLathe(name: string, options: {
  146527. shape: Vector3[];
  146528. radius?: number;
  146529. tessellation?: number;
  146530. clip?: number;
  146531. arc?: number;
  146532. closed?: boolean;
  146533. updatable?: boolean;
  146534. sideOrientation?: number;
  146535. frontUVs?: Vector4;
  146536. backUVs?: Vector4;
  146537. cap?: number;
  146538. invertUV?: boolean;
  146539. }, scene?: Nullable<Scene>): Mesh;
  146540. /**
  146541. * Creates a tiled plane mesh
  146542. * * You can set a limited pattern arrangement with the tiles
  146543. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146544. * * 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
  146545. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146546. * @param name defines the name of the mesh
  146547. * @param options defines the options used to create the mesh
  146548. * @param scene defines the hosting scene
  146549. * @returns the plane mesh
  146550. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146551. */
  146552. static CreateTiledPlane(name: string, options: {
  146553. pattern?: number;
  146554. tileSize?: number;
  146555. tileWidth?: number;
  146556. tileHeight?: number;
  146557. size?: number;
  146558. width?: number;
  146559. height?: number;
  146560. alignHorizontal?: number;
  146561. alignVertical?: number;
  146562. sideOrientation?: number;
  146563. frontUVs?: Vector4;
  146564. backUVs?: Vector4;
  146565. updatable?: boolean;
  146566. }, scene?: Nullable<Scene>): Mesh;
  146567. /**
  146568. * Creates a plane mesh
  146569. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146570. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146571. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146572. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146573. * * 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
  146574. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146575. * @param name defines the name of the mesh
  146576. * @param options defines the options used to create the mesh
  146577. * @param scene defines the hosting scene
  146578. * @returns the plane mesh
  146579. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146580. */
  146581. static CreatePlane(name: string, options: {
  146582. size?: number;
  146583. width?: number;
  146584. height?: number;
  146585. sideOrientation?: number;
  146586. frontUVs?: Vector4;
  146587. backUVs?: Vector4;
  146588. updatable?: boolean;
  146589. sourcePlane?: Plane;
  146590. }, scene?: Nullable<Scene>): Mesh;
  146591. /**
  146592. * Creates a ground mesh
  146593. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  146594. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  146595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146596. * @param name defines the name of the mesh
  146597. * @param options defines the options used to create the mesh
  146598. * @param scene defines the hosting scene
  146599. * @returns the ground mesh
  146600. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  146601. */
  146602. static CreateGround(name: string, options: {
  146603. width?: number;
  146604. height?: number;
  146605. subdivisions?: number;
  146606. subdivisionsX?: number;
  146607. subdivisionsY?: number;
  146608. updatable?: boolean;
  146609. }, scene?: Nullable<Scene>): Mesh;
  146610. /**
  146611. * Creates a tiled ground mesh
  146612. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  146613. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  146614. * * 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
  146615. * * 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
  146616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146617. * @param name defines the name of the mesh
  146618. * @param options defines the options used to create the mesh
  146619. * @param scene defines the hosting scene
  146620. * @returns the tiled ground mesh
  146621. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  146622. */
  146623. static CreateTiledGround(name: string, options: {
  146624. xmin: number;
  146625. zmin: number;
  146626. xmax: number;
  146627. zmax: number;
  146628. subdivisions?: {
  146629. w: number;
  146630. h: number;
  146631. };
  146632. precision?: {
  146633. w: number;
  146634. h: number;
  146635. };
  146636. updatable?: boolean;
  146637. }, scene?: Nullable<Scene>): Mesh;
  146638. /**
  146639. * Creates a ground mesh from a height map
  146640. * * The parameter `url` sets the URL of the height map image resource.
  146641. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  146642. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  146643. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  146644. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  146645. * * 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.
  146646. * * 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).
  146647. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  146648. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146649. * @param name defines the name of the mesh
  146650. * @param url defines the url to the height map
  146651. * @param options defines the options used to create the mesh
  146652. * @param scene defines the hosting scene
  146653. * @returns the ground mesh
  146654. * @see https://doc.babylonjs.com/babylon101/height_map
  146655. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  146656. */
  146657. static CreateGroundFromHeightMap(name: string, url: string, options: {
  146658. width?: number;
  146659. height?: number;
  146660. subdivisions?: number;
  146661. minHeight?: number;
  146662. maxHeight?: number;
  146663. colorFilter?: Color3;
  146664. alphaFilter?: number;
  146665. updatable?: boolean;
  146666. onReady?: (mesh: GroundMesh) => void;
  146667. }, scene?: Nullable<Scene>): GroundMesh;
  146668. /**
  146669. * Creates a polygon mesh
  146670. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146671. * * 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
  146672. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146673. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146674. * * 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)
  146675. * * Remember you can only change the shape positions, not their number when updating a polygon
  146676. * @param name defines the name of the mesh
  146677. * @param options defines the options used to create the mesh
  146678. * @param scene defines the hosting scene
  146679. * @param earcutInjection can be used to inject your own earcut reference
  146680. * @returns the polygon mesh
  146681. */
  146682. static CreatePolygon(name: string, options: {
  146683. shape: Vector3[];
  146684. holes?: Vector3[][];
  146685. depth?: number;
  146686. faceUV?: Vector4[];
  146687. faceColors?: Color4[];
  146688. updatable?: boolean;
  146689. sideOrientation?: number;
  146690. frontUVs?: Vector4;
  146691. backUVs?: Vector4;
  146692. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146693. /**
  146694. * Creates an extruded polygon mesh, with depth in the Y direction.
  146695. * * 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)
  146696. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146697. * @param name defines the name of the mesh
  146698. * @param options defines the options used to create the mesh
  146699. * @param scene defines the hosting scene
  146700. * @param earcutInjection can be used to inject your own earcut reference
  146701. * @returns the polygon mesh
  146702. */
  146703. static ExtrudePolygon(name: string, options: {
  146704. shape: Vector3[];
  146705. holes?: Vector3[][];
  146706. depth?: number;
  146707. faceUV?: Vector4[];
  146708. faceColors?: Color4[];
  146709. updatable?: boolean;
  146710. sideOrientation?: number;
  146711. frontUVs?: Vector4;
  146712. backUVs?: Vector4;
  146713. wrap?: boolean;
  146714. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146715. /**
  146716. * Creates a tube mesh.
  146717. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146718. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146719. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146720. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146721. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146722. * * 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)
  146723. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146724. * * 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
  146725. * * 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
  146726. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146727. * * 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
  146728. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146729. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146730. * @param name defines the name of the mesh
  146731. * @param options defines the options used to create the mesh
  146732. * @param scene defines the hosting scene
  146733. * @returns the tube mesh
  146734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146735. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146736. */
  146737. static CreateTube(name: string, options: {
  146738. path: Vector3[];
  146739. radius?: number;
  146740. tessellation?: number;
  146741. radiusFunction?: {
  146742. (i: number, distance: number): number;
  146743. };
  146744. cap?: number;
  146745. arc?: number;
  146746. updatable?: boolean;
  146747. sideOrientation?: number;
  146748. frontUVs?: Vector4;
  146749. backUVs?: Vector4;
  146750. instance?: Mesh;
  146751. invertUV?: boolean;
  146752. }, scene?: Nullable<Scene>): Mesh;
  146753. /**
  146754. * Creates a polyhedron mesh
  146755. * * 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
  146756. * * The parameter `size` (positive float, default 1) sets the polygon size
  146757. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  146758. * * 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`
  146759. * * 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
  146760. * * 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)`)
  146761. * * 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
  146762. * * 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
  146763. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146764. * * 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
  146765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146766. * @param name defines the name of the mesh
  146767. * @param options defines the options used to create the mesh
  146768. * @param scene defines the hosting scene
  146769. * @returns the polyhedron mesh
  146770. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  146771. */
  146772. static CreatePolyhedron(name: string, options: {
  146773. type?: number;
  146774. size?: number;
  146775. sizeX?: number;
  146776. sizeY?: number;
  146777. sizeZ?: number;
  146778. custom?: any;
  146779. faceUV?: Vector4[];
  146780. faceColors?: Color4[];
  146781. flat?: boolean;
  146782. updatable?: boolean;
  146783. sideOrientation?: number;
  146784. frontUVs?: Vector4;
  146785. backUVs?: Vector4;
  146786. }, scene?: Nullable<Scene>): Mesh;
  146787. /**
  146788. * Creates a decal mesh.
  146789. * 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
  146790. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146791. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146792. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146793. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146794. * @param name defines the name of the mesh
  146795. * @param sourceMesh defines the mesh where the decal must be applied
  146796. * @param options defines the options used to create the mesh
  146797. * @param scene defines the hosting scene
  146798. * @returns the decal mesh
  146799. * @see https://doc.babylonjs.com/how_to/decals
  146800. */
  146801. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146802. position?: Vector3;
  146803. normal?: Vector3;
  146804. size?: Vector3;
  146805. angle?: number;
  146806. }): Mesh;
  146807. /**
  146808. * Creates a Capsule Mesh
  146809. * @param name defines the name of the mesh.
  146810. * @param options the constructors options used to shape the mesh.
  146811. * @param scene defines the scene the mesh is scoped to.
  146812. * @returns the capsule mesh
  146813. * @see https://doc.babylonjs.com/how_to/capsule_shape
  146814. */
  146815. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  146816. }
  146817. }
  146818. declare module BABYLON {
  146819. /**
  146820. * A simplifier interface for future simplification implementations
  146821. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146822. */
  146823. export interface ISimplifier {
  146824. /**
  146825. * Simplification of a given mesh according to the given settings.
  146826. * Since this requires computation, it is assumed that the function runs async.
  146827. * @param settings The settings of the simplification, including quality and distance
  146828. * @param successCallback A callback that will be called after the mesh was simplified.
  146829. * @param errorCallback in case of an error, this callback will be called. optional.
  146830. */
  146831. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  146832. }
  146833. /**
  146834. * Expected simplification settings.
  146835. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  146836. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146837. */
  146838. export interface ISimplificationSettings {
  146839. /**
  146840. * Gets or sets the expected quality
  146841. */
  146842. quality: number;
  146843. /**
  146844. * Gets or sets the distance when this optimized version should be used
  146845. */
  146846. distance: number;
  146847. /**
  146848. * Gets an already optimized mesh
  146849. */
  146850. optimizeMesh?: boolean;
  146851. }
  146852. /**
  146853. * Class used to specify simplification options
  146854. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146855. */
  146856. export class SimplificationSettings implements ISimplificationSettings {
  146857. /** expected quality */
  146858. quality: number;
  146859. /** distance when this optimized version should be used */
  146860. distance: number;
  146861. /** already optimized mesh */
  146862. optimizeMesh?: boolean | undefined;
  146863. /**
  146864. * Creates a SimplificationSettings
  146865. * @param quality expected quality
  146866. * @param distance distance when this optimized version should be used
  146867. * @param optimizeMesh already optimized mesh
  146868. */
  146869. constructor(
  146870. /** expected quality */
  146871. quality: number,
  146872. /** distance when this optimized version should be used */
  146873. distance: number,
  146874. /** already optimized mesh */
  146875. optimizeMesh?: boolean | undefined);
  146876. }
  146877. /**
  146878. * Interface used to define a simplification task
  146879. */
  146880. export interface ISimplificationTask {
  146881. /**
  146882. * Array of settings
  146883. */
  146884. settings: Array<ISimplificationSettings>;
  146885. /**
  146886. * Simplification type
  146887. */
  146888. simplificationType: SimplificationType;
  146889. /**
  146890. * Mesh to simplify
  146891. */
  146892. mesh: Mesh;
  146893. /**
  146894. * Callback called on success
  146895. */
  146896. successCallback?: () => void;
  146897. /**
  146898. * Defines if parallel processing can be used
  146899. */
  146900. parallelProcessing: boolean;
  146901. }
  146902. /**
  146903. * Queue used to order the simplification tasks
  146904. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146905. */
  146906. export class SimplificationQueue {
  146907. private _simplificationArray;
  146908. /**
  146909. * Gets a boolean indicating that the process is still running
  146910. */
  146911. running: boolean;
  146912. /**
  146913. * Creates a new queue
  146914. */
  146915. constructor();
  146916. /**
  146917. * Adds a new simplification task
  146918. * @param task defines a task to add
  146919. */
  146920. addTask(task: ISimplificationTask): void;
  146921. /**
  146922. * Execute next task
  146923. */
  146924. executeNext(): void;
  146925. /**
  146926. * Execute a simplification task
  146927. * @param task defines the task to run
  146928. */
  146929. runSimplification(task: ISimplificationTask): void;
  146930. private getSimplifier;
  146931. }
  146932. /**
  146933. * The implemented types of simplification
  146934. * At the moment only Quadratic Error Decimation is implemented
  146935. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146936. */
  146937. export enum SimplificationType {
  146938. /** Quadratic error decimation */
  146939. QUADRATIC = 0
  146940. }
  146941. /**
  146942. * An implementation of the Quadratic Error simplification algorithm.
  146943. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  146944. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  146945. * @author RaananW
  146946. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146947. */
  146948. export class QuadraticErrorSimplification implements ISimplifier {
  146949. private _mesh;
  146950. private triangles;
  146951. private vertices;
  146952. private references;
  146953. private _reconstructedMesh;
  146954. /** Gets or sets the number pf sync interations */
  146955. syncIterations: number;
  146956. /** Gets or sets the aggressiveness of the simplifier */
  146957. aggressiveness: number;
  146958. /** Gets or sets the number of allowed iterations for decimation */
  146959. decimationIterations: number;
  146960. /** Gets or sets the espilon to use for bounding box computation */
  146961. boundingBoxEpsilon: number;
  146962. /**
  146963. * Creates a new QuadraticErrorSimplification
  146964. * @param _mesh defines the target mesh
  146965. */
  146966. constructor(_mesh: Mesh);
  146967. /**
  146968. * Simplification of a given mesh according to the given settings.
  146969. * Since this requires computation, it is assumed that the function runs async.
  146970. * @param settings The settings of the simplification, including quality and distance
  146971. * @param successCallback A callback that will be called after the mesh was simplified.
  146972. */
  146973. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  146974. private runDecimation;
  146975. private initWithMesh;
  146976. private init;
  146977. private reconstructMesh;
  146978. private initDecimatedMesh;
  146979. private isFlipped;
  146980. private updateTriangles;
  146981. private identifyBorder;
  146982. private updateMesh;
  146983. private vertexError;
  146984. private calculateError;
  146985. }
  146986. }
  146987. declare module BABYLON {
  146988. interface Scene {
  146989. /** @hidden (Backing field) */
  146990. _simplificationQueue: SimplificationQueue;
  146991. /**
  146992. * Gets or sets the simplification queue attached to the scene
  146993. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  146994. */
  146995. simplificationQueue: SimplificationQueue;
  146996. }
  146997. interface Mesh {
  146998. /**
  146999. * Simplify the mesh according to the given array of settings.
  147000. * Function will return immediately and will simplify async
  147001. * @param settings a collection of simplification settings
  147002. * @param parallelProcessing should all levels calculate parallel or one after the other
  147003. * @param simplificationType the type of simplification to run
  147004. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147005. * @returns the current mesh
  147006. */
  147007. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147008. }
  147009. /**
  147010. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147011. * created in a scene
  147012. */
  147013. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147014. /**
  147015. * The component name helpfull to identify the component in the list of scene components.
  147016. */
  147017. readonly name: string;
  147018. /**
  147019. * The scene the component belongs to.
  147020. */
  147021. scene: Scene;
  147022. /**
  147023. * Creates a new instance of the component for the given scene
  147024. * @param scene Defines the scene to register the component in
  147025. */
  147026. constructor(scene: Scene);
  147027. /**
  147028. * Registers the component in a given scene
  147029. */
  147030. register(): void;
  147031. /**
  147032. * Rebuilds the elements related to this component in case of
  147033. * context lost for instance.
  147034. */
  147035. rebuild(): void;
  147036. /**
  147037. * Disposes the component and the associated ressources
  147038. */
  147039. dispose(): void;
  147040. private _beforeCameraUpdate;
  147041. }
  147042. }
  147043. declare module BABYLON {
  147044. interface Mesh {
  147045. /**
  147046. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147047. */
  147048. thinInstanceEnablePicking: boolean;
  147049. /**
  147050. * Creates a new thin instance
  147051. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147052. * @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
  147053. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147054. */
  147055. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147056. /**
  147057. * Adds the transformation (matrix) of the current mesh as a thin instance
  147058. * @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
  147059. * @returns the thin instance index number
  147060. */
  147061. thinInstanceAddSelf(refresh: boolean): number;
  147062. /**
  147063. * Registers a custom attribute to be used with thin instances
  147064. * @param kind name of the attribute
  147065. * @param stride size in floats of the attribute
  147066. */
  147067. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147068. /**
  147069. * Sets the matrix of a thin instance
  147070. * @param index index of the thin instance
  147071. * @param matrix matrix to set
  147072. * @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
  147073. */
  147074. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147075. /**
  147076. * Sets the value of a custom attribute for a thin instance
  147077. * @param kind name of the attribute
  147078. * @param index index of the thin instance
  147079. * @param value value to set
  147080. * @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
  147081. */
  147082. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147083. /**
  147084. * 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.
  147085. */
  147086. thinInstanceCount: number;
  147087. /**
  147088. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147089. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147090. * @param buffer buffer to set
  147091. * @param stride size in floats of each value of the buffer
  147092. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147093. */
  147094. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147095. /**
  147096. * Gets the list of world matrices
  147097. * @return an array containing all the world matrices from the thin instances
  147098. */
  147099. thinInstanceGetWorldMatrices(): Matrix[];
  147100. /**
  147101. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147102. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147103. */
  147104. thinInstanceBufferUpdated(kind: string): void;
  147105. /**
  147106. * Applies a partial update to a buffer directly on the GPU
  147107. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  147108. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147109. * @param data the data to set in the GPU buffer
  147110. * @param offset the offset in the GPU buffer where to update the data
  147111. */
  147112. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147113. /**
  147114. * Refreshes the bounding info, taking into account all the thin instances defined
  147115. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147116. */
  147117. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147118. /** @hidden */
  147119. _thinInstanceInitializeUserStorage(): void;
  147120. /** @hidden */
  147121. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147122. /** @hidden */
  147123. _userThinInstanceBuffersStorage: {
  147124. data: {
  147125. [key: string]: Float32Array;
  147126. };
  147127. sizes: {
  147128. [key: string]: number;
  147129. };
  147130. vertexBuffers: {
  147131. [key: string]: Nullable<VertexBuffer>;
  147132. };
  147133. strides: {
  147134. [key: string]: number;
  147135. };
  147136. };
  147137. }
  147138. }
  147139. declare module BABYLON {
  147140. /**
  147141. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147142. */
  147143. export interface INavigationEnginePlugin {
  147144. /**
  147145. * plugin name
  147146. */
  147147. name: string;
  147148. /**
  147149. * Creates a navigation mesh
  147150. * @param meshes array of all the geometry used to compute the navigatio mesh
  147151. * @param parameters bunch of parameters used to filter geometry
  147152. */
  147153. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147154. /**
  147155. * Create a navigation mesh debug mesh
  147156. * @param scene is where the mesh will be added
  147157. * @returns debug display mesh
  147158. */
  147159. createDebugNavMesh(scene: Scene): Mesh;
  147160. /**
  147161. * Get a navigation mesh constrained position, closest to the parameter position
  147162. * @param position world position
  147163. * @returns the closest point to position constrained by the navigation mesh
  147164. */
  147165. getClosestPoint(position: Vector3): Vector3;
  147166. /**
  147167. * Get a navigation mesh constrained position, closest to the parameter position
  147168. * @param position world position
  147169. * @param result output the closest point to position constrained by the navigation mesh
  147170. */
  147171. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147172. /**
  147173. * Get a navigation mesh constrained position, within a particular radius
  147174. * @param position world position
  147175. * @param maxRadius the maximum distance to the constrained world position
  147176. * @returns the closest point to position constrained by the navigation mesh
  147177. */
  147178. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147179. /**
  147180. * Get a navigation mesh constrained position, within a particular radius
  147181. * @param position world position
  147182. * @param maxRadius the maximum distance to the constrained world position
  147183. * @param result output the closest point to position constrained by the navigation mesh
  147184. */
  147185. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147186. /**
  147187. * Compute the final position from a segment made of destination-position
  147188. * @param position world position
  147189. * @param destination world position
  147190. * @returns the resulting point along the navmesh
  147191. */
  147192. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147193. /**
  147194. * Compute the final position from a segment made of destination-position
  147195. * @param position world position
  147196. * @param destination world position
  147197. * @param result output the resulting point along the navmesh
  147198. */
  147199. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147200. /**
  147201. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147202. * @param start world position
  147203. * @param end world position
  147204. * @returns array containing world position composing the path
  147205. */
  147206. computePath(start: Vector3, end: Vector3): Vector3[];
  147207. /**
  147208. * If this plugin is supported
  147209. * @returns true if plugin is supported
  147210. */
  147211. isSupported(): boolean;
  147212. /**
  147213. * Create a new Crowd so you can add agents
  147214. * @param maxAgents the maximum agent count in the crowd
  147215. * @param maxAgentRadius the maximum radius an agent can have
  147216. * @param scene to attach the crowd to
  147217. * @returns the crowd you can add agents to
  147218. */
  147219. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147220. /**
  147221. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147222. * The queries will try to find a solution within those bounds
  147223. * default is (1,1,1)
  147224. * @param extent x,y,z value that define the extent around the queries point of reference
  147225. */
  147226. setDefaultQueryExtent(extent: Vector3): void;
  147227. /**
  147228. * Get the Bounding box extent specified by setDefaultQueryExtent
  147229. * @returns the box extent values
  147230. */
  147231. getDefaultQueryExtent(): Vector3;
  147232. /**
  147233. * build the navmesh from a previously saved state using getNavmeshData
  147234. * @param data the Uint8Array returned by getNavmeshData
  147235. */
  147236. buildFromNavmeshData(data: Uint8Array): void;
  147237. /**
  147238. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147239. * @returns data the Uint8Array that can be saved and reused
  147240. */
  147241. getNavmeshData(): Uint8Array;
  147242. /**
  147243. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147244. * @param result output the box extent values
  147245. */
  147246. getDefaultQueryExtentToRef(result: Vector3): void;
  147247. /**
  147248. * Release all resources
  147249. */
  147250. dispose(): void;
  147251. }
  147252. /**
  147253. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147254. */
  147255. export interface ICrowd {
  147256. /**
  147257. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147258. * You can attach anything to that node. The node position is updated in the scene update tick.
  147259. * @param pos world position that will be constrained by the navigation mesh
  147260. * @param parameters agent parameters
  147261. * @param transform hooked to the agent that will be update by the scene
  147262. * @returns agent index
  147263. */
  147264. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147265. /**
  147266. * Returns the agent position in world space
  147267. * @param index agent index returned by addAgent
  147268. * @returns world space position
  147269. */
  147270. getAgentPosition(index: number): Vector3;
  147271. /**
  147272. * Gets the agent position result in world space
  147273. * @param index agent index returned by addAgent
  147274. * @param result output world space position
  147275. */
  147276. getAgentPositionToRef(index: number, result: Vector3): void;
  147277. /**
  147278. * Gets the agent velocity in world space
  147279. * @param index agent index returned by addAgent
  147280. * @returns world space velocity
  147281. */
  147282. getAgentVelocity(index: number): Vector3;
  147283. /**
  147284. * Gets the agent velocity result in world space
  147285. * @param index agent index returned by addAgent
  147286. * @param result output world space velocity
  147287. */
  147288. getAgentVelocityToRef(index: number, result: Vector3): void;
  147289. /**
  147290. * remove a particular agent previously created
  147291. * @param index agent index returned by addAgent
  147292. */
  147293. removeAgent(index: number): void;
  147294. /**
  147295. * get the list of all agents attached to this crowd
  147296. * @returns list of agent indices
  147297. */
  147298. getAgents(): number[];
  147299. /**
  147300. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147301. * @param deltaTime in seconds
  147302. */
  147303. update(deltaTime: number): void;
  147304. /**
  147305. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147306. * @param index agent index returned by addAgent
  147307. * @param destination targeted world position
  147308. */
  147309. agentGoto(index: number, destination: Vector3): void;
  147310. /**
  147311. * Teleport the agent to a new position
  147312. * @param index agent index returned by addAgent
  147313. * @param destination targeted world position
  147314. */
  147315. agentTeleport(index: number, destination: Vector3): void;
  147316. /**
  147317. * Update agent parameters
  147318. * @param index agent index returned by addAgent
  147319. * @param parameters agent parameters
  147320. */
  147321. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147322. /**
  147323. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147324. * The queries will try to find a solution within those bounds
  147325. * default is (1,1,1)
  147326. * @param extent x,y,z value that define the extent around the queries point of reference
  147327. */
  147328. setDefaultQueryExtent(extent: Vector3): void;
  147329. /**
  147330. * Get the Bounding box extent specified by setDefaultQueryExtent
  147331. * @returns the box extent values
  147332. */
  147333. getDefaultQueryExtent(): Vector3;
  147334. /**
  147335. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147336. * @param result output the box extent values
  147337. */
  147338. getDefaultQueryExtentToRef(result: Vector3): void;
  147339. /**
  147340. * Release all resources
  147341. */
  147342. dispose(): void;
  147343. }
  147344. /**
  147345. * Configures an agent
  147346. */
  147347. export interface IAgentParameters {
  147348. /**
  147349. * Agent radius. [Limit: >= 0]
  147350. */
  147351. radius: number;
  147352. /**
  147353. * Agent height. [Limit: > 0]
  147354. */
  147355. height: number;
  147356. /**
  147357. * Maximum allowed acceleration. [Limit: >= 0]
  147358. */
  147359. maxAcceleration: number;
  147360. /**
  147361. * Maximum allowed speed. [Limit: >= 0]
  147362. */
  147363. maxSpeed: number;
  147364. /**
  147365. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147366. */
  147367. collisionQueryRange: number;
  147368. /**
  147369. * The path visibility optimization range. [Limit: > 0]
  147370. */
  147371. pathOptimizationRange: number;
  147372. /**
  147373. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147374. */
  147375. separationWeight: number;
  147376. }
  147377. /**
  147378. * Configures the navigation mesh creation
  147379. */
  147380. export interface INavMeshParameters {
  147381. /**
  147382. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147383. */
  147384. cs: number;
  147385. /**
  147386. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147387. */
  147388. ch: number;
  147389. /**
  147390. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147391. */
  147392. walkableSlopeAngle: number;
  147393. /**
  147394. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147395. * be considered walkable. [Limit: >= 3] [Units: vx]
  147396. */
  147397. walkableHeight: number;
  147398. /**
  147399. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147400. */
  147401. walkableClimb: number;
  147402. /**
  147403. * The distance to erode/shrink the walkable area of the heightfield away from
  147404. * obstructions. [Limit: >=0] [Units: vx]
  147405. */
  147406. walkableRadius: number;
  147407. /**
  147408. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147409. */
  147410. maxEdgeLen: number;
  147411. /**
  147412. * The maximum distance a simplfied contour's border edges should deviate
  147413. * the original raw contour. [Limit: >=0] [Units: vx]
  147414. */
  147415. maxSimplificationError: number;
  147416. /**
  147417. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147418. */
  147419. minRegionArea: number;
  147420. /**
  147421. * Any regions with a span count smaller than this value will, if possible,
  147422. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147423. */
  147424. mergeRegionArea: number;
  147425. /**
  147426. * The maximum number of vertices allowed for polygons generated during the
  147427. * contour to polygon conversion process. [Limit: >= 3]
  147428. */
  147429. maxVertsPerPoly: number;
  147430. /**
  147431. * Sets the sampling distance to use when generating the detail mesh.
  147432. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147433. */
  147434. detailSampleDist: number;
  147435. /**
  147436. * The maximum distance the detail mesh surface should deviate from heightfield
  147437. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147438. */
  147439. detailSampleMaxError: number;
  147440. }
  147441. }
  147442. declare module BABYLON {
  147443. /**
  147444. * RecastJS navigation plugin
  147445. */
  147446. export class RecastJSPlugin implements INavigationEnginePlugin {
  147447. /**
  147448. * Reference to the Recast library
  147449. */
  147450. bjsRECAST: any;
  147451. /**
  147452. * plugin name
  147453. */
  147454. name: string;
  147455. /**
  147456. * the first navmesh created. We might extend this to support multiple navmeshes
  147457. */
  147458. navMesh: any;
  147459. /**
  147460. * Initializes the recastJS plugin
  147461. * @param recastInjection can be used to inject your own recast reference
  147462. */
  147463. constructor(recastInjection?: any);
  147464. /**
  147465. * Creates a navigation mesh
  147466. * @param meshes array of all the geometry used to compute the navigatio mesh
  147467. * @param parameters bunch of parameters used to filter geometry
  147468. */
  147469. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147470. /**
  147471. * Create a navigation mesh debug mesh
  147472. * @param scene is where the mesh will be added
  147473. * @returns debug display mesh
  147474. */
  147475. createDebugNavMesh(scene: Scene): Mesh;
  147476. /**
  147477. * Get a navigation mesh constrained position, closest to the parameter position
  147478. * @param position world position
  147479. * @returns the closest point to position constrained by the navigation mesh
  147480. */
  147481. getClosestPoint(position: Vector3): Vector3;
  147482. /**
  147483. * Get a navigation mesh constrained position, closest to the parameter position
  147484. * @param position world position
  147485. * @param result output the closest point to position constrained by the navigation mesh
  147486. */
  147487. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147488. /**
  147489. * Get a navigation mesh constrained position, within a particular radius
  147490. * @param position world position
  147491. * @param maxRadius the maximum distance to the constrained world position
  147492. * @returns the closest point to position constrained by the navigation mesh
  147493. */
  147494. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147495. /**
  147496. * Get a navigation mesh constrained position, within a particular radius
  147497. * @param position world position
  147498. * @param maxRadius the maximum distance to the constrained world position
  147499. * @param result output the closest point to position constrained by the navigation mesh
  147500. */
  147501. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147502. /**
  147503. * Compute the final position from a segment made of destination-position
  147504. * @param position world position
  147505. * @param destination world position
  147506. * @returns the resulting point along the navmesh
  147507. */
  147508. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147509. /**
  147510. * Compute the final position from a segment made of destination-position
  147511. * @param position world position
  147512. * @param destination world position
  147513. * @param result output the resulting point along the navmesh
  147514. */
  147515. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147516. /**
  147517. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147518. * @param start world position
  147519. * @param end world position
  147520. * @returns array containing world position composing the path
  147521. */
  147522. computePath(start: Vector3, end: Vector3): Vector3[];
  147523. /**
  147524. * Create a new Crowd so you can add agents
  147525. * @param maxAgents the maximum agent count in the crowd
  147526. * @param maxAgentRadius the maximum radius an agent can have
  147527. * @param scene to attach the crowd to
  147528. * @returns the crowd you can add agents to
  147529. */
  147530. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147531. /**
  147532. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147533. * The queries will try to find a solution within those bounds
  147534. * default is (1,1,1)
  147535. * @param extent x,y,z value that define the extent around the queries point of reference
  147536. */
  147537. setDefaultQueryExtent(extent: Vector3): void;
  147538. /**
  147539. * Get the Bounding box extent specified by setDefaultQueryExtent
  147540. * @returns the box extent values
  147541. */
  147542. getDefaultQueryExtent(): Vector3;
  147543. /**
  147544. * build the navmesh from a previously saved state using getNavmeshData
  147545. * @param data the Uint8Array returned by getNavmeshData
  147546. */
  147547. buildFromNavmeshData(data: Uint8Array): void;
  147548. /**
  147549. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147550. * @returns data the Uint8Array that can be saved and reused
  147551. */
  147552. getNavmeshData(): Uint8Array;
  147553. /**
  147554. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147555. * @param result output the box extent values
  147556. */
  147557. getDefaultQueryExtentToRef(result: Vector3): void;
  147558. /**
  147559. * Disposes
  147560. */
  147561. dispose(): void;
  147562. /**
  147563. * If this plugin is supported
  147564. * @returns true if plugin is supported
  147565. */
  147566. isSupported(): boolean;
  147567. }
  147568. /**
  147569. * Recast detour crowd implementation
  147570. */
  147571. export class RecastJSCrowd implements ICrowd {
  147572. /**
  147573. * Recast/detour plugin
  147574. */
  147575. bjsRECASTPlugin: RecastJSPlugin;
  147576. /**
  147577. * Link to the detour crowd
  147578. */
  147579. recastCrowd: any;
  147580. /**
  147581. * One transform per agent
  147582. */
  147583. transforms: TransformNode[];
  147584. /**
  147585. * All agents created
  147586. */
  147587. agents: number[];
  147588. /**
  147589. * Link to the scene is kept to unregister the crowd from the scene
  147590. */
  147591. private _scene;
  147592. /**
  147593. * Observer for crowd updates
  147594. */
  147595. private _onBeforeAnimationsObserver;
  147596. /**
  147597. * Constructor
  147598. * @param plugin recastJS plugin
  147599. * @param maxAgents the maximum agent count in the crowd
  147600. * @param maxAgentRadius the maximum radius an agent can have
  147601. * @param scene to attach the crowd to
  147602. * @returns the crowd you can add agents to
  147603. */
  147604. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  147605. /**
  147606. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147607. * You can attach anything to that node. The node position is updated in the scene update tick.
  147608. * @param pos world position that will be constrained by the navigation mesh
  147609. * @param parameters agent parameters
  147610. * @param transform hooked to the agent that will be update by the scene
  147611. * @returns agent index
  147612. */
  147613. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147614. /**
  147615. * Returns the agent position in world space
  147616. * @param index agent index returned by addAgent
  147617. * @returns world space position
  147618. */
  147619. getAgentPosition(index: number): Vector3;
  147620. /**
  147621. * Returns the agent position result in world space
  147622. * @param index agent index returned by addAgent
  147623. * @param result output world space position
  147624. */
  147625. getAgentPositionToRef(index: number, result: Vector3): void;
  147626. /**
  147627. * Returns the agent velocity in world space
  147628. * @param index agent index returned by addAgent
  147629. * @returns world space velocity
  147630. */
  147631. getAgentVelocity(index: number): Vector3;
  147632. /**
  147633. * Returns the agent velocity result in world space
  147634. * @param index agent index returned by addAgent
  147635. * @param result output world space velocity
  147636. */
  147637. getAgentVelocityToRef(index: number, result: Vector3): void;
  147638. /**
  147639. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147640. * @param index agent index returned by addAgent
  147641. * @param destination targeted world position
  147642. */
  147643. agentGoto(index: number, destination: Vector3): void;
  147644. /**
  147645. * Teleport the agent to a new position
  147646. * @param index agent index returned by addAgent
  147647. * @param destination targeted world position
  147648. */
  147649. agentTeleport(index: number, destination: Vector3): void;
  147650. /**
  147651. * Update agent parameters
  147652. * @param index agent index returned by addAgent
  147653. * @param parameters agent parameters
  147654. */
  147655. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147656. /**
  147657. * remove a particular agent previously created
  147658. * @param index agent index returned by addAgent
  147659. */
  147660. removeAgent(index: number): void;
  147661. /**
  147662. * get the list of all agents attached to this crowd
  147663. * @returns list of agent indices
  147664. */
  147665. getAgents(): number[];
  147666. /**
  147667. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147668. * @param deltaTime in seconds
  147669. */
  147670. update(deltaTime: number): void;
  147671. /**
  147672. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147673. * The queries will try to find a solution within those bounds
  147674. * default is (1,1,1)
  147675. * @param extent x,y,z value that define the extent around the queries point of reference
  147676. */
  147677. setDefaultQueryExtent(extent: Vector3): void;
  147678. /**
  147679. * Get the Bounding box extent specified by setDefaultQueryExtent
  147680. * @returns the box extent values
  147681. */
  147682. getDefaultQueryExtent(): Vector3;
  147683. /**
  147684. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147685. * @param result output the box extent values
  147686. */
  147687. getDefaultQueryExtentToRef(result: Vector3): void;
  147688. /**
  147689. * Release all resources
  147690. */
  147691. dispose(): void;
  147692. }
  147693. }
  147694. declare module BABYLON {
  147695. /**
  147696. * Class used to enable access to IndexedDB
  147697. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  147698. */
  147699. export class Database implements IOfflineProvider {
  147700. private _callbackManifestChecked;
  147701. private _currentSceneUrl;
  147702. private _db;
  147703. private _enableSceneOffline;
  147704. private _enableTexturesOffline;
  147705. private _manifestVersionFound;
  147706. private _mustUpdateRessources;
  147707. private _hasReachedQuota;
  147708. private _isSupported;
  147709. private _idbFactory;
  147710. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  147711. private static IsUASupportingBlobStorage;
  147712. /**
  147713. * Gets a boolean indicating if Database storate is enabled (off by default)
  147714. */
  147715. static IDBStorageEnabled: boolean;
  147716. /**
  147717. * Gets a boolean indicating if scene must be saved in the database
  147718. */
  147719. get enableSceneOffline(): boolean;
  147720. /**
  147721. * Gets a boolean indicating if textures must be saved in the database
  147722. */
  147723. get enableTexturesOffline(): boolean;
  147724. /**
  147725. * Creates a new Database
  147726. * @param urlToScene defines the url to load the scene
  147727. * @param callbackManifestChecked defines the callback to use when manifest is checked
  147728. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  147729. */
  147730. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  147731. private static _ParseURL;
  147732. private static _ReturnFullUrlLocation;
  147733. private _checkManifestFile;
  147734. /**
  147735. * Open the database and make it available
  147736. * @param successCallback defines the callback to call on success
  147737. * @param errorCallback defines the callback to call on error
  147738. */
  147739. open(successCallback: () => void, errorCallback: () => void): void;
  147740. /**
  147741. * Loads an image from the database
  147742. * @param url defines the url to load from
  147743. * @param image defines the target DOM image
  147744. */
  147745. loadImage(url: string, image: HTMLImageElement): void;
  147746. private _loadImageFromDBAsync;
  147747. private _saveImageIntoDBAsync;
  147748. private _checkVersionFromDB;
  147749. private _loadVersionFromDBAsync;
  147750. private _saveVersionIntoDBAsync;
  147751. /**
  147752. * Loads a file from database
  147753. * @param url defines the URL to load from
  147754. * @param sceneLoaded defines a callback to call on success
  147755. * @param progressCallBack defines a callback to call when progress changed
  147756. * @param errorCallback defines a callback to call on error
  147757. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  147758. */
  147759. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  147760. private _loadFileAsync;
  147761. private _saveFileAsync;
  147762. /**
  147763. * Validates if xhr data is correct
  147764. * @param xhr defines the request to validate
  147765. * @param dataType defines the expected data type
  147766. * @returns true if data is correct
  147767. */
  147768. private static _ValidateXHRData;
  147769. }
  147770. }
  147771. declare module BABYLON {
  147772. /** @hidden */
  147773. export var gpuUpdateParticlesPixelShader: {
  147774. name: string;
  147775. shader: string;
  147776. };
  147777. }
  147778. declare module BABYLON {
  147779. /** @hidden */
  147780. export var gpuUpdateParticlesVertexShader: {
  147781. name: string;
  147782. shader: string;
  147783. };
  147784. }
  147785. declare module BABYLON {
  147786. /** @hidden */
  147787. export var clipPlaneFragmentDeclaration2: {
  147788. name: string;
  147789. shader: string;
  147790. };
  147791. }
  147792. declare module BABYLON {
  147793. /** @hidden */
  147794. export var gpuRenderParticlesPixelShader: {
  147795. name: string;
  147796. shader: string;
  147797. };
  147798. }
  147799. declare module BABYLON {
  147800. /** @hidden */
  147801. export var clipPlaneVertexDeclaration2: {
  147802. name: string;
  147803. shader: string;
  147804. };
  147805. }
  147806. declare module BABYLON {
  147807. /** @hidden */
  147808. export var gpuRenderParticlesVertexShader: {
  147809. name: string;
  147810. shader: string;
  147811. };
  147812. }
  147813. declare module BABYLON {
  147814. /**
  147815. * This represents a GPU particle system in Babylon
  147816. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  147817. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  147818. */
  147819. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  147820. /**
  147821. * The layer mask we are rendering the particles through.
  147822. */
  147823. layerMask: number;
  147824. private _capacity;
  147825. private _activeCount;
  147826. private _currentActiveCount;
  147827. private _accumulatedCount;
  147828. private _renderEffect;
  147829. private _updateEffect;
  147830. private _buffer0;
  147831. private _buffer1;
  147832. private _spriteBuffer;
  147833. private _updateVAO;
  147834. private _renderVAO;
  147835. private _targetIndex;
  147836. private _sourceBuffer;
  147837. private _targetBuffer;
  147838. private _currentRenderId;
  147839. private _started;
  147840. private _stopped;
  147841. private _timeDelta;
  147842. private _randomTexture;
  147843. private _randomTexture2;
  147844. private _attributesStrideSize;
  147845. private _updateEffectOptions;
  147846. private _randomTextureSize;
  147847. private _actualFrame;
  147848. private _customEffect;
  147849. private readonly _rawTextureWidth;
  147850. /**
  147851. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  147852. */
  147853. static get IsSupported(): boolean;
  147854. /**
  147855. * An event triggered when the system is disposed.
  147856. */
  147857. onDisposeObservable: Observable<IParticleSystem>;
  147858. /**
  147859. * Gets the maximum number of particles active at the same time.
  147860. * @returns The max number of active particles.
  147861. */
  147862. getCapacity(): number;
  147863. /**
  147864. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  147865. * to override the particles.
  147866. */
  147867. forceDepthWrite: boolean;
  147868. /**
  147869. * Gets or set the number of active particles
  147870. */
  147871. get activeParticleCount(): number;
  147872. set activeParticleCount(value: number);
  147873. private _preWarmDone;
  147874. /**
  147875. * Specifies if the particles are updated in emitter local space or world space.
  147876. */
  147877. isLocal: boolean;
  147878. /** Gets or sets a matrix to use to compute projection */
  147879. defaultProjectionMatrix: Matrix;
  147880. /**
  147881. * Is this system ready to be used/rendered
  147882. * @return true if the system is ready
  147883. */
  147884. isReady(): boolean;
  147885. /**
  147886. * Gets if the system has been started. (Note: this will still be true after stop is called)
  147887. * @returns True if it has been started, otherwise false.
  147888. */
  147889. isStarted(): boolean;
  147890. /**
  147891. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  147892. * @returns True if it has been stopped, otherwise false.
  147893. */
  147894. isStopped(): boolean;
  147895. /**
  147896. * Gets a boolean indicating that the system is stopping
  147897. * @returns true if the system is currently stopping
  147898. */
  147899. isStopping(): boolean;
  147900. /**
  147901. * Gets the number of particles active at the same time.
  147902. * @returns The number of active particles.
  147903. */
  147904. getActiveCount(): number;
  147905. /**
  147906. * Starts the particle system and begins to emit
  147907. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  147908. */
  147909. start(delay?: number): void;
  147910. /**
  147911. * Stops the particle system.
  147912. */
  147913. stop(): void;
  147914. /**
  147915. * Remove all active particles
  147916. */
  147917. reset(): void;
  147918. /**
  147919. * Returns the string "GPUParticleSystem"
  147920. * @returns a string containing the class name
  147921. */
  147922. getClassName(): string;
  147923. /**
  147924. * Gets the custom effect used to render the particles
  147925. * @param blendMode Blend mode for which the effect should be retrieved
  147926. * @returns The effect
  147927. */
  147928. getCustomEffect(blendMode?: number): Nullable<Effect>;
  147929. /**
  147930. * Sets the custom effect used to render the particles
  147931. * @param effect The effect to set
  147932. * @param blendMode Blend mode for which the effect should be set
  147933. */
  147934. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  147935. /** @hidden */
  147936. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  147937. /**
  147938. * Observable that will be called just before the particles are drawn
  147939. */
  147940. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  147941. /**
  147942. * Gets the name of the particle vertex shader
  147943. */
  147944. get vertexShaderName(): string;
  147945. private _colorGradientsTexture;
  147946. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  147947. /**
  147948. * Adds a new color gradient
  147949. * @param gradient defines the gradient to use (between 0 and 1)
  147950. * @param color1 defines the color to affect to the specified gradient
  147951. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  147952. * @returns the current particle system
  147953. */
  147954. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  147955. private _refreshColorGradient;
  147956. /** Force the system to rebuild all gradients that need to be resync */
  147957. forceRefreshGradients(): void;
  147958. /**
  147959. * Remove a specific color gradient
  147960. * @param gradient defines the gradient to remove
  147961. * @returns the current particle system
  147962. */
  147963. removeColorGradient(gradient: number): GPUParticleSystem;
  147964. private _angularSpeedGradientsTexture;
  147965. private _sizeGradientsTexture;
  147966. private _velocityGradientsTexture;
  147967. private _limitVelocityGradientsTexture;
  147968. private _dragGradientsTexture;
  147969. private _addFactorGradient;
  147970. /**
  147971. * Adds a new size gradient
  147972. * @param gradient defines the gradient to use (between 0 and 1)
  147973. * @param factor defines the size factor to affect to the specified gradient
  147974. * @returns the current particle system
  147975. */
  147976. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  147977. /**
  147978. * Remove a specific size gradient
  147979. * @param gradient defines the gradient to remove
  147980. * @returns the current particle system
  147981. */
  147982. removeSizeGradient(gradient: number): GPUParticleSystem;
  147983. private _refreshFactorGradient;
  147984. /**
  147985. * Adds a new angular speed gradient
  147986. * @param gradient defines the gradient to use (between 0 and 1)
  147987. * @param factor defines the angular speed to affect to the specified gradient
  147988. * @returns the current particle system
  147989. */
  147990. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  147991. /**
  147992. * Remove a specific angular speed gradient
  147993. * @param gradient defines the gradient to remove
  147994. * @returns the current particle system
  147995. */
  147996. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  147997. /**
  147998. * Adds a new velocity gradient
  147999. * @param gradient defines the gradient to use (between 0 and 1)
  148000. * @param factor defines the velocity to affect to the specified gradient
  148001. * @returns the current particle system
  148002. */
  148003. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148004. /**
  148005. * Remove a specific velocity gradient
  148006. * @param gradient defines the gradient to remove
  148007. * @returns the current particle system
  148008. */
  148009. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148010. /**
  148011. * Adds a new limit velocity gradient
  148012. * @param gradient defines the gradient to use (between 0 and 1)
  148013. * @param factor defines the limit velocity value to affect to the specified gradient
  148014. * @returns the current particle system
  148015. */
  148016. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148017. /**
  148018. * Remove a specific limit velocity gradient
  148019. * @param gradient defines the gradient to remove
  148020. * @returns the current particle system
  148021. */
  148022. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148023. /**
  148024. * Adds a new drag gradient
  148025. * @param gradient defines the gradient to use (between 0 and 1)
  148026. * @param factor defines the drag value to affect to the specified gradient
  148027. * @returns the current particle system
  148028. */
  148029. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148030. /**
  148031. * Remove a specific drag gradient
  148032. * @param gradient defines the gradient to remove
  148033. * @returns the current particle system
  148034. */
  148035. removeDragGradient(gradient: number): GPUParticleSystem;
  148036. /**
  148037. * Not supported by GPUParticleSystem
  148038. * @param gradient defines the gradient to use (between 0 and 1)
  148039. * @param factor defines the emit rate value to affect to the specified gradient
  148040. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148041. * @returns the current particle system
  148042. */
  148043. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148044. /**
  148045. * Not supported by GPUParticleSystem
  148046. * @param gradient defines the gradient to remove
  148047. * @returns the current particle system
  148048. */
  148049. removeEmitRateGradient(gradient: number): IParticleSystem;
  148050. /**
  148051. * Not supported by GPUParticleSystem
  148052. * @param gradient defines the gradient to use (between 0 and 1)
  148053. * @param factor defines the start size value to affect to the specified gradient
  148054. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148055. * @returns the current particle system
  148056. */
  148057. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148058. /**
  148059. * Not supported by GPUParticleSystem
  148060. * @param gradient defines the gradient to remove
  148061. * @returns the current particle system
  148062. */
  148063. removeStartSizeGradient(gradient: number): IParticleSystem;
  148064. /**
  148065. * Not supported by GPUParticleSystem
  148066. * @param gradient defines the gradient to use (between 0 and 1)
  148067. * @param min defines the color remap minimal range
  148068. * @param max defines the color remap maximal range
  148069. * @returns the current particle system
  148070. */
  148071. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148072. /**
  148073. * Not supported by GPUParticleSystem
  148074. * @param gradient defines the gradient to remove
  148075. * @returns the current particle system
  148076. */
  148077. removeColorRemapGradient(): IParticleSystem;
  148078. /**
  148079. * Not supported by GPUParticleSystem
  148080. * @param gradient defines the gradient to use (between 0 and 1)
  148081. * @param min defines the alpha remap minimal range
  148082. * @param max defines the alpha remap maximal range
  148083. * @returns the current particle system
  148084. */
  148085. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148086. /**
  148087. * Not supported by GPUParticleSystem
  148088. * @param gradient defines the gradient to remove
  148089. * @returns the current particle system
  148090. */
  148091. removeAlphaRemapGradient(): IParticleSystem;
  148092. /**
  148093. * Not supported by GPUParticleSystem
  148094. * @param gradient defines the gradient to use (between 0 and 1)
  148095. * @param color defines the color to affect to the specified gradient
  148096. * @returns the current particle system
  148097. */
  148098. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148099. /**
  148100. * Not supported by GPUParticleSystem
  148101. * @param gradient defines the gradient to remove
  148102. * @returns the current particle system
  148103. */
  148104. removeRampGradient(): IParticleSystem;
  148105. /**
  148106. * Not supported by GPUParticleSystem
  148107. * @returns the list of ramp gradients
  148108. */
  148109. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148110. /**
  148111. * Not supported by GPUParticleSystem
  148112. * Gets or sets a boolean indicating that ramp gradients must be used
  148113. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148114. */
  148115. get useRampGradients(): boolean;
  148116. set useRampGradients(value: boolean);
  148117. /**
  148118. * Not supported by GPUParticleSystem
  148119. * @param gradient defines the gradient to use (between 0 and 1)
  148120. * @param factor defines the life time factor to affect to the specified gradient
  148121. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148122. * @returns the current particle system
  148123. */
  148124. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148125. /**
  148126. * Not supported by GPUParticleSystem
  148127. * @param gradient defines the gradient to remove
  148128. * @returns the current particle system
  148129. */
  148130. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148131. /**
  148132. * Instantiates a GPU particle system.
  148133. * 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.
  148134. * @param name The name of the particle system
  148135. * @param options The options used to create the system
  148136. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148137. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148138. * @param customEffect a custom effect used to change the way particles are rendered by default
  148139. */
  148140. constructor(name: string, options: Partial<{
  148141. capacity: number;
  148142. randomTextureSize: number;
  148143. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148144. protected _reset(): void;
  148145. private _createUpdateVAO;
  148146. private _createRenderVAO;
  148147. private _initialize;
  148148. /** @hidden */
  148149. _recreateUpdateEffect(): void;
  148150. private _getEffect;
  148151. /**
  148152. * Fill the defines array according to the current settings of the particle system
  148153. * @param defines Array to be updated
  148154. * @param blendMode blend mode to take into account when updating the array
  148155. */
  148156. fillDefines(defines: Array<string>, blendMode?: number): void;
  148157. /**
  148158. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148159. * @param uniforms Uniforms array to fill
  148160. * @param attributes Attributes array to fill
  148161. * @param samplers Samplers array to fill
  148162. */
  148163. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148164. /** @hidden */
  148165. _recreateRenderEffect(): Effect;
  148166. /**
  148167. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148168. * @param preWarm defines if we are in the pre-warmimg phase
  148169. */
  148170. animate(preWarm?: boolean): void;
  148171. private _createFactorGradientTexture;
  148172. private _createSizeGradientTexture;
  148173. private _createAngularSpeedGradientTexture;
  148174. private _createVelocityGradientTexture;
  148175. private _createLimitVelocityGradientTexture;
  148176. private _createDragGradientTexture;
  148177. private _createColorGradientTexture;
  148178. /**
  148179. * Renders the particle system in its current state
  148180. * @param preWarm defines if the system should only update the particles but not render them
  148181. * @returns the current number of particles
  148182. */
  148183. render(preWarm?: boolean): number;
  148184. /**
  148185. * Rebuilds the particle system
  148186. */
  148187. rebuild(): void;
  148188. private _releaseBuffers;
  148189. private _releaseVAOs;
  148190. /**
  148191. * Disposes the particle system and free the associated resources
  148192. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148193. */
  148194. dispose(disposeTexture?: boolean): void;
  148195. /**
  148196. * Clones the particle system.
  148197. * @param name The name of the cloned object
  148198. * @param newEmitter The new emitter to use
  148199. * @returns the cloned particle system
  148200. */
  148201. clone(name: string, newEmitter: any): GPUParticleSystem;
  148202. /**
  148203. * Serializes the particle system to a JSON object
  148204. * @param serializeTexture defines if the texture must be serialized as well
  148205. * @returns the JSON object
  148206. */
  148207. serialize(serializeTexture?: boolean): any;
  148208. /**
  148209. * Parses a JSON object to create a GPU particle system.
  148210. * @param parsedParticleSystem The JSON object to parse
  148211. * @param sceneOrEngine The scene or the engine to create the particle system in
  148212. * @param rootUrl The root url to use to load external dependencies like texture
  148213. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148214. * @returns the parsed GPU particle system
  148215. */
  148216. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148217. }
  148218. }
  148219. declare module BABYLON {
  148220. /**
  148221. * Represents a set of particle systems working together to create a specific effect
  148222. */
  148223. export class ParticleSystemSet implements IDisposable {
  148224. /**
  148225. * Gets or sets base Assets URL
  148226. */
  148227. static BaseAssetsUrl: string;
  148228. private _emitterCreationOptions;
  148229. private _emitterNode;
  148230. /**
  148231. * Gets the particle system list
  148232. */
  148233. systems: IParticleSystem[];
  148234. /**
  148235. * Gets the emitter node used with this set
  148236. */
  148237. get emitterNode(): Nullable<TransformNode>;
  148238. /**
  148239. * Creates a new emitter mesh as a sphere
  148240. * @param options defines the options used to create the sphere
  148241. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148242. * @param scene defines the hosting scene
  148243. */
  148244. setEmitterAsSphere(options: {
  148245. diameter: number;
  148246. segments: number;
  148247. color: Color3;
  148248. }, renderingGroupId: number, scene: Scene): void;
  148249. /**
  148250. * Starts all particle systems of the set
  148251. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148252. */
  148253. start(emitter?: AbstractMesh): void;
  148254. /**
  148255. * Release all associated resources
  148256. */
  148257. dispose(): void;
  148258. /**
  148259. * Serialize the set into a JSON compatible object
  148260. * @param serializeTexture defines if the texture must be serialized as well
  148261. * @returns a JSON compatible representation of the set
  148262. */
  148263. serialize(serializeTexture?: boolean): any;
  148264. /**
  148265. * Parse a new ParticleSystemSet from a serialized source
  148266. * @param data defines a JSON compatible representation of the set
  148267. * @param scene defines the hosting scene
  148268. * @param gpu defines if we want GPU particles or CPU particles
  148269. * @returns a new ParticleSystemSet
  148270. */
  148271. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148272. }
  148273. }
  148274. declare module BABYLON {
  148275. /**
  148276. * This class is made for on one-liner static method to help creating particle system set.
  148277. */
  148278. export class ParticleHelper {
  148279. /**
  148280. * Gets or sets base Assets URL
  148281. */
  148282. static BaseAssetsUrl: string;
  148283. /** Define the Url to load snippets */
  148284. static SnippetUrl: string;
  148285. /**
  148286. * Create a default particle system that you can tweak
  148287. * @param emitter defines the emitter to use
  148288. * @param capacity defines the system capacity (default is 500 particles)
  148289. * @param scene defines the hosting scene
  148290. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148291. * @returns the new Particle system
  148292. */
  148293. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148294. /**
  148295. * This is the main static method (one-liner) of this helper to create different particle systems
  148296. * @param type This string represents the type to the particle system to create
  148297. * @param scene The scene where the particle system should live
  148298. * @param gpu If the system will use gpu
  148299. * @returns the ParticleSystemSet created
  148300. */
  148301. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148302. /**
  148303. * Static function used to export a particle system to a ParticleSystemSet variable.
  148304. * Please note that the emitter shape is not exported
  148305. * @param systems defines the particle systems to export
  148306. * @returns the created particle system set
  148307. */
  148308. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148309. /**
  148310. * Creates a particle system from a snippet saved in a remote file
  148311. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148312. * @param url defines the url to load from
  148313. * @param scene defines the hosting scene
  148314. * @param gpu If the system will use gpu
  148315. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148316. * @returns a promise that will resolve to the new particle system
  148317. */
  148318. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148319. /**
  148320. * Creates a particle system from a snippet saved by the particle system editor
  148321. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148322. * @param scene defines the hosting scene
  148323. * @param gpu If the system will use gpu
  148324. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148325. * @returns a promise that will resolve to the new particle system
  148326. */
  148327. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148328. }
  148329. }
  148330. declare module BABYLON {
  148331. interface Engine {
  148332. /**
  148333. * Create an effect to use with particle systems.
  148334. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148335. * the particle system for which you want to create a custom effect in the last parameter
  148336. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148337. * @param uniformsNames defines a list of attribute names
  148338. * @param samplers defines an array of string used to represent textures
  148339. * @param defines defines the string containing the defines to use to compile the shaders
  148340. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148341. * @param onCompiled defines a function to call when the effect creation is successful
  148342. * @param onError defines a function to call when the effect creation has failed
  148343. * @param particleSystem the particle system you want to create the effect for
  148344. * @returns the new Effect
  148345. */
  148346. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148347. }
  148348. interface Mesh {
  148349. /**
  148350. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148351. * @returns an array of IParticleSystem
  148352. */
  148353. getEmittedParticleSystems(): IParticleSystem[];
  148354. /**
  148355. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148356. * @returns an array of IParticleSystem
  148357. */
  148358. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148359. }
  148360. }
  148361. declare module BABYLON {
  148362. /** Defines the 4 color options */
  148363. export enum PointColor {
  148364. /** color value */
  148365. Color = 2,
  148366. /** uv value */
  148367. UV = 1,
  148368. /** random value */
  148369. Random = 0,
  148370. /** stated value */
  148371. Stated = 3
  148372. }
  148373. /**
  148374. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148375. * 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.
  148376. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148377. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148378. *
  148379. * Full documentation here : TO BE ENTERED
  148380. */
  148381. export class PointsCloudSystem implements IDisposable {
  148382. /**
  148383. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148384. * Example : var p = SPS.particles[i];
  148385. */
  148386. particles: CloudPoint[];
  148387. /**
  148388. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148389. */
  148390. nbParticles: number;
  148391. /**
  148392. * This a counter for your own usage. It's not set by any SPS functions.
  148393. */
  148394. counter: number;
  148395. /**
  148396. * The PCS name. This name is also given to the underlying mesh.
  148397. */
  148398. name: string;
  148399. /**
  148400. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148401. */
  148402. mesh: Mesh;
  148403. /**
  148404. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148405. * Please read :
  148406. */
  148407. vars: any;
  148408. /**
  148409. * @hidden
  148410. */
  148411. _size: number;
  148412. private _scene;
  148413. private _promises;
  148414. private _positions;
  148415. private _indices;
  148416. private _normals;
  148417. private _colors;
  148418. private _uvs;
  148419. private _indices32;
  148420. private _positions32;
  148421. private _colors32;
  148422. private _uvs32;
  148423. private _updatable;
  148424. private _isVisibilityBoxLocked;
  148425. private _alwaysVisible;
  148426. private _groups;
  148427. private _groupCounter;
  148428. private _computeParticleColor;
  148429. private _computeParticleTexture;
  148430. private _computeParticleRotation;
  148431. private _computeBoundingBox;
  148432. private _isReady;
  148433. /**
  148434. * Creates a PCS (Points Cloud System) object
  148435. * @param name (String) is the PCS name, this will be the underlying mesh name
  148436. * @param pointSize (number) is the size for each point
  148437. * @param scene (Scene) is the scene in which the PCS is added
  148438. * @param options defines the options of the PCS e.g.
  148439. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148440. */
  148441. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148442. updatable?: boolean;
  148443. });
  148444. /**
  148445. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148446. * If no points were added to the PCS, the returned mesh is just a single point.
  148447. * @returns a promise for the created mesh
  148448. */
  148449. buildMeshAsync(): Promise<Mesh>;
  148450. /**
  148451. * @hidden
  148452. */
  148453. private _buildMesh;
  148454. private _addParticle;
  148455. private _randomUnitVector;
  148456. private _getColorIndicesForCoord;
  148457. private _setPointsColorOrUV;
  148458. private _colorFromTexture;
  148459. private _calculateDensity;
  148460. /**
  148461. * Adds points to the PCS in random positions within a unit sphere
  148462. * @param nb (positive integer) the number of particles to be created from this model
  148463. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148464. * @returns the number of groups in the system
  148465. */
  148466. addPoints(nb: number, pointFunction?: any): number;
  148467. /**
  148468. * Adds points to the PCS from the surface of the model shape
  148469. * @param mesh is any Mesh object that will be used as a surface model for the points
  148470. * @param nb (positive integer) the number of particles to be created from this model
  148471. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148472. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148473. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148474. * @returns the number of groups in the system
  148475. */
  148476. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148477. /**
  148478. * Adds points to the PCS inside the model shape
  148479. * @param mesh is any Mesh object that will be used as a surface model for the points
  148480. * @param nb (positive integer) the number of particles to be created from this model
  148481. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148482. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148483. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148484. * @returns the number of groups in the system
  148485. */
  148486. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148487. /**
  148488. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148489. * This method calls `updateParticle()` for each particle of the SPS.
  148490. * For an animated SPS, it is usually called within the render loop.
  148491. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148492. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148493. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148494. * @returns the PCS.
  148495. */
  148496. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148497. /**
  148498. * Disposes the PCS.
  148499. */
  148500. dispose(): void;
  148501. /**
  148502. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148503. * doc :
  148504. * @returns the PCS.
  148505. */
  148506. refreshVisibleSize(): PointsCloudSystem;
  148507. /**
  148508. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148509. * @param size the size (float) of the visibility box
  148510. * note : this doesn't lock the PCS mesh bounding box.
  148511. * doc :
  148512. */
  148513. setVisibilityBox(size: number): void;
  148514. /**
  148515. * Gets whether the PCS is always visible or not
  148516. * doc :
  148517. */
  148518. get isAlwaysVisible(): boolean;
  148519. /**
  148520. * Sets the PCS as always visible or not
  148521. * doc :
  148522. */
  148523. set isAlwaysVisible(val: boolean);
  148524. /**
  148525. * Tells to `setParticles()` to compute the particle rotations or not
  148526. * Default value : false. The PCS is faster when it's set to false
  148527. * Note : particle rotations are only applied to parent particles
  148528. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148529. */
  148530. set computeParticleRotation(val: boolean);
  148531. /**
  148532. * Tells to `setParticles()` to compute the particle colors or not.
  148533. * Default value : true. The PCS is faster when it's set to false.
  148534. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148535. */
  148536. set computeParticleColor(val: boolean);
  148537. set computeParticleTexture(val: boolean);
  148538. /**
  148539. * Gets if `setParticles()` computes the particle colors or not.
  148540. * Default value : false. The PCS is faster when it's set to false.
  148541. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148542. */
  148543. get computeParticleColor(): boolean;
  148544. /**
  148545. * Gets if `setParticles()` computes the particle textures or not.
  148546. * Default value : false. The PCS is faster when it's set to false.
  148547. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148548. */
  148549. get computeParticleTexture(): boolean;
  148550. /**
  148551. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148552. */
  148553. set computeBoundingBox(val: boolean);
  148554. /**
  148555. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148556. */
  148557. get computeBoundingBox(): boolean;
  148558. /**
  148559. * This function does nothing. It may be overwritten to set all the particle first values.
  148560. * The PCS doesn't call this function, you may have to call it by your own.
  148561. * doc :
  148562. */
  148563. initParticles(): void;
  148564. /**
  148565. * This function does nothing. It may be overwritten to recycle a particle
  148566. * The PCS doesn't call this function, you can to call it
  148567. * doc :
  148568. * @param particle The particle to recycle
  148569. * @returns the recycled particle
  148570. */
  148571. recycleParticle(particle: CloudPoint): CloudPoint;
  148572. /**
  148573. * Updates a particle : this function should be overwritten by the user.
  148574. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148575. * doc :
  148576. * @example : just set a particle position or velocity and recycle conditions
  148577. * @param particle The particle to update
  148578. * @returns the updated particle
  148579. */
  148580. updateParticle(particle: CloudPoint): CloudPoint;
  148581. /**
  148582. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  148583. * This does nothing and may be overwritten by the user.
  148584. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148585. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148586. * @param update the boolean update value actually passed to setParticles()
  148587. */
  148588. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148589. /**
  148590. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  148591. * This will be passed three parameters.
  148592. * This does nothing and may be overwritten by the user.
  148593. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  148594. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  148595. * @param update the boolean update value actually passed to setParticles()
  148596. */
  148597. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  148598. }
  148599. }
  148600. declare module BABYLON {
  148601. /**
  148602. * Represents one particle of a points cloud system.
  148603. */
  148604. export class CloudPoint {
  148605. /**
  148606. * particle global index
  148607. */
  148608. idx: number;
  148609. /**
  148610. * The color of the particle
  148611. */
  148612. color: Nullable<Color4>;
  148613. /**
  148614. * The world space position of the particle.
  148615. */
  148616. position: Vector3;
  148617. /**
  148618. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  148619. */
  148620. rotation: Vector3;
  148621. /**
  148622. * The world space rotation quaternion of the particle.
  148623. */
  148624. rotationQuaternion: Nullable<Quaternion>;
  148625. /**
  148626. * The uv of the particle.
  148627. */
  148628. uv: Nullable<Vector2>;
  148629. /**
  148630. * The current speed of the particle.
  148631. */
  148632. velocity: Vector3;
  148633. /**
  148634. * The pivot point in the particle local space.
  148635. */
  148636. pivot: Vector3;
  148637. /**
  148638. * Must the particle be translated from its pivot point in its local space ?
  148639. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  148640. * Default : false
  148641. */
  148642. translateFromPivot: boolean;
  148643. /**
  148644. * Index of this particle in the global "positions" array (Internal use)
  148645. * @hidden
  148646. */
  148647. _pos: number;
  148648. /**
  148649. * @hidden Index of this particle in the global "indices" array (Internal use)
  148650. */
  148651. _ind: number;
  148652. /**
  148653. * Group this particle belongs to
  148654. */
  148655. _group: PointsGroup;
  148656. /**
  148657. * Group id of this particle
  148658. */
  148659. groupId: number;
  148660. /**
  148661. * Index of the particle in its group id (Internal use)
  148662. */
  148663. idxInGroup: number;
  148664. /**
  148665. * @hidden Particle BoundingInfo object (Internal use)
  148666. */
  148667. _boundingInfo: BoundingInfo;
  148668. /**
  148669. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  148670. */
  148671. _pcs: PointsCloudSystem;
  148672. /**
  148673. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  148674. */
  148675. _stillInvisible: boolean;
  148676. /**
  148677. * @hidden Last computed particle rotation matrix
  148678. */
  148679. _rotationMatrix: number[];
  148680. /**
  148681. * Parent particle Id, if any.
  148682. * Default null.
  148683. */
  148684. parentId: Nullable<number>;
  148685. /**
  148686. * @hidden Internal global position in the PCS.
  148687. */
  148688. _globalPosition: Vector3;
  148689. /**
  148690. * Creates a Point Cloud object.
  148691. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  148692. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  148693. * @param group (PointsGroup) is the group the particle belongs to
  148694. * @param groupId (integer) is the group identifier in the PCS.
  148695. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  148696. * @param pcs defines the PCS it is associated to
  148697. */
  148698. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  148699. /**
  148700. * get point size
  148701. */
  148702. get size(): Vector3;
  148703. /**
  148704. * Set point size
  148705. */
  148706. set size(scale: Vector3);
  148707. /**
  148708. * Legacy support, changed quaternion to rotationQuaternion
  148709. */
  148710. get quaternion(): Nullable<Quaternion>;
  148711. /**
  148712. * Legacy support, changed quaternion to rotationQuaternion
  148713. */
  148714. set quaternion(q: Nullable<Quaternion>);
  148715. /**
  148716. * Returns a boolean. True if the particle intersects a mesh, else false
  148717. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  148718. * @param target is the object (point or mesh) what the intersection is computed against
  148719. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  148720. * @returns true if it intersects
  148721. */
  148722. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  148723. /**
  148724. * get the rotation matrix of the particle
  148725. * @hidden
  148726. */
  148727. getRotationMatrix(m: Matrix): void;
  148728. }
  148729. /**
  148730. * Represents a group of points in a points cloud system
  148731. * * PCS internal tool, don't use it manually.
  148732. */
  148733. export class PointsGroup {
  148734. /**
  148735. * The group id
  148736. * @hidden
  148737. */
  148738. groupID: number;
  148739. /**
  148740. * image data for group (internal use)
  148741. * @hidden
  148742. */
  148743. _groupImageData: Nullable<ArrayBufferView>;
  148744. /**
  148745. * Image Width (internal use)
  148746. * @hidden
  148747. */
  148748. _groupImgWidth: number;
  148749. /**
  148750. * Image Height (internal use)
  148751. * @hidden
  148752. */
  148753. _groupImgHeight: number;
  148754. /**
  148755. * Custom position function (internal use)
  148756. * @hidden
  148757. */
  148758. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  148759. /**
  148760. * density per facet for surface points
  148761. * @hidden
  148762. */
  148763. _groupDensity: number[];
  148764. /**
  148765. * Only when points are colored by texture carries pointer to texture list array
  148766. * @hidden
  148767. */
  148768. _textureNb: number;
  148769. /**
  148770. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  148771. * PCS internal tool, don't use it manually.
  148772. * @hidden
  148773. */
  148774. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  148775. }
  148776. }
  148777. declare module BABYLON {
  148778. interface Scene {
  148779. /** @hidden (Backing field) */
  148780. _physicsEngine: Nullable<IPhysicsEngine>;
  148781. /** @hidden */
  148782. _physicsTimeAccumulator: number;
  148783. /**
  148784. * Gets the current physics engine
  148785. * @returns a IPhysicsEngine or null if none attached
  148786. */
  148787. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  148788. /**
  148789. * Enables physics to the current scene
  148790. * @param gravity defines the scene's gravity for the physics engine
  148791. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  148792. * @return a boolean indicating if the physics engine was initialized
  148793. */
  148794. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  148795. /**
  148796. * Disables and disposes the physics engine associated with the scene
  148797. */
  148798. disablePhysicsEngine(): void;
  148799. /**
  148800. * Gets a boolean indicating if there is an active physics engine
  148801. * @returns a boolean indicating if there is an active physics engine
  148802. */
  148803. isPhysicsEnabled(): boolean;
  148804. /**
  148805. * Deletes a physics compound impostor
  148806. * @param compound defines the compound to delete
  148807. */
  148808. deleteCompoundImpostor(compound: any): void;
  148809. /**
  148810. * An event triggered when physic simulation is about to be run
  148811. */
  148812. onBeforePhysicsObservable: Observable<Scene>;
  148813. /**
  148814. * An event triggered when physic simulation has been done
  148815. */
  148816. onAfterPhysicsObservable: Observable<Scene>;
  148817. }
  148818. interface AbstractMesh {
  148819. /** @hidden */
  148820. _physicsImpostor: Nullable<PhysicsImpostor>;
  148821. /**
  148822. * Gets or sets impostor used for physic simulation
  148823. * @see https://doc.babylonjs.com/features/physics_engine
  148824. */
  148825. physicsImpostor: Nullable<PhysicsImpostor>;
  148826. /**
  148827. * Gets the current physics impostor
  148828. * @see https://doc.babylonjs.com/features/physics_engine
  148829. * @returns a physics impostor or null
  148830. */
  148831. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  148832. /** Apply a physic impulse to the mesh
  148833. * @param force defines the force to apply
  148834. * @param contactPoint defines where to apply the force
  148835. * @returns the current mesh
  148836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  148837. */
  148838. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  148839. /**
  148840. * Creates a physic joint between two meshes
  148841. * @param otherMesh defines the other mesh to use
  148842. * @param pivot1 defines the pivot to use on this mesh
  148843. * @param pivot2 defines the pivot to use on the other mesh
  148844. * @param options defines additional options (can be plugin dependent)
  148845. * @returns the current mesh
  148846. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  148847. */
  148848. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  148849. /** @hidden */
  148850. _disposePhysicsObserver: Nullable<Observer<Node>>;
  148851. }
  148852. /**
  148853. * Defines the physics engine scene component responsible to manage a physics engine
  148854. */
  148855. export class PhysicsEngineSceneComponent implements ISceneComponent {
  148856. /**
  148857. * The component name helpful to identify the component in the list of scene components.
  148858. */
  148859. readonly name: string;
  148860. /**
  148861. * The scene the component belongs to.
  148862. */
  148863. scene: Scene;
  148864. /**
  148865. * Creates a new instance of the component for the given scene
  148866. * @param scene Defines the scene to register the component in
  148867. */
  148868. constructor(scene: Scene);
  148869. /**
  148870. * Registers the component in a given scene
  148871. */
  148872. register(): void;
  148873. /**
  148874. * Rebuilds the elements related to this component in case of
  148875. * context lost for instance.
  148876. */
  148877. rebuild(): void;
  148878. /**
  148879. * Disposes the component and the associated ressources
  148880. */
  148881. dispose(): void;
  148882. }
  148883. }
  148884. declare module BABYLON {
  148885. /**
  148886. * A helper for physics simulations
  148887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  148888. */
  148889. export class PhysicsHelper {
  148890. private _scene;
  148891. private _physicsEngine;
  148892. /**
  148893. * Initializes the Physics helper
  148894. * @param scene Babylon.js scene
  148895. */
  148896. constructor(scene: Scene);
  148897. /**
  148898. * Applies a radial explosion impulse
  148899. * @param origin the origin of the explosion
  148900. * @param radiusOrEventOptions the radius or the options of radial explosion
  148901. * @param strength the explosion strength
  148902. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148903. * @returns A physics radial explosion event, or null
  148904. */
  148905. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148906. /**
  148907. * Applies a radial explosion force
  148908. * @param origin the origin of the explosion
  148909. * @param radiusOrEventOptions the radius or the options of radial explosion
  148910. * @param strength the explosion strength
  148911. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148912. * @returns A physics radial explosion event, or null
  148913. */
  148914. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  148915. /**
  148916. * Creates a gravitational field
  148917. * @param origin the origin of the explosion
  148918. * @param radiusOrEventOptions the radius or the options of radial explosion
  148919. * @param strength the explosion strength
  148920. * @param falloff possible options: Constant & Linear. Defaults to Constant
  148921. * @returns A physics gravitational field event, or null
  148922. */
  148923. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  148924. /**
  148925. * Creates a physics updraft event
  148926. * @param origin the origin of the updraft
  148927. * @param radiusOrEventOptions the radius or the options of the updraft
  148928. * @param strength the strength of the updraft
  148929. * @param height the height of the updraft
  148930. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  148931. * @returns A physics updraft event, or null
  148932. */
  148933. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  148934. /**
  148935. * Creates a physics vortex event
  148936. * @param origin the of the vortex
  148937. * @param radiusOrEventOptions the radius or the options of the vortex
  148938. * @param strength the strength of the vortex
  148939. * @param height the height of the vortex
  148940. * @returns a Physics vortex event, or null
  148941. * A physics vortex event or null
  148942. */
  148943. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  148944. }
  148945. /**
  148946. * Represents a physics radial explosion event
  148947. */
  148948. class PhysicsRadialExplosionEvent {
  148949. private _scene;
  148950. private _options;
  148951. private _sphere;
  148952. private _dataFetched;
  148953. /**
  148954. * Initializes a radial explosioin event
  148955. * @param _scene BabylonJS scene
  148956. * @param _options The options for the vortex event
  148957. */
  148958. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  148959. /**
  148960. * Returns the data related to the radial explosion event (sphere).
  148961. * @returns The radial explosion event data
  148962. */
  148963. getData(): PhysicsRadialExplosionEventData;
  148964. /**
  148965. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  148966. * @param impostor A physics imposter
  148967. * @param origin the origin of the explosion
  148968. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  148969. */
  148970. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  148971. /**
  148972. * Triggers affecterd impostors callbacks
  148973. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  148974. */
  148975. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  148976. /**
  148977. * Disposes the sphere.
  148978. * @param force Specifies if the sphere should be disposed by force
  148979. */
  148980. dispose(force?: boolean): void;
  148981. /*** Helpers ***/
  148982. private _prepareSphere;
  148983. private _intersectsWithSphere;
  148984. }
  148985. /**
  148986. * Represents a gravitational field event
  148987. */
  148988. class PhysicsGravitationalFieldEvent {
  148989. private _physicsHelper;
  148990. private _scene;
  148991. private _origin;
  148992. private _options;
  148993. private _tickCallback;
  148994. private _sphere;
  148995. private _dataFetched;
  148996. /**
  148997. * Initializes the physics gravitational field event
  148998. * @param _physicsHelper A physics helper
  148999. * @param _scene BabylonJS scene
  149000. * @param _origin The origin position of the gravitational field event
  149001. * @param _options The options for the vortex event
  149002. */
  149003. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149004. /**
  149005. * Returns the data related to the gravitational field event (sphere).
  149006. * @returns A gravitational field event
  149007. */
  149008. getData(): PhysicsGravitationalFieldEventData;
  149009. /**
  149010. * Enables the gravitational field.
  149011. */
  149012. enable(): void;
  149013. /**
  149014. * Disables the gravitational field.
  149015. */
  149016. disable(): void;
  149017. /**
  149018. * Disposes the sphere.
  149019. * @param force The force to dispose from the gravitational field event
  149020. */
  149021. dispose(force?: boolean): void;
  149022. private _tick;
  149023. }
  149024. /**
  149025. * Represents a physics updraft event
  149026. */
  149027. class PhysicsUpdraftEvent {
  149028. private _scene;
  149029. private _origin;
  149030. private _options;
  149031. private _physicsEngine;
  149032. private _originTop;
  149033. private _originDirection;
  149034. private _tickCallback;
  149035. private _cylinder;
  149036. private _cylinderPosition;
  149037. private _dataFetched;
  149038. /**
  149039. * Initializes the physics updraft event
  149040. * @param _scene BabylonJS scene
  149041. * @param _origin The origin position of the updraft
  149042. * @param _options The options for the updraft event
  149043. */
  149044. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149045. /**
  149046. * Returns the data related to the updraft event (cylinder).
  149047. * @returns A physics updraft event
  149048. */
  149049. getData(): PhysicsUpdraftEventData;
  149050. /**
  149051. * Enables the updraft.
  149052. */
  149053. enable(): void;
  149054. /**
  149055. * Disables the updraft.
  149056. */
  149057. disable(): void;
  149058. /**
  149059. * Disposes the cylinder.
  149060. * @param force Specifies if the updraft should be disposed by force
  149061. */
  149062. dispose(force?: boolean): void;
  149063. private getImpostorHitData;
  149064. private _tick;
  149065. /*** Helpers ***/
  149066. private _prepareCylinder;
  149067. private _intersectsWithCylinder;
  149068. }
  149069. /**
  149070. * Represents a physics vortex event
  149071. */
  149072. class PhysicsVortexEvent {
  149073. private _scene;
  149074. private _origin;
  149075. private _options;
  149076. private _physicsEngine;
  149077. private _originTop;
  149078. private _tickCallback;
  149079. private _cylinder;
  149080. private _cylinderPosition;
  149081. private _dataFetched;
  149082. /**
  149083. * Initializes the physics vortex event
  149084. * @param _scene The BabylonJS scene
  149085. * @param _origin The origin position of the vortex
  149086. * @param _options The options for the vortex event
  149087. */
  149088. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149089. /**
  149090. * Returns the data related to the vortex event (cylinder).
  149091. * @returns The physics vortex event data
  149092. */
  149093. getData(): PhysicsVortexEventData;
  149094. /**
  149095. * Enables the vortex.
  149096. */
  149097. enable(): void;
  149098. /**
  149099. * Disables the cortex.
  149100. */
  149101. disable(): void;
  149102. /**
  149103. * Disposes the sphere.
  149104. * @param force
  149105. */
  149106. dispose(force?: boolean): void;
  149107. private getImpostorHitData;
  149108. private _tick;
  149109. /*** Helpers ***/
  149110. private _prepareCylinder;
  149111. private _intersectsWithCylinder;
  149112. }
  149113. /**
  149114. * Options fot the radial explosion event
  149115. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149116. */
  149117. export class PhysicsRadialExplosionEventOptions {
  149118. /**
  149119. * The radius of the sphere for the radial explosion.
  149120. */
  149121. radius: number;
  149122. /**
  149123. * The strenth of the explosion.
  149124. */
  149125. strength: number;
  149126. /**
  149127. * The strenght of the force in correspondence to the distance of the affected object
  149128. */
  149129. falloff: PhysicsRadialImpulseFalloff;
  149130. /**
  149131. * Sphere options for the radial explosion.
  149132. */
  149133. sphere: {
  149134. segments: number;
  149135. diameter: number;
  149136. };
  149137. /**
  149138. * Sphere options for the radial explosion.
  149139. */
  149140. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149141. }
  149142. /**
  149143. * Options fot the updraft event
  149144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149145. */
  149146. export class PhysicsUpdraftEventOptions {
  149147. /**
  149148. * The radius of the cylinder for the vortex
  149149. */
  149150. radius: number;
  149151. /**
  149152. * The strenth of the updraft.
  149153. */
  149154. strength: number;
  149155. /**
  149156. * The height of the cylinder for the updraft.
  149157. */
  149158. height: number;
  149159. /**
  149160. * The mode for the the updraft.
  149161. */
  149162. updraftMode: PhysicsUpdraftMode;
  149163. }
  149164. /**
  149165. * Options fot the vortex event
  149166. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149167. */
  149168. export class PhysicsVortexEventOptions {
  149169. /**
  149170. * The radius of the cylinder for the vortex
  149171. */
  149172. radius: number;
  149173. /**
  149174. * The strenth of the vortex.
  149175. */
  149176. strength: number;
  149177. /**
  149178. * The height of the cylinder for the vortex.
  149179. */
  149180. height: number;
  149181. /**
  149182. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149183. */
  149184. centripetalForceThreshold: number;
  149185. /**
  149186. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149187. */
  149188. centripetalForceMultiplier: number;
  149189. /**
  149190. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149191. */
  149192. centrifugalForceMultiplier: number;
  149193. /**
  149194. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149195. */
  149196. updraftForceMultiplier: number;
  149197. }
  149198. /**
  149199. * The strenght of the force in correspondence to the distance of the affected object
  149200. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149201. */
  149202. export enum PhysicsRadialImpulseFalloff {
  149203. /** Defines that impulse is constant in strength across it's whole radius */
  149204. Constant = 0,
  149205. /** Defines that impulse gets weaker if it's further from the origin */
  149206. Linear = 1
  149207. }
  149208. /**
  149209. * The strength of the force in correspondence to the distance of the affected object
  149210. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149211. */
  149212. export enum PhysicsUpdraftMode {
  149213. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149214. Center = 0,
  149215. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149216. Perpendicular = 1
  149217. }
  149218. /**
  149219. * Interface for a physics hit data
  149220. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149221. */
  149222. export interface PhysicsHitData {
  149223. /**
  149224. * The force applied at the contact point
  149225. */
  149226. force: Vector3;
  149227. /**
  149228. * The contact point
  149229. */
  149230. contactPoint: Vector3;
  149231. /**
  149232. * The distance from the origin to the contact point
  149233. */
  149234. distanceFromOrigin: number;
  149235. }
  149236. /**
  149237. * Interface for radial explosion event data
  149238. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149239. */
  149240. export interface PhysicsRadialExplosionEventData {
  149241. /**
  149242. * A sphere used for the radial explosion event
  149243. */
  149244. sphere: Mesh;
  149245. }
  149246. /**
  149247. * Interface for gravitational field event data
  149248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149249. */
  149250. export interface PhysicsGravitationalFieldEventData {
  149251. /**
  149252. * A sphere mesh used for the gravitational field event
  149253. */
  149254. sphere: Mesh;
  149255. }
  149256. /**
  149257. * Interface for updraft event data
  149258. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149259. */
  149260. export interface PhysicsUpdraftEventData {
  149261. /**
  149262. * A cylinder used for the updraft event
  149263. */
  149264. cylinder: Mesh;
  149265. }
  149266. /**
  149267. * Interface for vortex event data
  149268. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149269. */
  149270. export interface PhysicsVortexEventData {
  149271. /**
  149272. * A cylinder used for the vortex event
  149273. */
  149274. cylinder: Mesh;
  149275. }
  149276. /**
  149277. * Interface for an affected physics impostor
  149278. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149279. */
  149280. export interface PhysicsAffectedImpostorWithData {
  149281. /**
  149282. * The impostor affected by the effect
  149283. */
  149284. impostor: PhysicsImpostor;
  149285. /**
  149286. * The data about the hit/horce from the explosion
  149287. */
  149288. hitData: PhysicsHitData;
  149289. }
  149290. }
  149291. declare module BABYLON {
  149292. /** @hidden */
  149293. export var blackAndWhitePixelShader: {
  149294. name: string;
  149295. shader: string;
  149296. };
  149297. }
  149298. declare module BABYLON {
  149299. /**
  149300. * Post process used to render in black and white
  149301. */
  149302. export class BlackAndWhitePostProcess extends PostProcess {
  149303. /**
  149304. * Linear about to convert he result to black and white (default: 1)
  149305. */
  149306. degree: number;
  149307. /**
  149308. * Gets a string identifying the name of the class
  149309. * @returns "BlackAndWhitePostProcess" string
  149310. */
  149311. getClassName(): string;
  149312. /**
  149313. * Creates a black and white post process
  149314. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149315. * @param name The name of the effect.
  149316. * @param options The required width/height ratio to downsize to before computing the render pass.
  149317. * @param camera The camera to apply the render pass to.
  149318. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149319. * @param engine The engine which the post process will be applied. (default: current engine)
  149320. * @param reusable If the post process can be reused on the same frame. (default: false)
  149321. */
  149322. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149323. /** @hidden */
  149324. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149325. }
  149326. }
  149327. declare module BABYLON {
  149328. /**
  149329. * This represents a set of one or more post processes in Babylon.
  149330. * A post process can be used to apply a shader to a texture after it is rendered.
  149331. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149332. */
  149333. export class PostProcessRenderEffect {
  149334. private _postProcesses;
  149335. private _getPostProcesses;
  149336. private _singleInstance;
  149337. private _cameras;
  149338. private _indicesForCamera;
  149339. /**
  149340. * Name of the effect
  149341. * @hidden
  149342. */
  149343. _name: string;
  149344. /**
  149345. * Instantiates a post process render effect.
  149346. * A post process can be used to apply a shader to a texture after it is rendered.
  149347. * @param engine The engine the effect is tied to
  149348. * @param name The name of the effect
  149349. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149350. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149351. */
  149352. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149353. /**
  149354. * Checks if all the post processes in the effect are supported.
  149355. */
  149356. get isSupported(): boolean;
  149357. /**
  149358. * Updates the current state of the effect
  149359. * @hidden
  149360. */
  149361. _update(): void;
  149362. /**
  149363. * Attaches the effect on cameras
  149364. * @param cameras The camera to attach to.
  149365. * @hidden
  149366. */
  149367. _attachCameras(cameras: Camera): void;
  149368. /**
  149369. * Attaches the effect on cameras
  149370. * @param cameras The camera to attach to.
  149371. * @hidden
  149372. */
  149373. _attachCameras(cameras: Camera[]): void;
  149374. /**
  149375. * Detaches the effect on cameras
  149376. * @param cameras The camera to detatch from.
  149377. * @hidden
  149378. */
  149379. _detachCameras(cameras: Camera): void;
  149380. /**
  149381. * Detatches the effect on cameras
  149382. * @param cameras The camera to detatch from.
  149383. * @hidden
  149384. */
  149385. _detachCameras(cameras: Camera[]): void;
  149386. /**
  149387. * Enables the effect on given cameras
  149388. * @param cameras The camera to enable.
  149389. * @hidden
  149390. */
  149391. _enable(cameras: Camera): void;
  149392. /**
  149393. * Enables the effect on given cameras
  149394. * @param cameras The camera to enable.
  149395. * @hidden
  149396. */
  149397. _enable(cameras: Nullable<Camera[]>): void;
  149398. /**
  149399. * Disables the effect on the given cameras
  149400. * @param cameras The camera to disable.
  149401. * @hidden
  149402. */
  149403. _disable(cameras: Camera): void;
  149404. /**
  149405. * Disables the effect on the given cameras
  149406. * @param cameras The camera to disable.
  149407. * @hidden
  149408. */
  149409. _disable(cameras: Nullable<Camera[]>): void;
  149410. /**
  149411. * Gets a list of the post processes contained in the effect.
  149412. * @param camera The camera to get the post processes on.
  149413. * @returns The list of the post processes in the effect.
  149414. */
  149415. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149416. }
  149417. }
  149418. declare module BABYLON {
  149419. /** @hidden */
  149420. export var extractHighlightsPixelShader: {
  149421. name: string;
  149422. shader: string;
  149423. };
  149424. }
  149425. declare module BABYLON {
  149426. /**
  149427. * 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.
  149428. */
  149429. export class ExtractHighlightsPostProcess extends PostProcess {
  149430. /**
  149431. * The luminance threshold, pixels below this value will be set to black.
  149432. */
  149433. threshold: number;
  149434. /** @hidden */
  149435. _exposure: number;
  149436. /**
  149437. * Post process which has the input texture to be used when performing highlight extraction
  149438. * @hidden
  149439. */
  149440. _inputPostProcess: Nullable<PostProcess>;
  149441. /**
  149442. * Gets a string identifying the name of the class
  149443. * @returns "ExtractHighlightsPostProcess" string
  149444. */
  149445. getClassName(): string;
  149446. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149447. }
  149448. }
  149449. declare module BABYLON {
  149450. /** @hidden */
  149451. export var bloomMergePixelShader: {
  149452. name: string;
  149453. shader: string;
  149454. };
  149455. }
  149456. declare module BABYLON {
  149457. /**
  149458. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149459. */
  149460. export class BloomMergePostProcess extends PostProcess {
  149461. /** Weight of the bloom to be added to the original input. */
  149462. weight: number;
  149463. /**
  149464. * Gets a string identifying the name of the class
  149465. * @returns "BloomMergePostProcess" string
  149466. */
  149467. getClassName(): string;
  149468. /**
  149469. * Creates a new instance of @see BloomMergePostProcess
  149470. * @param name The name of the effect.
  149471. * @param originalFromInput Post process which's input will be used for the merge.
  149472. * @param blurred Blurred highlights post process which's output will be used.
  149473. * @param weight Weight of the bloom to be added to the original input.
  149474. * @param options The required width/height ratio to downsize to before computing the render pass.
  149475. * @param camera The camera to apply the render pass to.
  149476. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149477. * @param engine The engine which the post process will be applied. (default: current engine)
  149478. * @param reusable If the post process can be reused on the same frame. (default: false)
  149479. * @param textureType Type of textures used when performing the post process. (default: 0)
  149480. * @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)
  149481. */
  149482. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149483. /** Weight of the bloom to be added to the original input. */
  149484. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149485. }
  149486. }
  149487. declare module BABYLON {
  149488. /**
  149489. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149490. */
  149491. export class BloomEffect extends PostProcessRenderEffect {
  149492. private bloomScale;
  149493. /**
  149494. * @hidden Internal
  149495. */
  149496. _effects: Array<PostProcess>;
  149497. /**
  149498. * @hidden Internal
  149499. */
  149500. _downscale: ExtractHighlightsPostProcess;
  149501. private _blurX;
  149502. private _blurY;
  149503. private _merge;
  149504. /**
  149505. * The luminance threshold to find bright areas of the image to bloom.
  149506. */
  149507. get threshold(): number;
  149508. set threshold(value: number);
  149509. /**
  149510. * The strength of the bloom.
  149511. */
  149512. get weight(): number;
  149513. set weight(value: number);
  149514. /**
  149515. * Specifies the size of the bloom blur kernel, relative to the final output size
  149516. */
  149517. get kernel(): number;
  149518. set kernel(value: number);
  149519. /**
  149520. * Creates a new instance of @see BloomEffect
  149521. * @param scene The scene the effect belongs to.
  149522. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149523. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149524. * @param bloomWeight The the strength of bloom.
  149525. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149526. * @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)
  149527. */
  149528. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149529. /**
  149530. * Disposes each of the internal effects for a given camera.
  149531. * @param camera The camera to dispose the effect on.
  149532. */
  149533. disposeEffects(camera: Camera): void;
  149534. /**
  149535. * @hidden Internal
  149536. */
  149537. _updateEffects(): void;
  149538. /**
  149539. * Internal
  149540. * @returns if all the contained post processes are ready.
  149541. * @hidden
  149542. */
  149543. _isReady(): boolean;
  149544. }
  149545. }
  149546. declare module BABYLON {
  149547. /** @hidden */
  149548. export var chromaticAberrationPixelShader: {
  149549. name: string;
  149550. shader: string;
  149551. };
  149552. }
  149553. declare module BABYLON {
  149554. /**
  149555. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149556. */
  149557. export class ChromaticAberrationPostProcess extends PostProcess {
  149558. /**
  149559. * The amount of seperation of rgb channels (default: 30)
  149560. */
  149561. aberrationAmount: number;
  149562. /**
  149563. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149564. */
  149565. radialIntensity: number;
  149566. /**
  149567. * 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))
  149568. */
  149569. direction: Vector2;
  149570. /**
  149571. * 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))
  149572. */
  149573. centerPosition: Vector2;
  149574. /** The width of the screen to apply the effect on */
  149575. screenWidth: number;
  149576. /** The height of the screen to apply the effect on */
  149577. screenHeight: number;
  149578. /**
  149579. * Gets a string identifying the name of the class
  149580. * @returns "ChromaticAberrationPostProcess" string
  149581. */
  149582. getClassName(): string;
  149583. /**
  149584. * Creates a new instance ChromaticAberrationPostProcess
  149585. * @param name The name of the effect.
  149586. * @param screenWidth The width of the screen to apply the effect on.
  149587. * @param screenHeight The height of the screen to apply the effect on.
  149588. * @param options The required width/height ratio to downsize to before computing the render pass.
  149589. * @param camera The camera to apply the render pass to.
  149590. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149591. * @param engine The engine which the post process will be applied. (default: current engine)
  149592. * @param reusable If the post process can be reused on the same frame. (default: false)
  149593. * @param textureType Type of textures used when performing the post process. (default: 0)
  149594. * @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)
  149595. */
  149596. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149597. /** @hidden */
  149598. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  149599. }
  149600. }
  149601. declare module BABYLON {
  149602. /** @hidden */
  149603. export var circleOfConfusionPixelShader: {
  149604. name: string;
  149605. shader: string;
  149606. };
  149607. }
  149608. declare module BABYLON {
  149609. /**
  149610. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  149611. */
  149612. export class CircleOfConfusionPostProcess extends PostProcess {
  149613. /**
  149614. * 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.
  149615. */
  149616. lensSize: number;
  149617. /**
  149618. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149619. */
  149620. fStop: number;
  149621. /**
  149622. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149623. */
  149624. focusDistance: number;
  149625. /**
  149626. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  149627. */
  149628. focalLength: number;
  149629. /**
  149630. * Gets a string identifying the name of the class
  149631. * @returns "CircleOfConfusionPostProcess" string
  149632. */
  149633. getClassName(): string;
  149634. private _depthTexture;
  149635. /**
  149636. * Creates a new instance CircleOfConfusionPostProcess
  149637. * @param name The name of the effect.
  149638. * @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.
  149639. * @param options The required width/height ratio to downsize to before computing the render pass.
  149640. * @param camera The camera to apply the render pass to.
  149641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149642. * @param engine The engine which the post process will be applied. (default: current engine)
  149643. * @param reusable If the post process can be reused on the same frame. (default: false)
  149644. * @param textureType Type of textures used when performing the post process. (default: 0)
  149645. * @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)
  149646. */
  149647. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149648. /**
  149649. * 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.
  149650. */
  149651. set depthTexture(value: RenderTargetTexture);
  149652. }
  149653. }
  149654. declare module BABYLON {
  149655. /** @hidden */
  149656. export var colorCorrectionPixelShader: {
  149657. name: string;
  149658. shader: string;
  149659. };
  149660. }
  149661. declare module BABYLON {
  149662. /**
  149663. *
  149664. * This post-process allows the modification of rendered colors by using
  149665. * a 'look-up table' (LUT). This effect is also called Color Grading.
  149666. *
  149667. * The object needs to be provided an url to a texture containing the color
  149668. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  149669. * Use an image editing software to tweak the LUT to match your needs.
  149670. *
  149671. * For an example of a color LUT, see here:
  149672. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  149673. * For explanations on color grading, see here:
  149674. * @see http://udn.epicgames.com/Three/ColorGrading.html
  149675. *
  149676. */
  149677. export class ColorCorrectionPostProcess extends PostProcess {
  149678. private _colorTableTexture;
  149679. /**
  149680. * Gets the color table url used to create the LUT texture
  149681. */
  149682. colorTableUrl: string;
  149683. /**
  149684. * Gets a string identifying the name of the class
  149685. * @returns "ColorCorrectionPostProcess" string
  149686. */
  149687. getClassName(): string;
  149688. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149689. /** @hidden */
  149690. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  149691. }
  149692. }
  149693. declare module BABYLON {
  149694. /** @hidden */
  149695. export var convolutionPixelShader: {
  149696. name: string;
  149697. shader: string;
  149698. };
  149699. }
  149700. declare module BABYLON {
  149701. /**
  149702. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  149703. * input texture to perform effects such as edge detection or sharpening
  149704. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  149705. */
  149706. export class ConvolutionPostProcess extends PostProcess {
  149707. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  149708. kernel: number[];
  149709. /**
  149710. * Gets a string identifying the name of the class
  149711. * @returns "ConvolutionPostProcess" string
  149712. */
  149713. getClassName(): string;
  149714. /**
  149715. * Creates a new instance ConvolutionPostProcess
  149716. * @param name The name of the effect.
  149717. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  149718. * @param options The required width/height ratio to downsize to before computing the render pass.
  149719. * @param camera The camera to apply the render pass to.
  149720. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149721. * @param engine The engine which the post process will be applied. (default: current engine)
  149722. * @param reusable If the post process can be reused on the same frame. (default: false)
  149723. * @param textureType Type of textures used when performing the post process. (default: 0)
  149724. */
  149725. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  149726. /** @hidden */
  149727. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  149728. /**
  149729. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149730. */
  149731. static EdgeDetect0Kernel: number[];
  149732. /**
  149733. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149734. */
  149735. static EdgeDetect1Kernel: number[];
  149736. /**
  149737. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149738. */
  149739. static EdgeDetect2Kernel: number[];
  149740. /**
  149741. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149742. */
  149743. static SharpenKernel: number[];
  149744. /**
  149745. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149746. */
  149747. static EmbossKernel: number[];
  149748. /**
  149749. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  149750. */
  149751. static GaussianKernel: number[];
  149752. }
  149753. }
  149754. declare module BABYLON {
  149755. /**
  149756. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  149757. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  149758. * based on samples that have a large difference in distance than the center pixel.
  149759. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  149760. */
  149761. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  149762. /**
  149763. * The direction the blur should be applied
  149764. */
  149765. direction: Vector2;
  149766. /**
  149767. * Gets a string identifying the name of the class
  149768. * @returns "DepthOfFieldBlurPostProcess" string
  149769. */
  149770. getClassName(): string;
  149771. /**
  149772. * Creates a new instance CircleOfConfusionPostProcess
  149773. * @param name The name of the effect.
  149774. * @param scene The scene the effect belongs to.
  149775. * @param direction The direction the blur should be applied.
  149776. * @param kernel The size of the kernel used to blur.
  149777. * @param options The required width/height ratio to downsize to before computing the render pass.
  149778. * @param camera The camera to apply the render pass to.
  149779. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  149780. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  149781. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149782. * @param engine The engine which the post process will be applied. (default: current engine)
  149783. * @param reusable If the post process can be reused on the same frame. (default: false)
  149784. * @param textureType Type of textures used when performing the post process. (default: 0)
  149785. * @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)
  149786. */
  149787. 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);
  149788. }
  149789. }
  149790. declare module BABYLON {
  149791. /** @hidden */
  149792. export var depthOfFieldMergePixelShader: {
  149793. name: string;
  149794. shader: string;
  149795. };
  149796. }
  149797. declare module BABYLON {
  149798. /**
  149799. * Options to be set when merging outputs from the default pipeline.
  149800. */
  149801. export class DepthOfFieldMergePostProcessOptions {
  149802. /**
  149803. * The original image to merge on top of
  149804. */
  149805. originalFromInput: PostProcess;
  149806. /**
  149807. * Parameters to perform the merge of the depth of field effect
  149808. */
  149809. depthOfField?: {
  149810. circleOfConfusion: PostProcess;
  149811. blurSteps: Array<PostProcess>;
  149812. };
  149813. /**
  149814. * Parameters to perform the merge of bloom effect
  149815. */
  149816. bloom?: {
  149817. blurred: PostProcess;
  149818. weight: number;
  149819. };
  149820. }
  149821. /**
  149822. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149823. */
  149824. export class DepthOfFieldMergePostProcess extends PostProcess {
  149825. private blurSteps;
  149826. /**
  149827. * Gets a string identifying the name of the class
  149828. * @returns "DepthOfFieldMergePostProcess" string
  149829. */
  149830. getClassName(): string;
  149831. /**
  149832. * Creates a new instance of DepthOfFieldMergePostProcess
  149833. * @param name The name of the effect.
  149834. * @param originalFromInput Post process which's input will be used for the merge.
  149835. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  149836. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  149837. * @param options The required width/height ratio to downsize to before computing the render pass.
  149838. * @param camera The camera to apply the render pass to.
  149839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149840. * @param engine The engine which the post process will be applied. (default: current engine)
  149841. * @param reusable If the post process can be reused on the same frame. (default: false)
  149842. * @param textureType Type of textures used when performing the post process. (default: 0)
  149843. * @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)
  149844. */
  149845. 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);
  149846. /**
  149847. * Updates the effect with the current post process compile time values and recompiles the shader.
  149848. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  149849. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  149850. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  149851. * @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
  149852. * @param onCompiled Called when the shader has been compiled.
  149853. * @param onError Called if there is an error when compiling a shader.
  149854. */
  149855. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  149856. }
  149857. }
  149858. declare module BABYLON {
  149859. /**
  149860. * Specifies the level of max blur that should be applied when using the depth of field effect
  149861. */
  149862. export enum DepthOfFieldEffectBlurLevel {
  149863. /**
  149864. * Subtle blur
  149865. */
  149866. Low = 0,
  149867. /**
  149868. * Medium blur
  149869. */
  149870. Medium = 1,
  149871. /**
  149872. * Large blur
  149873. */
  149874. High = 2
  149875. }
  149876. /**
  149877. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  149878. */
  149879. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  149880. private _circleOfConfusion;
  149881. /**
  149882. * @hidden Internal, blurs from high to low
  149883. */
  149884. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  149885. private _depthOfFieldBlurY;
  149886. private _dofMerge;
  149887. /**
  149888. * @hidden Internal post processes in depth of field effect
  149889. */
  149890. _effects: Array<PostProcess>;
  149891. /**
  149892. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  149893. */
  149894. set focalLength(value: number);
  149895. get focalLength(): number;
  149896. /**
  149897. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  149898. */
  149899. set fStop(value: number);
  149900. get fStop(): number;
  149901. /**
  149902. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  149903. */
  149904. set focusDistance(value: number);
  149905. get focusDistance(): number;
  149906. /**
  149907. * 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.
  149908. */
  149909. set lensSize(value: number);
  149910. get lensSize(): number;
  149911. /**
  149912. * Creates a new instance DepthOfFieldEffect
  149913. * @param scene The scene the effect belongs to.
  149914. * @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.
  149915. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149916. * @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)
  149917. */
  149918. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  149919. /**
  149920. * Get the current class name of the current effet
  149921. * @returns "DepthOfFieldEffect"
  149922. */
  149923. getClassName(): string;
  149924. /**
  149925. * 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.
  149926. */
  149927. set depthTexture(value: RenderTargetTexture);
  149928. /**
  149929. * Disposes each of the internal effects for a given camera.
  149930. * @param camera The camera to dispose the effect on.
  149931. */
  149932. disposeEffects(camera: Camera): void;
  149933. /**
  149934. * @hidden Internal
  149935. */
  149936. _updateEffects(): void;
  149937. /**
  149938. * Internal
  149939. * @returns if all the contained post processes are ready.
  149940. * @hidden
  149941. */
  149942. _isReady(): boolean;
  149943. }
  149944. }
  149945. declare module BABYLON {
  149946. /** @hidden */
  149947. export var displayPassPixelShader: {
  149948. name: string;
  149949. shader: string;
  149950. };
  149951. }
  149952. declare module BABYLON {
  149953. /**
  149954. * DisplayPassPostProcess which produces an output the same as it's input
  149955. */
  149956. export class DisplayPassPostProcess extends PostProcess {
  149957. /**
  149958. * Gets a string identifying the name of the class
  149959. * @returns "DisplayPassPostProcess" string
  149960. */
  149961. getClassName(): string;
  149962. /**
  149963. * Creates the DisplayPassPostProcess
  149964. * @param name The name of the effect.
  149965. * @param options The required width/height ratio to downsize to before computing the render pass.
  149966. * @param camera The camera to apply the render pass to.
  149967. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149968. * @param engine The engine which the post process will be applied. (default: current engine)
  149969. * @param reusable If the post process can be reused on the same frame. (default: false)
  149970. */
  149971. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149972. /** @hidden */
  149973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  149974. }
  149975. }
  149976. declare module BABYLON {
  149977. /** @hidden */
  149978. export var filterPixelShader: {
  149979. name: string;
  149980. shader: string;
  149981. };
  149982. }
  149983. declare module BABYLON {
  149984. /**
  149985. * Applies a kernel filter to the image
  149986. */
  149987. export class FilterPostProcess extends PostProcess {
  149988. /** The matrix to be applied to the image */
  149989. kernelMatrix: Matrix;
  149990. /**
  149991. * Gets a string identifying the name of the class
  149992. * @returns "FilterPostProcess" string
  149993. */
  149994. getClassName(): string;
  149995. /**
  149996. *
  149997. * @param name The name of the effect.
  149998. * @param kernelMatrix The matrix to be applied to the image
  149999. * @param options The required width/height ratio to downsize to before computing the render pass.
  150000. * @param camera The camera to apply the render pass to.
  150001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150002. * @param engine The engine which the post process will be applied. (default: current engine)
  150003. * @param reusable If the post process can be reused on the same frame. (default: false)
  150004. */
  150005. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150006. /** @hidden */
  150007. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150008. }
  150009. }
  150010. declare module BABYLON {
  150011. /** @hidden */
  150012. export var fxaaPixelShader: {
  150013. name: string;
  150014. shader: string;
  150015. };
  150016. }
  150017. declare module BABYLON {
  150018. /** @hidden */
  150019. export var fxaaVertexShader: {
  150020. name: string;
  150021. shader: string;
  150022. };
  150023. }
  150024. declare module BABYLON {
  150025. /**
  150026. * Fxaa post process
  150027. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150028. */
  150029. export class FxaaPostProcess extends PostProcess {
  150030. /**
  150031. * Gets a string identifying the name of the class
  150032. * @returns "FxaaPostProcess" string
  150033. */
  150034. getClassName(): string;
  150035. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150036. private _getDefines;
  150037. /** @hidden */
  150038. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150039. }
  150040. }
  150041. declare module BABYLON {
  150042. /** @hidden */
  150043. export var grainPixelShader: {
  150044. name: string;
  150045. shader: string;
  150046. };
  150047. }
  150048. declare module BABYLON {
  150049. /**
  150050. * The GrainPostProcess adds noise to the image at mid luminance levels
  150051. */
  150052. export class GrainPostProcess extends PostProcess {
  150053. /**
  150054. * The intensity of the grain added (default: 30)
  150055. */
  150056. intensity: number;
  150057. /**
  150058. * If the grain should be randomized on every frame
  150059. */
  150060. animated: boolean;
  150061. /**
  150062. * Gets a string identifying the name of the class
  150063. * @returns "GrainPostProcess" string
  150064. */
  150065. getClassName(): string;
  150066. /**
  150067. * Creates a new instance of @see GrainPostProcess
  150068. * @param name The name of the effect.
  150069. * @param options The required width/height ratio to downsize to before computing the render pass.
  150070. * @param camera The camera to apply the render pass to.
  150071. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150072. * @param engine The engine which the post process will be applied. (default: current engine)
  150073. * @param reusable If the post process can be reused on the same frame. (default: false)
  150074. * @param textureType Type of textures used when performing the post process. (default: 0)
  150075. * @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)
  150076. */
  150077. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150078. /** @hidden */
  150079. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150080. }
  150081. }
  150082. declare module BABYLON {
  150083. /** @hidden */
  150084. export var highlightsPixelShader: {
  150085. name: string;
  150086. shader: string;
  150087. };
  150088. }
  150089. declare module BABYLON {
  150090. /**
  150091. * Extracts highlights from the image
  150092. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150093. */
  150094. export class HighlightsPostProcess extends PostProcess {
  150095. /**
  150096. * Gets a string identifying the name of the class
  150097. * @returns "HighlightsPostProcess" string
  150098. */
  150099. getClassName(): string;
  150100. /**
  150101. * Extracts highlights from the image
  150102. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150103. * @param name The name of the effect.
  150104. * @param options The required width/height ratio to downsize to before computing the render pass.
  150105. * @param camera The camera to apply the render pass to.
  150106. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150107. * @param engine The engine which the post process will be applied. (default: current engine)
  150108. * @param reusable If the post process can be reused on the same frame. (default: false)
  150109. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150110. */
  150111. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150112. }
  150113. }
  150114. declare module BABYLON {
  150115. /** @hidden */
  150116. export var mrtFragmentDeclaration: {
  150117. name: string;
  150118. shader: string;
  150119. };
  150120. }
  150121. declare module BABYLON {
  150122. /** @hidden */
  150123. export var geometryPixelShader: {
  150124. name: string;
  150125. shader: string;
  150126. };
  150127. }
  150128. declare module BABYLON {
  150129. /** @hidden */
  150130. export var geometryVertexShader: {
  150131. name: string;
  150132. shader: string;
  150133. };
  150134. }
  150135. declare module BABYLON {
  150136. /** @hidden */
  150137. interface ISavedTransformationMatrix {
  150138. world: Matrix;
  150139. viewProjection: Matrix;
  150140. }
  150141. /**
  150142. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150143. */
  150144. export class GeometryBufferRenderer {
  150145. /**
  150146. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150147. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150148. */
  150149. static readonly POSITION_TEXTURE_TYPE: number;
  150150. /**
  150151. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150152. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150153. */
  150154. static readonly VELOCITY_TEXTURE_TYPE: number;
  150155. /**
  150156. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150157. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150158. */
  150159. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150160. /**
  150161. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150162. * in order to compute objects velocities when enableVelocity is set to "true"
  150163. * @hidden
  150164. */
  150165. _previousTransformationMatrices: {
  150166. [index: number]: ISavedTransformationMatrix;
  150167. };
  150168. /**
  150169. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150170. * in order to compute objects velocities when enableVelocity is set to "true"
  150171. * @hidden
  150172. */
  150173. _previousBonesTransformationMatrices: {
  150174. [index: number]: Float32Array;
  150175. };
  150176. /**
  150177. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150178. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150179. */
  150180. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150181. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150182. renderTransparentMeshes: boolean;
  150183. private _scene;
  150184. private _resizeObserver;
  150185. private _multiRenderTarget;
  150186. private _ratio;
  150187. private _enablePosition;
  150188. private _enableVelocity;
  150189. private _enableReflectivity;
  150190. private _positionIndex;
  150191. private _velocityIndex;
  150192. private _reflectivityIndex;
  150193. protected _effect: Effect;
  150194. protected _cachedDefines: string;
  150195. /**
  150196. * Set the render list (meshes to be rendered) used in the G buffer.
  150197. */
  150198. set renderList(meshes: Mesh[]);
  150199. /**
  150200. * Gets wether or not G buffer are supported by the running hardware.
  150201. * This requires draw buffer supports
  150202. */
  150203. get isSupported(): boolean;
  150204. /**
  150205. * Returns the index of the given texture type in the G-Buffer textures array
  150206. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150207. * @returns the index of the given texture type in the G-Buffer textures array
  150208. */
  150209. getTextureIndex(textureType: number): number;
  150210. /**
  150211. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150212. */
  150213. get enablePosition(): boolean;
  150214. /**
  150215. * Sets whether or not objects positions are enabled for the G buffer.
  150216. */
  150217. set enablePosition(enable: boolean);
  150218. /**
  150219. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150220. */
  150221. get enableVelocity(): boolean;
  150222. /**
  150223. * Sets wether or not objects velocities are enabled for the G buffer.
  150224. */
  150225. set enableVelocity(enable: boolean);
  150226. /**
  150227. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150228. */
  150229. get enableReflectivity(): boolean;
  150230. /**
  150231. * Sets wether or not objects roughness are enabled for the G buffer.
  150232. */
  150233. set enableReflectivity(enable: boolean);
  150234. /**
  150235. * Gets the scene associated with the buffer.
  150236. */
  150237. get scene(): Scene;
  150238. /**
  150239. * Gets the ratio used by the buffer during its creation.
  150240. * How big is the buffer related to the main canvas.
  150241. */
  150242. get ratio(): number;
  150243. /** @hidden */
  150244. static _SceneComponentInitialization: (scene: Scene) => void;
  150245. /**
  150246. * Creates a new G Buffer for the scene
  150247. * @param scene The scene the buffer belongs to
  150248. * @param ratio How big is the buffer related to the main canvas.
  150249. */
  150250. constructor(scene: Scene, ratio?: number);
  150251. /**
  150252. * Checks wether everything is ready to render a submesh to the G buffer.
  150253. * @param subMesh the submesh to check readiness for
  150254. * @param useInstances is the mesh drawn using instance or not
  150255. * @returns true if ready otherwise false
  150256. */
  150257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150258. /**
  150259. * Gets the current underlying G Buffer.
  150260. * @returns the buffer
  150261. */
  150262. getGBuffer(): MultiRenderTarget;
  150263. /**
  150264. * Gets the number of samples used to render the buffer (anti aliasing).
  150265. */
  150266. get samples(): number;
  150267. /**
  150268. * Sets the number of samples used to render the buffer (anti aliasing).
  150269. */
  150270. set samples(value: number);
  150271. /**
  150272. * Disposes the renderer and frees up associated resources.
  150273. */
  150274. dispose(): void;
  150275. protected _createRenderTargets(): void;
  150276. private _copyBonesTransformationMatrices;
  150277. }
  150278. }
  150279. declare module BABYLON {
  150280. interface Scene {
  150281. /** @hidden (Backing field) */
  150282. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150283. /**
  150284. * Gets or Sets the current geometry buffer associated to the scene.
  150285. */
  150286. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150287. /**
  150288. * Enables a GeometryBufferRender and associates it with the scene
  150289. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150290. * @returns the GeometryBufferRenderer
  150291. */
  150292. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150293. /**
  150294. * Disables the GeometryBufferRender associated with the scene
  150295. */
  150296. disableGeometryBufferRenderer(): void;
  150297. }
  150298. /**
  150299. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150300. * in several rendering techniques.
  150301. */
  150302. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150303. /**
  150304. * The component name helpful to identify the component in the list of scene components.
  150305. */
  150306. readonly name: string;
  150307. /**
  150308. * The scene the component belongs to.
  150309. */
  150310. scene: Scene;
  150311. /**
  150312. * Creates a new instance of the component for the given scene
  150313. * @param scene Defines the scene to register the component in
  150314. */
  150315. constructor(scene: Scene);
  150316. /**
  150317. * Registers the component in a given scene
  150318. */
  150319. register(): void;
  150320. /**
  150321. * Rebuilds the elements related to this component in case of
  150322. * context lost for instance.
  150323. */
  150324. rebuild(): void;
  150325. /**
  150326. * Disposes the component and the associated ressources
  150327. */
  150328. dispose(): void;
  150329. private _gatherRenderTargets;
  150330. }
  150331. }
  150332. declare module BABYLON {
  150333. /** @hidden */
  150334. export var motionBlurPixelShader: {
  150335. name: string;
  150336. shader: string;
  150337. };
  150338. }
  150339. declare module BABYLON {
  150340. /**
  150341. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150342. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150343. * As an example, all you have to do is to create the post-process:
  150344. * var mb = new BABYLON.MotionBlurPostProcess(
  150345. * 'mb', // The name of the effect.
  150346. * scene, // The scene containing the objects to blur according to their velocity.
  150347. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150348. * camera // The camera to apply the render pass to.
  150349. * );
  150350. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150351. */
  150352. export class MotionBlurPostProcess extends PostProcess {
  150353. /**
  150354. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150355. */
  150356. motionStrength: number;
  150357. /**
  150358. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150359. */
  150360. get motionBlurSamples(): number;
  150361. /**
  150362. * Sets the number of iterations to be used for motion blur quality
  150363. */
  150364. set motionBlurSamples(samples: number);
  150365. private _motionBlurSamples;
  150366. private _geometryBufferRenderer;
  150367. /**
  150368. * Gets a string identifying the name of the class
  150369. * @returns "MotionBlurPostProcess" string
  150370. */
  150371. getClassName(): string;
  150372. /**
  150373. * Creates a new instance MotionBlurPostProcess
  150374. * @param name The name of the effect.
  150375. * @param scene The scene containing the objects to blur according to their velocity.
  150376. * @param options The required width/height ratio to downsize to before computing the render pass.
  150377. * @param camera The camera to apply the render pass to.
  150378. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150379. * @param engine The engine which the post process will be applied. (default: current engine)
  150380. * @param reusable If the post process can be reused on the same frame. (default: false)
  150381. * @param textureType Type of textures used when performing the post process. (default: 0)
  150382. * @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)
  150383. */
  150384. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150385. /**
  150386. * Excludes the given skinned mesh from computing bones velocities.
  150387. * 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.
  150388. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150389. */
  150390. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150391. /**
  150392. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150393. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150394. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150395. */
  150396. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150397. /**
  150398. * Disposes the post process.
  150399. * @param camera The camera to dispose the post process on.
  150400. */
  150401. dispose(camera?: Camera): void;
  150402. /** @hidden */
  150403. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150404. }
  150405. }
  150406. declare module BABYLON {
  150407. /** @hidden */
  150408. export var refractionPixelShader: {
  150409. name: string;
  150410. shader: string;
  150411. };
  150412. }
  150413. declare module BABYLON {
  150414. /**
  150415. * Post process which applies a refractin texture
  150416. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150417. */
  150418. export class RefractionPostProcess extends PostProcess {
  150419. private _refTexture;
  150420. private _ownRefractionTexture;
  150421. /** the base color of the refraction (used to taint the rendering) */
  150422. color: Color3;
  150423. /** simulated refraction depth */
  150424. depth: number;
  150425. /** the coefficient of the base color (0 to remove base color tainting) */
  150426. colorLevel: number;
  150427. /** Gets the url used to load the refraction texture */
  150428. refractionTextureUrl: string;
  150429. /**
  150430. * Gets or sets the refraction texture
  150431. * Please note that you are responsible for disposing the texture if you set it manually
  150432. */
  150433. get refractionTexture(): Texture;
  150434. set refractionTexture(value: Texture);
  150435. /**
  150436. * Gets a string identifying the name of the class
  150437. * @returns "RefractionPostProcess" string
  150438. */
  150439. getClassName(): string;
  150440. /**
  150441. * Initializes the RefractionPostProcess
  150442. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150443. * @param name The name of the effect.
  150444. * @param refractionTextureUrl Url of the refraction texture to use
  150445. * @param color the base color of the refraction (used to taint the rendering)
  150446. * @param depth simulated refraction depth
  150447. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150448. * @param camera The camera to apply the render pass to.
  150449. * @param options The required width/height ratio to downsize to before computing the render pass.
  150450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150451. * @param engine The engine which the post process will be applied. (default: current engine)
  150452. * @param reusable If the post process can be reused on the same frame. (default: false)
  150453. */
  150454. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150455. /**
  150456. * Disposes of the post process
  150457. * @param camera Camera to dispose post process on
  150458. */
  150459. dispose(camera: Camera): void;
  150460. /** @hidden */
  150461. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150462. }
  150463. }
  150464. declare module BABYLON {
  150465. /** @hidden */
  150466. export var sharpenPixelShader: {
  150467. name: string;
  150468. shader: string;
  150469. };
  150470. }
  150471. declare module BABYLON {
  150472. /**
  150473. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150474. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150475. */
  150476. export class SharpenPostProcess extends PostProcess {
  150477. /**
  150478. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150479. */
  150480. colorAmount: number;
  150481. /**
  150482. * How much sharpness should be applied (default: 0.3)
  150483. */
  150484. edgeAmount: number;
  150485. /**
  150486. * Gets a string identifying the name of the class
  150487. * @returns "SharpenPostProcess" string
  150488. */
  150489. getClassName(): string;
  150490. /**
  150491. * Creates a new instance ConvolutionPostProcess
  150492. * @param name The name of the effect.
  150493. * @param options The required width/height ratio to downsize to before computing the render pass.
  150494. * @param camera The camera to apply the render pass to.
  150495. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150496. * @param engine The engine which the post process will be applied. (default: current engine)
  150497. * @param reusable If the post process can be reused on the same frame. (default: false)
  150498. * @param textureType Type of textures used when performing the post process. (default: 0)
  150499. * @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)
  150500. */
  150501. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150502. /** @hidden */
  150503. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150504. }
  150505. }
  150506. declare module BABYLON {
  150507. /**
  150508. * PostProcessRenderPipeline
  150509. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150510. */
  150511. export class PostProcessRenderPipeline {
  150512. private engine;
  150513. private _renderEffects;
  150514. private _renderEffectsForIsolatedPass;
  150515. /**
  150516. * List of inspectable custom properties (used by the Inspector)
  150517. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150518. */
  150519. inspectableCustomProperties: IInspectable[];
  150520. /**
  150521. * @hidden
  150522. */
  150523. protected _cameras: Camera[];
  150524. /** @hidden */
  150525. _name: string;
  150526. /**
  150527. * Gets pipeline name
  150528. */
  150529. get name(): string;
  150530. /** Gets the list of attached cameras */
  150531. get cameras(): Camera[];
  150532. /**
  150533. * Initializes a PostProcessRenderPipeline
  150534. * @param engine engine to add the pipeline to
  150535. * @param name name of the pipeline
  150536. */
  150537. constructor(engine: Engine, name: string);
  150538. /**
  150539. * Gets the class name
  150540. * @returns "PostProcessRenderPipeline"
  150541. */
  150542. getClassName(): string;
  150543. /**
  150544. * If all the render effects in the pipeline are supported
  150545. */
  150546. get isSupported(): boolean;
  150547. /**
  150548. * Adds an effect to the pipeline
  150549. * @param renderEffect the effect to add
  150550. */
  150551. addEffect(renderEffect: PostProcessRenderEffect): void;
  150552. /** @hidden */
  150553. _rebuild(): void;
  150554. /** @hidden */
  150555. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150556. /** @hidden */
  150557. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  150558. /** @hidden */
  150559. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150560. /** @hidden */
  150561. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  150562. /** @hidden */
  150563. _attachCameras(cameras: Camera, unique: boolean): void;
  150564. /** @hidden */
  150565. _attachCameras(cameras: Camera[], unique: boolean): void;
  150566. /** @hidden */
  150567. _detachCameras(cameras: Camera): void;
  150568. /** @hidden */
  150569. _detachCameras(cameras: Nullable<Camera[]>): void;
  150570. /** @hidden */
  150571. _update(): void;
  150572. /** @hidden */
  150573. _reset(): void;
  150574. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  150575. /**
  150576. * Sets the required values to the prepass renderer.
  150577. * @param prePassRenderer defines the prepass renderer to setup.
  150578. * @returns true if the pre pass is needed.
  150579. */
  150580. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  150581. /**
  150582. * Disposes of the pipeline
  150583. */
  150584. dispose(): void;
  150585. }
  150586. }
  150587. declare module BABYLON {
  150588. /**
  150589. * PostProcessRenderPipelineManager class
  150590. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150591. */
  150592. export class PostProcessRenderPipelineManager {
  150593. private _renderPipelines;
  150594. /**
  150595. * Initializes a PostProcessRenderPipelineManager
  150596. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150597. */
  150598. constructor();
  150599. /**
  150600. * Gets the list of supported render pipelines
  150601. */
  150602. get supportedPipelines(): PostProcessRenderPipeline[];
  150603. /**
  150604. * Adds a pipeline to the manager
  150605. * @param renderPipeline The pipeline to add
  150606. */
  150607. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  150608. /**
  150609. * Attaches a camera to the pipeline
  150610. * @param renderPipelineName The name of the pipeline to attach to
  150611. * @param cameras the camera to attach
  150612. * @param unique if the camera can be attached multiple times to the pipeline
  150613. */
  150614. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  150615. /**
  150616. * Detaches a camera from the pipeline
  150617. * @param renderPipelineName The name of the pipeline to detach from
  150618. * @param cameras the camera to detach
  150619. */
  150620. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  150621. /**
  150622. * Enables an effect by name on a pipeline
  150623. * @param renderPipelineName the name of the pipeline to enable the effect in
  150624. * @param renderEffectName the name of the effect to enable
  150625. * @param cameras the cameras that the effect should be enabled on
  150626. */
  150627. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150628. /**
  150629. * Disables an effect by name on a pipeline
  150630. * @param renderPipelineName the name of the pipeline to disable the effect in
  150631. * @param renderEffectName the name of the effect to disable
  150632. * @param cameras the cameras that the effect should be disabled on
  150633. */
  150634. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  150635. /**
  150636. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  150637. */
  150638. update(): void;
  150639. /** @hidden */
  150640. _rebuild(): void;
  150641. /**
  150642. * Disposes of the manager and pipelines
  150643. */
  150644. dispose(): void;
  150645. }
  150646. }
  150647. declare module BABYLON {
  150648. interface Scene {
  150649. /** @hidden (Backing field) */
  150650. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150651. /**
  150652. * Gets the postprocess render pipeline manager
  150653. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150654. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150655. */
  150656. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  150657. }
  150658. /**
  150659. * Defines the Render Pipeline scene component responsible to rendering pipelines
  150660. */
  150661. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  150662. /**
  150663. * The component name helpfull to identify the component in the list of scene components.
  150664. */
  150665. readonly name: string;
  150666. /**
  150667. * The scene the component belongs to.
  150668. */
  150669. scene: Scene;
  150670. /**
  150671. * Creates a new instance of the component for the given scene
  150672. * @param scene Defines the scene to register the component in
  150673. */
  150674. constructor(scene: Scene);
  150675. /**
  150676. * Registers the component in a given scene
  150677. */
  150678. register(): void;
  150679. /**
  150680. * Rebuilds the elements related to this component in case of
  150681. * context lost for instance.
  150682. */
  150683. rebuild(): void;
  150684. /**
  150685. * Disposes the component and the associated ressources
  150686. */
  150687. dispose(): void;
  150688. private _gatherRenderTargets;
  150689. }
  150690. }
  150691. declare module BABYLON {
  150692. /**
  150693. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  150694. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  150695. */
  150696. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  150697. private _scene;
  150698. private _camerasToBeAttached;
  150699. /**
  150700. * ID of the sharpen post process,
  150701. */
  150702. private readonly SharpenPostProcessId;
  150703. /**
  150704. * @ignore
  150705. * ID of the image processing post process;
  150706. */
  150707. readonly ImageProcessingPostProcessId: string;
  150708. /**
  150709. * @ignore
  150710. * ID of the Fast Approximate Anti-Aliasing post process;
  150711. */
  150712. readonly FxaaPostProcessId: string;
  150713. /**
  150714. * ID of the chromatic aberration post process,
  150715. */
  150716. private readonly ChromaticAberrationPostProcessId;
  150717. /**
  150718. * ID of the grain post process
  150719. */
  150720. private readonly GrainPostProcessId;
  150721. /**
  150722. * Sharpen post process which will apply a sharpen convolution to enhance edges
  150723. */
  150724. sharpen: SharpenPostProcess;
  150725. private _sharpenEffect;
  150726. private bloom;
  150727. /**
  150728. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  150729. */
  150730. depthOfField: DepthOfFieldEffect;
  150731. /**
  150732. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  150733. */
  150734. fxaa: FxaaPostProcess;
  150735. /**
  150736. * Image post processing pass used to perform operations such as tone mapping or color grading.
  150737. */
  150738. imageProcessing: ImageProcessingPostProcess;
  150739. /**
  150740. * Chromatic aberration post process which will shift rgb colors in the image
  150741. */
  150742. chromaticAberration: ChromaticAberrationPostProcess;
  150743. private _chromaticAberrationEffect;
  150744. /**
  150745. * Grain post process which add noise to the image
  150746. */
  150747. grain: GrainPostProcess;
  150748. private _grainEffect;
  150749. /**
  150750. * Glow post process which adds a glow to emissive areas of the image
  150751. */
  150752. private _glowLayer;
  150753. /**
  150754. * Animations which can be used to tweak settings over a period of time
  150755. */
  150756. animations: Animation[];
  150757. private _imageProcessingConfigurationObserver;
  150758. private _sharpenEnabled;
  150759. private _bloomEnabled;
  150760. private _depthOfFieldEnabled;
  150761. private _depthOfFieldBlurLevel;
  150762. private _fxaaEnabled;
  150763. private _imageProcessingEnabled;
  150764. private _defaultPipelineTextureType;
  150765. private _bloomScale;
  150766. private _chromaticAberrationEnabled;
  150767. private _grainEnabled;
  150768. private _buildAllowed;
  150769. /**
  150770. * Gets active scene
  150771. */
  150772. get scene(): Scene;
  150773. /**
  150774. * Enable or disable the sharpen process from the pipeline
  150775. */
  150776. set sharpenEnabled(enabled: boolean);
  150777. get sharpenEnabled(): boolean;
  150778. private _resizeObserver;
  150779. private _hardwareScaleLevel;
  150780. private _bloomKernel;
  150781. /**
  150782. * Specifies the size of the bloom blur kernel, relative to the final output size
  150783. */
  150784. get bloomKernel(): number;
  150785. set bloomKernel(value: number);
  150786. /**
  150787. * Specifies the weight of the bloom in the final rendering
  150788. */
  150789. private _bloomWeight;
  150790. /**
  150791. * Specifies the luma threshold for the area that will be blurred by the bloom
  150792. */
  150793. private _bloomThreshold;
  150794. private _hdr;
  150795. /**
  150796. * The strength of the bloom.
  150797. */
  150798. set bloomWeight(value: number);
  150799. get bloomWeight(): number;
  150800. /**
  150801. * The strength of the bloom.
  150802. */
  150803. set bloomThreshold(value: number);
  150804. get bloomThreshold(): number;
  150805. /**
  150806. * The scale of the bloom, lower value will provide better performance.
  150807. */
  150808. set bloomScale(value: number);
  150809. get bloomScale(): number;
  150810. /**
  150811. * Enable or disable the bloom from the pipeline
  150812. */
  150813. set bloomEnabled(enabled: boolean);
  150814. get bloomEnabled(): boolean;
  150815. private _rebuildBloom;
  150816. /**
  150817. * If the depth of field is enabled.
  150818. */
  150819. get depthOfFieldEnabled(): boolean;
  150820. set depthOfFieldEnabled(enabled: boolean);
  150821. /**
  150822. * Blur level of the depth of field effect. (Higher blur will effect performance)
  150823. */
  150824. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  150825. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  150826. /**
  150827. * If the anti aliasing is enabled.
  150828. */
  150829. set fxaaEnabled(enabled: boolean);
  150830. get fxaaEnabled(): boolean;
  150831. private _samples;
  150832. /**
  150833. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  150834. */
  150835. set samples(sampleCount: number);
  150836. get samples(): number;
  150837. /**
  150838. * If image processing is enabled.
  150839. */
  150840. set imageProcessingEnabled(enabled: boolean);
  150841. get imageProcessingEnabled(): boolean;
  150842. /**
  150843. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  150844. */
  150845. set glowLayerEnabled(enabled: boolean);
  150846. get glowLayerEnabled(): boolean;
  150847. /**
  150848. * Gets the glow layer (or null if not defined)
  150849. */
  150850. get glowLayer(): Nullable<GlowLayer>;
  150851. /**
  150852. * Enable or disable the chromaticAberration process from the pipeline
  150853. */
  150854. set chromaticAberrationEnabled(enabled: boolean);
  150855. get chromaticAberrationEnabled(): boolean;
  150856. /**
  150857. * Enable or disable the grain process from the pipeline
  150858. */
  150859. set grainEnabled(enabled: boolean);
  150860. get grainEnabled(): boolean;
  150861. /**
  150862. * @constructor
  150863. * @param name - The rendering pipeline name (default: "")
  150864. * @param hdr - If high dynamic range textures should be used (default: true)
  150865. * @param scene - The scene linked to this pipeline (default: the last created scene)
  150866. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  150867. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  150868. */
  150869. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  150870. /**
  150871. * Get the class name
  150872. * @returns "DefaultRenderingPipeline"
  150873. */
  150874. getClassName(): string;
  150875. /**
  150876. * Force the compilation of the entire pipeline.
  150877. */
  150878. prepare(): void;
  150879. private _hasCleared;
  150880. private _prevPostProcess;
  150881. private _prevPrevPostProcess;
  150882. private _setAutoClearAndTextureSharing;
  150883. private _depthOfFieldSceneObserver;
  150884. private _buildPipeline;
  150885. private _disposePostProcesses;
  150886. /**
  150887. * Adds a camera to the pipeline
  150888. * @param camera the camera to be added
  150889. */
  150890. addCamera(camera: Camera): void;
  150891. /**
  150892. * Removes a camera from the pipeline
  150893. * @param camera the camera to remove
  150894. */
  150895. removeCamera(camera: Camera): void;
  150896. /**
  150897. * Dispose of the pipeline and stop all post processes
  150898. */
  150899. dispose(): void;
  150900. /**
  150901. * Serialize the rendering pipeline (Used when exporting)
  150902. * @returns the serialized object
  150903. */
  150904. serialize(): any;
  150905. /**
  150906. * Parse the serialized pipeline
  150907. * @param source Source pipeline.
  150908. * @param scene The scene to load the pipeline to.
  150909. * @param rootUrl The URL of the serialized pipeline.
  150910. * @returns An instantiated pipeline from the serialized object.
  150911. */
  150912. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  150913. }
  150914. }
  150915. declare module BABYLON {
  150916. /** @hidden */
  150917. export var lensHighlightsPixelShader: {
  150918. name: string;
  150919. shader: string;
  150920. };
  150921. }
  150922. declare module BABYLON {
  150923. /** @hidden */
  150924. export var depthOfFieldPixelShader: {
  150925. name: string;
  150926. shader: string;
  150927. };
  150928. }
  150929. declare module BABYLON {
  150930. /**
  150931. * BABYLON.JS Chromatic Aberration GLSL Shader
  150932. * Author: Olivier Guyot
  150933. * Separates very slightly R, G and B colors on the edges of the screen
  150934. * Inspired by Francois Tarlier & Martins Upitis
  150935. */
  150936. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  150937. /**
  150938. * @ignore
  150939. * The chromatic aberration PostProcess id in the pipeline
  150940. */
  150941. LensChromaticAberrationEffect: string;
  150942. /**
  150943. * @ignore
  150944. * The highlights enhancing PostProcess id in the pipeline
  150945. */
  150946. HighlightsEnhancingEffect: string;
  150947. /**
  150948. * @ignore
  150949. * The depth-of-field PostProcess id in the pipeline
  150950. */
  150951. LensDepthOfFieldEffect: string;
  150952. private _scene;
  150953. private _depthTexture;
  150954. private _grainTexture;
  150955. private _chromaticAberrationPostProcess;
  150956. private _highlightsPostProcess;
  150957. private _depthOfFieldPostProcess;
  150958. private _edgeBlur;
  150959. private _grainAmount;
  150960. private _chromaticAberration;
  150961. private _distortion;
  150962. private _highlightsGain;
  150963. private _highlightsThreshold;
  150964. private _dofDistance;
  150965. private _dofAperture;
  150966. private _dofDarken;
  150967. private _dofPentagon;
  150968. private _blurNoise;
  150969. /**
  150970. * @constructor
  150971. *
  150972. * Effect parameters are as follow:
  150973. * {
  150974. * chromatic_aberration: number; // from 0 to x (1 for realism)
  150975. * edge_blur: number; // from 0 to x (1 for realism)
  150976. * distortion: number; // from 0 to x (1 for realism)
  150977. * grain_amount: number; // from 0 to 1
  150978. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  150979. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  150980. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  150981. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  150982. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  150983. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  150984. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  150985. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  150986. * }
  150987. * Note: if an effect parameter is unset, effect is disabled
  150988. *
  150989. * @param name The rendering pipeline name
  150990. * @param parameters - An object containing all parameters (see above)
  150991. * @param scene The scene linked to this pipeline
  150992. * @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)
  150993. * @param cameras The array of cameras that the rendering pipeline will be attached to
  150994. */
  150995. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  150996. /**
  150997. * Get the class name
  150998. * @returns "LensRenderingPipeline"
  150999. */
  151000. getClassName(): string;
  151001. /**
  151002. * Gets associated scene
  151003. */
  151004. get scene(): Scene;
  151005. /**
  151006. * Gets or sets the edge blur
  151007. */
  151008. get edgeBlur(): number;
  151009. set edgeBlur(value: number);
  151010. /**
  151011. * Gets or sets the grain amount
  151012. */
  151013. get grainAmount(): number;
  151014. set grainAmount(value: number);
  151015. /**
  151016. * Gets or sets the chromatic aberration amount
  151017. */
  151018. get chromaticAberration(): number;
  151019. set chromaticAberration(value: number);
  151020. /**
  151021. * Gets or sets the depth of field aperture
  151022. */
  151023. get dofAperture(): number;
  151024. set dofAperture(value: number);
  151025. /**
  151026. * Gets or sets the edge distortion
  151027. */
  151028. get edgeDistortion(): number;
  151029. set edgeDistortion(value: number);
  151030. /**
  151031. * Gets or sets the depth of field distortion
  151032. */
  151033. get dofDistortion(): number;
  151034. set dofDistortion(value: number);
  151035. /**
  151036. * Gets or sets the darken out of focus amount
  151037. */
  151038. get darkenOutOfFocus(): number;
  151039. set darkenOutOfFocus(value: number);
  151040. /**
  151041. * Gets or sets a boolean indicating if blur noise is enabled
  151042. */
  151043. get blurNoise(): boolean;
  151044. set blurNoise(value: boolean);
  151045. /**
  151046. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151047. */
  151048. get pentagonBokeh(): boolean;
  151049. set pentagonBokeh(value: boolean);
  151050. /**
  151051. * Gets or sets the highlight grain amount
  151052. */
  151053. get highlightsGain(): number;
  151054. set highlightsGain(value: number);
  151055. /**
  151056. * Gets or sets the highlight threshold
  151057. */
  151058. get highlightsThreshold(): number;
  151059. set highlightsThreshold(value: number);
  151060. /**
  151061. * Sets the amount of blur at the edges
  151062. * @param amount blur amount
  151063. */
  151064. setEdgeBlur(amount: number): void;
  151065. /**
  151066. * Sets edge blur to 0
  151067. */
  151068. disableEdgeBlur(): void;
  151069. /**
  151070. * Sets the amout of grain
  151071. * @param amount Amount of grain
  151072. */
  151073. setGrainAmount(amount: number): void;
  151074. /**
  151075. * Set grain amount to 0
  151076. */
  151077. disableGrain(): void;
  151078. /**
  151079. * Sets the chromatic aberration amount
  151080. * @param amount amount of chromatic aberration
  151081. */
  151082. setChromaticAberration(amount: number): void;
  151083. /**
  151084. * Sets chromatic aberration amount to 0
  151085. */
  151086. disableChromaticAberration(): void;
  151087. /**
  151088. * Sets the EdgeDistortion amount
  151089. * @param amount amount of EdgeDistortion
  151090. */
  151091. setEdgeDistortion(amount: number): void;
  151092. /**
  151093. * Sets edge distortion to 0
  151094. */
  151095. disableEdgeDistortion(): void;
  151096. /**
  151097. * Sets the FocusDistance amount
  151098. * @param amount amount of FocusDistance
  151099. */
  151100. setFocusDistance(amount: number): void;
  151101. /**
  151102. * Disables depth of field
  151103. */
  151104. disableDepthOfField(): void;
  151105. /**
  151106. * Sets the Aperture amount
  151107. * @param amount amount of Aperture
  151108. */
  151109. setAperture(amount: number): void;
  151110. /**
  151111. * Sets the DarkenOutOfFocus amount
  151112. * @param amount amount of DarkenOutOfFocus
  151113. */
  151114. setDarkenOutOfFocus(amount: number): void;
  151115. private _pentagonBokehIsEnabled;
  151116. /**
  151117. * Creates a pentagon bokeh effect
  151118. */
  151119. enablePentagonBokeh(): void;
  151120. /**
  151121. * Disables the pentagon bokeh effect
  151122. */
  151123. disablePentagonBokeh(): void;
  151124. /**
  151125. * Enables noise blur
  151126. */
  151127. enableNoiseBlur(): void;
  151128. /**
  151129. * Disables noise blur
  151130. */
  151131. disableNoiseBlur(): void;
  151132. /**
  151133. * Sets the HighlightsGain amount
  151134. * @param amount amount of HighlightsGain
  151135. */
  151136. setHighlightsGain(amount: number): void;
  151137. /**
  151138. * Sets the HighlightsThreshold amount
  151139. * @param amount amount of HighlightsThreshold
  151140. */
  151141. setHighlightsThreshold(amount: number): void;
  151142. /**
  151143. * Disables highlights
  151144. */
  151145. disableHighlights(): void;
  151146. /**
  151147. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151148. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151149. */
  151150. dispose(disableDepthRender?: boolean): void;
  151151. private _createChromaticAberrationPostProcess;
  151152. private _createHighlightsPostProcess;
  151153. private _createDepthOfFieldPostProcess;
  151154. private _createGrainTexture;
  151155. }
  151156. }
  151157. declare module BABYLON {
  151158. /**
  151159. * Contains all parameters needed for the prepass to perform
  151160. * screen space subsurface scattering
  151161. */
  151162. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151163. /**
  151164. * Is subsurface enabled
  151165. */
  151166. enabled: boolean;
  151167. /**
  151168. * Name of the configuration
  151169. */
  151170. name: string;
  151171. /**
  151172. * Textures that should be present in the MRT for this effect to work
  151173. */
  151174. readonly texturesRequired: number[];
  151175. /**
  151176. * Builds a ssao2 configuration object
  151177. * @param scene The scene
  151178. */
  151179. constructor();
  151180. /**
  151181. * Disposes the configuration
  151182. */
  151183. dispose(): void;
  151184. }
  151185. }
  151186. declare module BABYLON {
  151187. /** @hidden */
  151188. export var ssao2PixelShader: {
  151189. name: string;
  151190. shader: string;
  151191. };
  151192. }
  151193. declare module BABYLON {
  151194. /** @hidden */
  151195. export var ssaoCombinePixelShader: {
  151196. name: string;
  151197. shader: string;
  151198. };
  151199. }
  151200. declare module BABYLON {
  151201. /**
  151202. * Render pipeline to produce ssao effect
  151203. */
  151204. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151205. /**
  151206. * @ignore
  151207. * The PassPostProcess id in the pipeline that contains the original scene color
  151208. */
  151209. SSAOOriginalSceneColorEffect: string;
  151210. /**
  151211. * @ignore
  151212. * The SSAO PostProcess id in the pipeline
  151213. */
  151214. SSAORenderEffect: string;
  151215. /**
  151216. * @ignore
  151217. * The horizontal blur PostProcess id in the pipeline
  151218. */
  151219. SSAOBlurHRenderEffect: string;
  151220. /**
  151221. * @ignore
  151222. * The vertical blur PostProcess id in the pipeline
  151223. */
  151224. SSAOBlurVRenderEffect: string;
  151225. /**
  151226. * @ignore
  151227. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151228. */
  151229. SSAOCombineRenderEffect: string;
  151230. /**
  151231. * The output strength of the SSAO post-process. Default value is 1.0.
  151232. */
  151233. totalStrength: number;
  151234. /**
  151235. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151236. */
  151237. maxZ: number;
  151238. /**
  151239. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151240. */
  151241. minZAspect: number;
  151242. private _samples;
  151243. /**
  151244. * Number of samples used for the SSAO calculations. Default value is 8
  151245. */
  151246. set samples(n: number);
  151247. get samples(): number;
  151248. private _textureSamples;
  151249. /**
  151250. * Number of samples to use for antialiasing
  151251. */
  151252. set textureSamples(n: number);
  151253. get textureSamples(): number;
  151254. /**
  151255. * Force rendering the geometry through geometry buffer
  151256. */
  151257. private _forceGeometryBuffer;
  151258. /**
  151259. * Ratio object used for SSAO ratio and blur ratio
  151260. */
  151261. private _ratio;
  151262. /**
  151263. * Dynamically generated sphere sampler.
  151264. */
  151265. private _sampleSphere;
  151266. private _ssao2PrePassConfiguration;
  151267. /**
  151268. * Blur filter offsets
  151269. */
  151270. private _samplerOffsets;
  151271. private _expensiveBlur;
  151272. /**
  151273. * If bilateral blur should be used
  151274. */
  151275. set expensiveBlur(b: boolean);
  151276. get expensiveBlur(): boolean;
  151277. /**
  151278. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151279. */
  151280. radius: number;
  151281. /**
  151282. * The base color of the SSAO post-process
  151283. * The final result is "base + ssao" between [0, 1]
  151284. */
  151285. base: number;
  151286. /**
  151287. * Support test.
  151288. */
  151289. static get IsSupported(): boolean;
  151290. private _scene;
  151291. private _randomTexture;
  151292. private _originalColorPostProcess;
  151293. private _ssaoPostProcess;
  151294. private _blurHPostProcess;
  151295. private _blurVPostProcess;
  151296. private _ssaoCombinePostProcess;
  151297. private _prePassRenderer;
  151298. /**
  151299. * Gets active scene
  151300. */
  151301. get scene(): Scene;
  151302. /**
  151303. * @constructor
  151304. * @param name The rendering pipeline name
  151305. * @param scene The scene linked to this pipeline
  151306. * @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 }
  151307. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151308. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151309. */
  151310. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151311. /**
  151312. * Get the class name
  151313. * @returns "SSAO2RenderingPipeline"
  151314. */
  151315. getClassName(): string;
  151316. /**
  151317. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151318. */
  151319. dispose(disableGeometryBufferRenderer?: boolean): void;
  151320. private _createBlurPostProcess;
  151321. /** @hidden */
  151322. _rebuild(): void;
  151323. private _bits;
  151324. private _radicalInverse_VdC;
  151325. private _hammersley;
  151326. private _hemisphereSample_uniform;
  151327. private _generateHemisphere;
  151328. private _getDefinesForSSAO;
  151329. private _createSSAOPostProcess;
  151330. private _createSSAOCombinePostProcess;
  151331. private _createRandomTexture;
  151332. /**
  151333. * Serialize the rendering pipeline (Used when exporting)
  151334. * @returns the serialized object
  151335. */
  151336. serialize(): any;
  151337. /**
  151338. * Parse the serialized pipeline
  151339. * @param source Source pipeline.
  151340. * @param scene The scene to load the pipeline to.
  151341. * @param rootUrl The URL of the serialized pipeline.
  151342. * @returns An instantiated pipeline from the serialized object.
  151343. */
  151344. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151345. /**
  151346. * Sets the required values to the prepass renderer.
  151347. * @param prePassRenderer defines the prepass renderer to setup
  151348. * @returns true if the pre pass is needed.
  151349. */
  151350. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151351. }
  151352. }
  151353. declare module BABYLON {
  151354. /** @hidden */
  151355. export var ssaoPixelShader: {
  151356. name: string;
  151357. shader: string;
  151358. };
  151359. }
  151360. declare module BABYLON {
  151361. /**
  151362. * Render pipeline to produce ssao effect
  151363. */
  151364. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151365. /**
  151366. * @ignore
  151367. * The PassPostProcess id in the pipeline that contains the original scene color
  151368. */
  151369. SSAOOriginalSceneColorEffect: string;
  151370. /**
  151371. * @ignore
  151372. * The SSAO PostProcess id in the pipeline
  151373. */
  151374. SSAORenderEffect: string;
  151375. /**
  151376. * @ignore
  151377. * The horizontal blur PostProcess id in the pipeline
  151378. */
  151379. SSAOBlurHRenderEffect: string;
  151380. /**
  151381. * @ignore
  151382. * The vertical blur PostProcess id in the pipeline
  151383. */
  151384. SSAOBlurVRenderEffect: string;
  151385. /**
  151386. * @ignore
  151387. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151388. */
  151389. SSAOCombineRenderEffect: string;
  151390. /**
  151391. * The output strength of the SSAO post-process. Default value is 1.0.
  151392. */
  151393. totalStrength: number;
  151394. /**
  151395. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151396. */
  151397. radius: number;
  151398. /**
  151399. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151400. * Must not be equal to fallOff and superior to fallOff.
  151401. * Default value is 0.0075
  151402. */
  151403. area: number;
  151404. /**
  151405. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151406. * Must not be equal to area and inferior to area.
  151407. * Default value is 0.000001
  151408. */
  151409. fallOff: number;
  151410. /**
  151411. * The base color of the SSAO post-process
  151412. * The final result is "base + ssao" between [0, 1]
  151413. */
  151414. base: number;
  151415. private _scene;
  151416. private _depthTexture;
  151417. private _randomTexture;
  151418. private _originalColorPostProcess;
  151419. private _ssaoPostProcess;
  151420. private _blurHPostProcess;
  151421. private _blurVPostProcess;
  151422. private _ssaoCombinePostProcess;
  151423. private _firstUpdate;
  151424. /**
  151425. * Gets active scene
  151426. */
  151427. get scene(): Scene;
  151428. /**
  151429. * @constructor
  151430. * @param name - The rendering pipeline name
  151431. * @param scene - The scene linked to this pipeline
  151432. * @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 }
  151433. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151434. */
  151435. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151436. /**
  151437. * Get the class name
  151438. * @returns "SSAORenderingPipeline"
  151439. */
  151440. getClassName(): string;
  151441. /**
  151442. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151443. */
  151444. dispose(disableDepthRender?: boolean): void;
  151445. private _createBlurPostProcess;
  151446. /** @hidden */
  151447. _rebuild(): void;
  151448. private _createSSAOPostProcess;
  151449. private _createSSAOCombinePostProcess;
  151450. private _createRandomTexture;
  151451. }
  151452. }
  151453. declare module BABYLON {
  151454. /** @hidden */
  151455. export var screenSpaceReflectionPixelShader: {
  151456. name: string;
  151457. shader: string;
  151458. };
  151459. }
  151460. declare module BABYLON {
  151461. /**
  151462. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151463. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151464. */
  151465. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151466. /**
  151467. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151468. */
  151469. threshold: number;
  151470. /**
  151471. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151472. */
  151473. strength: number;
  151474. /**
  151475. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151476. */
  151477. reflectionSpecularFalloffExponent: number;
  151478. /**
  151479. * 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]
  151480. */
  151481. step: number;
  151482. /**
  151483. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151484. */
  151485. roughnessFactor: number;
  151486. private _geometryBufferRenderer;
  151487. private _enableSmoothReflections;
  151488. private _reflectionSamples;
  151489. private _smoothSteps;
  151490. /**
  151491. * Gets a string identifying the name of the class
  151492. * @returns "ScreenSpaceReflectionPostProcess" string
  151493. */
  151494. getClassName(): string;
  151495. /**
  151496. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151497. * @param name The name of the effect.
  151498. * @param scene The scene containing the objects to calculate reflections.
  151499. * @param options The required width/height ratio to downsize to before computing the render pass.
  151500. * @param camera The camera to apply the render pass to.
  151501. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151502. * @param engine The engine which the post process will be applied. (default: current engine)
  151503. * @param reusable If the post process can be reused on the same frame. (default: false)
  151504. * @param textureType Type of textures used when performing the post process. (default: 0)
  151505. * @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)
  151506. */
  151507. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  151508. /**
  151509. * Gets wether or not smoothing reflections is enabled.
  151510. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151511. */
  151512. get enableSmoothReflections(): boolean;
  151513. /**
  151514. * Sets wether or not smoothing reflections is enabled.
  151515. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151516. */
  151517. set enableSmoothReflections(enabled: boolean);
  151518. /**
  151519. * Gets the number of samples taken while computing reflections. More samples count is high,
  151520. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151521. */
  151522. get reflectionSamples(): number;
  151523. /**
  151524. * Sets the number of samples taken while computing reflections. More samples count is high,
  151525. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151526. */
  151527. set reflectionSamples(samples: number);
  151528. /**
  151529. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151530. * more the post-process will require GPU power and can generate a drop in FPS.
  151531. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151532. */
  151533. get smoothSteps(): number;
  151534. set smoothSteps(steps: number);
  151535. private _updateEffectDefines;
  151536. /** @hidden */
  151537. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151538. }
  151539. }
  151540. declare module BABYLON {
  151541. /** @hidden */
  151542. export var standardPixelShader: {
  151543. name: string;
  151544. shader: string;
  151545. };
  151546. }
  151547. declare module BABYLON {
  151548. /**
  151549. * Standard rendering pipeline
  151550. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151551. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  151552. */
  151553. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151554. /**
  151555. * Public members
  151556. */
  151557. /**
  151558. * Post-process which contains the original scene color before the pipeline applies all the effects
  151559. */
  151560. originalPostProcess: Nullable<PostProcess>;
  151561. /**
  151562. * Post-process used to down scale an image x4
  151563. */
  151564. downSampleX4PostProcess: Nullable<PostProcess>;
  151565. /**
  151566. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  151567. */
  151568. brightPassPostProcess: Nullable<PostProcess>;
  151569. /**
  151570. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  151571. */
  151572. blurHPostProcesses: PostProcess[];
  151573. /**
  151574. * Post-process array storing all the vertical blur post-processes used by the pipeline
  151575. */
  151576. blurVPostProcesses: PostProcess[];
  151577. /**
  151578. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  151579. */
  151580. textureAdderPostProcess: Nullable<PostProcess>;
  151581. /**
  151582. * Post-process used to create volumetric lighting effect
  151583. */
  151584. volumetricLightPostProcess: Nullable<PostProcess>;
  151585. /**
  151586. * Post-process used to smooth the previous volumetric light post-process on the X axis
  151587. */
  151588. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  151589. /**
  151590. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  151591. */
  151592. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  151593. /**
  151594. * Post-process used to merge the volumetric light effect and the real scene color
  151595. */
  151596. volumetricLightMergePostProces: Nullable<PostProcess>;
  151597. /**
  151598. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  151599. */
  151600. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  151601. /**
  151602. * Base post-process used to calculate the average luminance of the final image for HDR
  151603. */
  151604. luminancePostProcess: Nullable<PostProcess>;
  151605. /**
  151606. * Post-processes used to create down sample post-processes in order to get
  151607. * the average luminance of the final image for HDR
  151608. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  151609. */
  151610. luminanceDownSamplePostProcesses: PostProcess[];
  151611. /**
  151612. * Post-process used to create a HDR effect (light adaptation)
  151613. */
  151614. hdrPostProcess: Nullable<PostProcess>;
  151615. /**
  151616. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  151617. */
  151618. textureAdderFinalPostProcess: Nullable<PostProcess>;
  151619. /**
  151620. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  151621. */
  151622. lensFlareFinalPostProcess: Nullable<PostProcess>;
  151623. /**
  151624. * Post-process used to merge the final HDR post-process and the real scene color
  151625. */
  151626. hdrFinalPostProcess: Nullable<PostProcess>;
  151627. /**
  151628. * Post-process used to create a lens flare effect
  151629. */
  151630. lensFlarePostProcess: Nullable<PostProcess>;
  151631. /**
  151632. * Post-process that merges the result of the lens flare post-process and the real scene color
  151633. */
  151634. lensFlareComposePostProcess: Nullable<PostProcess>;
  151635. /**
  151636. * Post-process used to create a motion blur effect
  151637. */
  151638. motionBlurPostProcess: Nullable<PostProcess>;
  151639. /**
  151640. * Post-process used to create a depth of field effect
  151641. */
  151642. depthOfFieldPostProcess: Nullable<PostProcess>;
  151643. /**
  151644. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151645. */
  151646. fxaaPostProcess: Nullable<FxaaPostProcess>;
  151647. /**
  151648. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  151649. */
  151650. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  151651. /**
  151652. * Represents the brightness threshold in order to configure the illuminated surfaces
  151653. */
  151654. brightThreshold: number;
  151655. /**
  151656. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  151657. */
  151658. blurWidth: number;
  151659. /**
  151660. * Sets if the blur for highlighted surfaces must be only horizontal
  151661. */
  151662. horizontalBlur: boolean;
  151663. /**
  151664. * Gets the overall exposure used by the pipeline
  151665. */
  151666. get exposure(): number;
  151667. /**
  151668. * Sets the overall exposure used by the pipeline
  151669. */
  151670. set exposure(value: number);
  151671. /**
  151672. * Texture used typically to simulate "dirty" on camera lens
  151673. */
  151674. lensTexture: Nullable<Texture>;
  151675. /**
  151676. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  151677. */
  151678. volumetricLightCoefficient: number;
  151679. /**
  151680. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  151681. */
  151682. volumetricLightPower: number;
  151683. /**
  151684. * Used the set the blur intensity to smooth the volumetric lights
  151685. */
  151686. volumetricLightBlurScale: number;
  151687. /**
  151688. * Light (spot or directional) used to generate the volumetric lights rays
  151689. * The source light must have a shadow generate so the pipeline can get its
  151690. * depth map
  151691. */
  151692. sourceLight: Nullable<SpotLight | DirectionalLight>;
  151693. /**
  151694. * For eye adaptation, represents the minimum luminance the eye can see
  151695. */
  151696. hdrMinimumLuminance: number;
  151697. /**
  151698. * For eye adaptation, represents the decrease luminance speed
  151699. */
  151700. hdrDecreaseRate: number;
  151701. /**
  151702. * For eye adaptation, represents the increase luminance speed
  151703. */
  151704. hdrIncreaseRate: number;
  151705. /**
  151706. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151707. */
  151708. get hdrAutoExposure(): boolean;
  151709. /**
  151710. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  151711. */
  151712. set hdrAutoExposure(value: boolean);
  151713. /**
  151714. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  151715. */
  151716. lensColorTexture: Nullable<Texture>;
  151717. /**
  151718. * The overall strengh for the lens flare effect
  151719. */
  151720. lensFlareStrength: number;
  151721. /**
  151722. * Dispersion coefficient for lens flare ghosts
  151723. */
  151724. lensFlareGhostDispersal: number;
  151725. /**
  151726. * Main lens flare halo width
  151727. */
  151728. lensFlareHaloWidth: number;
  151729. /**
  151730. * Based on the lens distortion effect, defines how much the lens flare result
  151731. * is distorted
  151732. */
  151733. lensFlareDistortionStrength: number;
  151734. /**
  151735. * Configures the blur intensity used for for lens flare (halo)
  151736. */
  151737. lensFlareBlurWidth: number;
  151738. /**
  151739. * Lens star texture must be used to simulate rays on the flares and is available
  151740. * in the documentation
  151741. */
  151742. lensStarTexture: Nullable<Texture>;
  151743. /**
  151744. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  151745. * flare effect by taking account of the dirt texture
  151746. */
  151747. lensFlareDirtTexture: Nullable<Texture>;
  151748. /**
  151749. * Represents the focal length for the depth of field effect
  151750. */
  151751. depthOfFieldDistance: number;
  151752. /**
  151753. * Represents the blur intensity for the blurred part of the depth of field effect
  151754. */
  151755. depthOfFieldBlurWidth: number;
  151756. /**
  151757. * Gets how much the image is blurred by the movement while using the motion blur post-process
  151758. */
  151759. get motionStrength(): number;
  151760. /**
  151761. * Sets how much the image is blurred by the movement while using the motion blur post-process
  151762. */
  151763. set motionStrength(strength: number);
  151764. /**
  151765. * Gets wether or not the motion blur post-process is object based or screen based.
  151766. */
  151767. get objectBasedMotionBlur(): boolean;
  151768. /**
  151769. * Sets wether or not the motion blur post-process should be object based or screen based
  151770. */
  151771. set objectBasedMotionBlur(value: boolean);
  151772. /**
  151773. * List of animations for the pipeline (IAnimatable implementation)
  151774. */
  151775. animations: Animation[];
  151776. /**
  151777. * Private members
  151778. */
  151779. private _scene;
  151780. private _currentDepthOfFieldSource;
  151781. private _basePostProcess;
  151782. private _fixedExposure;
  151783. private _currentExposure;
  151784. private _hdrAutoExposure;
  151785. private _hdrCurrentLuminance;
  151786. private _motionStrength;
  151787. private _isObjectBasedMotionBlur;
  151788. private _floatTextureType;
  151789. private _camerasToBeAttached;
  151790. private _ratio;
  151791. private _bloomEnabled;
  151792. private _depthOfFieldEnabled;
  151793. private _vlsEnabled;
  151794. private _lensFlareEnabled;
  151795. private _hdrEnabled;
  151796. private _motionBlurEnabled;
  151797. private _fxaaEnabled;
  151798. private _screenSpaceReflectionsEnabled;
  151799. private _motionBlurSamples;
  151800. private _volumetricLightStepsCount;
  151801. private _samples;
  151802. /**
  151803. * @ignore
  151804. * Specifies if the bloom pipeline is enabled
  151805. */
  151806. get BloomEnabled(): boolean;
  151807. set BloomEnabled(enabled: boolean);
  151808. /**
  151809. * @ignore
  151810. * Specifies if the depth of field pipeline is enabed
  151811. */
  151812. get DepthOfFieldEnabled(): boolean;
  151813. set DepthOfFieldEnabled(enabled: boolean);
  151814. /**
  151815. * @ignore
  151816. * Specifies if the lens flare pipeline is enabed
  151817. */
  151818. get LensFlareEnabled(): boolean;
  151819. set LensFlareEnabled(enabled: boolean);
  151820. /**
  151821. * @ignore
  151822. * Specifies if the HDR pipeline is enabled
  151823. */
  151824. get HDREnabled(): boolean;
  151825. set HDREnabled(enabled: boolean);
  151826. /**
  151827. * @ignore
  151828. * Specifies if the volumetric lights scattering effect is enabled
  151829. */
  151830. get VLSEnabled(): boolean;
  151831. set VLSEnabled(enabled: boolean);
  151832. /**
  151833. * @ignore
  151834. * Specifies if the motion blur effect is enabled
  151835. */
  151836. get MotionBlurEnabled(): boolean;
  151837. set MotionBlurEnabled(enabled: boolean);
  151838. /**
  151839. * Specifies if anti-aliasing is enabled
  151840. */
  151841. get fxaaEnabled(): boolean;
  151842. set fxaaEnabled(enabled: boolean);
  151843. /**
  151844. * Specifies if screen space reflections are enabled.
  151845. */
  151846. get screenSpaceReflectionsEnabled(): boolean;
  151847. set screenSpaceReflectionsEnabled(enabled: boolean);
  151848. /**
  151849. * Specifies the number of steps used to calculate the volumetric lights
  151850. * Typically in interval [50, 200]
  151851. */
  151852. get volumetricLightStepsCount(): number;
  151853. set volumetricLightStepsCount(count: number);
  151854. /**
  151855. * Specifies the number of samples used for the motion blur effect
  151856. * Typically in interval [16, 64]
  151857. */
  151858. get motionBlurSamples(): number;
  151859. set motionBlurSamples(samples: number);
  151860. /**
  151861. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151862. */
  151863. get samples(): number;
  151864. set samples(sampleCount: number);
  151865. /**
  151866. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  151867. * @constructor
  151868. * @param name The rendering pipeline name
  151869. * @param scene The scene linked to this pipeline
  151870. * @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)
  151871. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  151872. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151873. */
  151874. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  151875. private _buildPipeline;
  151876. private _createDownSampleX4PostProcess;
  151877. private _createBrightPassPostProcess;
  151878. private _createBlurPostProcesses;
  151879. private _createTextureAdderPostProcess;
  151880. private _createVolumetricLightPostProcess;
  151881. private _createLuminancePostProcesses;
  151882. private _createHdrPostProcess;
  151883. private _createLensFlarePostProcess;
  151884. private _createDepthOfFieldPostProcess;
  151885. private _createMotionBlurPostProcess;
  151886. private _getDepthTexture;
  151887. private _disposePostProcesses;
  151888. /**
  151889. * Dispose of the pipeline and stop all post processes
  151890. */
  151891. dispose(): void;
  151892. /**
  151893. * Serialize the rendering pipeline (Used when exporting)
  151894. * @returns the serialized object
  151895. */
  151896. serialize(): any;
  151897. /**
  151898. * Parse the serialized pipeline
  151899. * @param source Source pipeline.
  151900. * @param scene The scene to load the pipeline to.
  151901. * @param rootUrl The URL of the serialized pipeline.
  151902. * @returns An instantiated pipeline from the serialized object.
  151903. */
  151904. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  151905. /**
  151906. * Luminance steps
  151907. */
  151908. static LuminanceSteps: number;
  151909. }
  151910. }
  151911. declare module BABYLON {
  151912. /** @hidden */
  151913. export var stereoscopicInterlacePixelShader: {
  151914. name: string;
  151915. shader: string;
  151916. };
  151917. }
  151918. declare module BABYLON {
  151919. /**
  151920. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  151921. */
  151922. export class StereoscopicInterlacePostProcessI extends PostProcess {
  151923. private _stepSize;
  151924. private _passedProcess;
  151925. /**
  151926. * Gets a string identifying the name of the class
  151927. * @returns "StereoscopicInterlacePostProcessI" string
  151928. */
  151929. getClassName(): string;
  151930. /**
  151931. * Initializes a StereoscopicInterlacePostProcessI
  151932. * @param name The name of the effect.
  151933. * @param rigCameras The rig cameras to be appled to the post process
  151934. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  151935. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  151936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151937. * @param engine The engine which the post process will be applied. (default: current engine)
  151938. * @param reusable If the post process can be reused on the same frame. (default: false)
  151939. */
  151940. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151941. }
  151942. /**
  151943. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  151944. */
  151945. export class StereoscopicInterlacePostProcess extends PostProcess {
  151946. private _stepSize;
  151947. private _passedProcess;
  151948. /**
  151949. * Gets a string identifying the name of the class
  151950. * @returns "StereoscopicInterlacePostProcess" string
  151951. */
  151952. getClassName(): string;
  151953. /**
  151954. * Initializes a StereoscopicInterlacePostProcess
  151955. * @param name The name of the effect.
  151956. * @param rigCameras The rig cameras to be appled to the post process
  151957. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  151958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151959. * @param engine The engine which the post process will be applied. (default: current engine)
  151960. * @param reusable If the post process can be reused on the same frame. (default: false)
  151961. */
  151962. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  151963. }
  151964. }
  151965. declare module BABYLON {
  151966. /** @hidden */
  151967. export var tonemapPixelShader: {
  151968. name: string;
  151969. shader: string;
  151970. };
  151971. }
  151972. declare module BABYLON {
  151973. /** Defines operator used for tonemapping */
  151974. export enum TonemappingOperator {
  151975. /** Hable */
  151976. Hable = 0,
  151977. /** Reinhard */
  151978. Reinhard = 1,
  151979. /** HejiDawson */
  151980. HejiDawson = 2,
  151981. /** Photographic */
  151982. Photographic = 3
  151983. }
  151984. /**
  151985. * Defines a post process to apply tone mapping
  151986. */
  151987. export class TonemapPostProcess extends PostProcess {
  151988. private _operator;
  151989. /** Defines the required exposure adjustement */
  151990. exposureAdjustment: number;
  151991. /**
  151992. * Gets a string identifying the name of the class
  151993. * @returns "TonemapPostProcess" string
  151994. */
  151995. getClassName(): string;
  151996. /**
  151997. * Creates a new TonemapPostProcess
  151998. * @param name defines the name of the postprocess
  151999. * @param _operator defines the operator to use
  152000. * @param exposureAdjustment defines the required exposure adjustement
  152001. * @param camera defines the camera to use (can be null)
  152002. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152003. * @param engine defines the hosting engine (can be ignore if camera is set)
  152004. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152005. */
  152006. constructor(name: string, _operator: TonemappingOperator,
  152007. /** Defines the required exposure adjustement */
  152008. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152009. }
  152010. }
  152011. declare module BABYLON {
  152012. /** @hidden */
  152013. export var volumetricLightScatteringPixelShader: {
  152014. name: string;
  152015. shader: string;
  152016. };
  152017. }
  152018. declare module BABYLON {
  152019. /** @hidden */
  152020. export var volumetricLightScatteringPassVertexShader: {
  152021. name: string;
  152022. shader: string;
  152023. };
  152024. }
  152025. declare module BABYLON {
  152026. /** @hidden */
  152027. export var volumetricLightScatteringPassPixelShader: {
  152028. name: string;
  152029. shader: string;
  152030. };
  152031. }
  152032. declare module BABYLON {
  152033. /**
  152034. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152035. */
  152036. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152037. private _volumetricLightScatteringPass;
  152038. private _volumetricLightScatteringRTT;
  152039. private _viewPort;
  152040. private _screenCoordinates;
  152041. private _cachedDefines;
  152042. /**
  152043. * If not undefined, the mesh position is computed from the attached node position
  152044. */
  152045. attachedNode: {
  152046. position: Vector3;
  152047. };
  152048. /**
  152049. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152050. */
  152051. customMeshPosition: Vector3;
  152052. /**
  152053. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152054. */
  152055. useCustomMeshPosition: boolean;
  152056. /**
  152057. * If the post-process should inverse the light scattering direction
  152058. */
  152059. invert: boolean;
  152060. /**
  152061. * The internal mesh used by the post-process
  152062. */
  152063. mesh: Mesh;
  152064. /**
  152065. * @hidden
  152066. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152067. */
  152068. get useDiffuseColor(): boolean;
  152069. set useDiffuseColor(useDiffuseColor: boolean);
  152070. /**
  152071. * Array containing the excluded meshes not rendered in the internal pass
  152072. */
  152073. excludedMeshes: AbstractMesh[];
  152074. /**
  152075. * Controls the overall intensity of the post-process
  152076. */
  152077. exposure: number;
  152078. /**
  152079. * Dissipates each sample's contribution in range [0, 1]
  152080. */
  152081. decay: number;
  152082. /**
  152083. * Controls the overall intensity of each sample
  152084. */
  152085. weight: number;
  152086. /**
  152087. * Controls the density of each sample
  152088. */
  152089. density: number;
  152090. /**
  152091. * @constructor
  152092. * @param name The post-process name
  152093. * @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)
  152094. * @param camera The camera that the post-process will be attached to
  152095. * @param mesh The mesh used to create the light scattering
  152096. * @param samples The post-process quality, default 100
  152097. * @param samplingModeThe post-process filtering mode
  152098. * @param engine The babylon engine
  152099. * @param reusable If the post-process is reusable
  152100. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152101. */
  152102. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152103. /**
  152104. * Returns the string "VolumetricLightScatteringPostProcess"
  152105. * @returns "VolumetricLightScatteringPostProcess"
  152106. */
  152107. getClassName(): string;
  152108. private _isReady;
  152109. /**
  152110. * Sets the new light position for light scattering effect
  152111. * @param position The new custom light position
  152112. */
  152113. setCustomMeshPosition(position: Vector3): void;
  152114. /**
  152115. * Returns the light position for light scattering effect
  152116. * @return Vector3 The custom light position
  152117. */
  152118. getCustomMeshPosition(): Vector3;
  152119. /**
  152120. * Disposes the internal assets and detaches the post-process from the camera
  152121. */
  152122. dispose(camera: Camera): void;
  152123. /**
  152124. * Returns the render target texture used by the post-process
  152125. * @return the render target texture used by the post-process
  152126. */
  152127. getPass(): RenderTargetTexture;
  152128. private _meshExcluded;
  152129. private _createPass;
  152130. private _updateMeshScreenCoordinates;
  152131. /**
  152132. * Creates a default mesh for the Volumeric Light Scattering post-process
  152133. * @param name The mesh name
  152134. * @param scene The scene where to create the mesh
  152135. * @return the default mesh
  152136. */
  152137. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152138. }
  152139. }
  152140. declare module BABYLON {
  152141. /** @hidden */
  152142. export var screenSpaceCurvaturePixelShader: {
  152143. name: string;
  152144. shader: string;
  152145. };
  152146. }
  152147. declare module BABYLON {
  152148. /**
  152149. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152150. */
  152151. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152152. /**
  152153. * Defines how much ridge the curvature effect displays.
  152154. */
  152155. ridge: number;
  152156. /**
  152157. * Defines how much valley the curvature effect displays.
  152158. */
  152159. valley: number;
  152160. private _geometryBufferRenderer;
  152161. /**
  152162. * Gets a string identifying the name of the class
  152163. * @returns "ScreenSpaceCurvaturePostProcess" string
  152164. */
  152165. getClassName(): string;
  152166. /**
  152167. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152168. * @param name The name of the effect.
  152169. * @param scene The scene containing the objects to blur according to their velocity.
  152170. * @param options The required width/height ratio to downsize to before computing the render pass.
  152171. * @param camera The camera to apply the render pass to.
  152172. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152173. * @param engine The engine which the post process will be applied. (default: current engine)
  152174. * @param reusable If the post process can be reused on the same frame. (default: false)
  152175. * @param textureType Type of textures used when performing the post process. (default: 0)
  152176. * @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)
  152177. */
  152178. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152179. /**
  152180. * Support test.
  152181. */
  152182. static get IsSupported(): boolean;
  152183. /** @hidden */
  152184. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152185. }
  152186. }
  152187. declare module BABYLON {
  152188. interface Scene {
  152189. /** @hidden (Backing field) */
  152190. _boundingBoxRenderer: BoundingBoxRenderer;
  152191. /** @hidden (Backing field) */
  152192. _forceShowBoundingBoxes: boolean;
  152193. /**
  152194. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152195. */
  152196. forceShowBoundingBoxes: boolean;
  152197. /**
  152198. * Gets the bounding box renderer associated with the scene
  152199. * @returns a BoundingBoxRenderer
  152200. */
  152201. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152202. }
  152203. interface AbstractMesh {
  152204. /** @hidden (Backing field) */
  152205. _showBoundingBox: boolean;
  152206. /**
  152207. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152208. */
  152209. showBoundingBox: boolean;
  152210. }
  152211. /**
  152212. * Component responsible of rendering the bounding box of the meshes in a scene.
  152213. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152214. */
  152215. export class BoundingBoxRenderer implements ISceneComponent {
  152216. /**
  152217. * The component name helpfull to identify the component in the list of scene components.
  152218. */
  152219. readonly name: string;
  152220. /**
  152221. * The scene the component belongs to.
  152222. */
  152223. scene: Scene;
  152224. /**
  152225. * Color of the bounding box lines placed in front of an object
  152226. */
  152227. frontColor: Color3;
  152228. /**
  152229. * Color of the bounding box lines placed behind an object
  152230. */
  152231. backColor: Color3;
  152232. /**
  152233. * Defines if the renderer should show the back lines or not
  152234. */
  152235. showBackLines: boolean;
  152236. /**
  152237. * Observable raised before rendering a bounding box
  152238. */
  152239. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152240. /**
  152241. * Observable raised after rendering a bounding box
  152242. */
  152243. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152244. /**
  152245. * @hidden
  152246. */
  152247. renderList: SmartArray<BoundingBox>;
  152248. private _colorShader;
  152249. private _vertexBuffers;
  152250. private _indexBuffer;
  152251. private _fillIndexBuffer;
  152252. private _fillIndexData;
  152253. /**
  152254. * Instantiates a new bounding box renderer in a scene.
  152255. * @param scene the scene the renderer renders in
  152256. */
  152257. constructor(scene: Scene);
  152258. /**
  152259. * Registers the component in a given scene
  152260. */
  152261. register(): void;
  152262. private _evaluateSubMesh;
  152263. private _activeMesh;
  152264. private _prepareRessources;
  152265. private _createIndexBuffer;
  152266. /**
  152267. * Rebuilds the elements related to this component in case of
  152268. * context lost for instance.
  152269. */
  152270. rebuild(): void;
  152271. /**
  152272. * @hidden
  152273. */
  152274. reset(): void;
  152275. /**
  152276. * Render the bounding boxes of a specific rendering group
  152277. * @param renderingGroupId defines the rendering group to render
  152278. */
  152279. render(renderingGroupId: number): void;
  152280. /**
  152281. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152282. * @param mesh Define the mesh to render the occlusion bounding box for
  152283. */
  152284. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152285. /**
  152286. * Dispose and release the resources attached to this renderer.
  152287. */
  152288. dispose(): void;
  152289. }
  152290. }
  152291. declare module BABYLON {
  152292. interface Scene {
  152293. /** @hidden (Backing field) */
  152294. _depthRenderer: {
  152295. [id: string]: DepthRenderer;
  152296. };
  152297. /**
  152298. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152299. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152300. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152301. * @returns the created depth renderer
  152302. */
  152303. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  152304. /**
  152305. * Disables a depth renderer for a given camera
  152306. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152307. */
  152308. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152309. }
  152310. /**
  152311. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152312. * in several rendering techniques.
  152313. */
  152314. export class DepthRendererSceneComponent implements ISceneComponent {
  152315. /**
  152316. * The component name helpfull to identify the component in the list of scene components.
  152317. */
  152318. readonly name: string;
  152319. /**
  152320. * The scene the component belongs to.
  152321. */
  152322. scene: Scene;
  152323. /**
  152324. * Creates a new instance of the component for the given scene
  152325. * @param scene Defines the scene to register the component in
  152326. */
  152327. constructor(scene: Scene);
  152328. /**
  152329. * Registers the component in a given scene
  152330. */
  152331. register(): void;
  152332. /**
  152333. * Rebuilds the elements related to this component in case of
  152334. * context lost for instance.
  152335. */
  152336. rebuild(): void;
  152337. /**
  152338. * Disposes the component and the associated ressources
  152339. */
  152340. dispose(): void;
  152341. private _gatherRenderTargets;
  152342. private _gatherActiveCameraRenderTargets;
  152343. }
  152344. }
  152345. declare module BABYLON {
  152346. interface AbstractScene {
  152347. /** @hidden (Backing field) */
  152348. _prePassRenderer: Nullable<PrePassRenderer>;
  152349. /**
  152350. * Gets or Sets the current prepass renderer associated to the scene.
  152351. */
  152352. prePassRenderer: Nullable<PrePassRenderer>;
  152353. /**
  152354. * Enables the prepass and associates it with the scene
  152355. * @returns the PrePassRenderer
  152356. */
  152357. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152358. /**
  152359. * Disables the prepass associated with the scene
  152360. */
  152361. disablePrePassRenderer(): void;
  152362. }
  152363. /**
  152364. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152365. * in several rendering techniques.
  152366. */
  152367. export class PrePassRendererSceneComponent implements ISceneComponent {
  152368. /**
  152369. * The component name helpful to identify the component in the list of scene components.
  152370. */
  152371. readonly name: string;
  152372. /**
  152373. * The scene the component belongs to.
  152374. */
  152375. scene: Scene;
  152376. /**
  152377. * Creates a new instance of the component for the given scene
  152378. * @param scene Defines the scene to register the component in
  152379. */
  152380. constructor(scene: Scene);
  152381. /**
  152382. * Registers the component in a given scene
  152383. */
  152384. register(): void;
  152385. private _beforeCameraDraw;
  152386. private _afterCameraDraw;
  152387. private _beforeClearStage;
  152388. /**
  152389. * Rebuilds the elements related to this component in case of
  152390. * context lost for instance.
  152391. */
  152392. rebuild(): void;
  152393. /**
  152394. * Disposes the component and the associated ressources
  152395. */
  152396. dispose(): void;
  152397. }
  152398. }
  152399. declare module BABYLON {
  152400. /** @hidden */
  152401. export var fibonacci: {
  152402. name: string;
  152403. shader: string;
  152404. };
  152405. }
  152406. declare module BABYLON {
  152407. /** @hidden */
  152408. export var diffusionProfile: {
  152409. name: string;
  152410. shader: string;
  152411. };
  152412. }
  152413. declare module BABYLON {
  152414. /** @hidden */
  152415. export var subSurfaceScatteringPixelShader: {
  152416. name: string;
  152417. shader: string;
  152418. };
  152419. }
  152420. declare module BABYLON {
  152421. /**
  152422. * Sub surface scattering post process
  152423. */
  152424. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152425. /**
  152426. * Gets a string identifying the name of the class
  152427. * @returns "SubSurfaceScatteringPostProcess" string
  152428. */
  152429. getClassName(): string;
  152430. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152431. }
  152432. }
  152433. declare module BABYLON {
  152434. /**
  152435. * Contains all parameters needed for the prepass to perform
  152436. * screen space subsurface scattering
  152437. */
  152438. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152439. /** @hidden */
  152440. static _SceneComponentInitialization: (scene: Scene) => void;
  152441. private _ssDiffusionS;
  152442. private _ssFilterRadii;
  152443. private _ssDiffusionD;
  152444. /**
  152445. * Post process to attach for screen space subsurface scattering
  152446. */
  152447. postProcess: SubSurfaceScatteringPostProcess;
  152448. /**
  152449. * Diffusion profile color for subsurface scattering
  152450. */
  152451. get ssDiffusionS(): number[];
  152452. /**
  152453. * Diffusion profile max color channel value for subsurface scattering
  152454. */
  152455. get ssDiffusionD(): number[];
  152456. /**
  152457. * Diffusion profile filter radius for subsurface scattering
  152458. */
  152459. get ssFilterRadii(): number[];
  152460. /**
  152461. * Is subsurface enabled
  152462. */
  152463. enabled: boolean;
  152464. /**
  152465. * Name of the configuration
  152466. */
  152467. name: string;
  152468. /**
  152469. * Diffusion profile colors for subsurface scattering
  152470. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152471. * See ...
  152472. * Note that you can only store up to 5 of them
  152473. */
  152474. ssDiffusionProfileColors: Color3[];
  152475. /**
  152476. * Defines the ratio real world => scene units.
  152477. * Used for subsurface scattering
  152478. */
  152479. metersPerUnit: number;
  152480. /**
  152481. * Textures that should be present in the MRT for this effect to work
  152482. */
  152483. readonly texturesRequired: number[];
  152484. private _scene;
  152485. /**
  152486. * Builds a subsurface configuration object
  152487. * @param scene The scene
  152488. */
  152489. constructor(scene: Scene);
  152490. /**
  152491. * Adds a new diffusion profile.
  152492. * Useful for more realistic subsurface scattering on diverse materials.
  152493. * @param color The color of the diffusion profile. Should be the average color of the material.
  152494. * @return The index of the diffusion profile for the material subsurface configuration
  152495. */
  152496. addDiffusionProfile(color: Color3): number;
  152497. /**
  152498. * Creates the sss post process
  152499. * @return The created post process
  152500. */
  152501. createPostProcess(): SubSurfaceScatteringPostProcess;
  152502. /**
  152503. * Deletes all diffusion profiles.
  152504. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152505. */
  152506. clearAllDiffusionProfiles(): void;
  152507. /**
  152508. * Disposes this object
  152509. */
  152510. dispose(): void;
  152511. /**
  152512. * @hidden
  152513. * https://zero-radiance.github.io/post/sampling-diffusion/
  152514. *
  152515. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152516. * ------------------------------------------------------------------------------------
  152517. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152518. * PDF[r, phi, s] = r * R[r, phi, s]
  152519. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152520. * ------------------------------------------------------------------------------------
  152521. * We importance sample the color channel with the widest scattering distance.
  152522. */
  152523. getDiffusionProfileParameters(color: Color3): number;
  152524. /**
  152525. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152526. * 'u' is the random number (the value of the CDF): [0, 1).
  152527. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152528. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152529. */
  152530. private _sampleBurleyDiffusionProfile;
  152531. }
  152532. }
  152533. declare module BABYLON {
  152534. interface AbstractScene {
  152535. /** @hidden (Backing field) */
  152536. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152537. /**
  152538. * Gets or Sets the current prepass renderer associated to the scene.
  152539. */
  152540. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152541. /**
  152542. * Enables the subsurface effect for prepass
  152543. * @returns the SubSurfaceConfiguration
  152544. */
  152545. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152546. /**
  152547. * Disables the subsurface effect for prepass
  152548. */
  152549. disableSubSurfaceForPrePass(): void;
  152550. }
  152551. /**
  152552. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152553. * in several rendering techniques.
  152554. */
  152555. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  152556. /**
  152557. * The component name helpful to identify the component in the list of scene components.
  152558. */
  152559. readonly name: string;
  152560. /**
  152561. * The scene the component belongs to.
  152562. */
  152563. scene: Scene;
  152564. /**
  152565. * Creates a new instance of the component for the given scene
  152566. * @param scene Defines the scene to register the component in
  152567. */
  152568. constructor(scene: Scene);
  152569. /**
  152570. * Registers the component in a given scene
  152571. */
  152572. register(): void;
  152573. /**
  152574. * Serializes the component data to the specified json object
  152575. * @param serializationObject The object to serialize to
  152576. */
  152577. serialize(serializationObject: any): void;
  152578. /**
  152579. * Adds all the elements from the container to the scene
  152580. * @param container the container holding the elements
  152581. */
  152582. addFromContainer(container: AbstractScene): void;
  152583. /**
  152584. * Removes all the elements in the container from the scene
  152585. * @param container contains the elements to remove
  152586. * @param dispose if the removed element should be disposed (default: false)
  152587. */
  152588. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  152589. /**
  152590. * Rebuilds the elements related to this component in case of
  152591. * context lost for instance.
  152592. */
  152593. rebuild(): void;
  152594. /**
  152595. * Disposes the component and the associated ressources
  152596. */
  152597. dispose(): void;
  152598. }
  152599. }
  152600. declare module BABYLON {
  152601. /** @hidden */
  152602. export var outlinePixelShader: {
  152603. name: string;
  152604. shader: string;
  152605. };
  152606. }
  152607. declare module BABYLON {
  152608. /** @hidden */
  152609. export var outlineVertexShader: {
  152610. name: string;
  152611. shader: string;
  152612. };
  152613. }
  152614. declare module BABYLON {
  152615. interface Scene {
  152616. /** @hidden */
  152617. _outlineRenderer: OutlineRenderer;
  152618. /**
  152619. * Gets the outline renderer associated with the scene
  152620. * @returns a OutlineRenderer
  152621. */
  152622. getOutlineRenderer(): OutlineRenderer;
  152623. }
  152624. interface AbstractMesh {
  152625. /** @hidden (Backing field) */
  152626. _renderOutline: boolean;
  152627. /**
  152628. * Gets or sets a boolean indicating if the outline must be rendered as well
  152629. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  152630. */
  152631. renderOutline: boolean;
  152632. /** @hidden (Backing field) */
  152633. _renderOverlay: boolean;
  152634. /**
  152635. * Gets or sets a boolean indicating if the overlay must be rendered as well
  152636. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  152637. */
  152638. renderOverlay: boolean;
  152639. }
  152640. /**
  152641. * This class is responsible to draw bothe outline/overlay of meshes.
  152642. * It should not be used directly but through the available method on mesh.
  152643. */
  152644. export class OutlineRenderer implements ISceneComponent {
  152645. /**
  152646. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  152647. */
  152648. private static _StencilReference;
  152649. /**
  152650. * The name of the component. Each component must have a unique name.
  152651. */
  152652. name: string;
  152653. /**
  152654. * The scene the component belongs to.
  152655. */
  152656. scene: Scene;
  152657. /**
  152658. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  152659. */
  152660. zOffset: number;
  152661. private _engine;
  152662. private _effect;
  152663. private _cachedDefines;
  152664. private _savedDepthWrite;
  152665. /**
  152666. * Instantiates a new outline renderer. (There could be only one per scene).
  152667. * @param scene Defines the scene it belongs to
  152668. */
  152669. constructor(scene: Scene);
  152670. /**
  152671. * Register the component to one instance of a scene.
  152672. */
  152673. register(): void;
  152674. /**
  152675. * Rebuilds the elements related to this component in case of
  152676. * context lost for instance.
  152677. */
  152678. rebuild(): void;
  152679. /**
  152680. * Disposes the component and the associated ressources.
  152681. */
  152682. dispose(): void;
  152683. /**
  152684. * Renders the outline in the canvas.
  152685. * @param subMesh Defines the sumesh to render
  152686. * @param batch Defines the batch of meshes in case of instances
  152687. * @param useOverlay Defines if the rendering is for the overlay or the outline
  152688. */
  152689. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  152690. /**
  152691. * Returns whether or not the outline renderer is ready for a given submesh.
  152692. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  152693. * @param subMesh Defines the submesh to check readyness for
  152694. * @param useInstances Defines wheter wee are trying to render instances or not
  152695. * @returns true if ready otherwise false
  152696. */
  152697. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  152698. private _beforeRenderingMesh;
  152699. private _afterRenderingMesh;
  152700. }
  152701. }
  152702. declare module BABYLON {
  152703. /**
  152704. * Defines the basic options interface of a Sprite Frame Source Size.
  152705. */
  152706. export interface ISpriteJSONSpriteSourceSize {
  152707. /**
  152708. * number of the original width of the Frame
  152709. */
  152710. w: number;
  152711. /**
  152712. * number of the original height of the Frame
  152713. */
  152714. h: number;
  152715. }
  152716. /**
  152717. * Defines the basic options interface of a Sprite Frame Data.
  152718. */
  152719. export interface ISpriteJSONSpriteFrameData {
  152720. /**
  152721. * number of the x offset of the Frame
  152722. */
  152723. x: number;
  152724. /**
  152725. * number of the y offset of the Frame
  152726. */
  152727. y: number;
  152728. /**
  152729. * number of the width of the Frame
  152730. */
  152731. w: number;
  152732. /**
  152733. * number of the height of the Frame
  152734. */
  152735. h: number;
  152736. }
  152737. /**
  152738. * Defines the basic options interface of a JSON Sprite.
  152739. */
  152740. export interface ISpriteJSONSprite {
  152741. /**
  152742. * string name of the Frame
  152743. */
  152744. filename: string;
  152745. /**
  152746. * ISpriteJSONSpriteFrame basic object of the frame data
  152747. */
  152748. frame: ISpriteJSONSpriteFrameData;
  152749. /**
  152750. * boolean to flag is the frame was rotated.
  152751. */
  152752. rotated: boolean;
  152753. /**
  152754. * boolean to flag is the frame was trimmed.
  152755. */
  152756. trimmed: boolean;
  152757. /**
  152758. * ISpriteJSONSpriteFrame basic object of the source data
  152759. */
  152760. spriteSourceSize: ISpriteJSONSpriteFrameData;
  152761. /**
  152762. * ISpriteJSONSpriteFrame basic object of the source data
  152763. */
  152764. sourceSize: ISpriteJSONSpriteSourceSize;
  152765. }
  152766. /**
  152767. * Defines the basic options interface of a JSON atlas.
  152768. */
  152769. export interface ISpriteJSONAtlas {
  152770. /**
  152771. * Array of objects that contain the frame data.
  152772. */
  152773. frames: Array<ISpriteJSONSprite>;
  152774. /**
  152775. * object basic object containing the sprite meta data.
  152776. */
  152777. meta?: object;
  152778. }
  152779. }
  152780. declare module BABYLON {
  152781. /** @hidden */
  152782. export var spriteMapPixelShader: {
  152783. name: string;
  152784. shader: string;
  152785. };
  152786. }
  152787. declare module BABYLON {
  152788. /** @hidden */
  152789. export var spriteMapVertexShader: {
  152790. name: string;
  152791. shader: string;
  152792. };
  152793. }
  152794. declare module BABYLON {
  152795. /**
  152796. * Defines the basic options interface of a SpriteMap
  152797. */
  152798. export interface ISpriteMapOptions {
  152799. /**
  152800. * Vector2 of the number of cells in the grid.
  152801. */
  152802. stageSize?: Vector2;
  152803. /**
  152804. * Vector2 of the size of the output plane in World Units.
  152805. */
  152806. outputSize?: Vector2;
  152807. /**
  152808. * Vector3 of the position of the output plane in World Units.
  152809. */
  152810. outputPosition?: Vector3;
  152811. /**
  152812. * Vector3 of the rotation of the output plane.
  152813. */
  152814. outputRotation?: Vector3;
  152815. /**
  152816. * number of layers that the system will reserve in resources.
  152817. */
  152818. layerCount?: number;
  152819. /**
  152820. * number of max animation frames a single cell will reserve in resources.
  152821. */
  152822. maxAnimationFrames?: number;
  152823. /**
  152824. * number cell index of the base tile when the system compiles.
  152825. */
  152826. baseTile?: number;
  152827. /**
  152828. * boolean flip the sprite after its been repositioned by the framing data.
  152829. */
  152830. flipU?: boolean;
  152831. /**
  152832. * Vector3 scalar of the global RGB values of the SpriteMap.
  152833. */
  152834. colorMultiply?: Vector3;
  152835. }
  152836. /**
  152837. * Defines the IDisposable interface in order to be cleanable from resources.
  152838. */
  152839. export interface ISpriteMap extends IDisposable {
  152840. /**
  152841. * String name of the SpriteMap.
  152842. */
  152843. name: string;
  152844. /**
  152845. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  152846. */
  152847. atlasJSON: ISpriteJSONAtlas;
  152848. /**
  152849. * Texture of the SpriteMap.
  152850. */
  152851. spriteSheet: Texture;
  152852. /**
  152853. * The parameters to initialize the SpriteMap with.
  152854. */
  152855. options: ISpriteMapOptions;
  152856. }
  152857. /**
  152858. * Class used to manage a grid restricted sprite deployment on an Output plane.
  152859. */
  152860. export class SpriteMap implements ISpriteMap {
  152861. /** The Name of the spriteMap */
  152862. name: string;
  152863. /** The JSON file with the frame and meta data */
  152864. atlasJSON: ISpriteJSONAtlas;
  152865. /** The systems Sprite Sheet Texture */
  152866. spriteSheet: Texture;
  152867. /** Arguments passed with the Constructor */
  152868. options: ISpriteMapOptions;
  152869. /** Public Sprite Storage array, parsed from atlasJSON */
  152870. sprites: Array<ISpriteJSONSprite>;
  152871. /** Returns the Number of Sprites in the System */
  152872. get spriteCount(): number;
  152873. /** Returns the Position of Output Plane*/
  152874. get position(): Vector3;
  152875. /** Returns the Position of Output Plane*/
  152876. set position(v: Vector3);
  152877. /** Returns the Rotation of Output Plane*/
  152878. get rotation(): Vector3;
  152879. /** Returns the Rotation of Output Plane*/
  152880. set rotation(v: Vector3);
  152881. /** Sets the AnimationMap*/
  152882. get animationMap(): RawTexture;
  152883. /** Sets the AnimationMap*/
  152884. set animationMap(v: RawTexture);
  152885. /** Scene that the SpriteMap was created in */
  152886. private _scene;
  152887. /** Texture Buffer of Float32 that holds tile frame data*/
  152888. private _frameMap;
  152889. /** Texture Buffers of Float32 that holds tileMap data*/
  152890. private _tileMaps;
  152891. /** Texture Buffer of Float32 that holds Animation Data*/
  152892. private _animationMap;
  152893. /** Custom ShaderMaterial Central to the System*/
  152894. private _material;
  152895. /** Custom ShaderMaterial Central to the System*/
  152896. private _output;
  152897. /** Systems Time Ticker*/
  152898. private _time;
  152899. /**
  152900. * Creates a new SpriteMap
  152901. * @param name defines the SpriteMaps Name
  152902. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  152903. * @param spriteSheet is the Texture that the Sprites are on.
  152904. * @param options a basic deployment configuration
  152905. * @param scene The Scene that the map is deployed on
  152906. */
  152907. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  152908. /**
  152909. * Returns tileID location
  152910. * @returns Vector2 the cell position ID
  152911. */
  152912. getTileID(): Vector2;
  152913. /**
  152914. * Gets the UV location of the mouse over the SpriteMap.
  152915. * @returns Vector2 the UV position of the mouse interaction
  152916. */
  152917. getMousePosition(): Vector2;
  152918. /**
  152919. * Creates the "frame" texture Buffer
  152920. * -------------------------------------
  152921. * Structure of frames
  152922. * "filename": "Falling-Water-2.png",
  152923. * "frame": {"x":69,"y":103,"w":24,"h":32},
  152924. * "rotated": true,
  152925. * "trimmed": true,
  152926. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  152927. * "sourceSize": {"w":32,"h":32}
  152928. * @returns RawTexture of the frameMap
  152929. */
  152930. private _createFrameBuffer;
  152931. /**
  152932. * Creates the tileMap texture Buffer
  152933. * @param buffer normally and array of numbers, or a false to generate from scratch
  152934. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  152935. * @returns RawTexture of the tileMap
  152936. */
  152937. private _createTileBuffer;
  152938. /**
  152939. * Modifies the data of the tileMaps
  152940. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  152941. * @param pos is the iVector2 Coordinates of the Tile
  152942. * @param tile The SpriteIndex of the new Tile
  152943. */
  152944. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  152945. /**
  152946. * Creates the animationMap texture Buffer
  152947. * @param buffer normally and array of numbers, or a false to generate from scratch
  152948. * @returns RawTexture of the animationMap
  152949. */
  152950. private _createTileAnimationBuffer;
  152951. /**
  152952. * Modifies the data of the animationMap
  152953. * @param cellID is the Index of the Sprite
  152954. * @param _frame is the target Animation frame
  152955. * @param toCell is the Target Index of the next frame of the animation
  152956. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  152957. * @param speed is a global scalar of the time variable on the map.
  152958. */
  152959. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  152960. /**
  152961. * Exports the .tilemaps file
  152962. */
  152963. saveTileMaps(): void;
  152964. /**
  152965. * Imports the .tilemaps file
  152966. * @param url of the .tilemaps file
  152967. */
  152968. loadTileMaps(url: string): void;
  152969. /**
  152970. * Release associated resources
  152971. */
  152972. dispose(): void;
  152973. }
  152974. }
  152975. declare module BABYLON {
  152976. /**
  152977. * Class used to manage multiple sprites of different sizes on the same spritesheet
  152978. * @see https://doc.babylonjs.com/babylon101/sprites
  152979. */
  152980. export class SpritePackedManager extends SpriteManager {
  152981. /** defines the packed manager's name */
  152982. name: string;
  152983. /**
  152984. * Creates a new sprite manager from a packed sprite sheet
  152985. * @param name defines the manager's name
  152986. * @param imgUrl defines the sprite sheet url
  152987. * @param capacity defines the maximum allowed number of sprites
  152988. * @param scene defines the hosting scene
  152989. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  152990. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  152991. * @param samplingMode defines the smapling mode to use with spritesheet
  152992. * @param fromPacked set to true; do not alter
  152993. */
  152994. constructor(
  152995. /** defines the packed manager's name */
  152996. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  152997. }
  152998. }
  152999. declare module BABYLON {
  153000. /**
  153001. * Defines the list of states available for a task inside a AssetsManager
  153002. */
  153003. export enum AssetTaskState {
  153004. /**
  153005. * Initialization
  153006. */
  153007. INIT = 0,
  153008. /**
  153009. * Running
  153010. */
  153011. RUNNING = 1,
  153012. /**
  153013. * Done
  153014. */
  153015. DONE = 2,
  153016. /**
  153017. * Error
  153018. */
  153019. ERROR = 3
  153020. }
  153021. /**
  153022. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153023. */
  153024. export abstract class AbstractAssetTask {
  153025. /**
  153026. * Task name
  153027. */ name: string;
  153028. /**
  153029. * Callback called when the task is successful
  153030. */
  153031. onSuccess: (task: any) => void;
  153032. /**
  153033. * Callback called when the task is not successful
  153034. */
  153035. onError: (task: any, message?: string, exception?: any) => void;
  153036. /**
  153037. * Creates a new AssetsManager
  153038. * @param name defines the name of the task
  153039. */
  153040. constructor(
  153041. /**
  153042. * Task name
  153043. */ name: string);
  153044. private _isCompleted;
  153045. private _taskState;
  153046. private _errorObject;
  153047. /**
  153048. * Get if the task is completed
  153049. */
  153050. get isCompleted(): boolean;
  153051. /**
  153052. * Gets the current state of the task
  153053. */
  153054. get taskState(): AssetTaskState;
  153055. /**
  153056. * Gets the current error object (if task is in error)
  153057. */
  153058. get errorObject(): {
  153059. message?: string;
  153060. exception?: any;
  153061. };
  153062. /**
  153063. * Internal only
  153064. * @hidden
  153065. */
  153066. _setErrorObject(message?: string, exception?: any): void;
  153067. /**
  153068. * Execute the current task
  153069. * @param scene defines the scene where you want your assets to be loaded
  153070. * @param onSuccess is a callback called when the task is successfully executed
  153071. * @param onError is a callback called if an error occurs
  153072. */
  153073. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153074. /**
  153075. * Execute the current task
  153076. * @param scene defines the scene where you want your assets to be loaded
  153077. * @param onSuccess is a callback called when the task is successfully executed
  153078. * @param onError is a callback called if an error occurs
  153079. */
  153080. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153081. /**
  153082. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153083. * This can be used with failed tasks that have the reason for failure fixed.
  153084. */
  153085. reset(): void;
  153086. private onErrorCallback;
  153087. private onDoneCallback;
  153088. }
  153089. /**
  153090. * Define the interface used by progress events raised during assets loading
  153091. */
  153092. export interface IAssetsProgressEvent {
  153093. /**
  153094. * Defines the number of remaining tasks to process
  153095. */
  153096. remainingCount: number;
  153097. /**
  153098. * Defines the total number of tasks
  153099. */
  153100. totalCount: number;
  153101. /**
  153102. * Defines the task that was just processed
  153103. */
  153104. task: AbstractAssetTask;
  153105. }
  153106. /**
  153107. * Class used to share progress information about assets loading
  153108. */
  153109. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153110. /**
  153111. * Defines the number of remaining tasks to process
  153112. */
  153113. remainingCount: number;
  153114. /**
  153115. * Defines the total number of tasks
  153116. */
  153117. totalCount: number;
  153118. /**
  153119. * Defines the task that was just processed
  153120. */
  153121. task: AbstractAssetTask;
  153122. /**
  153123. * Creates a AssetsProgressEvent
  153124. * @param remainingCount defines the number of remaining tasks to process
  153125. * @param totalCount defines the total number of tasks
  153126. * @param task defines the task that was just processed
  153127. */
  153128. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153129. }
  153130. /**
  153131. * Define a task used by AssetsManager to load assets into a container
  153132. */
  153133. export class ContainerAssetTask extends AbstractAssetTask {
  153134. /**
  153135. * Defines the name of the task
  153136. */
  153137. name: string;
  153138. /**
  153139. * Defines the list of mesh's names you want to load
  153140. */
  153141. meshesNames: any;
  153142. /**
  153143. * Defines the root url to use as a base to load your meshes and associated resources
  153144. */
  153145. rootUrl: string;
  153146. /**
  153147. * Defines the filename or File of the scene to load from
  153148. */
  153149. sceneFilename: string | File;
  153150. /**
  153151. * Get the loaded asset container
  153152. */
  153153. loadedContainer: AssetContainer;
  153154. /**
  153155. * Gets the list of loaded meshes
  153156. */
  153157. loadedMeshes: Array<AbstractMesh>;
  153158. /**
  153159. * Gets the list of loaded particle systems
  153160. */
  153161. loadedParticleSystems: Array<IParticleSystem>;
  153162. /**
  153163. * Gets the list of loaded skeletons
  153164. */
  153165. loadedSkeletons: Array<Skeleton>;
  153166. /**
  153167. * Gets the list of loaded animation groups
  153168. */
  153169. loadedAnimationGroups: Array<AnimationGroup>;
  153170. /**
  153171. * Callback called when the task is successful
  153172. */
  153173. onSuccess: (task: ContainerAssetTask) => void;
  153174. /**
  153175. * Callback called when the task is successful
  153176. */
  153177. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153178. /**
  153179. * Creates a new ContainerAssetTask
  153180. * @param name defines the name of the task
  153181. * @param meshesNames defines the list of mesh's names you want to load
  153182. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153183. * @param sceneFilename defines the filename or File of the scene to load from
  153184. */
  153185. constructor(
  153186. /**
  153187. * Defines the name of the task
  153188. */
  153189. name: string,
  153190. /**
  153191. * Defines the list of mesh's names you want to load
  153192. */
  153193. meshesNames: any,
  153194. /**
  153195. * Defines the root url to use as a base to load your meshes and associated resources
  153196. */
  153197. rootUrl: string,
  153198. /**
  153199. * Defines the filename or File of the scene to load from
  153200. */
  153201. sceneFilename: string | File);
  153202. /**
  153203. * Execute the current task
  153204. * @param scene defines the scene where you want your assets to be loaded
  153205. * @param onSuccess is a callback called when the task is successfully executed
  153206. * @param onError is a callback called if an error occurs
  153207. */
  153208. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153209. }
  153210. /**
  153211. * Define a task used by AssetsManager to load meshes
  153212. */
  153213. export class MeshAssetTask extends AbstractAssetTask {
  153214. /**
  153215. * Defines the name of the task
  153216. */
  153217. name: string;
  153218. /**
  153219. * Defines the list of mesh's names you want to load
  153220. */
  153221. meshesNames: any;
  153222. /**
  153223. * Defines the root url to use as a base to load your meshes and associated resources
  153224. */
  153225. rootUrl: string;
  153226. /**
  153227. * Defines the filename or File of the scene to load from
  153228. */
  153229. sceneFilename: string | File;
  153230. /**
  153231. * Gets the list of loaded meshes
  153232. */
  153233. loadedMeshes: Array<AbstractMesh>;
  153234. /**
  153235. * Gets the list of loaded particle systems
  153236. */
  153237. loadedParticleSystems: Array<IParticleSystem>;
  153238. /**
  153239. * Gets the list of loaded skeletons
  153240. */
  153241. loadedSkeletons: Array<Skeleton>;
  153242. /**
  153243. * Gets the list of loaded animation groups
  153244. */
  153245. loadedAnimationGroups: Array<AnimationGroup>;
  153246. /**
  153247. * Callback called when the task is successful
  153248. */
  153249. onSuccess: (task: MeshAssetTask) => void;
  153250. /**
  153251. * Callback called when the task is successful
  153252. */
  153253. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153254. /**
  153255. * Creates a new MeshAssetTask
  153256. * @param name defines the name of the task
  153257. * @param meshesNames defines the list of mesh's names you want to load
  153258. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153259. * @param sceneFilename defines the filename or File of the scene to load from
  153260. */
  153261. constructor(
  153262. /**
  153263. * Defines the name of the task
  153264. */
  153265. name: string,
  153266. /**
  153267. * Defines the list of mesh's names you want to load
  153268. */
  153269. meshesNames: any,
  153270. /**
  153271. * Defines the root url to use as a base to load your meshes and associated resources
  153272. */
  153273. rootUrl: string,
  153274. /**
  153275. * Defines the filename or File of the scene to load from
  153276. */
  153277. sceneFilename: string | File);
  153278. /**
  153279. * Execute the current task
  153280. * @param scene defines the scene where you want your assets to be loaded
  153281. * @param onSuccess is a callback called when the task is successfully executed
  153282. * @param onError is a callback called if an error occurs
  153283. */
  153284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153285. }
  153286. /**
  153287. * Define a task used by AssetsManager to load text content
  153288. */
  153289. export class TextFileAssetTask extends AbstractAssetTask {
  153290. /**
  153291. * Defines the name of the task
  153292. */
  153293. name: string;
  153294. /**
  153295. * Defines the location of the file to load
  153296. */
  153297. url: string;
  153298. /**
  153299. * Gets the loaded text string
  153300. */
  153301. text: string;
  153302. /**
  153303. * Callback called when the task is successful
  153304. */
  153305. onSuccess: (task: TextFileAssetTask) => void;
  153306. /**
  153307. * Callback called when the task is successful
  153308. */
  153309. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153310. /**
  153311. * Creates a new TextFileAssetTask object
  153312. * @param name defines the name of the task
  153313. * @param url defines the location of the file to load
  153314. */
  153315. constructor(
  153316. /**
  153317. * Defines the name of the task
  153318. */
  153319. name: string,
  153320. /**
  153321. * Defines the location of the file to load
  153322. */
  153323. url: string);
  153324. /**
  153325. * Execute the current task
  153326. * @param scene defines the scene where you want your assets to be loaded
  153327. * @param onSuccess is a callback called when the task is successfully executed
  153328. * @param onError is a callback called if an error occurs
  153329. */
  153330. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153331. }
  153332. /**
  153333. * Define a task used by AssetsManager to load binary data
  153334. */
  153335. export class BinaryFileAssetTask extends AbstractAssetTask {
  153336. /**
  153337. * Defines the name of the task
  153338. */
  153339. name: string;
  153340. /**
  153341. * Defines the location of the file to load
  153342. */
  153343. url: string;
  153344. /**
  153345. * Gets the lodaded data (as an array buffer)
  153346. */
  153347. data: ArrayBuffer;
  153348. /**
  153349. * Callback called when the task is successful
  153350. */
  153351. onSuccess: (task: BinaryFileAssetTask) => void;
  153352. /**
  153353. * Callback called when the task is successful
  153354. */
  153355. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153356. /**
  153357. * Creates a new BinaryFileAssetTask object
  153358. * @param name defines the name of the new task
  153359. * @param url defines the location of the file to load
  153360. */
  153361. constructor(
  153362. /**
  153363. * Defines the name of the task
  153364. */
  153365. name: string,
  153366. /**
  153367. * Defines the location of the file to load
  153368. */
  153369. url: string);
  153370. /**
  153371. * Execute the current task
  153372. * @param scene defines the scene where you want your assets to be loaded
  153373. * @param onSuccess is a callback called when the task is successfully executed
  153374. * @param onError is a callback called if an error occurs
  153375. */
  153376. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153377. }
  153378. /**
  153379. * Define a task used by AssetsManager to load images
  153380. */
  153381. export class ImageAssetTask extends AbstractAssetTask {
  153382. /**
  153383. * Defines the name of the task
  153384. */
  153385. name: string;
  153386. /**
  153387. * Defines the location of the image to load
  153388. */
  153389. url: string;
  153390. /**
  153391. * Gets the loaded images
  153392. */
  153393. image: HTMLImageElement;
  153394. /**
  153395. * Callback called when the task is successful
  153396. */
  153397. onSuccess: (task: ImageAssetTask) => void;
  153398. /**
  153399. * Callback called when the task is successful
  153400. */
  153401. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153402. /**
  153403. * Creates a new ImageAssetTask
  153404. * @param name defines the name of the task
  153405. * @param url defines the location of the image to load
  153406. */
  153407. constructor(
  153408. /**
  153409. * Defines the name of the task
  153410. */
  153411. name: string,
  153412. /**
  153413. * Defines the location of the image to load
  153414. */
  153415. url: string);
  153416. /**
  153417. * Execute the current task
  153418. * @param scene defines the scene where you want your assets to be loaded
  153419. * @param onSuccess is a callback called when the task is successfully executed
  153420. * @param onError is a callback called if an error occurs
  153421. */
  153422. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153423. }
  153424. /**
  153425. * Defines the interface used by texture loading tasks
  153426. */
  153427. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153428. /**
  153429. * Gets the loaded texture
  153430. */
  153431. texture: TEX;
  153432. }
  153433. /**
  153434. * Define a task used by AssetsManager to load 2D textures
  153435. */
  153436. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153437. /**
  153438. * Defines the name of the task
  153439. */
  153440. name: string;
  153441. /**
  153442. * Defines the location of the file to load
  153443. */
  153444. url: string;
  153445. /**
  153446. * Defines if mipmap should not be generated (default is false)
  153447. */
  153448. noMipmap?: boolean | undefined;
  153449. /**
  153450. * Defines if texture must be inverted on Y axis (default is true)
  153451. */
  153452. invertY: boolean;
  153453. /**
  153454. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153455. */
  153456. samplingMode: number;
  153457. /**
  153458. * Gets the loaded texture
  153459. */
  153460. texture: Texture;
  153461. /**
  153462. * Callback called when the task is successful
  153463. */
  153464. onSuccess: (task: TextureAssetTask) => void;
  153465. /**
  153466. * Callback called when the task is successful
  153467. */
  153468. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153469. /**
  153470. * Creates a new TextureAssetTask object
  153471. * @param name defines the name of the task
  153472. * @param url defines the location of the file to load
  153473. * @param noMipmap defines if mipmap should not be generated (default is false)
  153474. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153475. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153476. */
  153477. constructor(
  153478. /**
  153479. * Defines the name of the task
  153480. */
  153481. name: string,
  153482. /**
  153483. * Defines the location of the file to load
  153484. */
  153485. url: string,
  153486. /**
  153487. * Defines if mipmap should not be generated (default is false)
  153488. */
  153489. noMipmap?: boolean | undefined,
  153490. /**
  153491. * Defines if texture must be inverted on Y axis (default is true)
  153492. */
  153493. invertY?: boolean,
  153494. /**
  153495. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153496. */
  153497. samplingMode?: number);
  153498. /**
  153499. * Execute the current task
  153500. * @param scene defines the scene where you want your assets to be loaded
  153501. * @param onSuccess is a callback called when the task is successfully executed
  153502. * @param onError is a callback called if an error occurs
  153503. */
  153504. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153505. }
  153506. /**
  153507. * Define a task used by AssetsManager to load cube textures
  153508. */
  153509. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153510. /**
  153511. * Defines the name of the task
  153512. */
  153513. name: string;
  153514. /**
  153515. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153516. */
  153517. url: string;
  153518. /**
  153519. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153520. */
  153521. extensions?: string[] | undefined;
  153522. /**
  153523. * Defines if mipmaps should not be generated (default is false)
  153524. */
  153525. noMipmap?: boolean | undefined;
  153526. /**
  153527. * Defines the explicit list of files (undefined by default)
  153528. */
  153529. files?: string[] | undefined;
  153530. /**
  153531. * Gets the loaded texture
  153532. */
  153533. texture: CubeTexture;
  153534. /**
  153535. * Callback called when the task is successful
  153536. */
  153537. onSuccess: (task: CubeTextureAssetTask) => void;
  153538. /**
  153539. * Callback called when the task is successful
  153540. */
  153541. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153542. /**
  153543. * Creates a new CubeTextureAssetTask
  153544. * @param name defines the name of the task
  153545. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153546. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153547. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153548. * @param files defines the explicit list of files (undefined by default)
  153549. */
  153550. constructor(
  153551. /**
  153552. * Defines the name of the task
  153553. */
  153554. name: string,
  153555. /**
  153556. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153557. */
  153558. url: string,
  153559. /**
  153560. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153561. */
  153562. extensions?: string[] | undefined,
  153563. /**
  153564. * Defines if mipmaps should not be generated (default is false)
  153565. */
  153566. noMipmap?: boolean | undefined,
  153567. /**
  153568. * Defines the explicit list of files (undefined by default)
  153569. */
  153570. files?: string[] | undefined);
  153571. /**
  153572. * Execute the current task
  153573. * @param scene defines the scene where you want your assets to be loaded
  153574. * @param onSuccess is a callback called when the task is successfully executed
  153575. * @param onError is a callback called if an error occurs
  153576. */
  153577. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153578. }
  153579. /**
  153580. * Define a task used by AssetsManager to load HDR cube textures
  153581. */
  153582. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  153583. /**
  153584. * Defines the name of the task
  153585. */
  153586. name: string;
  153587. /**
  153588. * Defines the location of the file to load
  153589. */
  153590. url: string;
  153591. /**
  153592. * Defines the desired size (the more it increases the longer the generation will be)
  153593. */
  153594. size: number;
  153595. /**
  153596. * Defines if mipmaps should not be generated (default is false)
  153597. */
  153598. noMipmap: boolean;
  153599. /**
  153600. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153601. */
  153602. generateHarmonics: boolean;
  153603. /**
  153604. * 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)
  153605. */
  153606. gammaSpace: boolean;
  153607. /**
  153608. * Internal Use Only
  153609. */
  153610. reserved: boolean;
  153611. /**
  153612. * Gets the loaded texture
  153613. */
  153614. texture: HDRCubeTexture;
  153615. /**
  153616. * Callback called when the task is successful
  153617. */
  153618. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  153619. /**
  153620. * Callback called when the task is successful
  153621. */
  153622. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  153623. /**
  153624. * Creates a new HDRCubeTextureAssetTask object
  153625. * @param name defines the name of the task
  153626. * @param url defines the location of the file to load
  153627. * @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.
  153628. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153629. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153630. * @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)
  153631. * @param reserved Internal use only
  153632. */
  153633. constructor(
  153634. /**
  153635. * Defines the name of the task
  153636. */
  153637. name: string,
  153638. /**
  153639. * Defines the location of the file to load
  153640. */
  153641. url: string,
  153642. /**
  153643. * Defines the desired size (the more it increases the longer the generation will be)
  153644. */
  153645. size: number,
  153646. /**
  153647. * Defines if mipmaps should not be generated (default is false)
  153648. */
  153649. noMipmap?: boolean,
  153650. /**
  153651. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  153652. */
  153653. generateHarmonics?: boolean,
  153654. /**
  153655. * 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)
  153656. */
  153657. gammaSpace?: boolean,
  153658. /**
  153659. * Internal Use Only
  153660. */
  153661. reserved?: boolean);
  153662. /**
  153663. * Execute the current task
  153664. * @param scene defines the scene where you want your assets to be loaded
  153665. * @param onSuccess is a callback called when the task is successfully executed
  153666. * @param onError is a callback called if an error occurs
  153667. */
  153668. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153669. }
  153670. /**
  153671. * Define a task used by AssetsManager to load Equirectangular cube textures
  153672. */
  153673. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  153674. /**
  153675. * Defines the name of the task
  153676. */
  153677. name: string;
  153678. /**
  153679. * Defines the location of the file to load
  153680. */
  153681. url: string;
  153682. /**
  153683. * Defines the desired size (the more it increases the longer the generation will be)
  153684. */
  153685. size: number;
  153686. /**
  153687. * Defines if mipmaps should not be generated (default is false)
  153688. */
  153689. noMipmap: boolean;
  153690. /**
  153691. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153692. * but the standard material would require them in Gamma space) (default is true)
  153693. */
  153694. gammaSpace: boolean;
  153695. /**
  153696. * Gets the loaded texture
  153697. */
  153698. texture: EquiRectangularCubeTexture;
  153699. /**
  153700. * Callback called when the task is successful
  153701. */
  153702. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  153703. /**
  153704. * Callback called when the task is successful
  153705. */
  153706. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  153707. /**
  153708. * Creates a new EquiRectangularCubeTextureAssetTask object
  153709. * @param name defines the name of the task
  153710. * @param url defines the location of the file to load
  153711. * @param size defines the desired size (the more it increases the longer the generation will be)
  153712. * If the size is omitted this implies you are using a preprocessed cubemap.
  153713. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153714. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  153715. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  153716. * (default is true)
  153717. */
  153718. constructor(
  153719. /**
  153720. * Defines the name of the task
  153721. */
  153722. name: string,
  153723. /**
  153724. * Defines the location of the file to load
  153725. */
  153726. url: string,
  153727. /**
  153728. * Defines the desired size (the more it increases the longer the generation will be)
  153729. */
  153730. size: number,
  153731. /**
  153732. * Defines if mipmaps should not be generated (default is false)
  153733. */
  153734. noMipmap?: boolean,
  153735. /**
  153736. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  153737. * but the standard material would require them in Gamma space) (default is true)
  153738. */
  153739. gammaSpace?: boolean);
  153740. /**
  153741. * Execute the current task
  153742. * @param scene defines the scene where you want your assets to be loaded
  153743. * @param onSuccess is a callback called when the task is successfully executed
  153744. * @param onError is a callback called if an error occurs
  153745. */
  153746. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153747. }
  153748. /**
  153749. * This class can be used to easily import assets into a scene
  153750. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  153751. */
  153752. export class AssetsManager {
  153753. private _scene;
  153754. private _isLoading;
  153755. protected _tasks: AbstractAssetTask[];
  153756. protected _waitingTasksCount: number;
  153757. protected _totalTasksCount: number;
  153758. /**
  153759. * Callback called when all tasks are processed
  153760. */
  153761. onFinish: (tasks: AbstractAssetTask[]) => void;
  153762. /**
  153763. * Callback called when a task is successful
  153764. */
  153765. onTaskSuccess: (task: AbstractAssetTask) => void;
  153766. /**
  153767. * Callback called when a task had an error
  153768. */
  153769. onTaskError: (task: AbstractAssetTask) => void;
  153770. /**
  153771. * Callback called when a task is done (whatever the result is)
  153772. */
  153773. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  153774. /**
  153775. * Observable called when all tasks are processed
  153776. */
  153777. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  153778. /**
  153779. * Observable called when a task had an error
  153780. */
  153781. onTaskErrorObservable: Observable<AbstractAssetTask>;
  153782. /**
  153783. * Observable called when all tasks were executed
  153784. */
  153785. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  153786. /**
  153787. * Observable called when a task is done (whatever the result is)
  153788. */
  153789. onProgressObservable: Observable<IAssetsProgressEvent>;
  153790. /**
  153791. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  153792. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  153793. */
  153794. useDefaultLoadingScreen: boolean;
  153795. /**
  153796. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  153797. * when all assets have been downloaded.
  153798. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  153799. */
  153800. autoHideLoadingUI: boolean;
  153801. /**
  153802. * Creates a new AssetsManager
  153803. * @param scene defines the scene to work on
  153804. */
  153805. constructor(scene: Scene);
  153806. /**
  153807. * Add a ContainerAssetTask to the list of active tasks
  153808. * @param taskName defines the name of the new task
  153809. * @param meshesNames defines the name of meshes to load
  153810. * @param rootUrl defines the root url to use to locate files
  153811. * @param sceneFilename defines the filename of the scene file
  153812. * @returns a new ContainerAssetTask object
  153813. */
  153814. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  153815. /**
  153816. * Add a MeshAssetTask to the list of active tasks
  153817. * @param taskName defines the name of the new task
  153818. * @param meshesNames defines the name of meshes to load
  153819. * @param rootUrl defines the root url to use to locate files
  153820. * @param sceneFilename defines the filename of the scene file
  153821. * @returns a new MeshAssetTask object
  153822. */
  153823. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  153824. /**
  153825. * Add a TextFileAssetTask to the list of active tasks
  153826. * @param taskName defines the name of the new task
  153827. * @param url defines the url of the file to load
  153828. * @returns a new TextFileAssetTask object
  153829. */
  153830. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  153831. /**
  153832. * Add a BinaryFileAssetTask to the list of active tasks
  153833. * @param taskName defines the name of the new task
  153834. * @param url defines the url of the file to load
  153835. * @returns a new BinaryFileAssetTask object
  153836. */
  153837. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  153838. /**
  153839. * Add a ImageAssetTask to the list of active tasks
  153840. * @param taskName defines the name of the new task
  153841. * @param url defines the url of the file to load
  153842. * @returns a new ImageAssetTask object
  153843. */
  153844. addImageTask(taskName: string, url: string): ImageAssetTask;
  153845. /**
  153846. * Add a TextureAssetTask to the list of active tasks
  153847. * @param taskName defines the name of the new task
  153848. * @param url defines the url of the file to load
  153849. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153850. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  153851. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  153852. * @returns a new TextureAssetTask object
  153853. */
  153854. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  153855. /**
  153856. * Add a CubeTextureAssetTask to the list of active tasks
  153857. * @param taskName defines the name of the new task
  153858. * @param url defines the url of the file to load
  153859. * @param extensions defines the extension to use to load the cube map (can be null)
  153860. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153861. * @param files defines the list of files to load (can be null)
  153862. * @returns a new CubeTextureAssetTask object
  153863. */
  153864. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  153865. /**
  153866. *
  153867. * Add a HDRCubeTextureAssetTask to the list of active tasks
  153868. * @param taskName defines the name of the new task
  153869. * @param url defines the url of the file to load
  153870. * @param size defines the size you want for the cubemap (can be null)
  153871. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153872. * @param generateHarmonics defines if you want to automatically generate (true by default)
  153873. * @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)
  153874. * @param reserved Internal use only
  153875. * @returns a new HDRCubeTextureAssetTask object
  153876. */
  153877. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  153878. /**
  153879. *
  153880. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  153881. * @param taskName defines the name of the new task
  153882. * @param url defines the url of the file to load
  153883. * @param size defines the size you want for the cubemap (can be null)
  153884. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  153885. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  153886. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  153887. * @returns a new EquiRectangularCubeTextureAssetTask object
  153888. */
  153889. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  153890. /**
  153891. * Remove a task from the assets manager.
  153892. * @param task the task to remove
  153893. */
  153894. removeTask(task: AbstractAssetTask): void;
  153895. private _decreaseWaitingTasksCount;
  153896. private _runTask;
  153897. /**
  153898. * Reset the AssetsManager and remove all tasks
  153899. * @return the current instance of the AssetsManager
  153900. */
  153901. reset(): AssetsManager;
  153902. /**
  153903. * Start the loading process
  153904. * @return the current instance of the AssetsManager
  153905. */
  153906. load(): AssetsManager;
  153907. /**
  153908. * Start the loading process as an async operation
  153909. * @return a promise returning the list of failed tasks
  153910. */
  153911. loadAsync(): Promise<void>;
  153912. }
  153913. }
  153914. declare module BABYLON {
  153915. /**
  153916. * Wrapper class for promise with external resolve and reject.
  153917. */
  153918. export class Deferred<T> {
  153919. /**
  153920. * The promise associated with this deferred object.
  153921. */
  153922. readonly promise: Promise<T>;
  153923. private _resolve;
  153924. private _reject;
  153925. /**
  153926. * The resolve method of the promise associated with this deferred object.
  153927. */
  153928. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  153929. /**
  153930. * The reject method of the promise associated with this deferred object.
  153931. */
  153932. get reject(): (reason?: any) => void;
  153933. /**
  153934. * Constructor for this deferred object.
  153935. */
  153936. constructor();
  153937. }
  153938. }
  153939. declare module BABYLON {
  153940. /**
  153941. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  153942. */
  153943. export class MeshExploder {
  153944. private _centerMesh;
  153945. private _meshes;
  153946. private _meshesOrigins;
  153947. private _toCenterVectors;
  153948. private _scaledDirection;
  153949. private _newPosition;
  153950. private _centerPosition;
  153951. /**
  153952. * Explodes meshes from a center mesh.
  153953. * @param meshes The meshes to explode.
  153954. * @param centerMesh The mesh to be center of explosion.
  153955. */
  153956. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  153957. private _setCenterMesh;
  153958. /**
  153959. * Get class name
  153960. * @returns "MeshExploder"
  153961. */
  153962. getClassName(): string;
  153963. /**
  153964. * "Exploded meshes"
  153965. * @returns Array of meshes with the centerMesh at index 0.
  153966. */
  153967. getMeshes(): Array<Mesh>;
  153968. /**
  153969. * Explodes meshes giving a specific direction
  153970. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  153971. */
  153972. explode(direction?: number): void;
  153973. }
  153974. }
  153975. declare module BABYLON {
  153976. /**
  153977. * Class used to help managing file picking and drag'n'drop
  153978. */
  153979. export class FilesInput {
  153980. /**
  153981. * List of files ready to be loaded
  153982. */
  153983. static get FilesToLoad(): {
  153984. [key: string]: File;
  153985. };
  153986. /**
  153987. * Callback called when a file is processed
  153988. */
  153989. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  153990. private _engine;
  153991. private _currentScene;
  153992. private _sceneLoadedCallback;
  153993. private _progressCallback;
  153994. private _additionalRenderLoopLogicCallback;
  153995. private _textureLoadingCallback;
  153996. private _startingProcessingFilesCallback;
  153997. private _onReloadCallback;
  153998. private _errorCallback;
  153999. private _elementToMonitor;
  154000. private _sceneFileToLoad;
  154001. private _filesToLoad;
  154002. /**
  154003. * Creates a new FilesInput
  154004. * @param engine defines the rendering engine
  154005. * @param scene defines the hosting scene
  154006. * @param sceneLoadedCallback callback called when scene is loaded
  154007. * @param progressCallback callback called to track progress
  154008. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154009. * @param textureLoadingCallback callback called when a texture is loading
  154010. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154011. * @param onReloadCallback callback called when a reload is requested
  154012. * @param errorCallback callback call if an error occurs
  154013. */
  154014. 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>);
  154015. private _dragEnterHandler;
  154016. private _dragOverHandler;
  154017. private _dropHandler;
  154018. /**
  154019. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154020. * @param elementToMonitor defines the DOM element to track
  154021. */
  154022. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154023. /** Gets the current list of files to load */
  154024. get filesToLoad(): File[];
  154025. /**
  154026. * Release all associated resources
  154027. */
  154028. dispose(): void;
  154029. private renderFunction;
  154030. private drag;
  154031. private drop;
  154032. private _traverseFolder;
  154033. private _processFiles;
  154034. /**
  154035. * Load files from a drop event
  154036. * @param event defines the drop event to use as source
  154037. */
  154038. loadFiles(event: any): void;
  154039. private _processReload;
  154040. /**
  154041. * Reload the current scene from the loaded files
  154042. */
  154043. reload(): void;
  154044. }
  154045. }
  154046. declare module BABYLON {
  154047. /**
  154048. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154049. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154050. */
  154051. export class SceneOptimization {
  154052. /**
  154053. * Defines the priority of this optimization (0 by default which means first in the list)
  154054. */
  154055. priority: number;
  154056. /**
  154057. * Gets a string describing the action executed by the current optimization
  154058. * @returns description string
  154059. */
  154060. getDescription(): string;
  154061. /**
  154062. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154063. * @param scene defines the current scene where to apply this optimization
  154064. * @param optimizer defines the current optimizer
  154065. * @returns true if everything that can be done was applied
  154066. */
  154067. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154068. /**
  154069. * Creates the SceneOptimization object
  154070. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154071. * @param desc defines the description associated with the optimization
  154072. */
  154073. constructor(
  154074. /**
  154075. * Defines the priority of this optimization (0 by default which means first in the list)
  154076. */
  154077. priority?: number);
  154078. }
  154079. /**
  154080. * Defines an optimization used to reduce the size of render target textures
  154081. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154082. */
  154083. export class TextureOptimization extends SceneOptimization {
  154084. /**
  154085. * Defines the priority of this optimization (0 by default which means first in the list)
  154086. */
  154087. priority: number;
  154088. /**
  154089. * 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
  154090. */
  154091. maximumSize: number;
  154092. /**
  154093. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154094. */
  154095. step: number;
  154096. /**
  154097. * Gets a string describing the action executed by the current optimization
  154098. * @returns description string
  154099. */
  154100. getDescription(): string;
  154101. /**
  154102. * Creates the TextureOptimization object
  154103. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154104. * @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
  154105. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154106. */
  154107. constructor(
  154108. /**
  154109. * Defines the priority of this optimization (0 by default which means first in the list)
  154110. */
  154111. priority?: number,
  154112. /**
  154113. * 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
  154114. */
  154115. maximumSize?: number,
  154116. /**
  154117. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154118. */
  154119. step?: number);
  154120. /**
  154121. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154122. * @param scene defines the current scene where to apply this optimization
  154123. * @param optimizer defines the current optimizer
  154124. * @returns true if everything that can be done was applied
  154125. */
  154126. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154127. }
  154128. /**
  154129. * Defines an optimization used to increase or decrease the rendering resolution
  154130. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154131. */
  154132. export class HardwareScalingOptimization extends SceneOptimization {
  154133. /**
  154134. * Defines the priority of this optimization (0 by default which means first in the list)
  154135. */
  154136. priority: number;
  154137. /**
  154138. * Defines the maximum scale to use (2 by default)
  154139. */
  154140. maximumScale: number;
  154141. /**
  154142. * Defines the step to use between two passes (0.5 by default)
  154143. */
  154144. step: number;
  154145. private _currentScale;
  154146. private _directionOffset;
  154147. /**
  154148. * Gets a string describing the action executed by the current optimization
  154149. * @return description string
  154150. */
  154151. getDescription(): string;
  154152. /**
  154153. * Creates the HardwareScalingOptimization object
  154154. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154155. * @param maximumScale defines the maximum scale to use (2 by default)
  154156. * @param step defines the step to use between two passes (0.5 by default)
  154157. */
  154158. constructor(
  154159. /**
  154160. * Defines the priority of this optimization (0 by default which means first in the list)
  154161. */
  154162. priority?: number,
  154163. /**
  154164. * Defines the maximum scale to use (2 by default)
  154165. */
  154166. maximumScale?: number,
  154167. /**
  154168. * Defines the step to use between two passes (0.5 by default)
  154169. */
  154170. step?: number);
  154171. /**
  154172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154173. * @param scene defines the current scene where to apply this optimization
  154174. * @param optimizer defines the current optimizer
  154175. * @returns true if everything that can be done was applied
  154176. */
  154177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154178. }
  154179. /**
  154180. * Defines an optimization used to remove shadows
  154181. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154182. */
  154183. export class ShadowsOptimization extends SceneOptimization {
  154184. /**
  154185. * Gets a string describing the action executed by the current optimization
  154186. * @return description string
  154187. */
  154188. getDescription(): string;
  154189. /**
  154190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154191. * @param scene defines the current scene where to apply this optimization
  154192. * @param optimizer defines the current optimizer
  154193. * @returns true if everything that can be done was applied
  154194. */
  154195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154196. }
  154197. /**
  154198. * Defines an optimization used to turn post-processes off
  154199. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154200. */
  154201. export class PostProcessesOptimization extends SceneOptimization {
  154202. /**
  154203. * Gets a string describing the action executed by the current optimization
  154204. * @return description string
  154205. */
  154206. getDescription(): string;
  154207. /**
  154208. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154209. * @param scene defines the current scene where to apply this optimization
  154210. * @param optimizer defines the current optimizer
  154211. * @returns true if everything that can be done was applied
  154212. */
  154213. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154214. }
  154215. /**
  154216. * Defines an optimization used to turn lens flares off
  154217. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154218. */
  154219. export class LensFlaresOptimization extends SceneOptimization {
  154220. /**
  154221. * Gets a string describing the action executed by the current optimization
  154222. * @return description string
  154223. */
  154224. getDescription(): string;
  154225. /**
  154226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154227. * @param scene defines the current scene where to apply this optimization
  154228. * @param optimizer defines the current optimizer
  154229. * @returns true if everything that can be done was applied
  154230. */
  154231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154232. }
  154233. /**
  154234. * Defines an optimization based on user defined callback.
  154235. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154236. */
  154237. export class CustomOptimization extends SceneOptimization {
  154238. /**
  154239. * Callback called to apply the custom optimization.
  154240. */
  154241. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154242. /**
  154243. * Callback called to get custom description
  154244. */
  154245. onGetDescription: () => string;
  154246. /**
  154247. * Gets a string describing the action executed by the current optimization
  154248. * @returns description string
  154249. */
  154250. getDescription(): string;
  154251. /**
  154252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154253. * @param scene defines the current scene where to apply this optimization
  154254. * @param optimizer defines the current optimizer
  154255. * @returns true if everything that can be done was applied
  154256. */
  154257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154258. }
  154259. /**
  154260. * Defines an optimization used to turn particles off
  154261. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154262. */
  154263. export class ParticlesOptimization extends SceneOptimization {
  154264. /**
  154265. * Gets a string describing the action executed by the current optimization
  154266. * @return description string
  154267. */
  154268. getDescription(): string;
  154269. /**
  154270. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154271. * @param scene defines the current scene where to apply this optimization
  154272. * @param optimizer defines the current optimizer
  154273. * @returns true if everything that can be done was applied
  154274. */
  154275. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154276. }
  154277. /**
  154278. * Defines an optimization used to turn render targets off
  154279. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154280. */
  154281. export class RenderTargetsOptimization extends SceneOptimization {
  154282. /**
  154283. * Gets a string describing the action executed by the current optimization
  154284. * @return description string
  154285. */
  154286. getDescription(): string;
  154287. /**
  154288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154289. * @param scene defines the current scene where to apply this optimization
  154290. * @param optimizer defines the current optimizer
  154291. * @returns true if everything that can be done was applied
  154292. */
  154293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154294. }
  154295. /**
  154296. * Defines an optimization used to merge meshes with compatible materials
  154297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154298. */
  154299. export class MergeMeshesOptimization extends SceneOptimization {
  154300. private static _UpdateSelectionTree;
  154301. /**
  154302. * Gets or sets a boolean which defines if optimization octree has to be updated
  154303. */
  154304. static get UpdateSelectionTree(): boolean;
  154305. /**
  154306. * Gets or sets a boolean which defines if optimization octree has to be updated
  154307. */
  154308. static set UpdateSelectionTree(value: boolean);
  154309. /**
  154310. * Gets a string describing the action executed by the current optimization
  154311. * @return description string
  154312. */
  154313. getDescription(): string;
  154314. private _canBeMerged;
  154315. /**
  154316. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154317. * @param scene defines the current scene where to apply this optimization
  154318. * @param optimizer defines the current optimizer
  154319. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154320. * @returns true if everything that can be done was applied
  154321. */
  154322. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154323. }
  154324. /**
  154325. * Defines a list of options used by SceneOptimizer
  154326. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154327. */
  154328. export class SceneOptimizerOptions {
  154329. /**
  154330. * Defines the target frame rate to reach (60 by default)
  154331. */
  154332. targetFrameRate: number;
  154333. /**
  154334. * Defines the interval between two checkes (2000ms by default)
  154335. */
  154336. trackerDuration: number;
  154337. /**
  154338. * Gets the list of optimizations to apply
  154339. */
  154340. optimizations: SceneOptimization[];
  154341. /**
  154342. * Creates a new list of options used by SceneOptimizer
  154343. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154344. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154345. */
  154346. constructor(
  154347. /**
  154348. * Defines the target frame rate to reach (60 by default)
  154349. */
  154350. targetFrameRate?: number,
  154351. /**
  154352. * Defines the interval between two checkes (2000ms by default)
  154353. */
  154354. trackerDuration?: number);
  154355. /**
  154356. * Add a new optimization
  154357. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154358. * @returns the current SceneOptimizerOptions
  154359. */
  154360. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154361. /**
  154362. * Add a new custom optimization
  154363. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154364. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154365. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154366. * @returns the current SceneOptimizerOptions
  154367. */
  154368. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154369. /**
  154370. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154371. * @param targetFrameRate defines the target frame rate (60 by default)
  154372. * @returns a SceneOptimizerOptions object
  154373. */
  154374. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154375. /**
  154376. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154377. * @param targetFrameRate defines the target frame rate (60 by default)
  154378. * @returns a SceneOptimizerOptions object
  154379. */
  154380. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154381. /**
  154382. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154383. * @param targetFrameRate defines the target frame rate (60 by default)
  154384. * @returns a SceneOptimizerOptions object
  154385. */
  154386. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154387. }
  154388. /**
  154389. * Class used to run optimizations in order to reach a target frame rate
  154390. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154391. */
  154392. export class SceneOptimizer implements IDisposable {
  154393. private _isRunning;
  154394. private _options;
  154395. private _scene;
  154396. private _currentPriorityLevel;
  154397. private _targetFrameRate;
  154398. private _trackerDuration;
  154399. private _currentFrameRate;
  154400. private _sceneDisposeObserver;
  154401. private _improvementMode;
  154402. /**
  154403. * Defines an observable called when the optimizer reaches the target frame rate
  154404. */
  154405. onSuccessObservable: Observable<SceneOptimizer>;
  154406. /**
  154407. * Defines an observable called when the optimizer enables an optimization
  154408. */
  154409. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154410. /**
  154411. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154412. */
  154413. onFailureObservable: Observable<SceneOptimizer>;
  154414. /**
  154415. * Gets a boolean indicating if the optimizer is in improvement mode
  154416. */
  154417. get isInImprovementMode(): boolean;
  154418. /**
  154419. * Gets the current priority level (0 at start)
  154420. */
  154421. get currentPriorityLevel(): number;
  154422. /**
  154423. * Gets the current frame rate checked by the SceneOptimizer
  154424. */
  154425. get currentFrameRate(): number;
  154426. /**
  154427. * Gets or sets the current target frame rate (60 by default)
  154428. */
  154429. get targetFrameRate(): number;
  154430. /**
  154431. * Gets or sets the current target frame rate (60 by default)
  154432. */
  154433. set targetFrameRate(value: number);
  154434. /**
  154435. * Gets or sets the current interval between two checks (every 2000ms by default)
  154436. */
  154437. get trackerDuration(): number;
  154438. /**
  154439. * Gets or sets the current interval between two checks (every 2000ms by default)
  154440. */
  154441. set trackerDuration(value: number);
  154442. /**
  154443. * Gets the list of active optimizations
  154444. */
  154445. get optimizations(): SceneOptimization[];
  154446. /**
  154447. * Creates a new SceneOptimizer
  154448. * @param scene defines the scene to work on
  154449. * @param options defines the options to use with the SceneOptimizer
  154450. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154451. * @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)
  154452. */
  154453. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154454. /**
  154455. * Stops the current optimizer
  154456. */
  154457. stop(): void;
  154458. /**
  154459. * Reset the optimizer to initial step (current priority level = 0)
  154460. */
  154461. reset(): void;
  154462. /**
  154463. * Start the optimizer. By default it will try to reach a specific framerate
  154464. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154465. */
  154466. start(): void;
  154467. private _checkCurrentState;
  154468. /**
  154469. * Release all resources
  154470. */
  154471. dispose(): void;
  154472. /**
  154473. * Helper function to create a SceneOptimizer with one single line of code
  154474. * @param scene defines the scene to work on
  154475. * @param options defines the options to use with the SceneOptimizer
  154476. * @param onSuccess defines a callback to call on success
  154477. * @param onFailure defines a callback to call on failure
  154478. * @returns the new SceneOptimizer object
  154479. */
  154480. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154481. }
  154482. }
  154483. declare module BABYLON {
  154484. /**
  154485. * Class used to serialize a scene into a string
  154486. */
  154487. export class SceneSerializer {
  154488. /**
  154489. * Clear cache used by a previous serialization
  154490. */
  154491. static ClearCache(): void;
  154492. /**
  154493. * Serialize a scene into a JSON compatible object
  154494. * @param scene defines the scene to serialize
  154495. * @returns a JSON compatible object
  154496. */
  154497. static Serialize(scene: Scene): any;
  154498. /**
  154499. * Serialize a mesh into a JSON compatible object
  154500. * @param toSerialize defines the mesh to serialize
  154501. * @param withParents defines if parents must be serialized as well
  154502. * @param withChildren defines if children must be serialized as well
  154503. * @returns a JSON compatible object
  154504. */
  154505. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154506. }
  154507. }
  154508. declare module BABYLON {
  154509. /**
  154510. * Class used to host texture specific utilities
  154511. */
  154512. export class TextureTools {
  154513. /**
  154514. * Uses the GPU to create a copy texture rescaled at a given size
  154515. * @param texture Texture to copy from
  154516. * @param width defines the desired width
  154517. * @param height defines the desired height
  154518. * @param useBilinearMode defines if bilinear mode has to be used
  154519. * @return the generated texture
  154520. */
  154521. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154522. }
  154523. }
  154524. declare module BABYLON {
  154525. /**
  154526. * This represents the different options available for the video capture.
  154527. */
  154528. export interface VideoRecorderOptions {
  154529. /** Defines the mime type of the video. */
  154530. mimeType: string;
  154531. /** Defines the FPS the video should be recorded at. */
  154532. fps: number;
  154533. /** Defines the chunk size for the recording data. */
  154534. recordChunckSize: number;
  154535. /** The audio tracks to attach to the recording. */
  154536. audioTracks?: MediaStreamTrack[];
  154537. }
  154538. /**
  154539. * This can help with recording videos from BabylonJS.
  154540. * This is based on the available WebRTC functionalities of the browser.
  154541. *
  154542. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154543. */
  154544. export class VideoRecorder {
  154545. private static readonly _defaultOptions;
  154546. /**
  154547. * Returns whether or not the VideoRecorder is available in your browser.
  154548. * @param engine Defines the Babylon Engine.
  154549. * @returns true if supported otherwise false.
  154550. */
  154551. static IsSupported(engine: Engine): boolean;
  154552. private readonly _options;
  154553. private _canvas;
  154554. private _mediaRecorder;
  154555. private _recordedChunks;
  154556. private _fileName;
  154557. private _resolve;
  154558. private _reject;
  154559. /**
  154560. * True when a recording is already in progress.
  154561. */
  154562. get isRecording(): boolean;
  154563. /**
  154564. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  154565. * @param engine Defines the BabylonJS Engine you wish to record.
  154566. * @param options Defines options that can be used to customize the capture.
  154567. */
  154568. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  154569. /**
  154570. * Stops the current recording before the default capture timeout passed in the startRecording function.
  154571. */
  154572. stopRecording(): void;
  154573. /**
  154574. * Starts recording the canvas for a max duration specified in parameters.
  154575. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  154576. * If null no automatic download will start and you can rely on the promise to get the data back.
  154577. * @param maxDuration Defines the maximum recording time in seconds.
  154578. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  154579. * @return A promise callback at the end of the recording with the video data in Blob.
  154580. */
  154581. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  154582. /**
  154583. * Releases internal resources used during the recording.
  154584. */
  154585. dispose(): void;
  154586. private _handleDataAvailable;
  154587. private _handleError;
  154588. private _handleStop;
  154589. }
  154590. }
  154591. declare module BABYLON {
  154592. /**
  154593. * Class containing a set of static utilities functions for screenshots
  154594. */
  154595. export class ScreenshotTools {
  154596. /**
  154597. * Captures a screenshot of the current rendering
  154598. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154599. * @param engine defines the rendering engine
  154600. * @param camera defines the source camera
  154601. * @param size This parameter can be set to a single number or to an object with the
  154602. * following (optional) properties: precision, width, height. If a single number is passed,
  154603. * it will be used for both width and height. If an object is passed, the screenshot size
  154604. * will be derived from the parameters. The precision property is a multiplier allowing
  154605. * rendering at a higher or lower resolution
  154606. * @param successCallback defines the callback receives a single parameter which contains the
  154607. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154608. * src parameter of an <img> to display it
  154609. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154610. * Check your browser for supported MIME types
  154611. */
  154612. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  154613. /**
  154614. * Captures a screenshot of the current rendering
  154615. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154616. * @param engine defines the rendering engine
  154617. * @param camera defines the source camera
  154618. * @param size This parameter can be set to a single number or to an object with the
  154619. * following (optional) properties: precision, width, height. If a single number is passed,
  154620. * it will be used for both width and height. If an object is passed, the screenshot size
  154621. * will be derived from the parameters. The precision property is a multiplier allowing
  154622. * rendering at a higher or lower resolution
  154623. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  154624. * Check your browser for supported MIME types
  154625. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154626. * to the src parameter of an <img> to display it
  154627. */
  154628. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  154629. /**
  154630. * Generates an image screenshot from the specified camera.
  154631. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154632. * @param engine The engine to use for rendering
  154633. * @param camera The camera to use for rendering
  154634. * @param size This parameter can be set to a single number or to an object with the
  154635. * following (optional) properties: precision, width, height. If a single number is passed,
  154636. * it will be used for both width and height. If an object is passed, the screenshot size
  154637. * will be derived from the parameters. The precision property is a multiplier allowing
  154638. * rendering at a higher or lower resolution
  154639. * @param successCallback The callback receives a single parameter which contains the
  154640. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  154641. * src parameter of an <img> to display it
  154642. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154643. * Check your browser for supported MIME types
  154644. * @param samples Texture samples (default: 1)
  154645. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154646. * @param fileName A name for for the downloaded file.
  154647. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154648. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  154649. */
  154650. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean, enableStencilBuffer?: boolean): void;
  154651. /**
  154652. * Generates an image screenshot from the specified camera.
  154653. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  154654. * @param engine The engine to use for rendering
  154655. * @param camera The camera to use for rendering
  154656. * @param size This parameter can be set to a single number or to an object with the
  154657. * following (optional) properties: precision, width, height. If a single number is passed,
  154658. * it will be used for both width and height. If an object is passed, the screenshot size
  154659. * will be derived from the parameters. The precision property is a multiplier allowing
  154660. * rendering at a higher or lower resolution
  154661. * @param mimeType The MIME type of the screenshot image (default: image/png).
  154662. * Check your browser for supported MIME types
  154663. * @param samples Texture samples (default: 1)
  154664. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  154665. * @param fileName A name for for the downloaded file.
  154666. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  154667. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  154668. * to the src parameter of an <img> to display it
  154669. */
  154670. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  154671. /**
  154672. * Gets height and width for screenshot size
  154673. * @private
  154674. */
  154675. private static _getScreenshotSize;
  154676. }
  154677. }
  154678. declare module BABYLON {
  154679. /**
  154680. * Interface for a data buffer
  154681. */
  154682. export interface IDataBuffer {
  154683. /**
  154684. * Reads bytes from the data buffer.
  154685. * @param byteOffset The byte offset to read
  154686. * @param byteLength The byte length to read
  154687. * @returns A promise that resolves when the bytes are read
  154688. */
  154689. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  154690. /**
  154691. * The byte length of the buffer.
  154692. */
  154693. readonly byteLength: number;
  154694. }
  154695. /**
  154696. * Utility class for reading from a data buffer
  154697. */
  154698. export class DataReader {
  154699. /**
  154700. * The data buffer associated with this data reader.
  154701. */
  154702. readonly buffer: IDataBuffer;
  154703. /**
  154704. * The current byte offset from the beginning of the data buffer.
  154705. */
  154706. byteOffset: number;
  154707. private _dataView;
  154708. private _dataByteOffset;
  154709. /**
  154710. * Constructor
  154711. * @param buffer The buffer to read
  154712. */
  154713. constructor(buffer: IDataBuffer);
  154714. /**
  154715. * Loads the given byte length.
  154716. * @param byteLength The byte length to load
  154717. * @returns A promise that resolves when the load is complete
  154718. */
  154719. loadAsync(byteLength: number): Promise<void>;
  154720. /**
  154721. * Read a unsigned 32-bit integer from the currently loaded data range.
  154722. * @returns The 32-bit integer read
  154723. */
  154724. readUint32(): number;
  154725. /**
  154726. * Read a byte array from the currently loaded data range.
  154727. * @param byteLength The byte length to read
  154728. * @returns The byte array read
  154729. */
  154730. readUint8Array(byteLength: number): Uint8Array;
  154731. /**
  154732. * Read a string from the currently loaded data range.
  154733. * @param byteLength The byte length to read
  154734. * @returns The string read
  154735. */
  154736. readString(byteLength: number): string;
  154737. /**
  154738. * Skips the given byte length the currently loaded data range.
  154739. * @param byteLength The byte length to skip
  154740. */
  154741. skipBytes(byteLength: number): void;
  154742. }
  154743. }
  154744. declare module BABYLON {
  154745. /**
  154746. * Class for storing data to local storage if available or in-memory storage otherwise
  154747. */
  154748. export class DataStorage {
  154749. private static _Storage;
  154750. private static _GetStorage;
  154751. /**
  154752. * Reads a string from the data storage
  154753. * @param key The key to read
  154754. * @param defaultValue The value if the key doesn't exist
  154755. * @returns The string value
  154756. */
  154757. static ReadString(key: string, defaultValue: string): string;
  154758. /**
  154759. * Writes a string to the data storage
  154760. * @param key The key to write
  154761. * @param value The value to write
  154762. */
  154763. static WriteString(key: string, value: string): void;
  154764. /**
  154765. * Reads a boolean from the data storage
  154766. * @param key The key to read
  154767. * @param defaultValue The value if the key doesn't exist
  154768. * @returns The boolean value
  154769. */
  154770. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  154771. /**
  154772. * Writes a boolean to the data storage
  154773. * @param key The key to write
  154774. * @param value The value to write
  154775. */
  154776. static WriteBoolean(key: string, value: boolean): void;
  154777. /**
  154778. * Reads a number from the data storage
  154779. * @param key The key to read
  154780. * @param defaultValue The value if the key doesn't exist
  154781. * @returns The number value
  154782. */
  154783. static ReadNumber(key: string, defaultValue: number): number;
  154784. /**
  154785. * Writes a number to the data storage
  154786. * @param key The key to write
  154787. * @param value The value to write
  154788. */
  154789. static WriteNumber(key: string, value: number): void;
  154790. }
  154791. }
  154792. declare module BABYLON {
  154793. /**
  154794. * Class used to record delta files between 2 scene states
  154795. */
  154796. export class SceneRecorder {
  154797. private _trackedScene;
  154798. private _savedJSON;
  154799. /**
  154800. * Track a given scene. This means the current scene state will be considered the original state
  154801. * @param scene defines the scene to track
  154802. */
  154803. track(scene: Scene): void;
  154804. /**
  154805. * Get the delta between current state and original state
  154806. * @returns a string containing the delta
  154807. */
  154808. getDelta(): any;
  154809. private _compareArray;
  154810. private _compareObjects;
  154811. private _compareCollections;
  154812. private static GetShadowGeneratorById;
  154813. /**
  154814. * Apply a given delta to a given scene
  154815. * @param deltaJSON defines the JSON containing the delta
  154816. * @param scene defines the scene to apply the delta to
  154817. */
  154818. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  154819. private static _ApplyPropertiesToEntity;
  154820. private static _ApplyDeltaForEntity;
  154821. }
  154822. }
  154823. declare module BABYLON {
  154824. /**
  154825. * A 3D trajectory consisting of an order list of vectors describing a
  154826. * path of motion through 3D space.
  154827. */
  154828. export class Trajectory {
  154829. private _points;
  154830. private readonly _segmentLength;
  154831. /**
  154832. * Serialize to JSON.
  154833. * @returns serialized JSON string
  154834. */
  154835. serialize(): string;
  154836. /**
  154837. * Deserialize from JSON.
  154838. * @param json serialized JSON string
  154839. * @returns deserialized Trajectory
  154840. */
  154841. static Deserialize(json: string): Trajectory;
  154842. /**
  154843. * Create a new empty Trajectory.
  154844. * @param segmentLength radius of discretization for Trajectory points
  154845. */
  154846. constructor(segmentLength?: number);
  154847. /**
  154848. * Get the length of the Trajectory.
  154849. * @returns length of the Trajectory
  154850. */
  154851. getLength(): number;
  154852. /**
  154853. * Append a new point to the Trajectory.
  154854. * NOTE: This implementation has many allocations.
  154855. * @param point point to append to the Trajectory
  154856. */
  154857. add(point: DeepImmutable<Vector3>): void;
  154858. /**
  154859. * Create a new Trajectory with a segment length chosen to make it
  154860. * probable that the new Trajectory will have a specified number of
  154861. * segments. This operation is imprecise.
  154862. * @param targetResolution number of segments desired
  154863. * @returns new Trajectory with approximately the requested number of segments
  154864. */
  154865. resampleAtTargetResolution(targetResolution: number): Trajectory;
  154866. /**
  154867. * Convert Trajectory segments into tokenized representation. This
  154868. * representation is an array of numbers where each nth number is the
  154869. * index of the token which is most similar to the nth segment of the
  154870. * Trajectory.
  154871. * @param tokens list of vectors which serve as discrete tokens
  154872. * @returns list of indices of most similar token per segment
  154873. */
  154874. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  154875. private static _forwardDir;
  154876. private static _inverseFromVec;
  154877. private static _upDir;
  154878. private static _fromToVec;
  154879. private static _lookMatrix;
  154880. /**
  154881. * Transform the rotation (i.e., direction) of a segment to isolate
  154882. * the relative transformation represented by the segment. This operation
  154883. * may or may not succeed due to singularities in the equations that define
  154884. * motion relativity in this context.
  154885. * @param priorVec the origin of the prior segment
  154886. * @param fromVec the origin of the current segment
  154887. * @param toVec the destination of the current segment
  154888. * @param result reference to output variable
  154889. * @returns whether or not transformation was successful
  154890. */
  154891. private static _transformSegmentDirToRef;
  154892. private static _bestMatch;
  154893. private static _score;
  154894. private static _bestScore;
  154895. /**
  154896. * Determine which token vector is most similar to the
  154897. * segment vector.
  154898. * @param segment segment vector
  154899. * @param tokens token vector list
  154900. * @returns index of the most similar token to the segment
  154901. */
  154902. private static _tokenizeSegment;
  154903. }
  154904. /**
  154905. * Class representing a set of known, named trajectories to which Trajectories can be
  154906. * added and using which Trajectories can be recognized.
  154907. */
  154908. export class TrajectoryClassifier {
  154909. private _maximumAllowableMatchCost;
  154910. private _vector3Alphabet;
  154911. private _levenshteinAlphabet;
  154912. private _nameToDescribedTrajectory;
  154913. /**
  154914. * Serialize to JSON.
  154915. * @returns JSON serialization
  154916. */
  154917. serialize(): string;
  154918. /**
  154919. * Deserialize from JSON.
  154920. * @param json JSON serialization
  154921. * @returns deserialized TrajectorySet
  154922. */
  154923. static Deserialize(json: string): TrajectoryClassifier;
  154924. /**
  154925. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  154926. * VERY naive, need to be generating these things from known
  154927. * sets. Better version later, probably eliminating this one.
  154928. * @returns auto-generated TrajectorySet
  154929. */
  154930. static Generate(): TrajectoryClassifier;
  154931. private constructor();
  154932. /**
  154933. * Add a new Trajectory to the set with a given name.
  154934. * @param trajectory new Trajectory to be added
  154935. * @param classification name to which to add the Trajectory
  154936. */
  154937. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  154938. /**
  154939. * Remove a known named trajectory and all Trajectories associated with it.
  154940. * @param classification name to remove
  154941. * @returns whether anything was removed
  154942. */
  154943. deleteClassification(classification: string): boolean;
  154944. /**
  154945. * Attempt to recognize a Trajectory from among all the classifications
  154946. * already known to the classifier.
  154947. * @param trajectory Trajectory to be recognized
  154948. * @returns classification of Trajectory if recognized, null otherwise
  154949. */
  154950. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  154951. }
  154952. }
  154953. declare module BABYLON {
  154954. /**
  154955. * An interface for all Hit test features
  154956. */
  154957. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  154958. /**
  154959. * Triggered when new babylon (transformed) hit test results are available
  154960. */
  154961. onHitTestResultObservable: Observable<T[]>;
  154962. }
  154963. /**
  154964. * Options used for hit testing
  154965. */
  154966. export interface IWebXRLegacyHitTestOptions {
  154967. /**
  154968. * Only test when user interacted with the scene. Default - hit test every frame
  154969. */
  154970. testOnPointerDownOnly?: boolean;
  154971. /**
  154972. * The node to use to transform the local results to world coordinates
  154973. */
  154974. worldParentNode?: TransformNode;
  154975. }
  154976. /**
  154977. * Interface defining the babylon result of raycasting/hit-test
  154978. */
  154979. export interface IWebXRLegacyHitResult {
  154980. /**
  154981. * Transformation matrix that can be applied to a node that will put it in the hit point location
  154982. */
  154983. transformationMatrix: Matrix;
  154984. /**
  154985. * The native hit test result
  154986. */
  154987. xrHitResult: XRHitResult | XRHitTestResult;
  154988. }
  154989. /**
  154990. * The currently-working hit-test module.
  154991. * Hit test (or Ray-casting) is used to interact with the real world.
  154992. * For further information read here - https://github.com/immersive-web/hit-test
  154993. */
  154994. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  154995. /**
  154996. * options to use when constructing this feature
  154997. */
  154998. readonly options: IWebXRLegacyHitTestOptions;
  154999. private _direction;
  155000. private _mat;
  155001. private _onSelectEnabled;
  155002. private _origin;
  155003. /**
  155004. * The module's name
  155005. */
  155006. static readonly Name: string;
  155007. /**
  155008. * The (Babylon) version of this module.
  155009. * This is an integer representing the implementation version.
  155010. * This number does not correspond to the WebXR specs version
  155011. */
  155012. static readonly Version: number;
  155013. /**
  155014. * Populated with the last native XR Hit Results
  155015. */
  155016. lastNativeXRHitResults: XRHitResult[];
  155017. /**
  155018. * Triggered when new babylon (transformed) hit test results are available
  155019. */
  155020. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155021. /**
  155022. * Creates a new instance of the (legacy version) hit test feature
  155023. * @param _xrSessionManager an instance of WebXRSessionManager
  155024. * @param options options to use when constructing this feature
  155025. */
  155026. constructor(_xrSessionManager: WebXRSessionManager,
  155027. /**
  155028. * options to use when constructing this feature
  155029. */
  155030. options?: IWebXRLegacyHitTestOptions);
  155031. /**
  155032. * execute a hit test with an XR Ray
  155033. *
  155034. * @param xrSession a native xrSession that will execute this hit test
  155035. * @param xrRay the ray (position and direction) to use for ray-casting
  155036. * @param referenceSpace native XR reference space to use for the hit-test
  155037. * @param filter filter function that will filter the results
  155038. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155039. */
  155040. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155041. /**
  155042. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155043. * @param event the (select) event to use to select with
  155044. * @param referenceSpace the reference space to use for this hit test
  155045. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155046. */
  155047. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155048. /**
  155049. * attach this feature
  155050. * Will usually be called by the features manager
  155051. *
  155052. * @returns true if successful.
  155053. */
  155054. attach(): boolean;
  155055. /**
  155056. * detach this feature.
  155057. * Will usually be called by the features manager
  155058. *
  155059. * @returns true if successful.
  155060. */
  155061. detach(): boolean;
  155062. /**
  155063. * Dispose this feature and all of the resources attached
  155064. */
  155065. dispose(): void;
  155066. protected _onXRFrame(frame: XRFrame): void;
  155067. private _onHitTestResults;
  155068. private _onSelect;
  155069. }
  155070. }
  155071. declare module BABYLON {
  155072. /**
  155073. * Options used for hit testing (version 2)
  155074. */
  155075. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155076. /**
  155077. * Do not create a permanent hit test. Will usually be used when only
  155078. * transient inputs are needed.
  155079. */
  155080. disablePermanentHitTest?: boolean;
  155081. /**
  155082. * Enable transient (for example touch-based) hit test inspections
  155083. */
  155084. enableTransientHitTest?: boolean;
  155085. /**
  155086. * Offset ray for the permanent hit test
  155087. */
  155088. offsetRay?: Vector3;
  155089. /**
  155090. * Offset ray for the transient hit test
  155091. */
  155092. transientOffsetRay?: Vector3;
  155093. /**
  155094. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155095. */
  155096. useReferenceSpace?: boolean;
  155097. /**
  155098. * Override the default entity type(s) of the hit-test result
  155099. */
  155100. entityTypes?: XRHitTestTrackableType[];
  155101. }
  155102. /**
  155103. * Interface defining the babylon result of hit-test
  155104. */
  155105. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155106. /**
  155107. * The input source that generated this hit test (if transient)
  155108. */
  155109. inputSource?: XRInputSource;
  155110. /**
  155111. * Is this a transient hit test
  155112. */
  155113. isTransient?: boolean;
  155114. /**
  155115. * Position of the hit test result
  155116. */
  155117. position: Vector3;
  155118. /**
  155119. * Rotation of the hit test result
  155120. */
  155121. rotationQuaternion: Quaternion;
  155122. /**
  155123. * The native hit test result
  155124. */
  155125. xrHitResult: XRHitTestResult;
  155126. }
  155127. /**
  155128. * The currently-working hit-test module.
  155129. * Hit test (or Ray-casting) is used to interact with the real world.
  155130. * For further information read here - https://github.com/immersive-web/hit-test
  155131. *
  155132. * Tested on chrome (mobile) 80.
  155133. */
  155134. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155135. /**
  155136. * options to use when constructing this feature
  155137. */
  155138. readonly options: IWebXRHitTestOptions;
  155139. private _tmpMat;
  155140. private _tmpPos;
  155141. private _tmpQuat;
  155142. private _transientXrHitTestSource;
  155143. private _xrHitTestSource;
  155144. private initHitTestSource;
  155145. /**
  155146. * The module's name
  155147. */
  155148. static readonly Name: string;
  155149. /**
  155150. * The (Babylon) version of this module.
  155151. * This is an integer representing the implementation version.
  155152. * This number does not correspond to the WebXR specs version
  155153. */
  155154. static readonly Version: number;
  155155. /**
  155156. * When set to true, each hit test will have its own position/rotation objects
  155157. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155158. * the developers will clone them or copy them as they see fit.
  155159. */
  155160. autoCloneTransformation: boolean;
  155161. /**
  155162. * Triggered when new babylon (transformed) hit test results are available
  155163. * Note - this will be called when results come back from the device. It can be an empty array!!
  155164. */
  155165. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155166. /**
  155167. * Use this to temporarily pause hit test checks.
  155168. */
  155169. paused: boolean;
  155170. /**
  155171. * Creates a new instance of the hit test feature
  155172. * @param _xrSessionManager an instance of WebXRSessionManager
  155173. * @param options options to use when constructing this feature
  155174. */
  155175. constructor(_xrSessionManager: WebXRSessionManager,
  155176. /**
  155177. * options to use when constructing this feature
  155178. */
  155179. options?: IWebXRHitTestOptions);
  155180. /**
  155181. * attach this feature
  155182. * Will usually be called by the features manager
  155183. *
  155184. * @returns true if successful.
  155185. */
  155186. attach(): boolean;
  155187. /**
  155188. * detach this feature.
  155189. * Will usually be called by the features manager
  155190. *
  155191. * @returns true if successful.
  155192. */
  155193. detach(): boolean;
  155194. /**
  155195. * Dispose this feature and all of the resources attached
  155196. */
  155197. dispose(): void;
  155198. protected _onXRFrame(frame: XRFrame): void;
  155199. private _processWebXRHitTestResult;
  155200. }
  155201. }
  155202. declare module BABYLON {
  155203. /**
  155204. * Configuration options of the anchor system
  155205. */
  155206. export interface IWebXRAnchorSystemOptions {
  155207. /**
  155208. * a node that will be used to convert local to world coordinates
  155209. */
  155210. worldParentNode?: TransformNode;
  155211. /**
  155212. * If set to true a reference of the created anchors will be kept until the next session starts
  155213. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155214. */
  155215. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155216. }
  155217. /**
  155218. * A babylon container for an XR Anchor
  155219. */
  155220. export interface IWebXRAnchor {
  155221. /**
  155222. * A babylon-assigned ID for this anchor
  155223. */
  155224. id: number;
  155225. /**
  155226. * Transformation matrix to apply to an object attached to this anchor
  155227. */
  155228. transformationMatrix: Matrix;
  155229. /**
  155230. * The native anchor object
  155231. */
  155232. xrAnchor: XRAnchor;
  155233. /**
  155234. * if defined, this object will be constantly updated by the anchor's position and rotation
  155235. */
  155236. attachedNode?: TransformNode;
  155237. }
  155238. /**
  155239. * An implementation of the anchor system for WebXR.
  155240. * For further information see https://github.com/immersive-web/anchors/
  155241. */
  155242. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155243. private _options;
  155244. private _lastFrameDetected;
  155245. private _trackedAnchors;
  155246. private _referenceSpaceForFrameAnchors;
  155247. private _futureAnchors;
  155248. /**
  155249. * The module's name
  155250. */
  155251. static readonly Name: string;
  155252. /**
  155253. * The (Babylon) version of this module.
  155254. * This is an integer representing the implementation version.
  155255. * This number does not correspond to the WebXR specs version
  155256. */
  155257. static readonly Version: number;
  155258. /**
  155259. * Observers registered here will be executed when a new anchor was added to the session
  155260. */
  155261. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155262. /**
  155263. * Observers registered here will be executed when an anchor was removed from the session
  155264. */
  155265. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155266. /**
  155267. * Observers registered here will be executed when an existing anchor updates
  155268. * This can execute N times every frame
  155269. */
  155270. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155271. /**
  155272. * Set the reference space to use for anchor creation, when not using a hit test.
  155273. * Will default to the session's reference space if not defined
  155274. */
  155275. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155276. /**
  155277. * constructs a new anchor system
  155278. * @param _xrSessionManager an instance of WebXRSessionManager
  155279. * @param _options configuration object for this feature
  155280. */
  155281. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155282. private _tmpVector;
  155283. private _tmpQuaternion;
  155284. private _populateTmpTransformation;
  155285. /**
  155286. * Create a new anchor point using a hit test result at a specific point in the scene
  155287. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155288. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155289. *
  155290. * @param hitTestResult The hit test result to use for this anchor creation
  155291. * @param position an optional position offset for this anchor
  155292. * @param rotationQuaternion an optional rotation offset for this anchor
  155293. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155294. */
  155295. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155296. /**
  155297. * Add a new anchor at a specific position and rotation
  155298. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155299. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155300. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155301. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155302. *
  155303. * @param position the position in which to add an anchor
  155304. * @param rotationQuaternion an optional rotation for the anchor transformation
  155305. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155306. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155307. */
  155308. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155309. /**
  155310. * detach this feature.
  155311. * Will usually be called by the features manager
  155312. *
  155313. * @returns true if successful.
  155314. */
  155315. detach(): boolean;
  155316. /**
  155317. * Dispose this feature and all of the resources attached
  155318. */
  155319. dispose(): void;
  155320. protected _onXRFrame(frame: XRFrame): void;
  155321. /**
  155322. * avoiding using Array.find for global support.
  155323. * @param xrAnchor the plane to find in the array
  155324. */
  155325. private _findIndexInAnchorArray;
  155326. private _updateAnchorWithXRFrame;
  155327. private _createAnchorAtTransformation;
  155328. }
  155329. }
  155330. declare module BABYLON {
  155331. /**
  155332. * Options used in the plane detector module
  155333. */
  155334. export interface IWebXRPlaneDetectorOptions {
  155335. /**
  155336. * The node to use to transform the local results to world coordinates
  155337. */
  155338. worldParentNode?: TransformNode;
  155339. /**
  155340. * If set to true a reference of the created planes will be kept until the next session starts
  155341. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155342. */
  155343. doNotRemovePlanesOnSessionEnded?: boolean;
  155344. }
  155345. /**
  155346. * A babylon interface for a WebXR plane.
  155347. * A Plane is actually a polygon, built from N points in space
  155348. *
  155349. * Supported in chrome 79, not supported in canary 81 ATM
  155350. */
  155351. export interface IWebXRPlane {
  155352. /**
  155353. * a babylon-assigned ID for this polygon
  155354. */
  155355. id: number;
  155356. /**
  155357. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155358. */
  155359. polygonDefinition: Array<Vector3>;
  155360. /**
  155361. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155362. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155363. */
  155364. transformationMatrix: Matrix;
  155365. /**
  155366. * the native xr-plane object
  155367. */
  155368. xrPlane: XRPlane;
  155369. }
  155370. /**
  155371. * The plane detector is used to detect planes in the real world when in AR
  155372. * For more information see https://github.com/immersive-web/real-world-geometry/
  155373. */
  155374. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155375. private _options;
  155376. private _detectedPlanes;
  155377. private _enabled;
  155378. private _lastFrameDetected;
  155379. /**
  155380. * The module's name
  155381. */
  155382. static readonly Name: string;
  155383. /**
  155384. * The (Babylon) version of this module.
  155385. * This is an integer representing the implementation version.
  155386. * This number does not correspond to the WebXR specs version
  155387. */
  155388. static readonly Version: number;
  155389. /**
  155390. * Observers registered here will be executed when a new plane was added to the session
  155391. */
  155392. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155393. /**
  155394. * Observers registered here will be executed when a plane is no longer detected in the session
  155395. */
  155396. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155397. /**
  155398. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155399. * This can execute N times every frame
  155400. */
  155401. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155402. /**
  155403. * construct a new Plane Detector
  155404. * @param _xrSessionManager an instance of xr Session manager
  155405. * @param _options configuration to use when constructing this feature
  155406. */
  155407. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155408. /**
  155409. * detach this feature.
  155410. * Will usually be called by the features manager
  155411. *
  155412. * @returns true if successful.
  155413. */
  155414. detach(): boolean;
  155415. /**
  155416. * Dispose this feature and all of the resources attached
  155417. */
  155418. dispose(): void;
  155419. protected _onXRFrame(frame: XRFrame): void;
  155420. private _init;
  155421. private _updatePlaneWithXRPlane;
  155422. /**
  155423. * avoiding using Array.find for global support.
  155424. * @param xrPlane the plane to find in the array
  155425. */
  155426. private findIndexInPlaneArray;
  155427. }
  155428. }
  155429. declare module BABYLON {
  155430. /**
  155431. * Options interface for the background remover plugin
  155432. */
  155433. export interface IWebXRBackgroundRemoverOptions {
  155434. /**
  155435. * Further background meshes to disable when entering AR
  155436. */
  155437. backgroundMeshes?: AbstractMesh[];
  155438. /**
  155439. * flags to configure the removal of the environment helper.
  155440. * If not set, the entire background will be removed. If set, flags should be set as well.
  155441. */
  155442. environmentHelperRemovalFlags?: {
  155443. /**
  155444. * Should the skybox be removed (default false)
  155445. */
  155446. skyBox?: boolean;
  155447. /**
  155448. * Should the ground be removed (default false)
  155449. */
  155450. ground?: boolean;
  155451. };
  155452. /**
  155453. * don't disable the environment helper
  155454. */
  155455. ignoreEnvironmentHelper?: boolean;
  155456. }
  155457. /**
  155458. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155459. */
  155460. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155461. /**
  155462. * read-only options to be used in this module
  155463. */
  155464. readonly options: IWebXRBackgroundRemoverOptions;
  155465. /**
  155466. * The module's name
  155467. */
  155468. static readonly Name: string;
  155469. /**
  155470. * The (Babylon) version of this module.
  155471. * This is an integer representing the implementation version.
  155472. * This number does not correspond to the WebXR specs version
  155473. */
  155474. static readonly Version: number;
  155475. /**
  155476. * registered observers will be triggered when the background state changes
  155477. */
  155478. onBackgroundStateChangedObservable: Observable<boolean>;
  155479. /**
  155480. * constructs a new background remover module
  155481. * @param _xrSessionManager the session manager for this module
  155482. * @param options read-only options to be used in this module
  155483. */
  155484. constructor(_xrSessionManager: WebXRSessionManager,
  155485. /**
  155486. * read-only options to be used in this module
  155487. */
  155488. options?: IWebXRBackgroundRemoverOptions);
  155489. /**
  155490. * attach this feature
  155491. * Will usually be called by the features manager
  155492. *
  155493. * @returns true if successful.
  155494. */
  155495. attach(): boolean;
  155496. /**
  155497. * detach this feature.
  155498. * Will usually be called by the features manager
  155499. *
  155500. * @returns true if successful.
  155501. */
  155502. detach(): boolean;
  155503. /**
  155504. * Dispose this feature and all of the resources attached
  155505. */
  155506. dispose(): void;
  155507. protected _onXRFrame(_xrFrame: XRFrame): void;
  155508. private _setBackgroundState;
  155509. }
  155510. }
  155511. declare module BABYLON {
  155512. /**
  155513. * Options for the controller physics feature
  155514. */
  155515. export class IWebXRControllerPhysicsOptions {
  155516. /**
  155517. * Should the headset get its own impostor
  155518. */
  155519. enableHeadsetImpostor?: boolean;
  155520. /**
  155521. * Optional parameters for the headset impostor
  155522. */
  155523. headsetImpostorParams?: {
  155524. /**
  155525. * The type of impostor to create. Default is sphere
  155526. */
  155527. impostorType: number;
  155528. /**
  155529. * the size of the impostor. Defaults to 10cm
  155530. */
  155531. impostorSize?: number | {
  155532. width: number;
  155533. height: number;
  155534. depth: number;
  155535. };
  155536. /**
  155537. * Friction definitions
  155538. */
  155539. friction?: number;
  155540. /**
  155541. * Restitution
  155542. */
  155543. restitution?: number;
  155544. };
  155545. /**
  155546. * The physics properties of the future impostors
  155547. */
  155548. physicsProperties?: {
  155549. /**
  155550. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  155551. * Note that this requires a physics engine that supports mesh impostors!
  155552. */
  155553. useControllerMesh?: boolean;
  155554. /**
  155555. * The type of impostor to create. Default is sphere
  155556. */
  155557. impostorType?: number;
  155558. /**
  155559. * the size of the impostor. Defaults to 10cm
  155560. */
  155561. impostorSize?: number | {
  155562. width: number;
  155563. height: number;
  155564. depth: number;
  155565. };
  155566. /**
  155567. * Friction definitions
  155568. */
  155569. friction?: number;
  155570. /**
  155571. * Restitution
  155572. */
  155573. restitution?: number;
  155574. };
  155575. /**
  155576. * the xr input to use with this pointer selection
  155577. */
  155578. xrInput: WebXRInput;
  155579. }
  155580. /**
  155581. * Add physics impostor to your webxr controllers,
  155582. * including naive calculation of their linear and angular velocity
  155583. */
  155584. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  155585. private readonly _options;
  155586. private _attachController;
  155587. private _controllers;
  155588. private _debugMode;
  155589. private _delta;
  155590. private _headsetImpostor?;
  155591. private _headsetMesh?;
  155592. private _lastTimestamp;
  155593. private _tmpQuaternion;
  155594. private _tmpVector;
  155595. /**
  155596. * The module's name
  155597. */
  155598. static readonly Name: string;
  155599. /**
  155600. * The (Babylon) version of this module.
  155601. * This is an integer representing the implementation version.
  155602. * This number does not correspond to the webxr specs version
  155603. */
  155604. static readonly Version: number;
  155605. /**
  155606. * Construct a new Controller Physics Feature
  155607. * @param _xrSessionManager the corresponding xr session manager
  155608. * @param _options options to create this feature with
  155609. */
  155610. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  155611. /**
  155612. * @hidden
  155613. * enable debugging - will show console outputs and the impostor mesh
  155614. */
  155615. _enablePhysicsDebug(): void;
  155616. /**
  155617. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  155618. * @param xrController the controller to add
  155619. */
  155620. addController(xrController: WebXRInputSource): void;
  155621. /**
  155622. * attach this feature
  155623. * Will usually be called by the features manager
  155624. *
  155625. * @returns true if successful.
  155626. */
  155627. attach(): boolean;
  155628. /**
  155629. * detach this feature.
  155630. * Will usually be called by the features manager
  155631. *
  155632. * @returns true if successful.
  155633. */
  155634. detach(): boolean;
  155635. /**
  155636. * Get the headset impostor, if enabled
  155637. * @returns the impostor
  155638. */
  155639. getHeadsetImpostor(): PhysicsImpostor | undefined;
  155640. /**
  155641. * Get the physics impostor of a specific controller.
  155642. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  155643. * @param controller the controller or the controller id of which to get the impostor
  155644. * @returns the impostor or null
  155645. */
  155646. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  155647. /**
  155648. * Update the physics properties provided in the constructor
  155649. * @param newProperties the new properties object
  155650. */
  155651. setPhysicsProperties(newProperties: {
  155652. impostorType?: number;
  155653. impostorSize?: number | {
  155654. width: number;
  155655. height: number;
  155656. depth: number;
  155657. };
  155658. friction?: number;
  155659. restitution?: number;
  155660. }): void;
  155661. protected _onXRFrame(_xrFrame: any): void;
  155662. private _detachController;
  155663. }
  155664. }
  155665. declare module BABYLON {
  155666. /**
  155667. * A babylon interface for a "WebXR" feature point.
  155668. * Represents the position and confidence value of a given feature point.
  155669. */
  155670. export interface IWebXRFeaturePoint {
  155671. /**
  155672. * Represents the position of the feature point in world space.
  155673. */
  155674. position: Vector3;
  155675. /**
  155676. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  155677. */
  155678. confidenceValue: number;
  155679. }
  155680. /**
  155681. * The feature point system is used to detect feature points from real world geometry.
  155682. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  155683. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  155684. */
  155685. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  155686. private _enabled;
  155687. private _featurePointCloud;
  155688. /**
  155689. * The module's name
  155690. */
  155691. static readonly Name: string;
  155692. /**
  155693. * The (Babylon) version of this module.
  155694. * This is an integer representing the implementation version.
  155695. * This number does not correspond to the WebXR specs version
  155696. */
  155697. static readonly Version: number;
  155698. /**
  155699. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  155700. * Will notify the observers about which feature points have been added.
  155701. */
  155702. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  155703. /**
  155704. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  155705. * Will notify the observers about which feature points have been updated.
  155706. */
  155707. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  155708. /**
  155709. * The current feature point cloud maintained across frames.
  155710. */
  155711. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  155712. /**
  155713. * construct the feature point system
  155714. * @param _xrSessionManager an instance of xr Session manager
  155715. */
  155716. constructor(_xrSessionManager: WebXRSessionManager);
  155717. /**
  155718. * Detach this feature.
  155719. * Will usually be called by the features manager
  155720. *
  155721. * @returns true if successful.
  155722. */
  155723. detach(): boolean;
  155724. /**
  155725. * Dispose this feature and all of the resources attached
  155726. */
  155727. dispose(): void;
  155728. /**
  155729. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  155730. */
  155731. protected _onXRFrame(frame: XRFrame): void;
  155732. /**
  155733. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  155734. */
  155735. private _init;
  155736. }
  155737. }
  155738. declare module BABYLON {
  155739. /**
  155740. * Configuration interface for the hand tracking feature
  155741. */
  155742. export interface IWebXRHandTrackingOptions {
  155743. /**
  155744. * The xrInput that will be used as source for new hands
  155745. */
  155746. xrInput: WebXRInput;
  155747. /**
  155748. * Configuration object for the joint meshes
  155749. */
  155750. jointMeshes?: {
  155751. /**
  155752. * Should the meshes created be invisible (defaults to false)
  155753. */
  155754. invisible?: boolean;
  155755. /**
  155756. * A source mesh to be used to create instances. Defaults to a sphere.
  155757. * This mesh will be the source for all other (25) meshes.
  155758. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  155759. */
  155760. sourceMesh?: Mesh;
  155761. /**
  155762. * Should the source mesh stay visible. Defaults to false
  155763. */
  155764. keepOriginalVisible?: boolean;
  155765. /**
  155766. * Scale factor for all instances (defaults to 2)
  155767. */
  155768. scaleFactor?: number;
  155769. /**
  155770. * Should each instance have its own physics impostor
  155771. */
  155772. enablePhysics?: boolean;
  155773. /**
  155774. * If enabled, override default physics properties
  155775. */
  155776. physicsProps?: {
  155777. friction?: number;
  155778. restitution?: number;
  155779. impostorType?: number;
  155780. };
  155781. /**
  155782. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  155783. */
  155784. handMesh?: AbstractMesh;
  155785. };
  155786. }
  155787. /**
  155788. * Parts of the hands divided to writs and finger names
  155789. */
  155790. export const enum HandPart {
  155791. /**
  155792. * HandPart - Wrist
  155793. */
  155794. WRIST = "wrist",
  155795. /**
  155796. * HandPart - The THumb
  155797. */
  155798. THUMB = "thumb",
  155799. /**
  155800. * HandPart - Index finger
  155801. */
  155802. INDEX = "index",
  155803. /**
  155804. * HandPart - Middle finger
  155805. */
  155806. MIDDLE = "middle",
  155807. /**
  155808. * HandPart - Ring finger
  155809. */
  155810. RING = "ring",
  155811. /**
  155812. * HandPart - Little finger
  155813. */
  155814. LITTLE = "little"
  155815. }
  155816. /**
  155817. * Representing a single hand (with its corresponding native XRHand object)
  155818. */
  155819. export class WebXRHand implements IDisposable {
  155820. /** the controller to which the hand correlates */
  155821. readonly xrController: WebXRInputSource;
  155822. /** the meshes to be used to track the hand joints */
  155823. readonly trackedMeshes: AbstractMesh[];
  155824. /**
  155825. * Hand-parts definition (key is HandPart)
  155826. */
  155827. handPartsDefinition: {
  155828. [key: string]: number[];
  155829. };
  155830. /**
  155831. * Populate the HandPartsDefinition object.
  155832. * This is called as a side effect since certain browsers don't have XRHand defined.
  155833. */
  155834. private generateHandPartsDefinition;
  155835. /**
  155836. * Construct a new hand object
  155837. * @param xrController the controller to which the hand correlates
  155838. * @param trackedMeshes the meshes to be used to track the hand joints
  155839. */
  155840. constructor(
  155841. /** the controller to which the hand correlates */
  155842. xrController: WebXRInputSource,
  155843. /** the meshes to be used to track the hand joints */
  155844. trackedMeshes: AbstractMesh[]);
  155845. /**
  155846. * Update this hand from the latest xr frame
  155847. * @param xrFrame xrFrame to update from
  155848. * @param referenceSpace The current viewer reference space
  155849. * @param scaleFactor optional scale factor for the meshes
  155850. */
  155851. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  155852. /**
  155853. * Get meshes of part of the hand
  155854. * @param part the part of hand to get
  155855. * @returns An array of meshes that correlate to the hand part requested
  155856. */
  155857. getHandPartMeshes(part: HandPart): AbstractMesh[];
  155858. /**
  155859. * Dispose this Hand object
  155860. */
  155861. dispose(): void;
  155862. }
  155863. /**
  155864. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  155865. */
  155866. export class WebXRHandTracking extends WebXRAbstractFeature {
  155867. /**
  155868. * options to use when constructing this feature
  155869. */
  155870. readonly options: IWebXRHandTrackingOptions;
  155871. private static _idCounter;
  155872. /**
  155873. * The module's name
  155874. */
  155875. static readonly Name: string;
  155876. /**
  155877. * The (Babylon) version of this module.
  155878. * This is an integer representing the implementation version.
  155879. * This number does not correspond to the WebXR specs version
  155880. */
  155881. static readonly Version: number;
  155882. /**
  155883. * This observable will notify registered observers when a new hand object was added and initialized
  155884. */
  155885. onHandAddedObservable: Observable<WebXRHand>;
  155886. /**
  155887. * This observable will notify its observers right before the hand object is disposed
  155888. */
  155889. onHandRemovedObservable: Observable<WebXRHand>;
  155890. private _hands;
  155891. /**
  155892. * Creates a new instance of the hit test feature
  155893. * @param _xrSessionManager an instance of WebXRSessionManager
  155894. * @param options options to use when constructing this feature
  155895. */
  155896. constructor(_xrSessionManager: WebXRSessionManager,
  155897. /**
  155898. * options to use when constructing this feature
  155899. */
  155900. options: IWebXRHandTrackingOptions);
  155901. /**
  155902. * Check if the needed objects are defined.
  155903. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  155904. */
  155905. isCompatible(): boolean;
  155906. /**
  155907. * attach this feature
  155908. * Will usually be called by the features manager
  155909. *
  155910. * @returns true if successful.
  155911. */
  155912. attach(): boolean;
  155913. /**
  155914. * detach this feature.
  155915. * Will usually be called by the features manager
  155916. *
  155917. * @returns true if successful.
  155918. */
  155919. detach(): boolean;
  155920. /**
  155921. * Dispose this feature and all of the resources attached
  155922. */
  155923. dispose(): void;
  155924. /**
  155925. * Get the hand object according to the controller id
  155926. * @param controllerId the controller id to which we want to get the hand
  155927. * @returns null if not found or the WebXRHand object if found
  155928. */
  155929. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  155930. /**
  155931. * Get a hand object according to the requested handedness
  155932. * @param handedness the handedness to request
  155933. * @returns null if not found or the WebXRHand object if found
  155934. */
  155935. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  155936. protected _onXRFrame(_xrFrame: XRFrame): void;
  155937. private _attachHand;
  155938. private _detachHand;
  155939. }
  155940. }
  155941. declare module BABYLON {
  155942. /**
  155943. * The motion controller class for all microsoft mixed reality controllers
  155944. */
  155945. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  155946. protected readonly _mapping: {
  155947. defaultButton: {
  155948. valueNodeName: string;
  155949. unpressedNodeName: string;
  155950. pressedNodeName: string;
  155951. };
  155952. defaultAxis: {
  155953. valueNodeName: string;
  155954. minNodeName: string;
  155955. maxNodeName: string;
  155956. };
  155957. buttons: {
  155958. "xr-standard-trigger": {
  155959. rootNodeName: string;
  155960. componentProperty: string;
  155961. states: string[];
  155962. };
  155963. "xr-standard-squeeze": {
  155964. rootNodeName: string;
  155965. componentProperty: string;
  155966. states: string[];
  155967. };
  155968. "xr-standard-touchpad": {
  155969. rootNodeName: string;
  155970. labelAnchorNodeName: string;
  155971. touchPointNodeName: string;
  155972. };
  155973. "xr-standard-thumbstick": {
  155974. rootNodeName: string;
  155975. componentProperty: string;
  155976. states: string[];
  155977. };
  155978. };
  155979. axes: {
  155980. "xr-standard-touchpad": {
  155981. "x-axis": {
  155982. rootNodeName: string;
  155983. };
  155984. "y-axis": {
  155985. rootNodeName: string;
  155986. };
  155987. };
  155988. "xr-standard-thumbstick": {
  155989. "x-axis": {
  155990. rootNodeName: string;
  155991. };
  155992. "y-axis": {
  155993. rootNodeName: string;
  155994. };
  155995. };
  155996. };
  155997. };
  155998. /**
  155999. * The base url used to load the left and right controller models
  156000. */
  156001. static MODEL_BASE_URL: string;
  156002. /**
  156003. * The name of the left controller model file
  156004. */
  156005. static MODEL_LEFT_FILENAME: string;
  156006. /**
  156007. * The name of the right controller model file
  156008. */
  156009. static MODEL_RIGHT_FILENAME: string;
  156010. profileId: string;
  156011. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156012. protected _getFilenameAndPath(): {
  156013. filename: string;
  156014. path: string;
  156015. };
  156016. protected _getModelLoadingConstraints(): boolean;
  156017. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156018. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156019. protected _updateModel(): void;
  156020. }
  156021. }
  156022. declare module BABYLON {
  156023. /**
  156024. * The motion controller class for oculus touch (quest, rift).
  156025. * This class supports legacy mapping as well the standard xr mapping
  156026. */
  156027. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156028. private _forceLegacyControllers;
  156029. private _modelRootNode;
  156030. /**
  156031. * The base url used to load the left and right controller models
  156032. */
  156033. static MODEL_BASE_URL: string;
  156034. /**
  156035. * The name of the left controller model file
  156036. */
  156037. static MODEL_LEFT_FILENAME: string;
  156038. /**
  156039. * The name of the right controller model file
  156040. */
  156041. static MODEL_RIGHT_FILENAME: string;
  156042. /**
  156043. * Base Url for the Quest controller model.
  156044. */
  156045. static QUEST_MODEL_BASE_URL: string;
  156046. profileId: string;
  156047. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156048. protected _getFilenameAndPath(): {
  156049. filename: string;
  156050. path: string;
  156051. };
  156052. protected _getModelLoadingConstraints(): boolean;
  156053. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156054. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156055. protected _updateModel(): void;
  156056. /**
  156057. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156058. * between the touch and touch 2.
  156059. */
  156060. private _isQuest;
  156061. }
  156062. }
  156063. declare module BABYLON {
  156064. /**
  156065. * The motion controller class for the standard HTC-Vive controllers
  156066. */
  156067. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156068. private _modelRootNode;
  156069. /**
  156070. * The base url used to load the left and right controller models
  156071. */
  156072. static MODEL_BASE_URL: string;
  156073. /**
  156074. * File name for the controller model.
  156075. */
  156076. static MODEL_FILENAME: string;
  156077. profileId: string;
  156078. /**
  156079. * Create a new Vive motion controller object
  156080. * @param scene the scene to use to create this controller
  156081. * @param gamepadObject the corresponding gamepad object
  156082. * @param handedness the handedness of the controller
  156083. */
  156084. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156085. protected _getFilenameAndPath(): {
  156086. filename: string;
  156087. path: string;
  156088. };
  156089. protected _getModelLoadingConstraints(): boolean;
  156090. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156091. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156092. protected _updateModel(): void;
  156093. }
  156094. }
  156095. declare module BABYLON {
  156096. /**
  156097. * A cursor which tracks a point on a path
  156098. */
  156099. export class PathCursor {
  156100. private path;
  156101. /**
  156102. * Stores path cursor callbacks for when an onchange event is triggered
  156103. */
  156104. private _onchange;
  156105. /**
  156106. * The value of the path cursor
  156107. */
  156108. value: number;
  156109. /**
  156110. * The animation array of the path cursor
  156111. */
  156112. animations: Animation[];
  156113. /**
  156114. * Initializes the path cursor
  156115. * @param path The path to track
  156116. */
  156117. constructor(path: Path2);
  156118. /**
  156119. * Gets the cursor point on the path
  156120. * @returns A point on the path cursor at the cursor location
  156121. */
  156122. getPoint(): Vector3;
  156123. /**
  156124. * Moves the cursor ahead by the step amount
  156125. * @param step The amount to move the cursor forward
  156126. * @returns This path cursor
  156127. */
  156128. moveAhead(step?: number): PathCursor;
  156129. /**
  156130. * Moves the cursor behind by the step amount
  156131. * @param step The amount to move the cursor back
  156132. * @returns This path cursor
  156133. */
  156134. moveBack(step?: number): PathCursor;
  156135. /**
  156136. * Moves the cursor by the step amount
  156137. * If the step amount is greater than one, an exception is thrown
  156138. * @param step The amount to move the cursor
  156139. * @returns This path cursor
  156140. */
  156141. move(step: number): PathCursor;
  156142. /**
  156143. * Ensures that the value is limited between zero and one
  156144. * @returns This path cursor
  156145. */
  156146. private ensureLimits;
  156147. /**
  156148. * Runs onchange callbacks on change (used by the animation engine)
  156149. * @returns This path cursor
  156150. */
  156151. private raiseOnChange;
  156152. /**
  156153. * Executes a function on change
  156154. * @param f A path cursor onchange callback
  156155. * @returns This path cursor
  156156. */
  156157. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156158. }
  156159. }
  156160. declare module BABYLON {
  156161. /** @hidden */
  156162. export var blurPixelShader: {
  156163. name: string;
  156164. shader: string;
  156165. };
  156166. }
  156167. declare module BABYLON {
  156168. /** @hidden */
  156169. export var pointCloudVertexDeclaration: {
  156170. name: string;
  156171. shader: string;
  156172. };
  156173. }
  156174. // Mixins
  156175. interface Window {
  156176. mozIndexedDB: IDBFactory;
  156177. webkitIndexedDB: IDBFactory;
  156178. msIndexedDB: IDBFactory;
  156179. webkitURL: typeof URL;
  156180. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156181. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156182. WebGLRenderingContext: WebGLRenderingContext;
  156183. MSGesture: MSGesture;
  156184. CANNON: any;
  156185. AudioContext: AudioContext;
  156186. webkitAudioContext: AudioContext;
  156187. PointerEvent: any;
  156188. Math: Math;
  156189. Uint8Array: Uint8ArrayConstructor;
  156190. Float32Array: Float32ArrayConstructor;
  156191. mozURL: typeof URL;
  156192. msURL: typeof URL;
  156193. VRFrameData: any; // WebVR, from specs 1.1
  156194. DracoDecoderModule: any;
  156195. setImmediate(handler: (...args: any[]) => void): number;
  156196. }
  156197. interface HTMLCanvasElement {
  156198. requestPointerLock(): void;
  156199. msRequestPointerLock?(): void;
  156200. mozRequestPointerLock?(): void;
  156201. webkitRequestPointerLock?(): void;
  156202. /** Track wether a record is in progress */
  156203. isRecording: boolean;
  156204. /** Capture Stream method defined by some browsers */
  156205. captureStream(fps?: number): MediaStream;
  156206. }
  156207. interface CanvasRenderingContext2D {
  156208. msImageSmoothingEnabled: boolean;
  156209. }
  156210. interface MouseEvent {
  156211. mozMovementX: number;
  156212. mozMovementY: number;
  156213. webkitMovementX: number;
  156214. webkitMovementY: number;
  156215. msMovementX: number;
  156216. msMovementY: number;
  156217. }
  156218. interface Navigator {
  156219. mozGetVRDevices: (any: any) => any;
  156220. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156221. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156222. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156223. webkitGetGamepads(): Gamepad[];
  156224. msGetGamepads(): Gamepad[];
  156225. webkitGamepads(): Gamepad[];
  156226. }
  156227. interface HTMLVideoElement {
  156228. mozSrcObject: any;
  156229. }
  156230. interface Math {
  156231. fround(x: number): number;
  156232. imul(a: number, b: number): number;
  156233. }
  156234. interface WebGLRenderingContext {
  156235. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156236. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156237. vertexAttribDivisor(index: number, divisor: number): void;
  156238. createVertexArray(): any;
  156239. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156240. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156241. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156242. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156243. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156244. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156245. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156246. // Queries
  156247. createQuery(): WebGLQuery;
  156248. deleteQuery(query: WebGLQuery): void;
  156249. beginQuery(target: number, query: WebGLQuery): void;
  156250. endQuery(target: number): void;
  156251. getQueryParameter(query: WebGLQuery, pname: number): any;
  156252. getQuery(target: number, pname: number): any;
  156253. MAX_SAMPLES: number;
  156254. RGBA8: number;
  156255. READ_FRAMEBUFFER: number;
  156256. DRAW_FRAMEBUFFER: number;
  156257. UNIFORM_BUFFER: number;
  156258. HALF_FLOAT_OES: number;
  156259. RGBA16F: number;
  156260. RGBA32F: number;
  156261. R32F: number;
  156262. RG32F: number;
  156263. RGB32F: number;
  156264. R16F: number;
  156265. RG16F: number;
  156266. RGB16F: number;
  156267. RED: number;
  156268. RG: number;
  156269. R8: number;
  156270. RG8: number;
  156271. UNSIGNED_INT_24_8: number;
  156272. DEPTH24_STENCIL8: number;
  156273. MIN: number;
  156274. MAX: number;
  156275. /* Multiple Render Targets */
  156276. drawBuffers(buffers: number[]): void;
  156277. readBuffer(src: number): void;
  156278. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156279. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156280. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156281. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156282. // Occlusion Query
  156283. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156284. ANY_SAMPLES_PASSED: number;
  156285. QUERY_RESULT_AVAILABLE: number;
  156286. QUERY_RESULT: number;
  156287. }
  156288. interface WebGLProgram {
  156289. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156290. }
  156291. interface EXT_disjoint_timer_query {
  156292. QUERY_COUNTER_BITS_EXT: number;
  156293. TIME_ELAPSED_EXT: number;
  156294. TIMESTAMP_EXT: number;
  156295. GPU_DISJOINT_EXT: number;
  156296. QUERY_RESULT_EXT: number;
  156297. QUERY_RESULT_AVAILABLE_EXT: number;
  156298. queryCounterEXT(query: WebGLQuery, target: number): void;
  156299. createQueryEXT(): WebGLQuery;
  156300. beginQueryEXT(target: number, query: WebGLQuery): void;
  156301. endQueryEXT(target: number): void;
  156302. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156303. deleteQueryEXT(query: WebGLQuery): void;
  156304. }
  156305. interface WebGLUniformLocation {
  156306. _currentState: any;
  156307. }
  156308. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156309. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156310. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156311. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156312. interface WebGLRenderingContext {
  156313. readonly RASTERIZER_DISCARD: number;
  156314. readonly DEPTH_COMPONENT24: number;
  156315. readonly TEXTURE_3D: number;
  156316. readonly TEXTURE_2D_ARRAY: number;
  156317. readonly TEXTURE_COMPARE_FUNC: number;
  156318. readonly TEXTURE_COMPARE_MODE: number;
  156319. readonly COMPARE_REF_TO_TEXTURE: number;
  156320. readonly TEXTURE_WRAP_R: number;
  156321. readonly HALF_FLOAT: number;
  156322. readonly RGB8: number;
  156323. readonly RED_INTEGER: number;
  156324. readonly RG_INTEGER: number;
  156325. readonly RGB_INTEGER: number;
  156326. readonly RGBA_INTEGER: number;
  156327. readonly R8_SNORM: number;
  156328. readonly RG8_SNORM: number;
  156329. readonly RGB8_SNORM: number;
  156330. readonly RGBA8_SNORM: number;
  156331. readonly R8I: number;
  156332. readonly RG8I: number;
  156333. readonly RGB8I: number;
  156334. readonly RGBA8I: number;
  156335. readonly R8UI: number;
  156336. readonly RG8UI: number;
  156337. readonly RGB8UI: number;
  156338. readonly RGBA8UI: number;
  156339. readonly R16I: number;
  156340. readonly RG16I: number;
  156341. readonly RGB16I: number;
  156342. readonly RGBA16I: number;
  156343. readonly R16UI: number;
  156344. readonly RG16UI: number;
  156345. readonly RGB16UI: number;
  156346. readonly RGBA16UI: number;
  156347. readonly R32I: number;
  156348. readonly RG32I: number;
  156349. readonly RGB32I: number;
  156350. readonly RGBA32I: number;
  156351. readonly R32UI: number;
  156352. readonly RG32UI: number;
  156353. readonly RGB32UI: number;
  156354. readonly RGBA32UI: number;
  156355. readonly RGB10_A2UI: number;
  156356. readonly R11F_G11F_B10F: number;
  156357. readonly RGB9_E5: number;
  156358. readonly RGB10_A2: number;
  156359. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156360. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156361. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156362. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156363. readonly DEPTH_COMPONENT32F: number;
  156364. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156365. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156366. 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;
  156367. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156368. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156369. readonly TRANSFORM_FEEDBACK: number;
  156370. readonly INTERLEAVED_ATTRIBS: number;
  156371. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156372. createTransformFeedback(): WebGLTransformFeedback;
  156373. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156374. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156375. beginTransformFeedback(primitiveMode: number): void;
  156376. endTransformFeedback(): void;
  156377. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156378. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156379. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156380. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156381. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156382. }
  156383. interface ImageBitmap {
  156384. readonly width: number;
  156385. readonly height: number;
  156386. close(): void;
  156387. }
  156388. interface WebGLQuery extends WebGLObject {
  156389. }
  156390. declare var WebGLQuery: {
  156391. prototype: WebGLQuery;
  156392. new(): WebGLQuery;
  156393. };
  156394. interface WebGLSampler extends WebGLObject {
  156395. }
  156396. declare var WebGLSampler: {
  156397. prototype: WebGLSampler;
  156398. new(): WebGLSampler;
  156399. };
  156400. interface WebGLSync extends WebGLObject {
  156401. }
  156402. declare var WebGLSync: {
  156403. prototype: WebGLSync;
  156404. new(): WebGLSync;
  156405. };
  156406. interface WebGLTransformFeedback extends WebGLObject {
  156407. }
  156408. declare var WebGLTransformFeedback: {
  156409. prototype: WebGLTransformFeedback;
  156410. new(): WebGLTransformFeedback;
  156411. };
  156412. interface WebGLVertexArrayObject extends WebGLObject {
  156413. }
  156414. declare var WebGLVertexArrayObject: {
  156415. prototype: WebGLVertexArrayObject;
  156416. new(): WebGLVertexArrayObject;
  156417. };
  156418. // Type definitions for WebVR API
  156419. // Project: https://w3c.github.io/webvr/
  156420. // Definitions by: six a <https://github.com/lostfictions>
  156421. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156422. interface VRDisplay extends EventTarget {
  156423. /**
  156424. * Dictionary of capabilities describing the VRDisplay.
  156425. */
  156426. readonly capabilities: VRDisplayCapabilities;
  156427. /**
  156428. * z-depth defining the far plane of the eye view frustum
  156429. * enables mapping of values in the render target depth
  156430. * attachment to scene coordinates. Initially set to 10000.0.
  156431. */
  156432. depthFar: number;
  156433. /**
  156434. * z-depth defining the near plane of the eye view frustum
  156435. * enables mapping of values in the render target depth
  156436. * attachment to scene coordinates. Initially set to 0.01.
  156437. */
  156438. depthNear: number;
  156439. /**
  156440. * An identifier for this distinct VRDisplay. Used as an
  156441. * association point in the Gamepad API.
  156442. */
  156443. readonly displayId: number;
  156444. /**
  156445. * A display name, a user-readable name identifying it.
  156446. */
  156447. readonly displayName: string;
  156448. readonly isConnected: boolean;
  156449. readonly isPresenting: boolean;
  156450. /**
  156451. * If this VRDisplay supports room-scale experiences, the optional
  156452. * stage attribute contains details on the room-scale parameters.
  156453. */
  156454. readonly stageParameters: VRStageParameters | null;
  156455. /**
  156456. * Passing the value returned by `requestAnimationFrame` to
  156457. * `cancelAnimationFrame` will unregister the callback.
  156458. * @param handle Define the hanle of the request to cancel
  156459. */
  156460. cancelAnimationFrame(handle: number): void;
  156461. /**
  156462. * Stops presenting to the VRDisplay.
  156463. * @returns a promise to know when it stopped
  156464. */
  156465. exitPresent(): Promise<void>;
  156466. /**
  156467. * Return the current VREyeParameters for the given eye.
  156468. * @param whichEye Define the eye we want the parameter for
  156469. * @returns the eye parameters
  156470. */
  156471. getEyeParameters(whichEye: string): VREyeParameters;
  156472. /**
  156473. * Populates the passed VRFrameData with the information required to render
  156474. * the current frame.
  156475. * @param frameData Define the data structure to populate
  156476. * @returns true if ok otherwise false
  156477. */
  156478. getFrameData(frameData: VRFrameData): boolean;
  156479. /**
  156480. * Get the layers currently being presented.
  156481. * @returns the list of VR layers
  156482. */
  156483. getLayers(): VRLayer[];
  156484. /**
  156485. * Return a VRPose containing the future predicted pose of the VRDisplay
  156486. * when the current frame will be presented. The value returned will not
  156487. * change until JavaScript has returned control to the browser.
  156488. *
  156489. * The VRPose will contain the position, orientation, velocity,
  156490. * and acceleration of each of these properties.
  156491. * @returns the pose object
  156492. */
  156493. getPose(): VRPose;
  156494. /**
  156495. * Return the current instantaneous pose of the VRDisplay, with no
  156496. * prediction applied.
  156497. * @returns the current instantaneous pose
  156498. */
  156499. getImmediatePose(): VRPose;
  156500. /**
  156501. * The callback passed to `requestAnimationFrame` will be called
  156502. * any time a new frame should be rendered. When the VRDisplay is
  156503. * presenting the callback will be called at the native refresh
  156504. * rate of the HMD. When not presenting this function acts
  156505. * identically to how window.requestAnimationFrame acts. Content should
  156506. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156507. * asynchronously from other displays and at differing refresh rates.
  156508. * @param callback Define the eaction to run next frame
  156509. * @returns the request handle it
  156510. */
  156511. requestAnimationFrame(callback: FrameRequestCallback): number;
  156512. /**
  156513. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156514. * Repeat calls while already presenting will update the VRLayers being displayed.
  156515. * @param layers Define the list of layer to present
  156516. * @returns a promise to know when the request has been fulfilled
  156517. */
  156518. requestPresent(layers: VRLayer[]): Promise<void>;
  156519. /**
  156520. * Reset the pose for this display, treating its current position and
  156521. * orientation as the "origin/zero" values. VRPose.position,
  156522. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156523. * updated when calling resetPose(). This should be called in only
  156524. * sitting-space experiences.
  156525. */
  156526. resetPose(): void;
  156527. /**
  156528. * The VRLayer provided to the VRDisplay will be captured and presented
  156529. * in the HMD. Calling this function has the same effect on the source
  156530. * canvas as any other operation that uses its source image, and canvases
  156531. * created without preserveDrawingBuffer set to true will be cleared.
  156532. * @param pose Define the pose to submit
  156533. */
  156534. submitFrame(pose?: VRPose): void;
  156535. }
  156536. declare var VRDisplay: {
  156537. prototype: VRDisplay;
  156538. new(): VRDisplay;
  156539. };
  156540. interface VRLayer {
  156541. leftBounds?: number[] | Float32Array | null;
  156542. rightBounds?: number[] | Float32Array | null;
  156543. source?: HTMLCanvasElement | null;
  156544. }
  156545. interface VRDisplayCapabilities {
  156546. readonly canPresent: boolean;
  156547. readonly hasExternalDisplay: boolean;
  156548. readonly hasOrientation: boolean;
  156549. readonly hasPosition: boolean;
  156550. readonly maxLayers: number;
  156551. }
  156552. interface VREyeParameters {
  156553. /** @deprecated */
  156554. readonly fieldOfView: VRFieldOfView;
  156555. readonly offset: Float32Array;
  156556. readonly renderHeight: number;
  156557. readonly renderWidth: number;
  156558. }
  156559. interface VRFieldOfView {
  156560. readonly downDegrees: number;
  156561. readonly leftDegrees: number;
  156562. readonly rightDegrees: number;
  156563. readonly upDegrees: number;
  156564. }
  156565. interface VRFrameData {
  156566. readonly leftProjectionMatrix: Float32Array;
  156567. readonly leftViewMatrix: Float32Array;
  156568. readonly pose: VRPose;
  156569. readonly rightProjectionMatrix: Float32Array;
  156570. readonly rightViewMatrix: Float32Array;
  156571. readonly timestamp: number;
  156572. }
  156573. interface VRPose {
  156574. readonly angularAcceleration: Float32Array | null;
  156575. readonly angularVelocity: Float32Array | null;
  156576. readonly linearAcceleration: Float32Array | null;
  156577. readonly linearVelocity: Float32Array | null;
  156578. readonly orientation: Float32Array | null;
  156579. readonly position: Float32Array | null;
  156580. readonly timestamp: number;
  156581. }
  156582. interface VRStageParameters {
  156583. sittingToStandingTransform?: Float32Array;
  156584. sizeX?: number;
  156585. sizeY?: number;
  156586. }
  156587. interface Navigator {
  156588. getVRDisplays(): Promise<VRDisplay[]>;
  156589. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  156590. }
  156591. interface Window {
  156592. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  156593. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  156594. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  156595. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156596. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  156597. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  156598. }
  156599. interface Gamepad {
  156600. readonly displayId: number;
  156601. }
  156602. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  156603. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  156604. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  156605. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  156606. type XRHandedness = "none" | "left" | "right";
  156607. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  156608. type XREye = "none" | "left" | "right";
  156609. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  156610. interface XRSpace extends EventTarget {}
  156611. interface XRRenderState {
  156612. depthNear?: number;
  156613. depthFar?: number;
  156614. inlineVerticalFieldOfView?: number;
  156615. baseLayer?: XRWebGLLayer;
  156616. }
  156617. interface XRInputSource {
  156618. handedness: XRHandedness;
  156619. targetRayMode: XRTargetRayMode;
  156620. targetRaySpace: XRSpace;
  156621. gripSpace: XRSpace | undefined;
  156622. gamepad: Gamepad | undefined;
  156623. profiles: Array<string>;
  156624. hand: XRHand | undefined;
  156625. }
  156626. interface XRSessionInit {
  156627. optionalFeatures?: string[];
  156628. requiredFeatures?: string[];
  156629. }
  156630. interface XRSession {
  156631. addEventListener: Function;
  156632. removeEventListener: Function;
  156633. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  156634. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  156635. requestAnimationFrame: Function;
  156636. end(): Promise<void>;
  156637. renderState: XRRenderState;
  156638. inputSources: Array<XRInputSource>;
  156639. // hit test
  156640. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  156641. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  156642. // legacy AR hit test
  156643. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  156644. // legacy plane detection
  156645. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  156646. }
  156647. interface XRReferenceSpace extends XRSpace {
  156648. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  156649. onreset: any;
  156650. }
  156651. type XRPlaneSet = Set<XRPlane>;
  156652. type XRAnchorSet = Set<XRAnchor>;
  156653. interface XRFrame {
  156654. session: XRSession;
  156655. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  156656. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  156657. // AR
  156658. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  156659. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  156660. // Anchors
  156661. trackedAnchors?: XRAnchorSet;
  156662. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  156663. // Planes
  156664. worldInformation: {
  156665. detectedPlanes?: XRPlaneSet;
  156666. };
  156667. // Hand tracking
  156668. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  156669. }
  156670. interface XRViewerPose extends XRPose {
  156671. views: Array<XRView>;
  156672. }
  156673. interface XRPose {
  156674. transform: XRRigidTransform;
  156675. emulatedPosition: boolean;
  156676. }
  156677. interface XRWebGLLayerOptions {
  156678. antialias?: boolean;
  156679. depth?: boolean;
  156680. stencil?: boolean;
  156681. alpha?: boolean;
  156682. multiview?: boolean;
  156683. framebufferScaleFactor?: number;
  156684. }
  156685. declare var XRWebGLLayer: {
  156686. prototype: XRWebGLLayer;
  156687. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  156688. };
  156689. interface XRWebGLLayer {
  156690. framebuffer: WebGLFramebuffer;
  156691. framebufferWidth: number;
  156692. framebufferHeight: number;
  156693. getViewport: Function;
  156694. }
  156695. declare class XRRigidTransform {
  156696. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  156697. position: DOMPointReadOnly;
  156698. orientation: DOMPointReadOnly;
  156699. matrix: Float32Array;
  156700. inverse: XRRigidTransform;
  156701. }
  156702. interface XRView {
  156703. eye: XREye;
  156704. projectionMatrix: Float32Array;
  156705. transform: XRRigidTransform;
  156706. }
  156707. interface XRInputSourceChangeEvent {
  156708. session: XRSession;
  156709. removed: Array<XRInputSource>;
  156710. added: Array<XRInputSource>;
  156711. }
  156712. interface XRInputSourceEvent extends Event {
  156713. readonly frame: XRFrame;
  156714. readonly inputSource: XRInputSource;
  156715. }
  156716. // Experimental(er) features
  156717. declare class XRRay {
  156718. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  156719. origin: DOMPointReadOnly;
  156720. direction: DOMPointReadOnly;
  156721. matrix: Float32Array;
  156722. }
  156723. declare enum XRHitTestTrackableType {
  156724. "point",
  156725. "plane",
  156726. "mesh",
  156727. }
  156728. interface XRHitResult {
  156729. hitMatrix: Float32Array;
  156730. }
  156731. interface XRTransientInputHitTestResult {
  156732. readonly inputSource: XRInputSource;
  156733. readonly results: Array<XRHitTestResult>;
  156734. }
  156735. interface XRHitTestResult {
  156736. getPose(baseSpace: XRSpace): XRPose | undefined;
  156737. // When anchor system is enabled
  156738. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  156739. }
  156740. interface XRHitTestSource {
  156741. cancel(): void;
  156742. }
  156743. interface XRTransientInputHitTestSource {
  156744. cancel(): void;
  156745. }
  156746. interface XRHitTestOptionsInit {
  156747. space: XRSpace;
  156748. entityTypes?: Array<XRHitTestTrackableType>;
  156749. offsetRay?: XRRay;
  156750. }
  156751. interface XRTransientInputHitTestOptionsInit {
  156752. profile: string;
  156753. entityTypes?: Array<XRHitTestTrackableType>;
  156754. offsetRay?: XRRay;
  156755. }
  156756. interface XRAnchor {
  156757. anchorSpace: XRSpace;
  156758. delete(): void;
  156759. }
  156760. interface XRPlane {
  156761. orientation: "Horizontal" | "Vertical";
  156762. planeSpace: XRSpace;
  156763. polygon: Array<DOMPointReadOnly>;
  156764. lastChangedTime: number;
  156765. }
  156766. interface XRJointSpace extends XRSpace {}
  156767. interface XRJointPose extends XRPose {
  156768. radius: number | undefined;
  156769. }
  156770. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  156771. readonly length: number;
  156772. [index: number]: XRJointSpace;
  156773. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  156774. readonly WRIST: number;
  156775. readonly THUMB_METACARPAL: number;
  156776. readonly THUMB_PHALANX_PROXIMAL: number;
  156777. readonly THUMB_PHALANX_DISTAL: number;
  156778. readonly THUMB_PHALANX_TIP: number;
  156779. readonly INDEX_METACARPAL: number;
  156780. readonly INDEX_PHALANX_PROXIMAL: number;
  156781. readonly INDEX_PHALANX_INTERMEDIATE: number;
  156782. readonly INDEX_PHALANX_DISTAL: number;
  156783. readonly INDEX_PHALANX_TIP: number;
  156784. readonly MIDDLE_METACARPAL: number;
  156785. readonly MIDDLE_PHALANX_PROXIMAL: number;
  156786. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  156787. readonly MIDDLE_PHALANX_DISTAL: number;
  156788. readonly MIDDLE_PHALANX_TIP: number;
  156789. readonly RING_METACARPAL: number;
  156790. readonly RING_PHALANX_PROXIMAL: number;
  156791. readonly RING_PHALANX_INTERMEDIATE: number;
  156792. readonly RING_PHALANX_DISTAL: number;
  156793. readonly RING_PHALANX_TIP: number;
  156794. readonly LITTLE_METACARPAL: number;
  156795. readonly LITTLE_PHALANX_PROXIMAL: number;
  156796. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  156797. readonly LITTLE_PHALANX_DISTAL: number;
  156798. readonly LITTLE_PHALANX_TIP: number;
  156799. }
  156800. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  156801. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  156802. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  156803. interface XRSession {
  156804. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  156805. }
  156806. interface XRFrame {
  156807. featurePointCloud? : Array<number>;
  156808. }